Skip to content

Commit 575b5b4

Browse files
author
lrhh123
committed
fix: 优化暂停按钮
1 parent 09d6958 commit 575b5b4

File tree

8 files changed

+109
-86
lines changed

8 files changed

+109
-86
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
- Add experimental support for vscode debugging
6666
- Revert https://github.com/electron-react-boilerplate/electron-react-boilerplate/pull/2365 as default for users, provide as opt in option
6767

68-
# 1.2.0-beta.1
68+
# 1.2.0
6969

7070
- Fix #2402
7171
- Simplify configs (https://github.com/electron-react-boilerplate/electron-react-boilerplate/pull/2406)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
## 下载地址
5858

59-
<a href="https://github.com/cs-lazy-tools/ChatGPT-On-CS/releases/download/v1.2.0-beta.1/1.2.0-beta.1.exe" style="display: inline-block; background-color: #008CBA; color: white; padding: 10px 20px; text-align: center; text-decoration: none; font-weight: bold; border-radius: 5px; margin: 4px 2px; cursor: pointer;">点击下载</a>
59+
<a href="https://github.com/cs-lazy-tools/ChatGPT-On-CS/releases/download/v1.2.0/1.2.0.exe" style="display: inline-block; background-color: #008CBA; color: white; padding: 10px 20px; text-align: center; text-decoration: none; font-weight: bold; border-radius: 5px; margin: 4px 2px; cursor: pointer;">点击下载</a>
6060

6161
如果网络环境导致下载不了,可以使用下面的地址下载:
6262

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "chatgpt-on-cs",
33
"description": "多平台智能客服,允许使用 ChatGPT 作为客服机器人",
4-
"version": "1.2.0-beta.1",
4+
"version": "1.2.0",
55
"keywords": [
66
"electron",
77
"boilerplate",

release/app/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

release/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chatgpt-on-cs",
3-
"version": "1.2.0-beta.1",
3+
"version": "1.2.0",
44
"description": "多平台智能客服,允许使用 ChatGPT 作为客服机器人",
55
"license": "AGPL-3.0",
66
"author": {

src/renderer/main-window/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Navbar from './components/layout/Navbar';
66
import Footer from './components/layout/Footer';
77
import ErrorBoundary from './components/ErrorBoundary';
88
import HomePage from './pages/Home';
9-
import ChatSessionsTable from '../dataview-window/components/SessionHistory';
109
import FullScreenLoader from './pages/FullScreenLoader';
1110
import Updater from './components/Updater';
1211
import SystemCheck from './components/SystemCheck';

src/renderer/main-window/components/Panels/index.tsx

Lines changed: 88 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import React, { useEffect, useState, useCallback } from 'react';
2-
import { Checkbox, Stack, HStack, Tooltip } from '@chakra-ui/react';
2+
import {
3+
Stack,
4+
HStack,
5+
Tooltip,
6+
IconButton,
7+
Text,
8+
VStack,
9+
Checkbox,
10+
} from '@chakra-ui/react';
311
import { useQuery } from '@tanstack/react-query';
12+
import { FiPause, FiPlay } from 'react-icons/fi'; // 引入播放器图标
413
import { useToast } from '../../hooks/useToast';
514
import {
615
getConfig,
@@ -39,7 +48,6 @@ const Panels = () => {
3948
}
4049
});
4150

42-
// eslint-disable-next-line react-hooks/exhaustive-deps
4351
const pausedHandler = useCallback(
4452
(message: any) => {
4553
if (message.event === 'has_paused') {
@@ -63,9 +71,8 @@ const Panels = () => {
6371
useEffect(() => {
6472
const unregister = registerEventHandler(pausedHandler);
6573

66-
// 组件卸载时注销事件处理器
6774
return () => unregister();
68-
}, [registerEventHandler, pausedHandler]); // eslint-disable-line
75+
}, [registerEventHandler, pausedHandler]);
6976

7077
useEffect(() => {
7178
if (data) {
@@ -83,7 +90,6 @@ const Panels = () => {
8390
cfg: updatedConfig,
8491
});
8592

86-
// 检查是否是 hasPaused 变更
8793
if ('hasPaused' in newConfig) {
8894
toast({
8995
title: '更新配置成功',
@@ -109,81 +115,84 @@ const Panels = () => {
109115
};
110116

111117
return (
112-
<>
113-
<Stack spacing={4}>
114-
<HStack width="full" alignItems="center">
115-
<Checkbox
116-
mr={4}
117-
isChecked={driverSettings.hasPaused}
118-
onChange={(e) =>
119-
handleUpdateConfig({ hasPaused: e.target.checked })
120-
}
121-
>
122-
<Tooltip label="暂停软件后,将不再自动回复消息">暂停软件</Tooltip>
123-
</Checkbox>
124-
<Checkbox
125-
isChecked={driverSettings.hasKeywordMatch}
126-
onChange={(e) =>
127-
handleUpdateConfig({ hasKeywordMatch: e.target.checked })
128-
}
129-
>
130-
<Tooltip label="将优先匹配关键词,未匹配的才去调用 GPT 接口">
131-
关键词匹配
132-
</Tooltip>
133-
</Checkbox>
134-
<Checkbox
135-
isChecked={driverSettings.hasUseGpt}
136-
onChange={(e) =>
137-
handleUpdateConfig({ hasUseGpt: e.target.checked })
138-
}
139-
>
140-
<Tooltip label="是否开启 GPT 回复,关闭后只会使用关键词回复">
141-
GPT 回复
142-
</Tooltip>
143-
</Checkbox>
144-
</HStack>
145-
<HStack width="full" alignItems="center">
146-
{/* <Checkbox
147-
isChecked={driverSettings.hasMouseClose}
148-
onChange={(e) =>
149-
handleUpdateConfig({ hasMouseClose: e.target.checked })
150-
}
151-
>
152-
<Tooltip label="是否开启鼠标移动时,自动暂停自动客服">
153-
鼠标移动自动暂停
154-
</Tooltip>
155-
</Checkbox> */}
156-
<Checkbox
157-
isChecked={driverSettings.hasTransfer}
158-
onChange={(e) =>
159-
handleUpdateConfig({ hasTransfer: e.target.checked })
160-
}
161-
>
162-
<Tooltip label="如果匹配到设定的关键词,将自动转人工">
163-
关键词转人工
164-
</Tooltip>
165-
</Checkbox>
166-
<Checkbox
167-
isChecked={driverSettings.hasReplace}
168-
onChange={(e) =>
169-
handleUpdateConfig({ hasReplace: e.target.checked })
170-
}
171-
>
172-
<Tooltip label="如果匹配到设定的关键词,将自动替换成自定义的关键词">
173-
关键词替换
174-
</Tooltip>
175-
</Checkbox>
176-
<Checkbox
177-
isChecked={driverSettings.hasReplace}
178-
onChange={(e) =>
179-
handleUpdateConfig({ hasEscClose: e.target.checked })
118+
<Stack spacing={4}>
119+
<HStack width="full" alignItems="center" justifyContent="space-between">
120+
<VStack width="35%">
121+
<Text fontSize="md">
122+
按下{driverSettings.hasPaused ? '开启' : '关闭'}自动回复
123+
</Text>
124+
<IconButton
125+
icon={driverSettings.hasPaused ? <FiPlay /> : <FiPause />}
126+
aria-label="Pause/Play"
127+
size="lg"
128+
mt={2}
129+
onClick={() =>
130+
handleUpdateConfig({ hasPaused: !driverSettings.hasPaused })
180131
}
181-
>
182-
<Tooltip label="当按下 ESC 键时自动暂停">按 ESC 键自动暂停</Tooltip>
183-
</Checkbox>
184-
</HStack>
185-
</Stack>
186-
</>
132+
isRound
133+
colorScheme={driverSettings.hasPaused ? 'green' : 'red'}
134+
/>
135+
</VStack>
136+
<VStack width="65%" alignItems="flex-start">
137+
<HStack>
138+
<Checkbox
139+
isChecked={driverSettings.hasKeywordMatch}
140+
onChange={(e) =>
141+
handleUpdateConfig({ hasKeywordMatch: e.target.checked })
142+
}
143+
>
144+
<Tooltip label="将优先匹配关键词,未匹配的才去调用 GPT 接口">
145+
关键词匹配
146+
</Tooltip>
147+
</Checkbox>
148+
<Checkbox
149+
isChecked={driverSettings.hasUseGpt}
150+
onChange={(e) =>
151+
handleUpdateConfig({ hasUseGpt: e.target.checked })
152+
}
153+
>
154+
<Tooltip label="是否开启 GPT 回复,关闭后只会使用关键词回复">
155+
GPT 回复
156+
</Tooltip>
157+
</Checkbox>
158+
</HStack>
159+
<HStack>
160+
<Checkbox
161+
isChecked={driverSettings.hasTransfer}
162+
onChange={(e) =>
163+
handleUpdateConfig({ hasTransfer: e.target.checked })
164+
}
165+
>
166+
<Tooltip label="如果匹配到设定的关键词,将自动转人工">
167+
关键词转人工
168+
</Tooltip>
169+
</Checkbox>
170+
<Checkbox
171+
isChecked={driverSettings.hasReplace}
172+
onChange={(e) =>
173+
handleUpdateConfig({ hasReplace: e.target.checked })
174+
}
175+
>
176+
<Tooltip label="如果匹配到设定的关键词,将自动替换成自定义的关键词">
177+
关键词替换
178+
</Tooltip>
179+
</Checkbox>
180+
</HStack>
181+
<HStack>
182+
<Checkbox
183+
isChecked={driverSettings.hasEscClose}
184+
onChange={(e) =>
185+
handleUpdateConfig({ hasEscClose: e.target.checked })
186+
}
187+
>
188+
<Tooltip label="当按下 ESC 键时自动暂停">
189+
按 ESC 键自动暂停
190+
</Tooltip>
191+
</Checkbox>
192+
</HStack>
193+
</VStack>
194+
</HStack>
195+
</Stack>
187196
);
188197
};
189198

src/renderer/main-window/components/layout/Footer.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import React from 'react';
2-
import { Box, Text, Stack, useColorModeValue } from '@chakra-ui/react';
2+
import {
3+
Box,
4+
Text,
5+
Stack,
6+
useColorModeValue,
7+
Tooltip,
8+
Link,
9+
} from '@chakra-ui/react';
310

411
const Footer = () => {
512
const bg = useColorModeValue('gray.100', 'gray.900');
@@ -14,6 +21,14 @@ const Footer = () => {
1421
bg={bg}
1522
>
1623
<Stack>
24+
<Box position={'absolute'}>
25+
<Tooltip label="查看文档获取帮助">
26+
<Link href="https://doc.lazaytools.top/docs" isExternal mr="auto">
27+
📚文档
28+
</Link>
29+
</Tooltip>
30+
</Box>
31+
1732
<Text fontSize="sm" alignSelf={{ base: 'center' }}>
1833
&copy; {new Date().getFullYear()} lrhh123. All rights reserved.
1934
</Text>

0 commit comments

Comments
 (0)