From 105c10ab0d09be0cc350c7b439ca2b95603b0a46 Mon Sep 17 00:00:00 2001 From: QC2168 Date: Fri, 4 Aug 2023 18:20:22 +0800 Subject: [PATCH 01/18] feat: reload page --- electron/main.ts | 4 ++++ electron/preload.ts | 1 + src/renderer.d.ts | 1 + 3 files changed, 6 insertions(+) diff --git a/electron/main.ts b/electron/main.ts index 51bb3ff..eab3adc 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -307,3 +307,7 @@ ipcMain.handle( 'injectRecommendConfig', async (event, system:RecommendSystemConfigEnum) => injectConfig(system), ); + +ipcMain.handle('reload', () => { + win.reload(); +}); diff --git a/electron/preload.ts b/electron/preload.ts index 156e11e..ee85b1e 100644 --- a/electron/preload.ts +++ b/electron/preload.ts @@ -170,6 +170,7 @@ contextBridge.exposeInMainWorld('win', { minimize: () => ipcRenderer.invoke('minimize-win'), maximize: () => ipcRenderer.invoke('maximize-win'), openLink: (url:string) => ipcRenderer.invoke('openLink', url), + reload: () => ipcRenderer.invoke('reload'), }); contextBridge.exposeInMainWorld('core', { diff --git a/src/renderer.d.ts b/src/renderer.d.ts index 96c6d78..7c5d434 100644 --- a/src/renderer.d.ts +++ b/src/renderer.d.ts @@ -11,6 +11,7 @@ export interface WinApi { minimize: () => Promise, maximize: () => Promise, openLink: (url:string) => Promise, + reload: () => Promise, } export interface Versions { node: () => string, From 994a90d950044e8b9020b9eb8206fe3353a57033 Mon Sep 17 00:00:00 2001 From: QC2168 Date: Fri, 4 Aug 2023 18:40:50 +0800 Subject: [PATCH 02/18] fix(home): keep current menu state --- src/App.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index 5b519b6..153c26d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,7 +2,9 @@ import { ConfigProvider, Layout, Menu, } from 'antd'; -import { Route, Routes, useNavigate } from 'react-router-dom'; +import { + Route, Routes, useNavigate, useLocation, +} from 'react-router-dom'; import Scan from '@/pages/scan'; import Home from './pages/home'; import Settings from './pages/settings'; @@ -14,6 +16,7 @@ const { function App() { const navigate = useNavigate(); + const location = useLocation(); const { themeConfig, menuItems, @@ -27,6 +30,7 @@ function App() { className="fixed w-screen z-10" onSelect={({ key }) => navigate(key)} defaultSelectedKeys={['home']} + selectedKeys={[location.pathname.substring(1)]} mode="horizontal" items={menuItems} /> From 4d7e4af7c15a221b9965afa807c101743e2f10cb Mon Sep 17 00:00:00 2001 From: QC2168 Date: Sat, 5 Aug 2023 13:00:11 +0800 Subject: [PATCH 03/18] refactor: modify antd language --- src/App.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index 153c26d..d7f077c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,7 @@ import { ConfigProvider, Layout, Menu, } from 'antd'; +import zhCN from 'antd/locale/zh_CN'; import { Route, Routes, useNavigate, useLocation, @@ -23,7 +24,7 @@ function App() { } = useLayout(); return ( - +
Date: Sat, 26 Aug 2023 11:08:16 +0800 Subject: [PATCH 04/18] refactor(electron): main code --- electron/main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index eab3adc..1ad6e63 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -197,7 +197,7 @@ ipcMain.handle('setDevice', (event, id: string) => mibInstance.setDevice(id)); ipcMain.handle('getDevices', () => getDevices(mibInstance.adbOpt.adbPath)); -ipcMain.handle('backup', async (event, id: SaveItemType | SaveItemType[]) => { +ipcMain.handle('backup', async (event, params: SaveItemType | SaveItemType[]) => { try { const result = await runBackupWorker({ task: 'backup', @@ -205,7 +205,7 @@ ipcMain.handle('backup', async (event, id: SaveItemType | SaveItemType[]) => { current: mibInstance.adbOpt.current, path: AdbPath, }, - params: id, + params, }); win.webContents.send('backupDone', result); } catch (error) { From 2589a64bf448a6fce5da01a30e8273717e2c353e Mon Sep 17 00:00:00 2001 From: QC2168 Date: Sat, 2 Sep 2023 10:40:58 +0800 Subject: [PATCH 05/18] feat(home): tour cmp --- src/pages/home/index.tsx | 85 +++++++++++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 15 deletions(-) diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx index 984d81b..e74b0f0 100644 --- a/src/pages/home/index.tsx +++ b/src/pages/home/index.tsx @@ -1,13 +1,13 @@ import { Button, Card, Empty, Select, Table, Input, - Typography, Space, + Typography, Space, Tour, type TourProps, } from 'antd'; - import { UploadOutlined, PlusOutlined, DownloadOutlined, } from '@ant-design/icons'; import BackupModal, { BackupModalRef as BackupModalRefExpose, MODAL_STATUS } from '@/pages/home/components/BackupModal'; import { useRef } from 'react'; +import { useLocalStorageState } from 'ahooks'; import useMessage from '@/utils/message'; import useDataSource from '@/pages/home/hooks/useDataSource'; import useEditOutput from '@/pages/home/hooks/useEditOutput'; @@ -19,6 +19,12 @@ const { Option } = Select; export default function Analysis() { const { createErrorMessage } = useMessage(); const [data, setData] = useDataSource(); + const [openTour, setOpenTour] = useLocalStorageState( + 'tour', + { + defaultValue: true, + }, + ); const { isEditOutput, showEditOutputInput, @@ -51,15 +57,56 @@ export default function Analysis() { delNode, }); const addNode = () => { + if (openTour) return; BackupModalRef.current?.open(MODAL_STATUS.ADD); }; + const addNodeRef = useRef(null); + const tableRef = useRef(null); + const backupBtnRef = useRef(null); + const restoreBtnRef = useRef(null); + const outputPathRef = useRef(null); + const chooseDeviceRef = useRef(null); + const steps: TourProps['steps'] = [ + { + title: '备份节点', + description: '这里是所有备份节点的列表', + target: () => tableRef.current as HTMLDivElement, + }, + { + title: '添加节点', + description: '点击这里,往列表添加备份节点,并根据实际需求,填写节点信息并添加', + target: () => addNodeRef.current as HTMLDivElement, + }, + { + title: '导出路径', + description: '设置一个根部导出路径,备份的文件都会被放到这里', + target: () => outputPathRef.current as HTMLDivElement, + }, + { + title: '选择设备', + description: '选择需要备份的数据(接入设备时,程序会自动选择)', + target: () => chooseDeviceRef.current as HTMLDivElement, + }, + { + title: '备份数据', + description: '点击这里会根据您配置的节点进行备份', + target: () => backupBtnRef.current as HTMLDivElement, + }, + { + title: '恢复数据', + description: '将已备份过的数据文件,原封不动的移动到设备中', + target: () => restoreBtnRef.current as HTMLDivElement, + }, + ]; + return (