Skip to content

Commit

Permalink
feat : 添加机器人分享功能
Browse files Browse the repository at this point in the history
  • Loading branch information
pojol committed Jun 19, 2023
1 parent 6762ec6 commit 13ca709
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 2 additions & 0 deletions editor/src/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface ConfigState {
heartColor: string
themeValue: string
modalOpen: boolean
runningTick: number
}

function initTheme(): string {
Expand All @@ -27,6 +28,7 @@ const initialState: ConfigState = {
heartColor: "#BDCDD6",
themeValue: initTheme(),
modalOpen: initModalOpen(),
runningTick: 2000,
}

const configSlice = createSlice({
Expand Down
25 changes: 19 additions & 6 deletions editor/src/pages/bots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
PlayCircleOutlined,
CheckCircleTwoTone,
CloseCircleTwoTone,
ExclamationCircleTwoTone
ExclamationCircleTwoTone,
CopyOutlined
} from "@ant-design/icons";

import { useLocation, history } from 'umi';
Expand Down Expand Up @@ -127,11 +128,6 @@ const Bots = (props: BotsProps) => {
})}
</>
),
},
{
title: "Desc",
dataIndex: "desc",
key: "desc",
}
]

Expand Down Expand Up @@ -388,6 +384,12 @@ const Bots = (props: BotsProps) => {

}

const handleBotShare = (e:any) => {
let url = new URL(window.location.href);
navigator.clipboard.writeText(url.origin+"/#/"+"editor/"+selectedRows[0].name)
message.success("share link copied to clipboard!")
}

var filepProps = {
name: "file",
multiple: true,
Expand Down Expand Up @@ -472,6 +474,17 @@ const Bots = (props: BotsProps) => {
{"download"}
</Button>
</Tooltip>
<Tooltip
placement="bottomLeft"
title={"Share the bot with others"}
>
<Button
icon={<CopyOutlined />}
onClick={handleBotShare}
>
{"share"}
</Button>
</Tooltip>
</Space>
</Col>
</Row>
Expand Down
6 changes: 5 additions & 1 deletion editor/src/pages/running.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import React, { useState, useEffect } from 'react';
const { Post } = require("../utils/request");
import Api from "../constant/api";
import { TaskTimer } from "tasktimer/lib/TaskTimer";
import { useSelector } from 'react-redux';
import { RootState } from "@/models/store";


export default function Running() {

const [runs, setRuns] = React.useState({});
const [botLst, setBotLst] = React.useState([]);
const { runningTick } = useSelector((state:RootState) => state.configSlice)

const cloumns = [
{
Expand Down Expand Up @@ -47,7 +51,7 @@ export default function Running() {
refreshBotList();
}

const timer = new TaskTimer(2000);
const timer = new TaskTimer(runningTick);
timer.on('tick', () => {
callback()
});
Expand Down

0 comments on commit 13ca709

Please sign in to comment.