diff --git a/CHANGELOG.md b/CHANGELOG.md
index f32ec6f..c249d5d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## [main] 0.0.5
- 支持对已经打开过的文件项目进行管理
+- 支持对用户对应服务器的调试工作内容进行保存(MVP 100%)
## [main] 0.0.4
- 修复选择模型后点击确认跳转回 deepseek 的 bug
diff --git a/README.md b/README.md
index 6e8ba41..fa77fda 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,7 @@
| `all` | 支持同时调试多个 MCP Server | `MVP` | 0% | `P1` |
| `all` | 支持通过大模型进行在线验证 | `迭代版本` | 100% | `Done` |
| `all` | 支持 completion/complete 协议字段 | `MVP` | 0% | `P1` |
-| `all` | 支持对用户对应服务器的调试工作内容进行保存 | `MVP` | 80% | `P0` |
+| `all` | 支持对用户对应服务器的调试工作内容进行保存 | `迭代版本` | 100% | `Done` |
| `render` | 高危操作权限确认 | `MVP` | 0% | `P1` |
| `service` | 对于连接的 mcp server 进行热更新 | `MVP` | 0% | `P1` |
| `service` | 系统配置信息云同步 | `MVP` | 0% | `P1` |
diff --git a/renderer/src/components/main-panel/prompt/prompt-reader.vue b/renderer/src/components/main-panel/prompt/prompt-reader.vue
index 2d2f075..28eb71a 100644
--- a/renderer/src/components/main-panel/prompt/prompt-reader.vue
+++ b/renderer/src/components/main-panel/prompt/prompt-reader.vue
@@ -3,20 +3,20 @@
{{ currentPrompt.name }}
-
+
-
-
-
+
@@ -39,6 +39,7 @@ import { tabs } from '../panel';
import { parsePromptTemplate, promptsManager, PromptStorage } from './prompts';
import { CasualRestAPI, PromptsGetResponse } from '@/hook/type';
import { useMessageBridge } from '@/api/message-bridge';
+import { getDefaultValue, normaliseJavascriptType } from '@/hook/mcp';
defineComponent({ name: 'prompt-reader' });
@@ -54,9 +55,11 @@ const props = defineProps({
const tab = tabs.content[props.tabId];
const tabStorage = tab.storage as PromptStorage;
+if (!tabStorage.formData) {
+ tabStorage.formData = {};
+}
+
const formRef = ref();
-// TODO: 将 formData 装入 tabStorage
-const formData = ref>({});
const loading = ref(false);
const responseData = ref();
@@ -93,11 +96,19 @@ const formRules = computed(() => {
});
const initFormData = () => {
- formData.value = {}
- currentPrompt.value?.params.forEach(param => {
- formData.value[param.name] = param.type === 'number' ? 0 :
- param.type === 'boolean' ? false : ''
- })
+
+ if (!currentPrompt.value?.params) return;
+
+ const newSchemaDataForm: Record = {};
+
+ currentPrompt.value.params.forEach(param => {
+ newSchemaDataForm[param.name] = getDefaultValue(param);
+ const originType = normaliseJavascriptType(typeof tabStorage.formData[param.name]);
+ if (tabStorage.formData[param.name]!== undefined && originType === param.type) {
+ newSchemaDataForm[param.name] = tabStorage.formData[param.name];
+ }
+ });
+
}
const resetForm = () => {
@@ -114,7 +125,7 @@ function handleSubmit() {
bridge.postMessage({
command: 'prompts/get',
- data: { promptId: currentPrompt.value.name, args: JSON.parse(JSON.stringify(formData.value)) }
+ data: { promptId: currentPrompt.value.name, args: JSON.parse(JSON.stringify(tabStorage.formData)) }
});
}
diff --git a/renderer/src/components/main-panel/prompt/prompt-templates.vue b/renderer/src/components/main-panel/prompt/prompt-templates.vue
index 816dd17..2b3b8ba 100644
--- a/renderer/src/components/main-panel/prompt/prompt-templates.vue
+++ b/renderer/src/components/main-panel/prompt/prompt-templates.vue
@@ -73,7 +73,9 @@ onMounted(() => {
commandCancel = bridge.addCommandListener('prompts/list', (data: CasualRestAPI) => {
promptsManager.templates = data.msg.prompts || [];
- if (promptsManager.templates.length > 0) {
+ const targetPrompt = promptsManager.templates.find(template => template.name === tabStorage.currentPromptName);
+
+ if (targetPrompt === undefined) {
tabStorage.currentPromptName = promptsManager.templates[0].name;
tabStorage.lastPromptGetResponse = undefined;
}
diff --git a/renderer/src/components/main-panel/prompt/prompts.ts b/renderer/src/components/main-panel/prompt/prompts.ts
index 3419894..b72e9ce 100644
--- a/renderer/src/components/main-panel/prompt/prompts.ts
+++ b/renderer/src/components/main-panel/prompt/prompts.ts
@@ -12,6 +12,7 @@ export const promptsManager = reactive<{
export interface PromptStorage {
currentPromptName: string;
lastPromptGetResponse?: PromptsGetResponse;
+ formData: Record;
}
export function parsePromptTemplate(template: string): {
diff --git a/service/tabs.锦恢的 MCP Server.json b/service/tabs.锦恢的 MCP Server.json
index a966a72..29fc449 100644
--- a/service/tabs.锦恢的 MCP Server.json
+++ b/service/tabs.锦恢的 MCP Server.json
@@ -1,5 +1,5 @@
{
- "currentIndex": 2,
+ "currentIndex": 0,
"tabs": [
{
"name": "交互测试",
@@ -160,6 +160,29 @@
]
}
}
+ },
+ {
+ "name": "提词",
+ "icon": "icon-chat",
+ "type": "blank",
+ "componentIndex": 1,
+ "storage": {
+ "formData": {
+ "message": "你好"
+ },
+ "currentPromptName": "translate",
+ "lastPromptGetResponse": {
+ "messages": [
+ {
+ "role": "user",
+ "content": {
+ "type": "text",
+ "text": "请将下面的话语翻译成中文:\n\n你好"
+ }
+ }
+ ]
+ }
+ }
}
]
}
\ No newline at end of file