From 60e531a447162ea042bb9c94384d25572281f0c4 Mon Sep 17 00:00:00 2001 From: lijing Date: Wed, 21 Oct 2026 18:04:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(theme):=20=E6=8E=A5=E5=85=A5=E4=BA=91?= =?UTF-8?q?=E6=B5=B7=E5=AD=90=E4=B8=BB=E9=A2=98=E9=80=9A=E9=81=93=EF=BC=88?= =?UTF-8?q?A=20=E7=B1=BB=E5=85=8D=E6=8F=92=E4=BB=B6=EF=BC=8C=E8=A7=84?= =?UTF-8?q?=E8=8C=83=20v1.12=20=C2=A72/=C2=A73=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - index.html 插 A 类 loader:唯一接入点,FOUC 门/manifest 预取/主题 link 追加与排序 全由通道 yh-theme-init.js 承担,主题升级走 /static 通道,本应用无需重新构建 - vite.config 加 /static dev 代理(YH_THEME_PROXY_TARGET 可覆盖,默认线上通道) - host.config 回写 __APP_CONFIG__.serviceHost(仅同源):init 的 appearance 请求有硬性 同源限制,跨源会被直接跳过;本地 dev 保持空串走同源 /api 代理 - 顶栏头像接平台键 yh-avatar,监听 yh-appearance-updated,userInfo 兜底 - view-ui-plus 声明锁 1.3.24(对齐通道皮肤生成版本) --- index.html | 20 ++++++++++++++++++++ package.json | 2 +- src/assets/config/host.config.ts | 26 ++++++++++++++++++++++++++ src/components/layout.vue | 23 +++++++++++++++++++++-- vite.config.ts | 6 ++++++ 5 files changed, 74 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 5d7555f..5420b4d 100644 --- a/index.html +++ b/index.html @@ -29,6 +29,26 @@ } })(); + + <%- title %> diff --git a/package.json b/package.json index f324a24..d22b223 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "pdfjs-dist": "^4.10.38", "pinia": "^2.1.4", "sass": "^1.64.1", - "view-ui-plus": "^1.3.16", + "view-ui-plus": "1.3.24", "vite-plugin-mock": "2.9.6", "vue": "^3.4.19", "vue-router": "4", diff --git a/src/assets/config/host.config.ts b/src/assets/config/host.config.ts index d514898..ddbfdb5 100644 --- a/src/assets/config/host.config.ts +++ b/src/assets/config/host.config.ts @@ -107,4 +107,30 @@ if (ishttps) { } } +/** + * 回写 __APP_CONFIG__.serviceHost(仅同源场景)——云海子 A 类接入 §3 外观三键。 + * 主题通道 yh-theme-init.js 的 appearance 请求有硬性同源限制: + * if (!url || !appearanceSameOrigin(url)) return; → 跨源会被直接跳过、连请求都不发。 + * 本地 dev:serviceHost 是 VITE_SERVICE_HOST 的绝对地址(跨源),此时不能回写, + * 保持空串让 init 走同源 "/api/appearance",由 vite 代理转发到后端。 + * 生产:serviceHost = 同域 ctx(https://base.../),同源,回写后 init 请求正确前缀。 + * 已有 env-config 下发值时不动(以平台配置为准)。 + */ +try { + const w = window as any; + w.__APP_CONFIG__ = w.__APP_CONFIG__ || {}; + if (!w.__APP_CONFIG__.serviceHost) { + const candidate = conf.serviceHost || ""; + let sameOrigin = !candidate; + try { + sameOrigin = new URL(candidate, window.location.href).origin === window.location.origin; + } catch { + sameOrigin = false; + } + if (sameOrigin) w.__APP_CONFIG__.serviceHost = candidate; + } +} catch { + /* 极端环境无 window:忽略,保持同源兜底 */ +} + export default conf; diff --git a/src/components/layout.vue b/src/components/layout.vue index 77f74ee..b25787c 100644 --- a/src/components/layout.vue +++ b/src/components/layout.vue @@ -1,5 +1,5 @@