From a535690bc60c589ce5c4de8bcac19bb052b1d741 Mon Sep 17 00:00:00 2001 From: Kirigaya <1193466151@qq.com> Date: Mon, 28 Apr 2025 14:57:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=B3=E9=97=AD=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E9=A1=B5=20key=20=E9=87=8D=E6=8E=92=E5=BA=8F=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- renderer/package-lock.json | 24 +++- renderer/package.json | 1 + renderer/public/default-light.css | 2 +- renderer/public/index.html | 2 +- renderer/src/App.vue | 8 +- .../chat/message/toolcall-result-item.vue | 112 ++++++++++++++---- .../main-panel/chat/message/toolcall.vue | 2 +- .../components/main-panel/chat/task-loop.ts | 2 +- renderer/src/components/main-panel/index.vue | 4 +- renderer/src/components/main-panel/panel.ts | 7 +- renderer/src/hook/panel.ts | 6 +- renderer/src/views/debug/index.vue | 2 +- 12 files changed, 131 insertions(+), 41 deletions(-) diff --git a/renderer/package-lock.json b/renderer/package-lock.json index ca29cb2..92b19e8 100644 --- a/renderer/package-lock.json +++ b/renderer/package-lock.json @@ -14,6 +14,7 @@ "markdown-it": "^14.1.0", "markdown-it-katex": "^2.0.3", "openai": "^4.93.0", + "uuid": "^11.1.0", "vue": "^3.2.13", "vue-i18n": "^11.1.0", "vue-router": "^4.0.3" @@ -11820,6 +11821,16 @@ "websocket-driver": "^0.7.4" } }, + "node_modules/sockjs/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz", @@ -12970,13 +12981,16 @@ } }, "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmmirror.com/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true, + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", + "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], "license": "MIT", "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } }, "node_modules/v8-compile-cache": { diff --git a/renderer/package.json b/renderer/package.json index d9df251..31082f4 100644 --- a/renderer/package.json +++ b/renderer/package.json @@ -14,6 +14,7 @@ "markdown-it": "^14.1.0", "markdown-it-katex": "^2.0.3", "openai": "^4.93.0", + "uuid": "^11.1.0", "vue": "^3.2.13", "vue-i18n": "^11.1.0", "vue-router": "^4.0.3" diff --git a/renderer/public/default-light.css b/renderer/public/default-light.css index 83bad3c..50adca9 100644 --- a/renderer/public/default-light.css +++ b/renderer/public/default-light.css @@ -22,7 +22,7 @@ --vscode-scrollbarSlider-activeBackground: rgba(0, 0, 0, 0.6); --vscode-progressBar-background: #0e70c0; --vscode-editor-background: #ffffff; - --vscode-editor-foreground: #000000; + --vscode-editor-foreground: #3d3d3d; --vscode-editorStickyScroll-background: #ffffff; --vscode-editorStickyScrollHover-background: #f0f0f0; --vscode-editorStickyScroll-shadow: #dddddd; diff --git a/renderer/public/index.html b/renderer/public/index.html index e014924..57989f9 100644 --- a/renderer/public/index.html +++ b/renderer/public/index.html @@ -7,7 +7,7 @@ - + diff --git a/renderer/src/App.vue b/renderer/src/App.vue index f8d236d..501c47f 100644 --- a/renderer/src/App.vue +++ b/renderer/src/App.vue @@ -29,8 +29,8 @@ bridge.addCommandListener('hello', data => { function initDebug() { - // connectionArgs.commandString = 'node /Users/bytedance/projects/mcp/servers/src/puppeteer/dist/index.js'; - connectionArgs.commandString = 'node C:/Users/K/code/servers/src/puppeteer/dist/index.js'; + connectionArgs.commandString = 'node /Users/bytedance/projects/mcp/servers/src/puppeteer/dist/index.js'; + // connectionArgs.commandString = 'node C:/Users/K/code/servers/src/puppeteer/dist/index.js'; // connectionArgs.commandString = 'uv run mcp run bing-picture.py'; connectionArgs.cwd = '../servers'; connectionMethods.current = 'STDIO'; @@ -107,4 +107,8 @@ onMounted(() => { max-width: 300px; } + +.icon-chat:before { + font-weight: 1000; +} diff --git a/renderer/src/components/main-panel/chat/message/toolcall-result-item.vue b/renderer/src/components/main-panel/chat/message/toolcall-result-item.vue index 82f3043..e1de7d6 100644 --- a/renderer/src/components/main-panel/chat/message/toolcall-result-item.vue +++ b/renderer/src/components/main-panel/chat/message/toolcall-result-item.vue @@ -5,25 +5,32 @@
-
- screenshot +
+ screenshot - + + + + + + + + +
- - - - - -
{{ JSON.stringify(props.item) }}
@@ -62,7 +69,7 @@ if (ocr) { const { id, progress: p = 1.0, status = 'finish' } = data; if (id === workerId) { progressText.value = status; - progress.value = Math.min(Math.ceil(Math.max(p * 100 ,0)), 100); + progress.value = Math.min(Math.ceil(Math.max(p * 100, 0)), 100); } }, { once: false }); @@ -88,13 +95,48 @@ if (props.item.data) { console.log(props.item.data); getBlobUrlByFilename(props.item.data).then(url => { console.log(url); - + if (url) { thumbnail.value = url; } }); } +const showFullImage = () => { + const img = new Image(); + img.src = thumbnail.value; + img.onload = () => { + const overlay = document.createElement('div'); + overlay.style.position = 'fixed'; + overlay.style.top = '0'; + overlay.style.left = '0'; + overlay.style.width = '100%'; + overlay.style.height = '100%'; + overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.8)'; + overlay.style.zIndex = '9999'; + overlay.style.display = 'flex'; + overlay.style.justifyContent = 'center'; + overlay.style.alignItems = 'center'; + overlay.onclick = () => document.body.removeChild(overlay); + + const imgContainer = document.createElement('div'); + imgContainer.style.maxWidth = '90vw'; + imgContainer.style.maxHeight = '90vh'; + imgContainer.style.overflow = 'auto'; + + const fullImg = new Image(); + fullImg.src = thumbnail.value; + fullImg.style.width = 'auto'; + fullImg.style.height = 'auto'; + fullImg.style.maxWidth = '100%'; + fullImg.style.maxHeight = '100%'; + + imgContainer.appendChild(fullImg); + overlay.appendChild(imgContainer); + document.body.appendChild(overlay); + }; +}; + \ No newline at end of file diff --git a/renderer/src/components/main-panel/chat/message/toolcall.vue b/renderer/src/components/main-panel/chat/message/toolcall.vue index fe50241..175a277 100644 --- a/renderer/src/components/main-panel/chat/message/toolcall.vue +++ b/renderer/src/components/main-panel/chat/message/toolcall.vue @@ -45,7 +45,7 @@ 反馈 - + diff --git a/renderer/src/components/main-panel/chat/task-loop.ts b/renderer/src/components/main-panel/chat/task-loop.ts index 55ff11d..9d84bc2 100644 --- a/renderer/src/components/main-panel/chat/task-loop.ts +++ b/renderer/src/components/main-panel/chat/task-loop.ts @@ -312,7 +312,7 @@ export class TaskLoop { const toolCallResult = await this.handleToolCalls(this.streamingToolCalls.value); - console.log(toolCallResult); + console.log('toolCallResult', toolCallResult); if (toolCallResult.state === MessageState.ParseJsonError) { // 如果是因为解析 JSON 错误,则重新开始 diff --git a/renderer/src/components/main-panel/index.vue b/renderer/src/components/main-panel/index.vue index 164ca1e..eff5fe9 100644 --- a/renderer/src/components/main-panel/index.vue +++ b/renderer/src/components/main-panel/index.vue @@ -6,7 +6,7 @@ @@ -56,7 +56,7 @@ function pageAddNewTab() { } } -function setActiveTab(index: number) { +function setActiveTab(index: number) { if (index >= 0 && index < tabs.content.length) { tabs.activeIndex = index; // 如果不在 debug 路由,则进入 diff --git a/renderer/src/components/main-panel/panel.ts b/renderer/src/components/main-panel/panel.ts index 03db395..6b914a0 100644 --- a/renderer/src/components/main-panel/panel.ts +++ b/renderer/src/components/main-panel/panel.ts @@ -1,5 +1,5 @@ import { watch, reactive } from 'vue'; -import { useRoute, useRouter } from 'vue-router'; +import { v4 as uuidv4 } from 'uuid'; import Resource from './resource/index.vue'; import Chat from './chat/index.vue'; @@ -11,6 +11,7 @@ import { safeSavePanels, savePanels } from '@/hook/panel'; const { t } = I18n.global; interface Tab { + id: string; name: string; icon: string; type: string; @@ -52,6 +53,7 @@ watch( export function createTab(type: string, index: number): Tab { let customName: string | null = null; + const id = uuidv4(); return { get name() { @@ -65,6 +67,7 @@ export function createTab(type: string, index: number): Tab { }, icon: 'icon-blank', type, + id, componentIndex: -1, component: undefined, storage: {}, @@ -83,6 +86,8 @@ export function closeTab(index: number) { tabs.content.splice(index, 1); + console.log(tabs.content); + // 调整活动标签索引 if (tabs.activeIndex >= index) { tabs.activeIndex = Math.max(0, tabs.activeIndex - 1); diff --git a/renderer/src/hook/panel.ts b/renderer/src/hook/panel.ts index 0648413..0713523 100644 --- a/renderer/src/hook/panel.ts +++ b/renderer/src/hook/panel.ts @@ -2,6 +2,7 @@ import { useMessageBridge } from "@/api/message-bridge"; import { pinkLog } from "@/views/setting/util"; import { debugModes, tabs } from "@/components/main-panel/panel"; import { markRaw, ref, nextTick } from "vue"; +import { v4 as uuidv4 } from 'uuid'; interface SaveTabItem { name: string; @@ -48,6 +49,7 @@ export function loadPanels() { const component = tab.componentIndex >= 0? markRaw(debugModes[tab.componentIndex]) : undefined; tabs.content.push({ + id: uuidv4(), name: tab.name, icon: tab.icon, type: tab.type, @@ -57,7 +59,7 @@ export function loadPanels() { }); } - tabs.activeIndex = persistTab.currentIndex; + tabs.activeIndex = persistTab.currentIndex; } panelLoaded.value = true; @@ -76,7 +78,7 @@ export function safeSavePanels() { clearTimeout(debounceHandler); debounceHandler = setTimeout(() => { savePanels(); - }, 1000); + }, 100); } export function savePanels(saveHandler?: () => void) { diff --git a/renderer/src/views/debug/index.vue b/renderer/src/views/debug/index.vue index 3e401e0..68e51eb 100644 --- a/renderer/src/views/debug/index.vue +++ b/renderer/src/views/debug/index.vue @@ -8,7 +8,7 @@