From 91708315f301d47d738d253fc221573117e5f325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Sat, 28 Feb 2026 00:53:26 +0800 Subject: [PATCH] =?UTF-8?q?style(ai):=20=E6=A0=BC=E5=BC=8F=E5=8C=96=20AI?= =?UTF-8?q?=20API=20=E9=94=99=E8=AF=AF=E6=B6=88=E6=81=AF=E5=92=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=20AI=20=E8=A7=86=E5=9B=BE=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 格式化 Ollama 和 OpenAI API 的错误消息字符串以提高可读性 - 移除 AI 视图中的 BaseURL 输入字段并硬编码为固定端点 - 简化 AI 视图中 API 调用的基础 URL 配置逻辑 - 修复多个组件中的代码格式和空格缩进问题 - 清理经销商订单视图中的多余注释和代码结构 - 调整表单组件的标签和布局格式以提升用户体验 --- src/api/ai/ollama.ts | 13 +- src/api/ai/openai.ts | 12 +- src/views/ai/index.vue | 25 +- src/views/glt/shopDealerOrder2/index.vue | 6 +- .../shopDealerCapital/components/search.vue | 10 +- .../shopDealerOrder/components/search.vue | 3 +- src/views/shop/shopDealerOrder/index.vue | 20 +- .../shopDealerOrder2/components/Import.vue | 94 +-- .../shopDealerOrder2/components/search.vue | 43 +- .../components/shopDealerOrderEdit.vue | 365 ++++----- src/views/shop/shopDealerOrder2/index.vue | 726 +++++++++--------- .../components/shopDealerUserEdit.vue | 131 ++-- src/views/shop/shopDealerUser/index.vue | 176 +++-- .../system/setting/components/privacy.vue | 4 +- .../system/setting/components/wx-official.vue | 4 +- .../system/setting/components/wx-work.vue | 4 +- src/views/system/setting/index.vue | 6 +- 17 files changed, 846 insertions(+), 796 deletions(-) diff --git a/src/api/ai/ollama.ts b/src/api/ai/ollama.ts index 03aaf41..48316bc 100644 --- a/src/api/ai/ollama.ts +++ b/src/api/ai/ollama.ts @@ -48,7 +48,9 @@ export async function listOllamaModels(opts?: { baseURL?: string }) { if (!res.ok) { const text = await res.text().catch(() => ''); throw new Error( - `listOllamaModels failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}` + `listOllamaModels failed: ${res.status} ${res.statusText}${ + text ? ` - ${text}` : '' + }` ); } return (await res.json()) as OllamaTagsResponse; @@ -68,7 +70,9 @@ export async function ollamaChat( if (!res.ok) { const text = await res.text().catch(() => ''); throw new Error( - `ollamaChat failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}` + `ollamaChat failed: ${res.status} ${res.statusText}${ + text ? ` - ${text}` : '' + }` ); } return (await res.json()) as OllamaChatResponseChunk; @@ -97,7 +101,9 @@ export async function ollamaChatStream( if (!res.ok || !res.body) { const text = await res.text().catch(() => ''); throw new Error( - `ollamaChatStream failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}` + `ollamaChatStream failed: ${res.status} ${res.statusText}${ + text ? ` - ${text}` : '' + }` ); } @@ -143,4 +149,3 @@ export async function ollamaChatStream( opts.onDone?.(); } - diff --git a/src/api/ai/openai.ts b/src/api/ai/openai.ts index 4ada4fa..59368ca 100644 --- a/src/api/ai/openai.ts +++ b/src/api/ai/openai.ts @@ -71,7 +71,9 @@ export async function listModels(opts?: { apiKey?: string; baseURL?: string }) { if (!res.ok) { const text = await res.text().catch(() => ''); throw new Error( - `listModels failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}` + `listModels failed: ${res.status} ${res.statusText}${ + text ? ` - ${text}` : '' + }` ); } return (await res.json()) as OpenAIListModelsResponse; @@ -91,7 +93,9 @@ export async function chatCompletions( if (!res.ok) { const text = await res.text().catch(() => ''); throw new Error( - `chatCompletions failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}` + `chatCompletions failed: ${res.status} ${res.statusText}${ + text ? ` - ${text}` : '' + }` ); } return (await res.json()) as OpenAIChatCompletionResponse; @@ -124,7 +128,9 @@ export async function chatCompletionsStream( if (!res.ok || !res.body) { const text = await res.text().catch(() => ''); throw new Error( - `chatCompletionsStream failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}` + `chatCompletionsStream failed: ${res.status} ${res.statusText}${ + text ? ` - ${text}` : '' + }` ); } diff --git a/src/views/ai/index.vue b/src/views/ai/index.vue index 372bb75..de84085 100644 --- a/src/views/ai/index.vue +++ b/src/views/ai/index.vue @@ -1,7 +1,6 @@ diff --git a/src/views/shop/shopDealerOrder2/components/search.vue b/src/views/shop/shopDealerOrder2/components/search.vue index a47cc62..74cd0e5 100644 --- a/src/views/shop/shopDealerOrder2/components/search.vue +++ b/src/views/shop/shopDealerOrder2/components/search.vue @@ -14,14 +14,17 @@ diff --git a/src/views/shop/shopDealerOrder2/index.vue b/src/views/shop/shopDealerOrder2/index.vue index c24b12c..dea769b 100644 --- a/src/views/shop/shopDealerOrder2/index.vue +++ b/src/views/shop/shopDealerOrder2/index.vue @@ -21,7 +21,6 @@ /> - - - - - - - - - - - + + + + + + + + + + + - - 删除 - + 删除 @@ -119,363 +122,384 @@ - + diff --git a/src/views/shop/shopDealerUser/components/shopDealerUserEdit.vue b/src/views/shop/shopDealerUser/components/shopDealerUserEdit.vue index 7a995b6..992a6fc 100644 --- a/src/views/shop/shopDealerUser/components/shopDealerUserEdit.vue +++ b/src/views/shop/shopDealerUser/components/shopDealerUserEdit.vue @@ -40,7 +40,7 @@ 经销商 门店 - + @@ -65,20 +65,20 @@ /> - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -144,44 +144,44 @@ /> - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -190,7 +190,10 @@ import { computed, ref, reactive, watch } from 'vue'; import { Form, message } from 'ant-design-vue'; import { assignObject, toDateString, uuid } from 'ele-admin-pro'; - import { addShopDealerUser, updateShopDealerUser } from '@/api/shop/shopDealerUser'; + import { + addShopDealerUser, + updateShopDealerUser + } from '@/api/shop/shopDealerUser'; import { ShopDealerUser } from '@/api/shop/shopDealerUser/model'; import { useThemeStore } from '@/store/modules/theme'; import { storeToRefs } from 'pinia'; @@ -260,11 +263,15 @@ }; const createTimeText = computed(() => { - return form.createTime ? toDateString(form.createTime, 'yyyy-MM-dd HH:mm:ss') : ''; + return form.createTime + ? toDateString(form.createTime, 'yyyy-MM-dd HH:mm:ss') + : ''; }); const updateTimeText = computed(() => { - return form.updateTime ? toDateString(form.updateTime, 'yyyy-MM-dd HH:mm:ss') : ''; + return form.updateTime + ? toDateString(form.updateTime, 'yyyy-MM-dd HH:mm:ss') + : ''; }); const selectedUserText = ref(''); @@ -369,13 +376,7 @@ .then(() => { loading.value = true; // 不在弹窗里编辑的字段不提交,避免误更新(如自增ID、删除标识等) - const { - isDelete, - tenantId, - createTime, - updateTime, - ...rest - } = form; + const { isDelete, tenantId, createTime, updateTime, ...rest } = form; const formData: ShopDealerUser = { ...rest }; // userId 新增需要,编辑不允许修改 if (isUpdate.value) { @@ -385,7 +386,9 @@ if (isUpdate.value && !formData.payPassword) { delete formData.payPassword; } - const saveOrUpdate = isUpdate.value ? updateShopDealerUser : addShopDealerUser; + const saveOrUpdate = isUpdate.value + ? updateShopDealerUser + : addShopDealerUser; saveOrUpdate(formData) .then((msg) => { loading.value = false; @@ -412,12 +415,12 @@ // 不回显密码,避免误操作 form.payPassword = ''; selectedUserText.value = ''; - if(props.data.image){ + if (props.data.image) { images.value.push({ uid: uuid(), url: props.data.image, status: 'done' - }) + }); } isUpdate.value = true; } else { diff --git a/src/views/shop/shopDealerUser/index.vue b/src/views/shop/shopDealerUser/index.vue index 029b225..b4afa0b 100644 --- a/src/views/shop/shopDealerUser/index.vue +++ b/src/views/shop/shopDealerUser/index.vue @@ -1,85 +1,100 @@