diff --git a/app/src/main/ipc.ts b/app/src/main/ipc.ts index 7c13da8..755f9f6 100644 --- a/app/src/main/ipc.ts +++ b/app/src/main/ipc.ts @@ -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) - }) \ No newline at end of file + }) + +ipcMain.handle('getVersion', async (_event) => { + return app.getVersion() +}) \ No newline at end of file diff --git a/app/src/main/windows.ts b/app/src/main/windows.ts index f91a8bf..e9c7130 100644 --- a/app/src/main/windows.ts +++ b/app/src/main/windows.ts @@ -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 @@ -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') diff --git a/app/src/preload/index.d.ts b/app/src/preload/index.d.ts index 805c1d5..12d217f 100644 --- a/app/src/preload/index.d.ts +++ b/app/src/preload/index.d.ts @@ -13,6 +13,7 @@ declare global { closeWindow: (name: WindowNameType) => void, initTable: () => void, getConfig: () => Promise + getVersion: () => string } } } diff --git a/app/src/preload/index.ts b/app/src/preload/index.ts index 268d18c..3b6c4c5 100644 --- a/app/src/preload/index.ts +++ b/app/src/preload/index.ts @@ -27,6 +27,11 @@ const api = { }, getConfig: () => { return (ipcRenderer.invoke("getConfig") as Promise) + }, + getVersion: async() => { + + const version = await ipcRenderer.invoke("getVersion") + return version } } diff --git a/app/src/renderer/src/layouts/About/index.tsx b/app/src/renderer/src/layouts/About/index.tsx new file mode 100644 index 0000000..736b738 --- /dev/null +++ b/app/src/renderer/src/layouts/About/index.tsx @@ -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 ( +
+ autoMate v{version} +
+ ); +} + +export default About; \ No newline at end of file diff --git a/app/src/renderer/src/router/index.tsx b/app/src/renderer/src/router/index.tsx index 5ca0b95..0ce2742 100644 --- a/app/src/renderer/src/router/index.tsx +++ b/app/src/renderer/src/router/index.tsx @@ -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: }, + { + path: "about", + element: + }, { path: "config", element: , diff --git a/app/types.d.ts b/app/types.d.ts index f143d7f..c7a0d32 100644 --- a/app/types.d.ts +++ b/app/types.d.ts @@ -15,7 +15,7 @@ type ContentType = { } -type WindowNameType = 'search' | 'config' | 'code' | 'interactive' +type WindowNameType = 'search' | 'config' | 'code' | 'interactive' | 'about' type ConfigType = { id: number diff --git a/server/agent/prompt.py b/server/agent/prompt.py index 6bae400..a635b22 100644 --- a/server/agent/prompt.py +++ b/server/agent/prompt.py @@ -3,10 +3,10 @@ code_prompt=string.Template("""# 背景 # 你是一位资深的python程序员,根据用户的需求编写python代码。 ############# # 目标 # -你需要根据用户需求编写新的代码,如果对话的上下文中有代码则需要在已有的代码之上进行修改,如果有不清楚的地方要和用户沟通不要自己瞎猜。 +你需要根据用户需求编写新的代码,如果对话的上下文中有代码则需要在已有的代码之上进行修改,如果对需求不清楚要向用户问清,不要自己瞎猜。 ############# # 约束 # -生成代码时请一定要遵守以下规则否则会出错! +生成代码时请一定要遵守以下规则,否则会出错: 1. 代码中只能使用官方内置库和以下依赖库: selenium、python-docx、requests 2. 以下是我封装好的函数,如果有需要可以直接在代码中使用,无需import: