feat(基础设置): 前端独立部署(品牌配置+自持域名证书)拆分为独立标签页;基础设置页移除该区块
This commit is contained in:
parent
90bd48b2f9
commit
db5c935f87
@ -23,8 +23,9 @@
|
||||
- **API 封装**
|
||||
- `src/api/frontconfig/frontConfig.ts`(新目录,`frontConfigGetByDomain` + `FrontConfigPublicItem`)
|
||||
- `src/api/setting.warehouse/settingwarehouse.ts` 新增 3 个封装与 `SettingWarehouseFrontConfig` 等类型
|
||||
- **配置管理页面(基础设置)**:`src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue`
|
||||
- 底部「前端独立部署」区块:品牌表单(title/logo/favicon/login_bg + 主题键值编辑)+ 保存品牌配置(`saveFrontConfig`)
|
||||
- **配置管理(「前端独立部署」独立标签页)**:`src/views/system/setting/basicManagement/newview/pages/FrontConfigForm.vue`
|
||||
- 由 `.../newview/config/template-config.ts` `tabPages` 注册为独立 tab `frontConfig`「前端独立部署」,不再挤在基础设置(`WarehouseSettingsForm.vue`)内
|
||||
- 品牌表单(title/logo/favicon/login_bg + 主题键值编辑)+ 保存品牌配置(`saveFrontConfig`)
|
||||
- 自持域名&证书表单(domain/pem/key)+ 上传证书(`saveFrontCert`)
|
||||
- 加载即 `getFrontConfig` 回显;meta 展示 `domain / cert_expire_at / sync_status`
|
||||
- 已通过 type-check / build。
|
||||
@ -59,16 +60,16 @@
|
||||
> - A5 theme→CSS 变量:`src/stores/modules/frontBrand.ts` `applyThemeCssVars(theme)` 将 theme 顶层键写入 `--<key>` 至 `<html>`(仅标量值;非法键/嵌套对象忽略;键需 `[A-Za-z_][A-Za-z0-9_-]*`);brand 为空/换品牌时清除已应用变量(无残留)。约定:theme 键即 CSS 变量名(如 `primary`→`--primary`,`bgColor`→`--bgColor`)
|
||||
> - 验证:type-check 通过
|
||||
|
||||
### 模块 B:配置管理页完善(基础设置)【P1】
|
||||
### 模块 B:配置页完善(前端独立部署标签页)【P1】
|
||||
| # | 任务 | 涉及文件 | 说明 / 验收 |
|
||||
|---|---|---|---|
|
||||
| B1 | 同步状态详情回显 | `.../newview/pages/WarehouseSettingsForm.vue` | meta 区补充 `sync_attempts / last_sync_error / last_synced_at`;`sync_status=2` 时红色展示 `last_sync_error` 文案 |
|
||||
| B1 | 同步状态详情回显 | `.../newview/pages/FrontConfigForm.vue` | meta 区补充 `sync_attempts / last_sync_error / last_synced_at`;`sync_status=2` 时红色展示 `last_sync_error` 文案 |
|
||||
| B2 | 证书到期提醒 | 同上 | `cert_expire_at` 距当前 <30 天(或已过期)时给出 `el-alert`/tag 提醒;未上传显示“未上传” |
|
||||
| B3 | 保存/上传后处理核对 | ✅ 已落地:`WarehouseSettingsForm.vue` 品牌/证书按钮区补语义提示文案(品牌留空即清空、主题删空即清空、保存/上传成功后自动重新加载),实现已符合(空值清空 + 成功后 loadFrontConfig) |
|
||||
| B3 | 保存/上传后处理核对 | ✅ 已落地:`FrontConfigForm.vue` 品牌/证书按钮区补语义提示文案(品牌留空即清空、主题删空即清空、保存/上传成功后自动重新加载),实现已符合(空值清空 + 成功后 loadFrontConfig);该区块已随拆分迁至独立「前端独立部署」tab |
|
||||
| B4 | 接口登记核对 | `workflows/api-doc-agent/config/接口.md` | 4 个 method 应 `启用=是、占位=否`(api-list-update 已自动同步;人工复核一次) |
|
||||
|
||||
> ✅ **进度(2026-09-08):B1 ~ B4 已全部落地**
|
||||
> - B1 同步状态详情:`WarehouseSettingsForm.vue` meta 区新增「同步详情」列(`last_synced_at` · 尝试 `sync_attempts` 次);`sync_status=2` 时顶部红 `el-alert` 展示 `last_sync_error`
|
||||
> - B1 同步状态详情:`FrontConfigForm.vue` meta 区新增「同步详情」列(`last_synced_at` · 尝试 `sync_attempts` 次);`sync_status=2` 时顶部红 `el-alert` 展示 `last_sync_error`
|
||||
> - B2 证书状态:meta「证书状态」列按 `cert_expire_at` 显示 tag(未上传→灰、正常→绿、≤30 天→黄「剩 N 天」、过期→红);过期/临期在配置区顶部显示 `el-alert` 提醒
|
||||
> - B4 接口登记核对:`workflows/api-doc-agent/config/接口.md` 人工复核通过 —— 4 个 method(frontConfig.getByDomain / setting.warehouse.getFrontConfig / saveFrontConfig / saveFrontCert)均 `启用=是、占位=否`,归属路径正确
|
||||
> - 验证:type-check 通过
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
## 1. 使用链路(速览)
|
||||
|
||||
```
|
||||
仓库侧(本系统 · 基础设置) 后端 部署后的浏览器
|
||||
仓库侧(本系统 ·「前端独立部署」标签页) 后端 部署后的浏览器
|
||||
──────────────────────────────────────────────────────────────────────────────
|
||||
1 保存品牌 title/logo/favicon/login_bg/theme → wms_warehouse_front_config
|
||||
2 上传域名 domain + 证书 pem/key(saveFrontCert)
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
## 2. 仓库侧操作(网页后台)
|
||||
|
||||
入口:**系统设置 → 基础设置(仓库设置)→ 底部「前端独立部署」**(`basicManagement/newview` 的 `WarehouseSettingsForm`)。
|
||||
入口:**系统设置 → 基础设置(仓库设置)→「前端独立部署」标签页**(`basicManagement/newview` 独立表单页 `FrontConfigForm.vue`,由 `config/template-config.ts` 的 `tabPages` 注册;已不再挤在基础设置页内)。
|
||||
|
||||
### 2.1 保存品牌配置(saveFrontConfig)
|
||||
- 字段:
|
||||
@ -115,7 +115,7 @@
|
||||
3. 未登记域名 / 直连主域名:接口返回 404 / `configured=false` → 前端静默使用系统默认品牌(无报错)。
|
||||
4. 本地联调建议:改 hosts 把自持域名指向本机测试环境即可看到品牌效果;确认无旧品牌残留可清理站点数据后刷新。
|
||||
5. **多仓库同一部署的域名解析(A6)**:一套前端部署可同时服务多个仓库——
|
||||
- 各仓库在各自基础设置里登记自己的 `domain`(一仓一行、`domain` 全局唯一),并各自保存品牌/证书;
|
||||
- 各仓库在各自「前端独立部署」标签页里登记自己的 `domain`(一仓一行、`domain` 全局唯一),并各自保存品牌/证书;
|
||||
- 后端按访问 hostname 从 `wms_warehouse_front_config` 及缓存 `front:config:domain:{domain}` 返回对应仓库的公开品牌;
|
||||
- 前端仅按 `location.hostname` 调 `frontConfig.getByDomain`,对“多仓库同部署”无感知;
|
||||
- `saveFrontConfig`/`saveFrontCert` 保存成功后后端会自动清理新旧域名缓存,因此换域名/改品牌基本即时生效(600s 缓存窗口内读到旧值属正常,无需前端处理);
|
||||
@ -128,7 +128,7 @@
|
||||
| 层 | 文件/位置 |
|
||||
|---|---|
|
||||
| API 封装 | `src/api/frontconfig/frontConfig.ts`;`src/api/setting.warehouse/settingwarehouse.ts`(3 个管理接口) |
|
||||
| 配置管理 | `src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue`「前端独立部署」区块 |
|
||||
| 配置管理(独立标签页) | `src/views/system/setting/basicManagement/newview/pages/FrontConfigForm.vue`(品牌配置 + 自持域名&证书);tab 注册:`.../newview/config/template-config.ts` `tabPages`(name=`frontConfig`);基础设置页已移除该区块(`.../pages/WarehouseSettingsForm.vue` 仅剩仓库配置) |
|
||||
| 品牌 store | `src/stores/modules/frontBrand.ts`(loadBrandByDomain / applyThemeCssVars / applyBrandGlobals) |
|
||||
| 入口触发 | `src/main.ts` |
|
||||
| 登录页品牌 | `src/views/login/index.vue` |
|
||||
|
||||
@ -21,6 +21,7 @@ import { ref, isRef, computed, type Component, type Ref } from 'vue'
|
||||
import DetailPanel from './components/DetailPanel.vue'
|
||||
import LogPanel from './components/LogPanel.vue'
|
||||
import WarehouseSettingsForm from '../pages/WarehouseSettingsForm.vue'
|
||||
import FrontConfigForm from '../pages/FrontConfigForm.vue'
|
||||
import ApiAppFormDialog from '../pages/ApiAppFormDialog.vue'
|
||||
import DeliveryPlanFormDialog from '../pages/DeliveryPlanFormDialog.vue'
|
||||
import DefinitionFormDialog from '../pages/DefinitionFormDialog.vue'
|
||||
@ -55,6 +56,7 @@ export const COMPONENT_REGISTRY: Record<string, Component> = {
|
||||
DetailPanel,
|
||||
LogPanel,
|
||||
WarehouseSettingsForm,
|
||||
FrontConfigForm,
|
||||
ApiAppFormDialog,
|
||||
DeliveryPlanFormDialog,
|
||||
DeliveryPlanCopyDialog,
|
||||
@ -1294,6 +1296,22 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
detailSections: []
|
||||
},
|
||||
|
||||
// ===== 前端独立部署(品牌配置 + 自持域名&证书,独立表单项页) =====
|
||||
{
|
||||
name: 'frontConfig',
|
||||
label: '前端独立部署',
|
||||
viewType: 'form',
|
||||
formPage: FrontConfigForm,
|
||||
scanBoxCacheKey: 'basic-settings-frontconfig',
|
||||
scanBoxFieldKeys: [],
|
||||
tableColumnKeys: [],
|
||||
upperTableDefaults: {
|
||||
title: '',
|
||||
showSelection: false
|
||||
},
|
||||
detailSections: []
|
||||
},
|
||||
|
||||
// ===== 标签页二:API开放接口(scan-box + upper-table 列表) =====
|
||||
{
|
||||
name: 'apiOpen',
|
||||
|
||||
@ -0,0 +1,478 @@
|
||||
<!--
|
||||
FrontConfigForm — 仓库「前端独立部署」配置页(独立标签页,表单项页面)
|
||||
对接接口:
|
||||
- setting.warehouse.getFrontConfig:加载当前仓库前端部署配置(品牌 + 域名/证书状态)
|
||||
- setting.warehouse.saveFrontConfig:保存品牌配置(title/logo/favicon/login_bg/theme)
|
||||
- setting.warehouse.saveFrontCert:上传自持域名 HTTPS 证书(domain + pem/key)
|
||||
该页从基础设置(WarehouseSettingsForm)独立拆出,作为 basicManagement/newview 的
|
||||
viewType='form' 标签页渲染。
|
||||
-->
|
||||
<template>
|
||||
<div v-loading="frontPageLoading" class="front-config-page">
|
||||
<div class="settings-header">
|
||||
<div class="header-text">
|
||||
<span class="title">前端独立部署</span>
|
||||
<span class="sub">按仓库自持域名部署并品牌化前端(站点标题 / Logo / favicon / 登录页 / 主题 / HTTPS 证书)</span>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<el-button :loading="frontPageLoading" @click="loadFrontConfig">刷新</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="front-config-section">
|
||||
<el-divider content-position="left" class="front-config-divider">前端独立部署(品牌配置)</el-divider>
|
||||
<el-alert
|
||||
v-if="frontCertStatus.level === 'danger' || frontCertStatus.level === 'warning'"
|
||||
:type="frontCertStatus.level"
|
||||
:title="frontCertStatus.title"
|
||||
:description="frontCertStatus.desc"
|
||||
show-icon
|
||||
:closable="false"
|
||||
class="mb-16 front-config-alert"
|
||||
/>
|
||||
<el-alert
|
||||
v-if="frontSyncFailed"
|
||||
type="error"
|
||||
title="证书部署同步失败"
|
||||
:description="frontMeta.last_sync_error || '同步失败,请重新上传证书或稍后重试'"
|
||||
show-icon
|
||||
:closable="false"
|
||||
class="mb-16 front-config-alert"
|
||||
/>
|
||||
<el-descriptions v-if="frontMeta.domain" :column="4" border size="small" class="front-config-meta">
|
||||
<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="同步状态">{{ frontSyncStatusText }}</el-descriptions-item>
|
||||
<el-descriptions-item label="同步详情">{{ frontMeta.last_synced_at || '—' }} · 尝试 {{ frontMeta.sync_attempts ?? 0 }} 次</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-form label-width="140px" label-position="right" class="front-config-form">
|
||||
<el-form-item label="站点标题">
|
||||
<el-input v-model="frontForm.title" maxlength="100" clearable placeholder="站点标题(留空表示清空)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Logo 地址">
|
||||
<el-input v-model="frontForm.logo_url" maxlength="255" clearable placeholder="Logo 图片 URL(留空清空)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="favicon 地址">
|
||||
<el-input v-model="frontForm.favicon_url" maxlength="255" clearable placeholder="favicon 图标 URL(留空清空)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="登录页背景图">
|
||||
<el-input v-model="frontForm.login_bg_url" maxlength="255" clearable placeholder="登录页背景图 URL(留空清空)" />
|
||||
</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 对象/数组/数字/布尔" />
|
||||
<el-button type="danger" plain size="small" @click="removeFrontThemeRow(idx)">删除</el-button>
|
||||
</div>
|
||||
<div class="front-theme-actions">
|
||||
<el-button type="primary" plain size="small" @click="addFrontThemeRow">新增自定义键</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="frontSaving" @click="saveFrontConfig">保存品牌配置</el-button>
|
||||
<span class="front-config-hint">品牌字段留空即清空;主题删空全部键后保存即清空主题;保存成功后自动重新加载</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-divider content-position="left" class="front-config-divider">前端独立部署(自持域名 & 证书)</el-divider>
|
||||
<el-form label-width="140px" label-position="right" class="front-config-form">
|
||||
<el-form-item label="自持域名">
|
||||
<el-input v-model="frontCert.domain" maxlength="100" clearable placeholder="如 self.example.com(全局唯一)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="证书 PEM">
|
||||
<el-input v-model="frontCert.pem" type="textarea" :rows="4" placeholder="-----BEGIN CERTIFICATE-----..." />
|
||||
</el-form-item>
|
||||
<el-form-item label="私钥 PEM">
|
||||
<el-input v-model="frontCert.key" type="textarea" :rows="4" placeholder="-----BEGIN PRIVATE KEY-----..." />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="warning" :loading="frontCertSaving" @click="submitFrontCert">上传证书</el-button>
|
||||
<span class="front-config-hint">上传成功后自动写入证书到期时间、重置同步状态并重新加载配置</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
settingWarehouseGetFrontConfig,
|
||||
settingWarehouseSaveFrontConfig,
|
||||
settingWarehouseSaveFrontCert,
|
||||
unwrapSettingWarehousePayload
|
||||
} from '@/api/setting.warehouse/settingwarehouse'
|
||||
|
||||
defineOptions({ name: 'FrontConfigForm' })
|
||||
|
||||
const okCode = (code: unknown) => code === 1 || code === 200 || code === 0
|
||||
|
||||
/** getFrontConfig 响应:仓库前端部署元信息(品牌 + 证书/同步内部字段,仅用于本页回显) */
|
||||
type FrontConfigMeta = {
|
||||
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_expire_at?: string | null
|
||||
sync_status?: number
|
||||
sync_attempts?: number
|
||||
last_sync_error?: string
|
||||
last_synced_at?: string | null
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
// ── 前端独立部署(品牌 & 域名证书):getFrontConfig / saveFrontConfig / saveFrontCert ──
|
||||
const frontPageLoading = ref(false)
|
||||
const frontSaving = ref(false)
|
||||
const frontCertSaving = ref(false)
|
||||
const frontMeta = reactive<FrontConfigMeta>({})
|
||||
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: ''
|
||||
})
|
||||
const frontThemeRows = ref<Array<{ key: string; value: string }>>([])
|
||||
const frontCert = reactive({ domain: '', pem: '', key: '' })
|
||||
|
||||
const frontSyncStatusText = computed(() => {
|
||||
const s = Number(frontMeta.sync_status)
|
||||
if (s === 0) return '待同步'
|
||||
if (s === 1) return '同步成功'
|
||||
if (s === 2) return '同步失败'
|
||||
return frontMeta.sync_status ?? '—'
|
||||
})
|
||||
|
||||
/** 同步是否失败(用于同步失败告警) */
|
||||
const frontSyncFailed = computed(() => Number(frontMeta.sync_status) === 2)
|
||||
|
||||
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())}`
|
||||
}
|
||||
|
||||
/** 证书状态:none=未上传,success=正常,warning=30 天内到期,danger=已过期 */
|
||||
const frontCertStatus = computed<{
|
||||
level: 'success' | 'warning' | 'danger' | 'info' | 'none'
|
||||
text: string
|
||||
title: string
|
||||
desc: string
|
||||
}>(() => {
|
||||
const raw = String(frontMeta.cert_expire_at ?? '').trim()
|
||||
if (!raw) return { level: 'none', text: '未上传', title: '', desc: '' }
|
||||
const ts = Date.parse(raw)
|
||||
if (Number.isNaN(ts)) return { level: 'info', text: raw, title: '', desc: '' }
|
||||
const days = Math.ceil((ts - Date.now()) / 86400000)
|
||||
const when = fmtFrontDate(ts)
|
||||
if (days < 0) {
|
||||
return {
|
||||
level: 'danger',
|
||||
text: `${when} 已过期`,
|
||||
title: 'HTTPS 证书已过期',
|
||||
desc: `证书已于 ${when} 过期(${-days} 天),自持域名将无法正常访问,请重新上传证书。`
|
||||
}
|
||||
}
|
||||
if (days <= 30) {
|
||||
return {
|
||||
level: 'warning',
|
||||
text: `${when} 到期(剩 ${days} 天)`,
|
||||
title: 'HTTPS 证书即将到期',
|
||||
desc: `证书将于 ${when} 到期,剩余 ${days} 天,请及时更新证书。`
|
||||
}
|
||||
}
|
||||
return { level: 'success', text: `有效期至 ${when}`, title: '', desc: '' }
|
||||
})
|
||||
|
||||
/** 证书 tag 类型(none/info 一律用 info 灰) */
|
||||
const frontCertTagType = computed<'success' | 'warning' | 'danger' | 'info'>(() => {
|
||||
const level = frontCertStatus.value.level
|
||||
return level === 'success' || level === 'warning' || level === 'danger' ? level : 'info'
|
||||
})
|
||||
|
||||
function stringifyFrontThemeValue(v: unknown): string {
|
||||
if (v === null || v === undefined) return ''
|
||||
if (typeof v === 'string') return v
|
||||
try {
|
||||
return JSON.stringify(v)
|
||||
} catch {
|
||||
return String(v)
|
||||
}
|
||||
}
|
||||
|
||||
function parseFrontThemeValue(text: string): unknown {
|
||||
const t = text.trim()
|
||||
if (!t) return ''
|
||||
try {
|
||||
return JSON.parse(t)
|
||||
} catch {
|
||||
return t
|
||||
}
|
||||
}
|
||||
|
||||
function addFrontThemeRow() {
|
||||
frontThemeRows.value.push({ key: '', value: '' })
|
||||
}
|
||||
|
||||
function removeFrontThemeRow(index: number) {
|
||||
frontThemeRows.value.splice(index, 1)
|
||||
}
|
||||
|
||||
async function loadFrontConfig() {
|
||||
frontPageLoading.value = true
|
||||
try {
|
||||
const res = await settingWarehouseGetFrontConfig()
|
||||
if (!res || !okCode(res.code)) {
|
||||
ElMessage.error(res?.message || '获取前端部署配置失败')
|
||||
return
|
||||
}
|
||||
const cfg = unwrapSettingWarehousePayload(res as Record<string, unknown>)
|
||||
Object.keys(frontMeta).forEach((k) => delete frontMeta[k])
|
||||
Object.assign(frontMeta, cfg)
|
||||
frontForm.title = String(cfg.title ?? '')
|
||||
frontForm.logo_url = String(cfg.logo_url ?? '')
|
||||
frontForm.favicon_url = String(cfg.favicon_url ?? '')
|
||||
frontForm.login_bg_url = String(cfg.login_bg_url ?? '')
|
||||
// theme:与 getFrontConfig 响应参数一致,按对象键逐项展开编辑
|
||||
let themeObj: Record<string, unknown> | null = null
|
||||
if (cfg.theme && typeof cfg.theme === 'object' && !Array.isArray(cfg.theme)) {
|
||||
themeObj = cfg.theme as Record<string, unknown>
|
||||
} else if (typeof cfg.theme === 'string' && cfg.theme.trim()) {
|
||||
try {
|
||||
const parsed = JSON.parse(cfg.theme)
|
||||
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) themeObj = parsed as Record<string, unknown>
|
||||
} catch {
|
||||
// 忽略无法解析的主题字符串
|
||||
}
|
||||
}
|
||||
const src = themeObj
|
||||
// 约定 4 字段单独编辑(允许空),其余键进入自定义 CSS 变量区
|
||||
FRONT_THEME_FIXED_KEYS.forEach((k) => {
|
||||
frontThemeDefault[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)
|
||||
} else if (value !== undefined && value !== null && String(value).trim() !== '') {
|
||||
frontThemeRows.value.push({ key: k, value: stringifyFrontThemeValue(value) })
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
ElMessage.error(e instanceof Error ? e.message : '获取前端部署配置失败')
|
||||
} finally {
|
||||
frontPageLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
frontThemeRows.value.forEach((row) => {
|
||||
const key = row.key.trim()
|
||||
const valueText = row.value.trim()
|
||||
if (!key || !valueText) return
|
||||
themeObj[key] = parseFrontThemeValue(valueText)
|
||||
})
|
||||
const res = await settingWarehouseSaveFrontConfig({
|
||||
title: frontForm.title.trim(),
|
||||
logo_url: frontForm.logo_url.trim(),
|
||||
favicon_url: frontForm.favicon_url.trim(),
|
||||
login_bg_url: frontForm.login_bg_url.trim(),
|
||||
theme: themeObj
|
||||
})
|
||||
if (!res || !okCode(res.code)) {
|
||||
ElMessage.error(res?.message || '保存品牌配置失败')
|
||||
return
|
||||
}
|
||||
ElMessage.success('品牌配置已保存')
|
||||
await loadFrontConfig()
|
||||
} catch (e: unknown) {
|
||||
ElMessage.error(e instanceof Error ? e.message : '保存品牌配置失败')
|
||||
} finally {
|
||||
frontSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitFrontCert() {
|
||||
const domain = frontCert.domain.trim()
|
||||
const pem = frontCert.pem.trim()
|
||||
const key = frontCert.key.trim()
|
||||
if (!domain || !pem || !key) {
|
||||
ElMessage.warning('域名、证书 PEM、私钥 PEM 均必填')
|
||||
return
|
||||
}
|
||||
frontCertSaving.value = true
|
||||
try {
|
||||
const res = await settingWarehouseSaveFrontCert({ domain, pem, key })
|
||||
if (!res || !okCode(res.code)) {
|
||||
ElMessage.error(res?.message || '证书上传失败')
|
||||
return
|
||||
}
|
||||
ElMessage.success('证书已上传并生效')
|
||||
frontCert.domain = ''
|
||||
frontCert.pem = ''
|
||||
frontCert.key = ''
|
||||
await loadFrontConfig()
|
||||
} catch (e: unknown) {
|
||||
ElMessage.error(e instanceof Error ? e.message : '证书上传失败')
|
||||
} finally {
|
||||
frontCertSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
loadFrontConfig()
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.front-config-page {
|
||||
padding: 12px 16px 24px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.settings-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.header-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.sub {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.mb-16 {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.front-config-section {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.front-config-divider {
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.front-config-meta {
|
||||
margin-bottom: 12px;
|
||||
max-width: 720px;
|
||||
}
|
||||
|
||||
.front-config-alert {
|
||||
margin: 0 0 12px;
|
||||
max-width: 720px;
|
||||
}
|
||||
|
||||
.front-config-form {
|
||||
max-width: 720px;
|
||||
}
|
||||
|
||||
.front-config-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.front-theme-editor {
|
||||
width: 100%;
|
||||
max-width: 560px;
|
||||
}
|
||||
|
||||
.front-theme-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
|
||||
&__key {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
.front-theme-actions {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.front-theme-hint {
|
||||
margin-left: 0;
|
||||
margin-top: 6px;
|
||||
}
|
||||
</style>
|
||||
@ -237,105 +237,6 @@
|
||||
<el-empty v-else description="暂无可编辑字段,请检查接口返回" />
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="front-config-section" v-loading="frontPageLoading">
|
||||
<el-divider content-position="left" class="front-config-divider">前端独立部署(品牌配置)</el-divider>
|
||||
<el-alert
|
||||
v-if="frontCertStatus.level === 'danger' || frontCertStatus.level === 'warning'"
|
||||
:type="frontCertStatus.level"
|
||||
:title="frontCertStatus.title"
|
||||
:description="frontCertStatus.desc"
|
||||
show-icon
|
||||
:closable="false"
|
||||
class="mb-16 front-config-alert"
|
||||
/>
|
||||
<el-alert
|
||||
v-if="frontSyncFailed"
|
||||
type="error"
|
||||
title="证书部署同步失败"
|
||||
:description="frontMeta.last_sync_error || '同步失败,请重新上传证书或稍后重试'"
|
||||
show-icon
|
||||
:closable="false"
|
||||
class="mb-16 front-config-alert"
|
||||
/>
|
||||
<el-descriptions v-if="frontMeta.domain" :column="4" border size="small" class="front-config-meta">
|
||||
<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="同步状态">{{ frontSyncStatusText }}</el-descriptions-item>
|
||||
<el-descriptions-item label="同步详情">{{ frontMeta.last_synced_at || '—' }} · 尝试 {{ frontMeta.sync_attempts ?? 0 }} 次</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-form label-width="140px" label-position="right" class="front-config-form">
|
||||
<el-form-item label="站点标题">
|
||||
<el-input v-model="frontForm.title" maxlength="100" clearable placeholder="站点标题(留空表示清空)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Logo 地址">
|
||||
<el-input v-model="frontForm.logo_url" maxlength="255" clearable placeholder="Logo 图片 URL(留空清空)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="favicon 地址">
|
||||
<el-input v-model="frontForm.favicon_url" maxlength="255" clearable placeholder="favicon 图标 URL(留空清空)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="登录页背景图">
|
||||
<el-input v-model="frontForm.login_bg_url" maxlength="255" clearable placeholder="登录页背景图 URL(留空清空)" />
|
||||
</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 对象/数组/数字/布尔" />
|
||||
<el-button type="danger" plain size="small" @click="removeFrontThemeRow(idx)">删除</el-button>
|
||||
</div>
|
||||
<div class="front-theme-actions">
|
||||
<el-button type="primary" plain size="small" @click="addFrontThemeRow">新增自定义键</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="frontSaving" @click="saveFrontConfig">保存品牌配置</el-button>
|
||||
<el-button :disabled="frontPageLoading" @click="loadFrontConfig">重新加载</el-button>
|
||||
<span class="front-config-hint">品牌字段留空即清空;主题删空全部键后保存即清空主题;保存成功后自动重新加载</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-divider content-position="left" class="front-config-divider">前端独立部署(自持域名 & 证书)</el-divider>
|
||||
<el-form label-width="140px" label-position="right" class="front-config-form">
|
||||
<el-form-item label="自持域名">
|
||||
<el-input v-model="frontCert.domain" maxlength="100" clearable placeholder="如 self.example.com(全局唯一)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="证书 PEM">
|
||||
<el-input v-model="frontCert.pem" type="textarea" :rows="4" placeholder="-----BEGIN CERTIFICATE-----..." />
|
||||
</el-form-item>
|
||||
<el-form-item label="私钥 PEM">
|
||||
<el-input v-model="frontCert.key" type="textarea" :rows="4" placeholder="-----BEGIN PRIVATE KEY-----..." />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="warning" :loading="frontCertSaving" @click="submitFrontCert">上传证书</el-button>
|
||||
<span class="front-config-hint">上传成功后自动写入证书到期时间、重置同步状态并重新加载配置</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -347,9 +248,6 @@ import {
|
||||
settingWarehouseGetSettings,
|
||||
settingWarehouseGetFieldMeta,
|
||||
settingWarehouseSaveSettings,
|
||||
settingWarehouseGetFrontConfig,
|
||||
settingWarehouseSaveFrontConfig,
|
||||
settingWarehouseSaveFrontCert,
|
||||
unwrapSettingWarehousePayload,
|
||||
buildSaveSettingsRequest,
|
||||
normalizeGetSettingsPayload,
|
||||
@ -722,218 +620,6 @@ const displayFields = computed(() =>
|
||||
useMetaForm.value && normalizedFields.value.length ? normalizedFields.value : FALLBACK_FIELDS
|
||||
)
|
||||
|
||||
// ── 前端独立部署(品牌 & 域名证书):getFrontConfig / saveFrontConfig / saveFrontCert ──
|
||||
const frontPageLoading = ref(false)
|
||||
const frontSaving = ref(false)
|
||||
const frontCertSaving = ref(false)
|
||||
const frontMeta = reactive<Record<string, any>>({})
|
||||
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: ''
|
||||
})
|
||||
const frontThemeRows = ref<Array<{ key: string; value: string }>>([])
|
||||
const frontCert = reactive({ domain: '', pem: '', key: '' })
|
||||
|
||||
const frontSyncStatusText = computed(() => {
|
||||
const s = Number(frontMeta.sync_status)
|
||||
if (s === 0) return '待同步'
|
||||
if (s === 1) return '同步成功'
|
||||
if (s === 2) return '同步失败'
|
||||
return frontMeta.sync_status ?? '—'
|
||||
})
|
||||
|
||||
/** 同步是否失败(用于同步失败告警) */
|
||||
const frontSyncFailed = computed(() => Number(frontMeta.sync_status) === 2)
|
||||
|
||||
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())}`
|
||||
}
|
||||
|
||||
/** 证书状态:none=未上传,success=正常,warning=30 天内到期,danger=已过期 */
|
||||
const frontCertStatus = computed<{
|
||||
level: 'success' | 'warning' | 'danger' | 'info' | 'none'
|
||||
text: string
|
||||
title: string
|
||||
desc: string
|
||||
}>(() => {
|
||||
const raw = String(frontMeta.cert_expire_at ?? '').trim()
|
||||
if (!raw) return { level: 'none', text: '未上传', title: '', desc: '' }
|
||||
const ts = Date.parse(raw)
|
||||
if (Number.isNaN(ts)) return { level: 'info', text: raw, title: '', desc: '' }
|
||||
const days = Math.ceil((ts - Date.now()) / 86400000)
|
||||
const when = fmtFrontDate(ts)
|
||||
if (days < 0) {
|
||||
return {
|
||||
level: 'danger',
|
||||
text: `${when} 已过期`,
|
||||
title: 'HTTPS 证书已过期',
|
||||
desc: `证书已于 ${when} 过期(${-days} 天),自持域名将无法正常访问,请重新上传证书。`
|
||||
}
|
||||
}
|
||||
if (days <= 30) {
|
||||
return {
|
||||
level: 'warning',
|
||||
text: `${when} 到期(剩 ${days} 天)`,
|
||||
title: 'HTTPS 证书即将到期',
|
||||
desc: `证书将于 ${when} 到期,剩余 ${days} 天,请及时更新证书。`
|
||||
}
|
||||
}
|
||||
return { level: 'success', text: `有效期至 ${when}`, title: '', desc: '' }
|
||||
})
|
||||
|
||||
/** 证书 tag 类型(none/info 一律用 info 灰) */
|
||||
const frontCertTagType = computed<'success' | 'warning' | 'danger' | 'info'>(() => {
|
||||
const level = frontCertStatus.value.level
|
||||
return level === 'success' || level === 'warning' || level === 'danger' ? level : 'info'
|
||||
})
|
||||
|
||||
function stringifyFrontThemeValue(v: unknown): string {
|
||||
if (v === null || v === undefined) return ''
|
||||
if (typeof v === 'string') return v
|
||||
try {
|
||||
return JSON.stringify(v)
|
||||
} catch {
|
||||
return String(v)
|
||||
}
|
||||
}
|
||||
|
||||
function parseFrontThemeValue(text: string): unknown {
|
||||
const t = text.trim()
|
||||
if (!t) return ''
|
||||
try {
|
||||
return JSON.parse(t)
|
||||
} catch {
|
||||
return t
|
||||
}
|
||||
}
|
||||
|
||||
function addFrontThemeRow() {
|
||||
frontThemeRows.value.push({ key: '', value: '' })
|
||||
}
|
||||
|
||||
function removeFrontThemeRow(index: number) {
|
||||
frontThemeRows.value.splice(index, 1)
|
||||
}
|
||||
|
||||
async function loadFrontConfig() {
|
||||
frontPageLoading.value = true
|
||||
try {
|
||||
const res = await settingWarehouseGetFrontConfig()
|
||||
if (!res || !okCode(res.code)) {
|
||||
ElMessage.error(res?.message || '获取前端部署配置失败')
|
||||
return
|
||||
}
|
||||
const cfg = unwrapSettingWarehousePayload(res as Record<string, unknown>)
|
||||
Object.keys(frontMeta).forEach((k) => delete frontMeta[k])
|
||||
Object.assign(frontMeta, cfg)
|
||||
frontForm.title = String(cfg.title ?? '')
|
||||
frontForm.logo_url = String(cfg.logo_url ?? '')
|
||||
frontForm.favicon_url = String(cfg.favicon_url ?? '')
|
||||
frontForm.login_bg_url = String(cfg.login_bg_url ?? '')
|
||||
// theme:与 getFrontConfig 响应参数一致,按对象键逐项展开编辑
|
||||
let themeObj: Record<string, unknown> | null = null
|
||||
if (cfg.theme && typeof cfg.theme === 'object' && !Array.isArray(cfg.theme)) {
|
||||
themeObj = cfg.theme as Record<string, unknown>
|
||||
} else if (typeof cfg.theme === 'string' && cfg.theme.trim()) {
|
||||
try {
|
||||
const parsed = JSON.parse(cfg.theme)
|
||||
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) themeObj = parsed as Record<string, unknown>
|
||||
} catch {
|
||||
// 忽略无法解析的主题字符串
|
||||
}
|
||||
}
|
||||
const src = themeObj
|
||||
// 约定 4 字段单独编辑(允许空),其余键进入自定义 CSS 变量区
|
||||
FRONT_THEME_FIXED_KEYS.forEach((k) => {
|
||||
frontThemeDefault[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)
|
||||
} else if (value !== undefined && value !== null && String(value).trim() !== '') {
|
||||
frontThemeRows.value.push({ key: k, value: stringifyFrontThemeValue(value) })
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
ElMessage.error(e instanceof Error ? e.message : '获取前端部署配置失败')
|
||||
} finally {
|
||||
frontPageLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
frontThemeRows.value.forEach((row) => {
|
||||
const key = row.key.trim()
|
||||
const valueText = row.value.trim()
|
||||
if (!key || !valueText) return
|
||||
themeObj[key] = parseFrontThemeValue(valueText)
|
||||
})
|
||||
const res = await settingWarehouseSaveFrontConfig({
|
||||
title: frontForm.title.trim(),
|
||||
logo_url: frontForm.logo_url.trim(),
|
||||
favicon_url: frontForm.favicon_url.trim(),
|
||||
login_bg_url: frontForm.login_bg_url.trim(),
|
||||
theme: themeObj
|
||||
})
|
||||
if (!res || !okCode(res.code)) {
|
||||
ElMessage.error(res?.message || '保存品牌配置失败')
|
||||
return
|
||||
}
|
||||
ElMessage.success('品牌配置已保存')
|
||||
await loadFrontConfig()
|
||||
} catch (e: unknown) {
|
||||
ElMessage.error(e instanceof Error ? e.message : '保存品牌配置失败')
|
||||
} finally {
|
||||
frontSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitFrontCert() {
|
||||
const domain = frontCert.domain.trim()
|
||||
const pem = frontCert.pem.trim()
|
||||
const key = frontCert.key.trim()
|
||||
if (!domain || !pem || !key) {
|
||||
ElMessage.warning('域名、证书 PEM、私钥 PEM 均必填')
|
||||
return
|
||||
}
|
||||
frontCertSaving.value = true
|
||||
try {
|
||||
const res = await settingWarehouseSaveFrontCert({ domain, pem, key })
|
||||
if (!res || !okCode(res.code)) {
|
||||
ElMessage.error(res?.message || '证书上传失败')
|
||||
return
|
||||
}
|
||||
ElMessage.success('证书已上传并生效')
|
||||
frontCert.domain = ''
|
||||
frontCert.pem = ''
|
||||
frontCert.key = ''
|
||||
await loadFrontConfig()
|
||||
} catch (e: unknown) {
|
||||
ElMessage.error(e instanceof Error ? e.message : '证书上传失败')
|
||||
} finally {
|
||||
frontCertSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadAll() {
|
||||
loadError.value = ''
|
||||
pageLoading.value = true
|
||||
@ -987,7 +673,6 @@ async function handleSave() {
|
||||
}
|
||||
|
||||
loadAll()
|
||||
loadFrontConfig()
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@ -1188,74 +873,4 @@ loadFrontConfig()
|
||||
}
|
||||
}
|
||||
|
||||
.front-config-section {
|
||||
margin-top: 24px;
|
||||
border-top: 1px dashed #e4e7ed;
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.front-config-divider {
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.front-config-meta {
|
||||
margin-bottom: 12px;
|
||||
max-width: 720px;
|
||||
}
|
||||
|
||||
.front-config-alert {
|
||||
margin: 0 0 12px;
|
||||
max-width: 720px;
|
||||
}
|
||||
|
||||
.front-config-form {
|
||||
max-width: 720px;
|
||||
}
|
||||
|
||||
.front-config-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.front-theme-editor {
|
||||
width: 100%;
|
||||
max-width: 560px;
|
||||
}
|
||||
|
||||
.front-theme-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
|
||||
&__key {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
.front-theme-actions {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.front-theme-hint {
|
||||
margin-left: 0;
|
||||
margin-top: 6px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user