From 4899bc1793d4260f3773c3d78e822be71015c7a9 Mon Sep 17 00:00:00 2001 From: Sisyphus Date: Tue, 14 Jul 2026 19:15:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(F006-W18):=20admin=20=E5=89=8D=E7=AB=AF=20B?= =?UTF-8?q?UG=20A/B/C=20(=E5=AE=A2=E6=88=B7=E8=BF=90=E7=BB=B4=E5=8F=8D?= =?UTF-8?q?=E9=A6=88)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG A: APIKey 申请搜企业搜不到 - ApplyApiKeyDialog.vue loadCustomers 加 name 参数调后端, 不再本地 filter - 去掉 filteredCustomers computed, 表格直接用 customers - searchKey 输入加 debounce 300ms watch 调 loadCustomers BUG B: 企业列表/行业/标签管理等菜单不显示 - menu.ts filterByFrontendTruth 加 url 规范化匹配 - 后端 url 带 / (如 /user/enterprise/enterprise), MENU_LABELS 不带 / - normalizeUrl = url.replace(/^\//,"") 后再 has() 匹配 BUG C: baseURL 空串 巨变数字 nginx 不通 - request.ts baseURL:"" 改 "/api" - 巨变数字 nginx 只有 /api/ location (没独立 /sys/ /auth/ 等) - devbox nginx /api/ 也去前缀 (rewrite ^/api/(.*)\$ /\$1), 兼容 dist 验证: baseURL:"/api" ✓ devbox 实测: name=郑州巨变 返 1 条命中 --- src/modules/openapi/ApplyApiKeyDialog.vue | 26 +++++++++++++---------- src/stores/menu.ts | 10 +++++---- src/utils/request.ts | 4 +++- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/modules/openapi/ApplyApiKeyDialog.vue b/src/modules/openapi/ApplyApiKeyDialog.vue index b566b9e..00d2624 100644 --- a/src/modules/openapi/ApplyApiKeyDialog.vue +++ b/src/modules/openapi/ApplyApiKeyDialog.vue @@ -16,7 +16,7 @@ * * 后端调 /sys/openapi/app/apply */ -import { ref, reactive, computed, watch } from 'vue' +import { ref, reactive, watch } from 'vue' import { ElMessage } from 'element-plus' import { httpGet, httpPost } from '@/utils/request' @@ -70,10 +70,14 @@ const form = reactive({ const customers = ref([]) const loadingCustomers = ref(false) -async function loadCustomers() { +// F002-W18 修: 后端已支持 name 模糊搜, 前端把 searchKey 传给后端, 不再本地 filter +async function loadCustomers(searchKey?: string) { loadingCustomers.value = true try { - const data = await httpGet('/sys/openapi/customer/list') + const data = await httpGet('/sys/openapi/customer/list', { + name: searchKey || undefined, + limit: 1000 + }) customers.value = Array.isArray(data) ? data : [] } catch (e: any) { ElMessage.error(e?.msg || e?.message || '加载客户列表失败') @@ -85,13 +89,13 @@ async function loadCustomers() { watch(visible, v => { if (v) loadCustomers() }) -const filteredCustomers = computed(() => { - if (!form.searchKey) return customers.value - const k = form.searchKey.toLowerCase() - return customers.value.filter(c => - (c.customerName || '').toLowerCase().includes(k) || - (c.customerCode || '').toLowerCase().includes(k) - ) +// F002-W18 修: searchKey 变化 debounce 300ms 调后端 +let searchTimer: ReturnType | null = null +watch(() => form.searchKey, (val) => { + if (searchTimer) clearTimeout(searchTimer) + searchTimer = setTimeout(() => { + loadCustomers(val || undefined) + }, 300) }) function onSelectionChange(rows: Customer[]) { @@ -246,7 +250,7 @@ function notifyContact() { /> { if (!filtered.length) return null return { ...item, children: filtered } } - // 子菜单: url 必须在 MENU_LABELS 里, 且首次出现 - if (!allowedUrls.has(item.url)) return null - if (seenUrls.has(item.url)) return null - seenUrls.add(item.url) + // F002-W18 修: 后端 url 可能带 / 前缀 (如 /user/enterprise/enterprise), + // MENU_LABELS 不带 / (如 user/enterprise/enterprise), 规范化后匹配 + const normalizedUrl = item.url.replace(/^\//, '') + if (!allowedUrls.has(item.url) && !allowedUrls.has(normalizedUrl)) return null + if (seenUrls.has(normalizedUrl)) return null + seenUrls.add(normalizedUrl) return item }) .filter((item): item is ResolvedMenu => item !== null) diff --git a/src/utils/request.ts b/src/utils/request.ts index a266529..517d556 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -19,7 +19,9 @@ export interface ApiEnvelope { const STORAGE_KEY = 'access_token' export const http: AxiosInstance = axios.create({ - baseURL: '', + // F002-W18 修: baseURL '/api' 让巨变数字 nginx /api/ location 转发 (去 /api 前缀) + // devbox nginx 同样有 /api/ location (rewrite ^/api/(.*)$ /$1 break), 兼容 + baseURL: '/api', timeout: 15000 })