1
This commit is contained in:
parent
db5c935f87
commit
1d29952e22
@ -9,3 +9,7 @@ VITE_FILE_SERVER_BASE = 'https://ye4s.file.gzxunren.com'
|
||||
|
||||
VITE_APP_IM_WS_URL=wss://your-im-server.com/ws
|
||||
VITE_APP_IM_API_URL=https://your-im-server.com/api
|
||||
|
||||
# frontConfig.getByDomain 品牌豁免域名(逗号分隔,可多个;留空=不豁免,便于本地调试品牌配置)
|
||||
# 注意:主域名被豁免后访问主域名将不拉取品牌(显示默认「天豹云仓」);要在 localhost 验证品牌标题请勿把 localhost 加入豁免
|
||||
VITE_FRONT_CONFIG_EXEMPT_HOSTS = 'wms.wms.gztbyc.com'
|
||||
|
||||
@ -9,3 +9,6 @@ VITE_FILE_SERVER_BASE = 'https://ye4s.file.gzxunren.com'
|
||||
|
||||
VITE_APP_IM_WS_URL=wss://your-im-server.com/ws
|
||||
VITE_APP_IM_API_URL=https://your-im-server.com/api
|
||||
|
||||
# frontConfig.getByDomain 品牌豁免域名(逗号分隔,可多个;主域名不拉取/不使用品牌配置)
|
||||
VITE_FRONT_CONFIG_EXEMPT_HOSTS = 'wms.wms.gztbyc.com'
|
||||
|
||||
@ -121,4 +121,4 @@
|
||||
- `saveFrontConfig`:只受理品牌字段,`domain`/证书字段传了也会被白名单忽略;`theme` 须合法 JSON 对象或 JSON 字符串。
|
||||
- `getByDomain`:仅返回公开品牌字段,绝不返回证书/同步内部字段;未登记域名返回 404 + 60s 空缓存防穿透。
|
||||
- 证书 PEM/私钥:禁止出现在前端响应/日志;前端只需展示由 `getFrontConfig` 返回的 `cert_expire_at/sync_status` 等。
|
||||
- 主题结构:已确定 4 个约定默认字段(`siteName` 网页名称 / `mainLogoUrl` 主页面 Logo / `loginLogoUrl` 登录页 Logo / `loginText` 登录页文字),**允许留空**(留空不写入 `theme` → 前端用系统默认值:站点默认标题“天豹云仓”、登录标语默认“现代化仓储管理系统 - 助力企业高效运营”等);其余 theme 键仍作动态 CSS 变量(`--<key>`)应用,约定 4 键不映射 CSS 变量。
|
||||
- 主题结构:`theme` 仅作动态 CSS 变量容器(顶层标量键→`--<key>`,文案类不再放主题)。网页名称/Logo 等业务语义由品牌顶层字段承担:网页名称=`title`、主页面/登录页 Logo=`logo_url`(`getByDomain` 读取、`saveFrontConfig` 保存)。历史 theme 中曾约定的 siteName/mainLogoUrl/loginLogoUrl/loginText 不再展示/编辑,保存时透传保留。
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
3 访问 https://<自持域名>/... │
|
||||
▼
|
||||
免鉴权 frontConfig.getByDomain(domain) ← 按 hostname 拉品牌
|
||||
应用:网页名称/登录页 Logo·文字/主页面 Logo(theme 4 约定字段)、
|
||||
品牌 Logo/背景/favicon、document.title、其余 theme 键→CSS 变量
|
||||
应用:网页名称(title)/主页面·登录页 Logo(logo_url)/背景/favicon、
|
||||
document.title、其余 theme 键→CSS 变量(theme 不再承载业务键)
|
||||
```
|
||||
|
||||
- 品牌与「域名+证书」**分开保存**;变更域名必须走 `saveFrontCert`(重新校验证书)。
|
||||
@ -35,15 +35,11 @@
|
||||
- 字段:
|
||||
- 站点标题 `title`(≤100)
|
||||
- Logo `logo_url`、favicon `favicon_url`、登录背景 `login_bg_url`(各 ≤255)
|
||||
- 主题 `theme`:分两组编辑,保存时组装为 JSON 对象
|
||||
- 约定 4 个默认字段(页面按语义消费,均**允许留空**):
|
||||
- 网页名称 `siteName`(对应系统默认标题“天豹云仓”,留空=用默认)
|
||||
- 主页面 Logo `mainLogoUrl`(顶栏 Logo,留空=用默认图片)
|
||||
- 登录页 Logo `loginLogoUrl`(登录页 Logo,留空=用品牌 `logo_url`)
|
||||
- 登录页文字 `loginText`(登录页标语,留空默认“现代化仓储管理系统 - 助力企业高效运营”)
|
||||
- 约定键留空时**不写入** `theme`,前端使用系统默认值/默认文案
|
||||
- 自定义键值:主题键即前端 CSS 变量名,值支持文本或 JSON(对象/数组/数字/布尔);应用时顶层标量键写入 `--<key>`(约定 4 字段不映射 CSS 变量)
|
||||
- 品牌字段留空即清空该字段;主题约定键留空=用默认,自定义键删空全部行=清空该部分。
|
||||
- 主题 `theme`:仅承载“自定义 CSS 变量”键值,保存时组装为 JSON 对象
|
||||
- 每个键即前端 CSS 变量名(如 `primary`→`--primary`),值支持文本或 JSON(对象/数组/数字/布尔);应用时顶层标量键写入 `--<key>`
|
||||
- 网页名称/Logo 等业务字段一律使用上方品牌顶层字段配置:网页名称=`title`、主页面/登录页 Logo=`logo_url`、登录背景=`login_bg_url`、favicon=`favicon_url`(`getByDomain` 读取、`saveFrontConfig` 保存)
|
||||
- 历史 theme 中曾约定过的 `siteName/mainLogoUrl/loginLogoUrl/loginText` 不再展示与编辑,保存时原样透传保留(不丢失历史数据)
|
||||
- 品牌字段留空即清空该字段;主题自定义键删空全部行=清空主题。
|
||||
- 点击「保存品牌配置」→ 成功后自动刷新回显。
|
||||
- 说明:此处不受理 `domain`/证书字段(后端白名单忽略)。
|
||||
|
||||
@ -111,7 +107,7 @@
|
||||
|
||||
1. 把本系统部署(或已有部署)解析到自持域名:`<自持域名> -> 部署 IP/负载`,并配置 HTTPS(证书由后端部署链路提供,前端不需持证)。
|
||||
2. 浏览器访问 `https://<自持域名>`:前端入口自动按 `location.hostname` 调 `frontConfig.getByDomain` 应用品牌。
|
||||
- 生效项:网页名称(登录页标题与 document.title)、主页面 Logo(顶栏)、登录页 Logo/登录页文字(theme 4 约定字段,空=默认)、品牌 Logo/背景、favicon、其余 `theme` 键→CSS 变量(`--<key>`)。
|
||||
- 生效项:网页名称=`title`(登录页标题与 document.title)、主页面/登录页 Logo=`logo_url`、登录背景、favicon;其余 `theme` 键→CSS 变量(`--<key>`)。登录页文字无独立配置字段,用默认标语“现代化仓储管理系统 - 助力企业高效运营”。
|
||||
3. 未登记域名 / 直连主域名:接口返回 404 / `configured=false` → 前端静默使用系统默认品牌(无报错)。
|
||||
4. 本地联调建议:改 hosts 把自持域名指向本机测试环境即可看到品牌效果;确认无旧品牌残留可清理站点数据后刷新。
|
||||
5. **多仓库同一部署的域名解析(A6)**:一套前端部署可同时服务多个仓库——
|
||||
|
||||
6
env.d.ts
vendored
6
env.d.ts
vendored
@ -1,4 +1,10 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
/** frontConfig.getByDomain 品牌豁免域名(逗号分隔多个;显式置空=不豁免,未配置回退主域名 wms.wms.gztbyc.com) */
|
||||
readonly VITE_FRONT_CONFIG_EXEMPT_HOSTS?: string
|
||||
}
|
||||
|
||||
declare module '@/utils/auth' {
|
||||
export function getToken(): string | undefined
|
||||
export function setToken(token: string): void
|
||||
|
||||
@ -4,7 +4,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Vite App</title>
|
||||
<!-- 加载前静态兜底:中性“加载中...”,不直接显示仓库/默认品牌;运行时由 frontBrand 决定(主域名→天豹云仓;非主域名成功→品牌名/失败→天豹云仓) -->
|
||||
<title>加载中...</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
@ -286,7 +286,9 @@ export function settingWarehouseSaveSettings(
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 前端独立部署配置记录(getFrontConfig / saveFrontConfig / saveFrontCert 响应,一仓一行) */
|
||||
/** 前端独立部署配置记录(getFrontConfig / saveFrontConfig / saveFrontCert 响应,一仓一行,共 15 字段)
|
||||
* 证书内容已改为直接入库:响应返回 cert_pem/key_pem(PEM 原文)供 settings 页回显,
|
||||
* 不再返回 cert_path/key_path(路径字段仅由后端定时任务部署后回填,不出现在响应中)。 */
|
||||
export type SettingWarehouseFrontConfig = {
|
||||
warehouse_id?: number
|
||||
domain?: string
|
||||
@ -295,8 +297,11 @@ export type SettingWarehouseFrontConfig = {
|
||||
favicon_url?: string
|
||||
login_bg_url?: string
|
||||
theme?: Record<string, unknown> | string | null
|
||||
cert_path?: string
|
||||
key_path?: string
|
||||
/** 证书 PEM 原文(读 cert_pem 列;未配置为空字符串;仅 settings 页回显,公共接口 frontConfig.getByDomain 不返回) */
|
||||
cert_pem?: string
|
||||
/** 私钥 PEM 原文(读 cert_key 列;未配置为空字符串;仅 settings 页回显,公共接口 frontConfig.getByDomain 不返回) */
|
||||
key_pem?: string
|
||||
/** 证书到期时间(saveFrontCert 上传后按证书 validTo 权威写入;未上传为 null) */
|
||||
cert_expire_at?: string | null
|
||||
sync_status?: number
|
||||
sync_attempts?: number
|
||||
|
||||
@ -105,6 +105,7 @@
|
||||
class="value-input"
|
||||
@change="handleCustomChange"
|
||||
@blur="normalizeTextValue(field)"
|
||||
@paste="handleTextPaste($event, field)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -676,6 +677,7 @@
|
||||
class="compact-value-input"
|
||||
@change="handleCompactChange"
|
||||
@blur="normalizeTextValue(field)"
|
||||
@paste="handleTextPaste($event, field)"
|
||||
/>
|
||||
</div>
|
||||
<el-input
|
||||
@ -686,6 +688,8 @@
|
||||
clearable
|
||||
style="width: 100%"
|
||||
@change="handleCompactChange"
|
||||
@blur="normalizeTextValue(field)"
|
||||
@paste="handleTextPaste($event, field)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@ -1094,6 +1098,19 @@ function handleTextOperatorChange(field: any) {
|
||||
handleOperatorChange(field)
|
||||
}
|
||||
|
||||
/** 多值文本规整统一入口:换行/制表/中文标点 → 半角逗号;contains 额外剔除内部空白 */
|
||||
function normalizeMultiValueRaw(operator: string, rawValue: any): string {
|
||||
if (rawValue === undefined || rawValue === null || rawValue === '') return ''
|
||||
let normalized = normalizeMultiValueText(String(rawValue))
|
||||
if (operator === 'contains') {
|
||||
normalized = normalized
|
||||
.replace(/\s+/g, '')
|
||||
.replace(/,+/g, ',')
|
||||
.replace(/^,|,$/g, '')
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
|
||||
function normalizeTextValue(field: any) {
|
||||
const operator = customConditions[field.value].operator
|
||||
const value = customConditions[field.value].value
|
||||
@ -1102,14 +1119,7 @@ function normalizeTextValue(field: any) {
|
||||
return
|
||||
}
|
||||
|
||||
let normalizedValue = normalizeMultiValueText(String(value))
|
||||
if (operator === 'contains') {
|
||||
normalizedValue = normalizedValue
|
||||
.replace(/\s+/g, '')
|
||||
.replace(/,+/g, ',')
|
||||
.replace(/^,|,$/g, '')
|
||||
}
|
||||
|
||||
const normalizedValue = normalizeMultiValueRaw(operator, value)
|
||||
if (normalizedValue !== value) {
|
||||
customConditions[field.value].value = normalizedValue
|
||||
handleCustomChange()
|
||||
@ -1138,6 +1148,25 @@ function handleMultiValuePaste(event: ClipboardEvent, field: any) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 单行文本框粘贴换行兜底:浏览器对 <input>(非 textarea)粘贴会直接丢弃换行,把多单号粘连成一行
|
||||
* (如 SYS..A\nSYS..B -> SYS..ASYS..B)。此处粘贴时拦截,抢在浏览器剥换行前把换行/制表转成逗号,
|
||||
* 保证后续 contains/in/notin 可按逗号正确拆分传参 */
|
||||
function handleTextPaste(event: ClipboardEvent, field: any) {
|
||||
const pasted = event.clipboardData?.getData('text') || ''
|
||||
if (!pasted || !/[\r\n\t]/.test(pasted)) return
|
||||
|
||||
event.preventDefault()
|
||||
const normalizedPaste = normalizeMultiValueText(pasted)
|
||||
if (!normalizedPaste) return
|
||||
|
||||
const current = String(customConditions[field.value].value || '').trim()
|
||||
customConditions[field.value].value = current
|
||||
? `${current.replace(/,+$/g, '')},${normalizedPaste}`
|
||||
: normalizedPaste
|
||||
|
||||
handleCustomChange()
|
||||
}
|
||||
|
||||
const defaultDayStart = new Date(2000, 0, 1, 0, 0, 0)
|
||||
const defaultDayEnd = new Date(2000, 0, 1, 23, 59, 59)
|
||||
|
||||
@ -1399,11 +1428,13 @@ function buildAndEmitCustomCondition() {
|
||||
|
||||
let conditionValue = condition.value
|
||||
|
||||
// 处理多值操作符:contains / in / notin 逗号分隔 -> 数组
|
||||
if (['contains', 'in', 'notin'].includes(op) && typeof conditionValue === 'string' && conditionValue) {
|
||||
const values = conditionValue.split(',').map((v: string) => v.trim()).filter(Boolean)
|
||||
if (values.length > 0) {
|
||||
conditionValue = values
|
||||
// 多值操作符 contains/in/notin:换行等分隔符先统一为逗号,再按逗号拆分为数组后传参
|
||||
if (['contains', 'in', 'notin'].includes(op)) {
|
||||
const normalized = normalizeMultiValueRaw(op, conditionValue)
|
||||
if (normalized) {
|
||||
conditionValue = normalized.split(',').map((v: string) => v.trim()).filter(Boolean)
|
||||
} else {
|
||||
conditionValue = ''
|
||||
}
|
||||
}
|
||||
|
||||
@ -1572,9 +1603,13 @@ function buildConditionsObject() {
|
||||
|
||||
let conditionValue = condition.value
|
||||
|
||||
if (['contains', 'in', 'notin'].includes(op) && typeof conditionValue === 'string' && conditionValue) {
|
||||
const values = conditionValue.split(',').map((v: string) => v.trim()).filter(Boolean)
|
||||
if (values.length > 0) conditionValue = values
|
||||
if (['contains', 'in', 'notin'].includes(op)) {
|
||||
const normalized = normalizeMultiValueRaw(op, conditionValue)
|
||||
if (normalized) {
|
||||
conditionValue = normalized.split(',').map((v: string) => v.trim()).filter(Boolean)
|
||||
} else {
|
||||
conditionValue = ''
|
||||
}
|
||||
}
|
||||
|
||||
const rangeMeta = resolveRangeConditionMeta(field, op)
|
||||
|
||||
49
src/main.ts
49
src/main.ts
@ -1,4 +1,4 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createApp, watch } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import ElementPlus from 'element-plus'
|
||||
import 'element-plus/dist/index.css'
|
||||
@ -9,6 +9,7 @@ import router from './router'
|
||||
import './permission' // permission control
|
||||
import SvgIcon from '@/components/SvgIcon/index.vue'
|
||||
import i18n, { loadServerMessages } from '@/lang/index'
|
||||
import getPageTitle from '@/utils/get-page-title'
|
||||
|
||||
import '@/styles/index.scss' // global css
|
||||
import { getToken } from '@/utils/auth'
|
||||
@ -49,8 +50,52 @@ usePrinterComponentStore(pinia).bindRuntimeEvents()
|
||||
|
||||
app.mount('#app')
|
||||
|
||||
// ── 页面/浏览器标题(document.title)统一在此设置 ──
|
||||
// 使用显式 pinia 的 frontBrand store 引用(与品牌加载同源),避免组件/守卫上下文取到不一致实例。
|
||||
// 品牌加载完成前只显示“页面名”(不拼站点,不闪现默认“天豹云仓”);加载完成后:
|
||||
// 成功→“页面名 - 品牌名”;失败/豁免→“页面名 - 天豹云仓”;/login 用纯站点名。
|
||||
const frontBrandStore = useFrontBrandStore(pinia)
|
||||
|
||||
function resolveRoutePageTitle(route: { name?: unknown; meta?: Record<string, unknown> }): string {
|
||||
const tryMenuKey = (raw: unknown) => {
|
||||
if (raw === undefined || raw === null || raw === '') return ''
|
||||
const key = String(raw).replace(/_Child$/, '')
|
||||
const path = `menu.${key}`
|
||||
return i18n.global.te(path) ? String(i18n.global.t(path)) : ''
|
||||
}
|
||||
const fromName = tryMenuKey(route.name)
|
||||
if (fromName) return fromName
|
||||
const fromMeta = tryMenuKey(route.meta?.title)
|
||||
if (fromMeta) return fromMeta
|
||||
const metaTitle = route.meta?.title
|
||||
return metaTitle != null && metaTitle !== '' ? String(metaTitle) : route.name != null ? String(route.name) : ''
|
||||
}
|
||||
|
||||
function applyDocumentTitle(route?: typeof router.currentRoute.value): void {
|
||||
const target = route || router.currentRoute.value
|
||||
if (!target || !target.path) return
|
||||
const page = resolveRoutePageTitle(target)
|
||||
if (!frontBrandStore.loaded) {
|
||||
// 品牌加载中:仅页面名(/login 用中性“加载中...”),不显示默认站点名
|
||||
document.title = target.path.startsWith('/login') ? '加载中...' : page || '加载中...'
|
||||
return
|
||||
}
|
||||
const site = frontBrandStore.siteTitle || '天豹云仓'
|
||||
if (target.path.startsWith('/login')) {
|
||||
document.title = site
|
||||
return
|
||||
}
|
||||
document.title = getPageTitle(page, site)
|
||||
}
|
||||
applyDocumentTitle()
|
||||
watch(
|
||||
[() => frontBrandStore.loaded, () => frontBrandStore.siteTitle, () => router.currentRoute.value.path],
|
||||
() => applyDocumentTitle()
|
||||
)
|
||||
router.afterEach((to) => applyDocumentTitle(to))
|
||||
|
||||
// 前端独立部署品牌:登录前按当前访问域名拉取(免鉴权),成功后应用 favicon / 登录页标题品牌;失败静默走默认品牌
|
||||
useFrontBrandStore(pinia).loadBrandByDomain()
|
||||
frontBrandStore.loadBrandByDomain()
|
||||
|
||||
// 整页刷新(F5 / 顶部刷新)后的“一次自动连接”兜底:
|
||||
// 等路由守卫初始化(getInfo)完成、拿到登录上下文后再执行一次;
|
||||
|
||||
@ -7,9 +7,6 @@ import NProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { usePrinterComponentStore } from '@/stores/modules/printerComponent'
|
||||
import { useFrontBrandStore } from '@/stores/modules/frontBrand'
|
||||
import getPageTitle from '@/utils/get-page-title'
|
||||
import i18n from '@/lang'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
|
||||
type RouteLogNode = {
|
||||
@ -33,23 +30,6 @@ function formatRoutesForLog(routes: readonly RouteRecordRaw[]): RouteLogNode[] {
|
||||
|
||||
NProgress.configure({ showSpinner: false })
|
||||
|
||||
/** 与侧边栏 / 标签一致:优先按路由 name、再按 meta.title 匹配 menu.* 文案 */
|
||||
function resolveRouteDocumentTitle(route: typeof router.currentRoute.value) {
|
||||
const tryMenuKey = (raw: unknown) => {
|
||||
if (raw === undefined || raw === null || raw === '') return ''
|
||||
const key = String(raw).replace(/_Child$/, '')
|
||||
const path = `menu.${key}`
|
||||
return i18n.global.te(path) ? String(i18n.global.t(path)) : ''
|
||||
}
|
||||
|
||||
const metaTitle = route.meta?.title as string | undefined
|
||||
const fromName = tryMenuKey(route.name)
|
||||
if (fromName) return fromName
|
||||
const fromMetaAsKey = tryMenuKey(metaTitle)
|
||||
if (fromMetaAsKey) return fromMetaAsKey
|
||||
return metaTitle || (route.name != null ? String(route.name) : '')
|
||||
}
|
||||
|
||||
const whiteList = ['/login','/redirect','/admin/land'] // no redirect whitelist
|
||||
|
||||
/** 登录后“一次连接”:先加载用户偏好(含打印组件分用户+仓库配置),再自动连接一次 */
|
||||
@ -74,8 +54,7 @@ function maybeRetryPrintConnectionsAfterRefresh() {
|
||||
router.beforeEach(async (to, from) => {
|
||||
NProgress.start()
|
||||
// console.log("路由表",router.getRoutes());
|
||||
// 前端独立部署:页面标题前缀使用域名品牌站点标题(无则系统默认)
|
||||
document.title = getPageTitle(resolveRouteDocumentTitle(to), useFrontBrandStore().siteTitle)
|
||||
// 页面/浏览器标题统一由 App.vue(组件读 frontBrand store)设置,此处不再设置
|
||||
|
||||
const hasToken = getToken()
|
||||
|
||||
|
||||
@ -8,6 +8,39 @@ function isOkCode(code: unknown): boolean {
|
||||
return code === 200 || code === 1 || code === 0
|
||||
}
|
||||
|
||||
/** 豁免域名兜底(未配置 VITE_FRONT_CONFIG_EXEMPT_HOSTS 时保持主域名豁免的历史默认行为) */
|
||||
const DEFAULT_FRONT_BRAND_EXEMPT_HOSTS = 'wms.wms.gztbyc.com'
|
||||
|
||||
/**
|
||||
* 解析豁免域名集合(主域名/自有默认站):命中后不拉取、不使用 frontConfig.getByDomain 品牌配置。
|
||||
* 来源 .env 的 VITE_FRONT_CONFIG_EXEMPT_HOSTS(逗号分隔,可分别配置开发/生产环境的豁免域名):
|
||||
* - 显式置空(= 空值)→ 不豁免任何域名;
|
||||
* - 未配置(undefined)→ 回退默认主域名 wms.wms.gztbyc.com。
|
||||
*/
|
||||
function resolveFrontBrandExemptHosts(): Set<string> {
|
||||
const raw = import.meta.env.VITE_FRONT_CONFIG_EXEMPT_HOSTS
|
||||
const source = raw === undefined || raw === null ? DEFAULT_FRONT_BRAND_EXEMPT_HOSTS : String(raw)
|
||||
return new Set(
|
||||
source
|
||||
.split(',')
|
||||
.map((s) => s.trim().toLowerCase())
|
||||
.filter(Boolean)
|
||||
)
|
||||
}
|
||||
|
||||
/** 豁免域名集合(按 import.meta.env 编译期静态替换) */
|
||||
const FRONT_BRAND_EXEMPT_HOSTS = resolveFrontBrandExemptHosts()
|
||||
|
||||
/** 归一化访问域名:去协议/路径/端口、转小写,用于豁免判定与请求域名 */
|
||||
function normalizeFrontHost(raw?: string): string {
|
||||
let host = (raw || '').trim().replace(/^https?:\/\//, '')
|
||||
const slashIdx = host.indexOf('/')
|
||||
if (slashIdx >= 0) host = host.slice(0, slashIdx)
|
||||
const colonIdx = host.indexOf(':')
|
||||
if (colonIdx >= 0) host = host.slice(0, colonIdx)
|
||||
return host.toLowerCase()
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端独立部署品牌(frontConfig.getByDomain 消费端)
|
||||
*
|
||||
@ -21,7 +54,8 @@ export const useFrontBrandStore = defineStore('frontBrand', () => {
|
||||
/** 品牌配置;null=使用系统默认品牌 */
|
||||
const brand = ref<FrontConfigPublicItem | null>(null)
|
||||
|
||||
/** theme 约定 4 字段键(文案/资源类,不映射 CSS 变量):网页名称/主页面 logo/登录页 logo/登录页文字 */
|
||||
/** 历史 theme 约定键(曾承载 网页名称/主页面logo/登录页logo/登录页文字):现由品牌顶层字段(title/logo_url 等)配置,
|
||||
* 不再从 theme 语义消费;此处仅用于 applyThemeCssVars 排除,避免历史残留污染自定义 CSS 变量 */
|
||||
const FRONT_THEME_DEFAULT_KEYS = ['siteName', 'mainLogoUrl', 'loginLogoUrl', 'loginText'] as const
|
||||
|
||||
/** theme 归一化为对象(支持对象或 JSON 字符串) */
|
||||
@ -41,20 +75,20 @@ export const useFrontBrandStore = defineStore('frontBrand', () => {
|
||||
return {}
|
||||
})
|
||||
|
||||
/** 网页名称:theme.siteName,缺省回退品牌 title,再回退系统默认标题(settings.title,默认“天豹云仓”) */
|
||||
const siteName = computed(() => {
|
||||
const name = String(themeObj.value.siteName ?? '').trim() || brand.value?.title?.trim() || ''
|
||||
return name || defaultSettings.title || '天豹云仓'
|
||||
})
|
||||
/** 登录页文字(slogan):theme.loginText(空→调用方用默认文案) */
|
||||
const themeLoginText = computed(() => String(themeObj.value.loginText ?? '').trim())
|
||||
/** 登录页 logo:theme.loginLogoUrl,缺省回退品牌 logo_url */
|
||||
const themeLoginLogoUrl = computed(() => String(themeObj.value.loginLogoUrl ?? '').trim() || brand.value?.logo_url?.trim() || '')
|
||||
/** 主页面/顶栏 logo:theme.mainLogoUrl(空→调用方用默认图片) */
|
||||
const themeMainLogoUrl = computed(() => String(themeObj.value.mainLogoUrl ?? '').trim())
|
||||
/** 网页名称:品牌顶层 title,缺省回退系统默认标题(settings.title,默认“天豹云仓”)。不再从 theme 约定 siteName */
|
||||
const siteName = computed(() => brand.value?.title?.trim() || defaultSettings.title || '天豹云仓')
|
||||
/** 登录页文字(slogan):无独立配置字段时为默认文案(登录页用默认标语)。不再从 theme 约定 loginText */
|
||||
const themeLoginText = computed(() => '')
|
||||
/** 登录页 logo:品牌顶层 logo_url(空→调用方用默认图片)。不再从 theme 约定 loginLogoUrl */
|
||||
const themeLoginLogoUrl = computed(() => brand.value?.logo_url?.trim() || '')
|
||||
/** 主页面/顶栏 logo:品牌顶层 logo_url(空→调用方用默认图片)。不再从 theme 约定 mainLogoUrl */
|
||||
const themeMainLogoUrl = computed(() => brand.value?.logo_url?.trim() || '')
|
||||
|
||||
/** 站点标题/网页名称(theme.siteName 或品牌 title,最后回退系统默认标题 settings.title) */
|
||||
const siteTitle = computed(() => siteName.value)
|
||||
|
||||
// 浏览器标题(document.title)由 App.vue 组件统一设置(组件注入 store 可靠),此处不做标题写入
|
||||
|
||||
/** 品牌 Logo(空串→调用方回退默认 Logo) */
|
||||
const logoUrl = computed(() => brand.value?.logo_url?.trim() || '')
|
||||
/** 登录页背景图(空串→调用方用默认背景) */
|
||||
@ -65,9 +99,16 @@ export const useFrontBrandStore = defineStore('frontBrand', () => {
|
||||
/** 按当前访问域名拉取品牌并应用全局(favicon / 登录页标题 / theme CSS 变量) */
|
||||
async function loadBrandByDomain(domain?: string): Promise<void> {
|
||||
if (loaded.value) return
|
||||
const host = normalizeFrontHost(domain ?? window.location.hostname)
|
||||
// 主域名豁免:不拉取、不应用 getByDomain 品牌配置,直接保持系统默认品牌(默认标题/默认 logo/无主题 CSS 变量)
|
||||
if (!host || FRONT_BRAND_EXEMPT_HOSTS.has(host)) {
|
||||
brand.value = null
|
||||
loaded.value = true
|
||||
applyThemeCssVars(null)
|
||||
applyBrandGlobals()
|
||||
return
|
||||
}
|
||||
try {
|
||||
const rawHost = domain ?? window.location.hostname
|
||||
const host = (rawHost || '').trim().replace(/^https?:\/\//, '')
|
||||
if (host) {
|
||||
const res: any = await frontConfigGetByDomain({ domain: host })
|
||||
const data = res?.data && typeof res.data === 'object' ? res.data : res
|
||||
@ -83,6 +124,23 @@ export const useFrontBrandStore = defineStore('frontBrand', () => {
|
||||
// 无论成功/失败都应用主题:无 theme/brand=null 时清除上一次已应用的 CSS 变量,避免换域名后残留旧主题
|
||||
applyThemeCssVars(brand.value?.theme)
|
||||
applyBrandGlobals()
|
||||
// 浏览器标题由 App.vue 监听 frontBrand.loaded/siteTitle 统一设置:成功→品牌名;失败/豁免→默认“天豹云仓”。
|
||||
// 追加兜底:品牌加载成功后短时轮询修正标题站点名(应对运行环境存在重复模块/其它写入把标题写成默认的情况),
|
||||
// 保证最终标题稳定为品牌名。
|
||||
if (brand.value) {
|
||||
let guardTries = 0
|
||||
const guardTimer = window.setInterval(() => {
|
||||
const site = siteTitle.value || '天豹云仓'
|
||||
const cur = document.title || ''
|
||||
if (cur !== site && !cur.endsWith(` - ${site}`)) {
|
||||
const sep = cur.lastIndexOf(' - ')
|
||||
document.title = sep > 0 ? `${cur.slice(0, sep)} - ${site}` : site
|
||||
}
|
||||
if (++guardTries >= 12 || document.title === site || document.title.endsWith(` - ${site}`)) {
|
||||
window.clearInterval(guardTimer)
|
||||
}
|
||||
}, 200)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,10 +187,7 @@ export const useFrontBrandStore = defineStore('frontBrand', () => {
|
||||
const icon = document.querySelector<HTMLLinkElement>('link[rel~="icon"]')
|
||||
if (icon) icon.href = b.favicon_url.trim()
|
||||
}
|
||||
// 登录页标题:已登录系统内的路由标题由 permission 守卫按 siteTitle 维护
|
||||
if (siteName.value && /\/login(\/|$|\?)/.test(window.location.pathname)) {
|
||||
document.title = siteName.value
|
||||
}
|
||||
// 浏览器标题(document.title)由 App.vue 组件统一设置,此处仅处理 favicon
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
import defaultSettings from '@/settings'
|
||||
|
||||
const title = defaultSettings.title || '天豹云仓'
|
||||
|
||||
export default function getPageTitle(pageTitle) {
|
||||
if (pageTitle) {
|
||||
return `${pageTitle} - ${title}`
|
||||
}
|
||||
return `${title}`
|
||||
}
|
||||
@ -256,7 +256,7 @@ const userStore = useUserStore()
|
||||
// ── 前端独立部署品牌(frontConfig.getByDomain):按域名替换 Logo / 标题 / 背景 ──
|
||||
const frontBrand = useFrontBrandStore()
|
||||
const brand = computed(() => frontBrand.brand)
|
||||
// 主题约定:网页名称(theme.siteName||brand.title)、登录页 logo(theme.loginLogoUrl||品牌 logo)、登录页文字(theme.loginText)
|
||||
// 网页名称=品牌顶层 title(站点标题)、登录页 logo=品牌顶层 logo_url;登录页文字无独立配置字段时用默认标语(saveFrontConfig 顶层品牌字段配置)
|
||||
const brandName = computed(() => frontBrand.siteTitle)
|
||||
const brandLogo = computed(() => frontBrand.themeLoginLogoUrl || '../../../public/logo/1.png')
|
||||
const loginDesc = computed(() => frontBrand.themeLoginText || '现代化仓储管理系统 - 助力企业高效运营')
|
||||
|
||||
@ -1544,36 +1544,17 @@ async function loadWaveStoreOptions() {
|
||||
}
|
||||
}
|
||||
|
||||
/** order.wave.batchList where:需透传操作符的模糊文本字段(波次号/创建人/快递;其余字段保持等值/区间等标量语义) */
|
||||
const WAVE_OPERATOR_FUZZY_FIELDS = new Set(['wave_no', 'creator', 'logistics_name'])
|
||||
/** 多值文本操作符(与全站列表页约定一致):contains/in/notin 的 value 以数组下发,其余为字符串 */
|
||||
const WAVE_OPERATOR_MULTI_VALUE = new Set(['contains', 'in', 'notin'])
|
||||
|
||||
function buildWhereConditions(rawConditions: Record<string, any>) {
|
||||
const where: Record<string, any> = {}
|
||||
Object.keys(rawConditions || {}).forEach((key) => {
|
||||
const condition = rawConditions[key]
|
||||
if (condition && typeof condition === 'object' && 'operator' in condition) {
|
||||
const rawValue = condition.value
|
||||
if (rawValue === undefined || rawValue === null || rawValue === '' || (Array.isArray(rawValue) && rawValue.length === 0)) {
|
||||
const value = condition.value
|
||||
if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) {
|
||||
return
|
||||
}
|
||||
// 模糊文本字段:操作符经 where 下发后端({ operator, value }),contains/in/notin 多值以数组传递
|
||||
if (WAVE_OPERATOR_FUZZY_FIELDS.has(key)) {
|
||||
const operator = String(condition.operator || 'like')
|
||||
const text = (Array.isArray(rawValue) ? rawValue.join(',') : String(rawValue)).trim()
|
||||
if (!text) return
|
||||
if (WAVE_OPERATOR_MULTI_VALUE.has(operator)) {
|
||||
const values = text.split(',').map((v: string) => v.trim()).filter(Boolean)
|
||||
if (!values.length) return
|
||||
where[key] = { operator, value: values }
|
||||
} else {
|
||||
where[key] = { operator, value: text }
|
||||
}
|
||||
return
|
||||
}
|
||||
// 其余字段(select 等值、min/max 区间等):保持标量值透传
|
||||
where[key] = rawValue
|
||||
// order.wave.batchList where 为标量白名单:等值/模糊字段直接透传 value(store_id 支持数组 in)
|
||||
where[key] = value
|
||||
return
|
||||
}
|
||||
if (condition !== undefined && condition !== null && condition !== '') {
|
||||
|
||||
@ -982,36 +982,17 @@ async function loadWaveStoreOptions() {
|
||||
}
|
||||
}
|
||||
|
||||
/** order.wave.batchList where:需透传操作符的模糊文本字段(波次号/创建人/快递;其余字段保持等值/区间等标量语义) */
|
||||
const WAVE_OPERATOR_FUZZY_FIELDS = new Set(['wave_no', 'creator', 'logistics_name'])
|
||||
/** 多值文本操作符(与全站列表页约定一致):contains/in/notin 的 value 以数组下发,其余为字符串 */
|
||||
const WAVE_OPERATOR_MULTI_VALUE = new Set(['contains', 'in', 'notin'])
|
||||
|
||||
function buildWhereConditions(rawConditions: Record<string, any>) {
|
||||
const where: Record<string, any> = {}
|
||||
Object.keys(rawConditions || {}).forEach((key) => {
|
||||
const condition = rawConditions[key]
|
||||
if (condition && typeof condition === 'object' && 'operator' in condition) {
|
||||
const rawValue = condition.value
|
||||
if (rawValue === undefined || rawValue === null || rawValue === '' || (Array.isArray(rawValue) && rawValue.length === 0)) {
|
||||
const value = condition.value
|
||||
if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) {
|
||||
return
|
||||
}
|
||||
// 模糊文本字段:操作符经 where 下发后端({ operator, value }),contains/in/notin 多值以数组传递
|
||||
if (WAVE_OPERATOR_FUZZY_FIELDS.has(key)) {
|
||||
const operator = String(condition.operator || 'like')
|
||||
const text = (Array.isArray(rawValue) ? rawValue.join(',') : String(rawValue)).trim()
|
||||
if (!text) return
|
||||
if (WAVE_OPERATOR_MULTI_VALUE.has(operator)) {
|
||||
const values = text.split(',').map((v: string) => v.trim()).filter(Boolean)
|
||||
if (!values.length) return
|
||||
where[key] = { operator, value: values }
|
||||
} else {
|
||||
where[key] = { operator, value: text }
|
||||
}
|
||||
return
|
||||
}
|
||||
// 其余字段(select 等值、min/max 区间等):保持标量值透传
|
||||
where[key] = rawValue
|
||||
// order.wave.batchList where 为标量白名单:等值/模糊字段直接透传 value(store_id 支持数组 in)
|
||||
where[key] = value
|
||||
return
|
||||
}
|
||||
if (condition !== undefined && condition !== null && condition !== '') {
|
||||
|
||||
@ -9,7 +9,6 @@ export const WAVE_PAGE_CONFIG = {
|
||||
|
||||
import {
|
||||
buyerMessageHasFilterOptions,
|
||||
ORDER_BULK_SEARCH_OPERATORS,
|
||||
scanBasicField,
|
||||
scanWorkflowField,
|
||||
type ToolbarButtonConfig,
|
||||
@ -104,13 +103,7 @@ export const waveUpperTableDefaults = {
|
||||
/** 左侧筛选可用字段(对标待处理订单 ScanBox 分组排序) */
|
||||
export const waveAvailableFields = [
|
||||
// ===== 波次信息 =====
|
||||
waveScanBasicField({
|
||||
label: '波次号',
|
||||
value: 'wave_no',
|
||||
type: 'text',
|
||||
operators: ORDER_BULK_SEARCH_OPERATORS,
|
||||
defaultOperator: 'like'
|
||||
}),
|
||||
waveScanBasicField({ label: '波次号', value: 'wave_no', type: 'text' }),
|
||||
waveScanBasicField({
|
||||
label: '货主',
|
||||
value: 'store_id',
|
||||
@ -215,20 +208,8 @@ export const waveAvailableFields = [
|
||||
{ label: 'PDA策略', value: 2 }
|
||||
]
|
||||
}), group: WAVE_SCAN_OTHER_GROUP },
|
||||
{ ...waveScanBasicField({
|
||||
label: '快递',
|
||||
value: 'logistics_name',
|
||||
type: 'text',
|
||||
operators: ORDER_BULK_SEARCH_OPERATORS,
|
||||
defaultOperator: 'like'
|
||||
}), group: WAVE_SCAN_OTHER_GROUP },
|
||||
{ ...waveScanBasicField({
|
||||
label: '创建人',
|
||||
value: 'creator',
|
||||
type: 'text',
|
||||
operators: ORDER_BULK_SEARCH_OPERATORS,
|
||||
defaultOperator: 'like'
|
||||
}), group: WAVE_SCAN_OTHER_GROUP },
|
||||
{ ...waveScanBasicField({ label: '快递', value: 'logistics_name', type: 'text' }), group: WAVE_SCAN_OTHER_GROUP },
|
||||
{ ...waveScanBasicField({ label: '创建人', value: 'creator', type: 'text' }), group: WAVE_SCAN_OTHER_GROUP },
|
||||
]
|
||||
|
||||
/** 抓取散单候选:左侧筛选可用字段 */
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<!--
|
||||
FrontConfigForm — 仓库「前端独立部署」配置页(独立标签页,表单项页面)
|
||||
对接接口:
|
||||
- setting.warehouse.getFrontConfig:加载当前仓库前端部署配置(品牌 + 域名/证书状态)
|
||||
- setting.warehouse.getFrontConfig:加载当前仓库前端部署配置(品牌 + 域名/证书状态 + cert_pem/key_pem 证书内容回显)
|
||||
- setting.warehouse.saveFrontConfig:保存品牌配置(title/logo/favicon/login_bg/theme)
|
||||
- setting.warehouse.saveFrontCert:上传自持域名 HTTPS 证书(domain + pem/key)
|
||||
该页从基础设置(WarehouseSettingsForm)独立拆出,作为 basicManagement/newview 的
|
||||
@ -39,13 +39,23 @@
|
||||
:closable="false"
|
||||
class="mb-16 front-config-alert"
|
||||
/>
|
||||
<el-descriptions v-if="frontMeta.domain" :column="4" border size="small" class="front-config-meta">
|
||||
<!-- 配置回显全量展示(getFrontConfig 响应字段;无数据显式置空占位,不做条件隐藏) -->
|
||||
<el-descriptions :column="2" border size="small" class="front-config-meta">
|
||||
<el-descriptions-item label="当前仓库 ID">{{ frontMeta.warehouse_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="自持域名">{{ frontMeta.domain || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="证书状态">
|
||||
<el-tag :type="frontCertTagType" size="small" effect="plain">{{ frontCertStatus.text }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="证书到期时间">{{ formatFrontDateTime(frontMeta.cert_expire_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="证书内容">
|
||||
<span v-if="frontHasCert">已配置(见下方回显)</span>
|
||||
<span v-else>未配置</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="配置更新时间">{{ formatFrontDateTime(frontMeta.updated_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="同步状态">{{ frontSyncStatusText }}</el-descriptions-item>
|
||||
<el-descriptions-item label="同步详情">{{ frontMeta.last_synced_at || '—' }} · 尝试 {{ frontMeta.sync_attempts ?? 0 }} 次</el-descriptions-item>
|
||||
<el-descriptions-item label="同步尝试次数">{{ frontMeta.sync_attempts ?? 0 }} 次</el-descriptions-item>
|
||||
<el-descriptions-item label="最近同步成功时间">{{ formatFrontDateTime(frontMeta.last_synced_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="最近同步失败原因">{{ frontMeta.last_sync_error || '—' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-form label-width="140px" label-position="right" class="front-config-form">
|
||||
<el-form-item label="站点标题">
|
||||
@ -62,27 +72,6 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="主题配置">
|
||||
<div class="front-theme-editor">
|
||||
<div class="front-theme-default">
|
||||
<div class="front-theme-row">
|
||||
<span class="front-theme-row__label">网页名称</span>
|
||||
<el-input v-model="frontThemeDefault.siteName" class="front-theme-row__value" placeholder="如:XX云仓(留空使用系统默认:天豹云仓)" clearable maxlength="100" />
|
||||
</div>
|
||||
<div class="front-theme-row">
|
||||
<span class="front-theme-row__label">主页面 Logo</span>
|
||||
<el-input v-model="frontThemeDefault.mainLogoUrl" class="front-theme-row__value" placeholder="主页面/顶栏 Logo 图片 URL(可留空)" clearable maxlength="255" />
|
||||
</div>
|
||||
<div class="front-theme-row">
|
||||
<span class="front-theme-row__label">登录页 Logo</span>
|
||||
<el-input v-model="frontThemeDefault.loginLogoUrl" class="front-theme-row__value" placeholder="登录页 Logo 图片 URL(留空用品牌 Logo)" clearable maxlength="255" />
|
||||
</div>
|
||||
<div class="front-theme-row">
|
||||
<span class="front-theme-row__label">登录页文字</span>
|
||||
<el-input v-model="frontThemeDefault.loginText" class="front-theme-row__value" placeholder="登录页标语(留空默认:现代化仓储管理系统 - 助力企业高效运营)" clearable maxlength="200" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="front-config-hint front-theme-hint">以上 4 个为约定主题字段,均可留空:留空不写入主题、使用系统默认值。</div>
|
||||
|
||||
<el-divider content-position="left" class="front-config-divider">自定义主题键值(映射 CSS 变量 --<key>)</el-divider>
|
||||
<div v-for="(row, idx) in frontThemeRows" :key="`front-theme-${idx}`" class="front-theme-row">
|
||||
<el-input v-model="row.key" class="front-theme-row__key" placeholder="键(如 primary)" maxlength="60" />
|
||||
<el-input v-model="row.value" class="front-theme-row__value" placeholder="值:文本,或 JSON 对象/数组/数字/布尔" />
|
||||
@ -91,6 +80,7 @@
|
||||
<div class="front-theme-actions">
|
||||
<el-button type="primary" plain size="small" @click="addFrontThemeRow">新增自定义键</el-button>
|
||||
</div>
|
||||
<div class="front-config-hint front-theme-hint">主题仅承载 CSS 变量自定义键(保存后应用为 --<key>);网页名称/Logo/favicon/登录背景等品牌字段见上方表单(getFrontConfig/saveFrontConfig 顶层字段),不再写入主题。</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
@ -115,6 +105,52 @@
|
||||
<span class="front-config-hint">上传成功后自动写入证书到期时间、重置同步状态并重新加载配置</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 证书内容回显:getFrontConfig 响应返回 cert_pem/key_pem(PEM 原文),仅本仓库设置页可见;
|
||||
始终渲染该区块,未配置时显式置空占位,有证书时默认展开 -->
|
||||
<el-divider content-position="left" class="front-config-divider">证书内容回显(cert_pem / key_pem)</el-divider>
|
||||
<div class="front-cert-echo">
|
||||
<el-alert
|
||||
type="info"
|
||||
show-icon
|
||||
:closable="false"
|
||||
class="front-cert-echo__alert"
|
||||
title="证书内容已直接存库并由 getFrontConfig 回显"
|
||||
:description="`来自接口响应(仅登录仓库主体 settings 页可见,公共接口 frontConfig.getByDomain 不返回);未配置时为空。证书到期:${formatFrontDateTime(frontMeta.cert_expire_at)}。私钥敏感,请勿外泄。`"
|
||||
/>
|
||||
<el-collapse v-model="frontCertEchoOpen" class="front-cert-echo__collapse">
|
||||
<el-collapse-item name="cert_pem" title="证书 PEM(cert_pem)">
|
||||
<div class="front-cert-echo__bar">
|
||||
<el-tag v-if="frontHasCert" type="success" size="small" effect="plain">已配置</el-tag>
|
||||
<el-tag v-else type="info" size="small" effect="plain">未配置</el-tag>
|
||||
<el-button size="small" :disabled="!frontHasCert" @click="copyFrontText(frontMeta.cert_pem)">复制证书</el-button>
|
||||
</div>
|
||||
<el-input
|
||||
type="textarea"
|
||||
:rows="6"
|
||||
readonly
|
||||
:model-value="String(frontMeta.cert_pem ?? '')"
|
||||
placeholder="未配置(空)"
|
||||
class="front-cert-echo__pem"
|
||||
/>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item name="key_pem" title="私钥 PEM(key_pem · 敏感)">
|
||||
<div class="front-cert-echo__bar">
|
||||
<el-tag v-if="frontHasKey" type="success" size="small" effect="plain">已配置</el-tag>
|
||||
<el-tag v-else type="info" size="small" effect="plain">未配置</el-tag>
|
||||
<el-button size="small" :disabled="!frontHasKey" @click="copyFrontText(frontMeta.key_pem)">复制私钥</el-button>
|
||||
</div>
|
||||
<el-input
|
||||
type="textarea"
|
||||
:rows="6"
|
||||
readonly
|
||||
:model-value="String(frontMeta.key_pem ?? '')"
|
||||
placeholder="未配置(空)"
|
||||
class="front-cert-echo__pem"
|
||||
/>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -133,21 +169,24 @@ defineOptions({ name: 'FrontConfigForm' })
|
||||
|
||||
const okCode = (code: unknown) => code === 1 || code === 200 || code === 0
|
||||
|
||||
/** getFrontConfig 响应:仓库前端部署元信息(品牌 + 证书/同步内部字段,仅用于本页回显) */
|
||||
/** getFrontConfig 响应:仓库前端部署元信息(品牌 + 证书/同步内部字段,仅用于本页回显)
|
||||
* 最新接口返回 cert_pem/key_pem(PEM 原文),不再返回 cert_path/key_path。 */
|
||||
type FrontConfigMeta = {
|
||||
warehouse_id?: number
|
||||
domain?: string
|
||||
title?: string
|
||||
logo_url?: string
|
||||
favicon_url?: string
|
||||
login_bg_url?: string
|
||||
theme?: Record<string, unknown> | string | null
|
||||
cert_path?: string
|
||||
key_path?: string
|
||||
cert_pem?: string
|
||||
key_pem?: string
|
||||
cert_expire_at?: string | null
|
||||
sync_status?: number
|
||||
sync_attempts?: number
|
||||
last_sync_error?: string
|
||||
last_synced_at?: string | null
|
||||
updated_at?: string | null
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
@ -156,15 +195,15 @@ const frontPageLoading = ref(false)
|
||||
const frontSaving = ref(false)
|
||||
const frontCertSaving = ref(false)
|
||||
const frontMeta = reactive<FrontConfigMeta>({})
|
||||
/** 证书回显折叠面板展开项(有证书时默认展开 cert_pem/key_pem) */
|
||||
const frontCertEchoOpen = ref<string[]>([])
|
||||
const frontForm = reactive({ title: '', logo_url: '', favicon_url: '', login_bg_url: '' })
|
||||
/** 主题约定 4 字段(文案/资源类,允许空;空=不写入主题、使用默认) */
|
||||
const FRONT_THEME_FIXED_KEYS = ['siteName', 'mainLogoUrl', 'loginLogoUrl', 'loginText'] as const
|
||||
const frontThemeDefault = reactive<Record<string, string>>({
|
||||
siteName: '',
|
||||
mainLogoUrl: '',
|
||||
loginLogoUrl: '',
|
||||
loginText: ''
|
||||
})
|
||||
/** 历史遗留 theme 约定键(曾承载 网页名称/主页面Logo/登录页Logo/登录页文字)。
|
||||
* 现已改由品牌顶层字段(saveFrontConfig:title/logo_url 等)配置,theme 不再约定这些业务键。
|
||||
* 加载时隐藏不展示、保存时原样保留,避免历史数据丢失。 */
|
||||
const FRONT_THEME_LEGACY_KEYS = ['siteName', 'mainLogoUrl', 'loginLogoUrl', 'loginText'] as const
|
||||
/** 历史遗留 theme 键原值(只读保留:不展示、不编辑,保存时透传回写) */
|
||||
const frontThemeLegacy = reactive<Record<string, unknown>>({})
|
||||
const frontThemeRows = ref<Array<{ key: string; value: string }>>([])
|
||||
const frontCert = reactive({ domain: '', pem: '', key: '' })
|
||||
|
||||
@ -179,12 +218,43 @@ const frontSyncStatusText = computed(() => {
|
||||
/** 同步是否失败(用于同步失败告警) */
|
||||
const frontSyncFailed = computed(() => Number(frontMeta.sync_status) === 2)
|
||||
|
||||
/** 是否已配置证书(cert_pem 非空,用于回显区展示) */
|
||||
const frontHasCert = computed(() => Boolean(frontMeta.cert_pem && String(frontMeta.cert_pem).trim()))
|
||||
/** 是否回显私钥(key_pem 非空) */
|
||||
const frontHasKey = computed(() => Boolean(frontMeta.key_pem && String(frontMeta.key_pem).trim()))
|
||||
|
||||
/** 复制接口回显的证书/私钥内容到剪贴板 */
|
||||
async function copyFrontText(text: unknown) {
|
||||
const value = String(text ?? '').trim()
|
||||
if (!value) {
|
||||
ElMessage.warning('无内容可复制')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await navigator.clipboard.writeText(value)
|
||||
ElMessage.success('已复制到剪贴板')
|
||||
} catch {
|
||||
ElMessage.warning('复制失败,请手动全选复制')
|
||||
}
|
||||
}
|
||||
|
||||
function fmtFrontDate(ts: number): string {
|
||||
const d = new Date(ts)
|
||||
const p = (n: number) => String(n).padStart(2, '0')
|
||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`
|
||||
}
|
||||
|
||||
/** 格式化接口返回的时间字段(ISO/秒/毫秒时间戳 → 本地 YYYY-MM-DD HH:mm:ss),空值/非法返回 '—' */
|
||||
function formatFrontDateTime(value: unknown): string {
|
||||
const raw = String(value ?? '').trim()
|
||||
if (!raw) return '—'
|
||||
const ts = Date.parse(raw)
|
||||
if (Number.isNaN(ts)) return '—'
|
||||
const d = new Date(ts)
|
||||
const p = (n: number) => String(n).padStart(2, '0')
|
||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`
|
||||
}
|
||||
|
||||
/** 证书状态:none=未上传,success=正常,warning=30 天内到期,danger=已过期 */
|
||||
const frontCertStatus = computed<{
|
||||
level: 'success' | 'warning' | 'danger' | 'info' | 'none'
|
||||
@ -262,6 +332,9 @@ async function loadFrontConfig() {
|
||||
const cfg = unwrapSettingWarehousePayload(res as Record<string, unknown>)
|
||||
Object.keys(frontMeta).forEach((k) => delete frontMeta[k])
|
||||
Object.assign(frontMeta, cfg)
|
||||
// 有证书内容时默认展开证书/私钥回显面板(无则收起,字段仍以「未配置」占位展示)
|
||||
frontCertEchoOpen.value =
|
||||
cfg.cert_pem || cfg.key_pem ? ['cert_pem', 'key_pem'] : []
|
||||
frontForm.title = String(cfg.title ?? '')
|
||||
frontForm.logo_url = String(cfg.logo_url ?? '')
|
||||
frontForm.favicon_url = String(cfg.favicon_url ?? '')
|
||||
@ -279,16 +352,14 @@ async function loadFrontConfig() {
|
||||
}
|
||||
}
|
||||
const src = themeObj
|
||||
// 约定 4 字段单独编辑(允许空),其余键进入自定义 CSS 变量区
|
||||
FRONT_THEME_FIXED_KEYS.forEach((k) => {
|
||||
frontThemeDefault[k] = ''
|
||||
})
|
||||
// 历史遗留约定键:只读保留(隐藏不展示);其余键进入自定义 CSS 变量区编辑
|
||||
Object.keys(frontThemeLegacy).forEach((k) => delete frontThemeLegacy[k])
|
||||
frontThemeRows.value = []
|
||||
if (src) {
|
||||
Object.keys(src).forEach((k) => {
|
||||
const value = src[k]
|
||||
if (FRONT_THEME_FIXED_KEYS.includes(k as (typeof FRONT_THEME_FIXED_KEYS)[number])) {
|
||||
frontThemeDefault[k] = stringifyFrontThemeValue(value)
|
||||
if (FRONT_THEME_LEGACY_KEYS.includes(k as (typeof FRONT_THEME_LEGACY_KEYS)[number])) {
|
||||
frontThemeLegacy[k] = value
|
||||
} else if (value !== undefined && value !== null && String(value).trim() !== '') {
|
||||
frontThemeRows.value.push({ key: k, value: stringifyFrontThemeValue(value) })
|
||||
}
|
||||
@ -304,16 +375,13 @@ async function loadFrontConfig() {
|
||||
async function saveFrontConfig() {
|
||||
frontSaving.value = true
|
||||
try {
|
||||
const themeObj: Record<string, unknown> = {}
|
||||
// 约定 4 字段允许空:空值不写入主题(前端用默认文案/图片)
|
||||
FRONT_THEME_FIXED_KEYS.forEach((k) => {
|
||||
const val = String(frontThemeDefault[k] ?? '').trim()
|
||||
if (val) themeObj[k] = val
|
||||
})
|
||||
const themeObj: Record<string, unknown> = { ...frontThemeLegacy }
|
||||
frontThemeRows.value.forEach((row) => {
|
||||
const key = row.key.trim()
|
||||
const valueText = row.value.trim()
|
||||
if (!key || !valueText) return
|
||||
// 历史遗留约定键不可通过自定义区再次写入(已由顶层品牌字段承担)
|
||||
if (FRONT_THEME_LEGACY_KEYS.includes(key as (typeof FRONT_THEME_LEGACY_KEYS)[number])) return
|
||||
themeObj[key] = parseFrontThemeValue(valueText)
|
||||
})
|
||||
const res = await settingWarehouseSaveFrontConfig({
|
||||
@ -450,17 +518,6 @@ loadFrontConfig()
|
||||
flex: 0 0 180px;
|
||||
}
|
||||
|
||||
&__label {
|
||||
flex: 0 0 180px;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
text-align: right;
|
||||
padding-right: 4px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__value {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
@ -475,4 +532,30 @@ loadFrontConfig()
|
||||
margin-left: 0;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.front-cert-echo {
|
||||
max-width: 720px;
|
||||
|
||||
&__alert {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
&__collapse {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
&__bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
&__pem {
|
||||
:deep(.el-textarea__inner) {
|
||||
font-family: var(--el-font-family-mono), Consolas, Menlo, monospace;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user