Skip to content

Commit

Permalink
feat(settings): about repo
Browse files Browse the repository at this point in the history
  • Loading branch information
QC2168 committed Jun 25, 2023
1 parent 3f61c80 commit 34177e4
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 11 deletions.
23 changes: 22 additions & 1 deletion electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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')) {
Expand Down Expand Up @@ -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();
}
});
1 change: 1 addition & 0 deletions electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
2 changes: 0 additions & 2 deletions src/pages/home/hooks/useBackup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pick<BackupModalRef, 'open'> & { delNode: (i: number) => void }>) {
const [instance] = useMib();
const [backupLoading, setBackupLoading] = useState<boolean>(false);
const [restoreLoading, setRestoreLoading] = useState<boolean>(false);
const {
Expand Down
2 changes: 0 additions & 2 deletions src/pages/home/hooks/useEditOutput.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { useState } from 'react';
import useMib from '@/pages/home/hooks/useMib';
import { useMount } from 'ahooks';
import useMessage from '@/utils/message';

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!);
Expand Down
3 changes: 0 additions & 3 deletions src/pages/scan/index.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -33,8 +32,6 @@ export default function Index() {
const [themeMode] = useRecoilState(themeModeState);
const [chartOption, setChartOption] = useSetState<EChartsOption>(chartDefaultOption as EChartsOption);
const [loading, setLoading] = useState(false);
const [, u] = useMib();

const enterLoading = async () => {
setIsClick(true);
setLoading(true);
Expand Down
27 changes: 24 additions & 3 deletions src/pages/settings/index.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -32,7 +33,9 @@ export default function Index() {
}
setRebooting(false);
};

const openRepo = async () => {
await window.win.openLink('https://github.com/QC2168/mib');
};
return (
<div className="px-8 py-2">
<Form
Expand All @@ -53,6 +56,24 @@ export default function Index() {
<Form.Item label="设备连接服务(ADB)">
<Button type="primary" icon={<ReloadOutlined />} loading={rebooting} disabled={rebooting} onClick={() => rebootADB()}>{rebooting ? '正在重启服务' : '重启服务'}</Button>
</Form.Item>
<Form.Item label="关于项目">
<Space>
<Button type="primary" onClick={() => openRepo()} icon={<GithubOutlined />}>项目地址</Button>
<Popover
title="联系作者加入交流群/反馈/建议"
content={(
<Image
width={150}
src={wechat}
/>
)}
>
<Button icon={<WechatOutlined />} type="primary">联系作者</Button>
</Popover>

</Space>

</Form.Item>
</Form>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/renderer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface WinApi {
close: () => Promise<void>,
minimize: () => Promise<void>,
maximize: () => Promise<void>,
openLink: (url:string) => Promise<void>,
}
export interface MibApi {
instance: () => Promise<Mib>,
Expand Down

0 comments on commit 34177e4

Please sign in to comment.