mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 13:07:17 +08:00
增加关于页面
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {ipcMain, IpcMainEvent } from "electron"
|
||||
import {app, ipcMain, IpcMainEvent } from "electron"
|
||||
import { getWindowByName, getWindowByEvent} from "./windows"
|
||||
|
||||
ipcMain.on('openWindow', (_event: IpcMainEvent, name: WindowNameType, router_url="") => {
|
||||
@@ -13,4 +13,8 @@ ipcMain.on('closeWindow', (_event: IpcMainEvent, name: WindowNameType) => {
|
||||
ipcMain.on('setIgnoreMouseEvents',
|
||||
(event: IpcMainEvent, ignore: boolean, options?:{forward: boolean}) => {
|
||||
getWindowByEvent(event).setIgnoreMouseEvents(ignore, options)
|
||||
})
|
||||
})
|
||||
|
||||
ipcMain.handle('getVersion', async (_event) => {
|
||||
return app.getVersion()
|
||||
})
|
||||
@@ -27,7 +27,7 @@ export const config = {
|
||||
config: {
|
||||
id: 0,
|
||||
options: {
|
||||
initShow: true,
|
||||
initShow: false,
|
||||
width: 830,
|
||||
height: 670,
|
||||
openDevTools: false,
|
||||
@@ -35,6 +35,18 @@ export const config = {
|
||||
transparent: false,
|
||||
hash: '/#config'
|
||||
}
|
||||
},
|
||||
about: {
|
||||
id: 0,
|
||||
options: {
|
||||
initShow: true,
|
||||
width: 830,
|
||||
height: 670,
|
||||
openDevTools: true,
|
||||
frame: true,
|
||||
transparent: false,
|
||||
hash: '/#about'
|
||||
}
|
||||
}
|
||||
|
||||
} as Record<WindowNameType, {id: number, options: OptionsType }>
|
||||
@@ -76,9 +88,10 @@ function createTray(){
|
||||
})
|
||||
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{ label: '搜索', click: () => { getWindowByName('search').show() } },
|
||||
{ label: '关于', click: () => { getWindowByName('about').show() } },
|
||||
|
||||
{ label: '配置', click: () => { getWindowByName('config').show() } },
|
||||
{ label: '代码', click: () => { getWindowByName('code').show() } },
|
||||
|
||||
{ label: '退出', click: async () => {
|
||||
try{
|
||||
await fetch('http://127.0.0.1:5000/shutdown')
|
||||
|
||||
1
app/src/preload/index.d.ts
vendored
1
app/src/preload/index.d.ts
vendored
@@ -13,6 +13,7 @@ declare global {
|
||||
closeWindow: (name: WindowNameType) => void,
|
||||
initTable: () => void,
|
||||
getConfig: () => Promise<ConfigType>
|
||||
getVersion: () => string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ const api = {
|
||||
},
|
||||
getConfig: () => {
|
||||
return (ipcRenderer.invoke("getConfig") as Promise<ConfigType>)
|
||||
},
|
||||
getVersion: async() => {
|
||||
|
||||
const version = await ipcRenderer.invoke("getVersion")
|
||||
return version
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
19
app/src/renderer/src/layouts/About/index.tsx
Normal file
19
app/src/renderer/src/layouts/About/index.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
function About() {
|
||||
const [version, setVersion] = useState('');
|
||||
useEffect(() => {
|
||||
async function fetchVersion() {
|
||||
const version = await window.api.getVersion();
|
||||
setVersion(version);
|
||||
}
|
||||
fetchVersion();
|
||||
}, []);
|
||||
return (
|
||||
<h5>
|
||||
autoMate v{version}
|
||||
</h5>
|
||||
);
|
||||
}
|
||||
|
||||
export default About;
|
||||
@@ -14,12 +14,17 @@ import CategoryAction from "@renderer/pages/Category/CategoryAction";
|
||||
import { Setting } from "@renderer/pages/Setting";
|
||||
import SettingAction from "@renderer/pages/Setting/SettingAction";
|
||||
import SettingLoader from "@renderer/pages/Setting/SettingLoader";
|
||||
import About from "@renderer/layouts/About";
|
||||
|
||||
const router = createHashRouter([
|
||||
{
|
||||
path: "/",
|
||||
element: <Home />
|
||||
},
|
||||
{
|
||||
path: "about",
|
||||
element: <About />
|
||||
},
|
||||
{
|
||||
path: "config",
|
||||
element: <Config />,
|
||||
|
||||
2
app/types.d.ts
vendored
2
app/types.d.ts
vendored
@@ -15,7 +15,7 @@ type ContentType = {
|
||||
}
|
||||
|
||||
|
||||
type WindowNameType = 'search' | 'config' | 'code' | 'interactive'
|
||||
type WindowNameType = 'search' | 'config' | 'code' | 'interactive' | 'about'
|
||||
|
||||
type ConfigType = {
|
||||
id: number
|
||||
|
||||
@@ -3,10 +3,10 @@ code_prompt=string.Template("""# 背景 #
|
||||
你是一位资深的python程序员,根据用户的需求编写python代码。
|
||||
#############
|
||||
# 目标 #
|
||||
你需要根据用户需求编写新的代码,如果对话的上下文中有代码则需要在已有的代码之上进行修改,如果有不清楚的地方要和用户沟通不要自己瞎猜。
|
||||
你需要根据用户需求编写新的代码,如果对话的上下文中有代码则需要在已有的代码之上进行修改,如果对需求不清楚要向用户问清,不要自己瞎猜。
|
||||
#############
|
||||
# 约束 #
|
||||
生成代码时请一定要遵守以下规则否则会出错!
|
||||
生成代码时请一定要遵守以下规则,否则会出错:
|
||||
1. 代码中只能使用官方内置库和以下依赖库:
|
||||
selenium、python-docx、requests
|
||||
2. 以下是我封装好的函数,如果有需要可以直接在代码中使用,无需import:
|
||||
|
||||
Reference in New Issue
Block a user