From 34177e4d2e3ff7622d62611cc837376192ae6c3f Mon Sep 17 00:00:00 2001 From: QC2168 Date: Sun, 25 Jun 2023 21:05:31 +0800 Subject: [PATCH] feat(settings): about repo --- electron/main.ts | 23 ++++++++++++++++++++++- electron/preload.ts | 1 + src/pages/home/hooks/useBackup.tsx | 2 -- src/pages/home/hooks/useEditOutput.ts | 2 -- src/pages/scan/index.tsx | 3 --- src/pages/settings/index.tsx | 27 ++++++++++++++++++++++++--- src/renderer.d.ts | 1 + 7 files changed, 48 insertions(+), 11 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index d5006f4..b75fb18 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -3,7 +3,9 @@ import Mib, { devices as getDevices, type SaveItemType, addNode, removeNode, editNode, editOutputPath, } from '@qc2168/mib'; -import { app, BrowserWindow, ipcMain } from 'electron'; +import { + app, BrowserWindow, ipcMain, shell, Notification, +} from 'electron'; import { release } from 'os'; // import installExtension, { // REACT_DEVELOPER_TOOLS, @@ -19,6 +21,9 @@ const AdbPath = app.isPackaged ? join(process.cwd(), '/resources/resources/adb/a const mibInstance = new Mib(); mibInstance.setAdbPath(AdbPath); + +const NOTIFICATION_TITLE = 'MIB'; + // Disable GPU Acceleration for Windows 7 if (release() .startsWith('6.1')) { @@ -260,3 +265,19 @@ ipcMain.handle('scan', async (event, path:string) => { }); } }); + +// open link +ipcMain.handle('openLink', async (event, url:string) => { + try { + await shell.openExternal(url); + new Notification({ + title: NOTIFICATION_TITLE, + body: '访问链接失败1', + }).show(); + } catch (error) { + new Notification({ + title: NOTIFICATION_TITLE, + body: '访问链接失败', + }).show(); + } +}); diff --git a/electron/preload.ts b/electron/preload.ts index fe1e1a6..1cd254f 100644 --- a/electron/preload.ts +++ b/electron/preload.ts @@ -167,6 +167,7 @@ contextBridge.exposeInMainWorld('win', { close: () => ipcRenderer.invoke('close-win'), minimize: () => ipcRenderer.invoke('minimize-win'), maximize: () => ipcRenderer.invoke('maximize-win'), + openLink: (url:string) => ipcRenderer.invoke('openLink', url), }); contextBridge.exposeInMainWorld('core', { diff --git a/src/pages/home/hooks/useBackup.tsx b/src/pages/home/hooks/useBackup.tsx index 44ed852..339b278 100644 --- a/src/pages/home/hooks/useBackup.tsx +++ b/src/pages/home/hooks/useBackup.tsx @@ -13,11 +13,9 @@ import useDevices from '@/pages/home/hooks/useDevices'; import { BackupModalRef, MODAL_STATUS } from '@/pages/home/components/BackupModal'; import { useMount } from 'ahooks'; import styles from '../index.module.less'; -import useMib from './useMib'; const { confirm } = Modal; export default function useBackup(opt: Partial & { delNode: (i: number) => void }>) { - const [instance] = useMib(); const [backupLoading, setBackupLoading] = useState(false); const [restoreLoading, setRestoreLoading] = useState(false); const { diff --git a/src/pages/home/hooks/useEditOutput.ts b/src/pages/home/hooks/useEditOutput.ts index e6ff0b7..b370f96 100644 --- a/src/pages/home/hooks/useEditOutput.ts +++ b/src/pages/home/hooks/useEditOutput.ts @@ -1,5 +1,4 @@ import { useState } from 'react'; -import useMib from '@/pages/home/hooks/useMib'; import { useMount } from 'ahooks'; import useMessage from '@/utils/message'; @@ -7,7 +6,6 @@ export default function useEditOutput() { const [isEditOutput, setIsEditOutput] = useState(false); const [tempOutput, setTempOutput] = useState(''); const [outputPath, setOutputPath] = useState(''); - const [, u] = useMib(); const { createSuccessMessage, createErrorMessage } = useMessage(); const tempOutputChange = (event:any) => { setTempOutput(event.target!.value!); diff --git a/src/pages/scan/index.tsx b/src/pages/scan/index.tsx index c4c3603..85437e5 100644 --- a/src/pages/scan/index.tsx +++ b/src/pages/scan/index.tsx @@ -1,5 +1,4 @@ import { useState } from 'react'; -import useMib from '@/pages/home/hooks/useMib'; import * as echarts from 'echarts/core'; import { SearchOutlined } from '@ant-design/icons'; import { @@ -33,8 +32,6 @@ export default function Index() { const [themeMode] = useRecoilState(themeModeState); const [chartOption, setChartOption] = useSetState(chartDefaultOption as EChartsOption); const [loading, setLoading] = useState(false); - const [, u] = useMib(); - const enterLoading = async () => { setIsClick(true); setLoading(true); diff --git a/src/pages/settings/index.tsx b/src/pages/settings/index.tsx index e63d367..d3ad719 100644 --- a/src/pages/settings/index.tsx +++ b/src/pages/settings/index.tsx @@ -1,12 +1,13 @@ import { - Form, Radio, Button, + Form, Radio, Button, Popover, Space, Image, } from 'antd'; -import { ReloadOutlined } from '@ant-design/icons'; +import { GithubOutlined, ReloadOutlined, WechatOutlined } from '@ant-design/icons'; import { ThemeType } from '@/lib/css/theme'; import { useRecoilState } from 'recoil'; import { Local } from '@/utils/storage'; import { useState } from 'react'; import useMessage from '@/utils/message'; +import wechat from '@/assets/images/wechat.jpg'; import { themeModeState } from '../../../state/themeState'; import { version } from '../../../package.json'; @@ -32,7 +33,9 @@ export default function Index() { } setRebooting(false); }; - + const openRepo = async () => { + await window.win.openLink('https://github.com/QC2168/mib'); + }; return (
+ + + + +)} + > + + + + + +
); diff --git a/src/renderer.d.ts b/src/renderer.d.ts index bdf5440..1c5319d 100644 --- a/src/renderer.d.ts +++ b/src/renderer.d.ts @@ -9,6 +9,7 @@ export interface WinApi { close: () => Promise, minimize: () => Promise, maximize: () => Promise, + openLink: (url:string) => Promise, } export interface MibApi { instance: () => Promise,