Files
JayuCloud/JC-Salon-Frontend/src/views/admin/SystemSettingsView.vue
T

1186 lines
73 KiB
Vue
Raw Normal View History

2026-09-05 23:46:35 +08:00
<template>
<div class="system-settings">
<div class="settings-topbar">
<nav class="settings-tabs" role="tablist" aria-label="系统设置">
<button
v-for="item in sections"
:key="item.key"
type="button"
role="tab"
:aria-selected="activeSection === item.key"
:class="['settings-tab', { 'is-active': activeSection === item.key }]"
@click="activeSection = item.key"
>{{ item.label }}</button>
</nav>
<span class="settings-health"><i />当前环境设置</span>
</div>
<main class="settings-body" :aria-busy="loading">
<aside class="settings-subnav" aria-label="页内分组导航">
<span class="settings-subnav__label">分组导航</span>
<button
v-for="item in groupNavItems"
:key="item.id"
type="button"
:class="['settings-subnav__item', { 'is-active': activeGroup === item.id }]"
@click="scrollToGroup(item.id)"
>
<span>{{ item.label }}</span>
<em v-if="item.badge">{{ item.badge }}</em>
</button>
</aside>
<div class="settings-content">
<div v-if="activeSection === 'runtime'" class="settings-groups">
<section id="settings-group-account" class="settings-group">
<header class="settings-group__head">
<div class="settings-group__head-main">
<div class="settings-group__title"><h2>账号与登录</h2></div>
<p class="settings-group__desc">控制账号创建和店长登录后的默认行为,三项参数分别独立保存。</p>
</div>
<span class="meta">3 项参数</span>
</header>
<div class="settings-group__body">
<div class="field-grid cols-3">
<article class="field">
<div class="field__head"><span class="field__label">后台新增用户默认密码</span><span class="tag">USER</span></div>
<p class="field__desc">新增或重置店长账号时使用,不影响已有账号。</p>
<div class="field__control field__control--password">
<a-input-password v-model:value="defaultPasswordForm.configValue" autocomplete="new-password" placeholder="请输入 8-32 位强密码" />
<a-switch v-model:checked="defaultPasswordEnabled" checked-children="启用" un-checked-children="停用" />
</div>
<div class="field__foot">
<span :class="['status-pill', { 'is-muted': !defaultPasswordEnabled }]">{{ defaultPasswordEnabled ? '启用' : '停用' }}</span>
<span class="control-note">{{ defaultPasswordForm.configValue ? '已填写' : '未设置' }}</span>
<a-button class="field__save" size="small" type="primary" :loading="savingDefaultPassword" @click="saveDefaultPassword">保存密码设置</a-button>
</div>
</article>
<article class="field">
<div class="field__head"><span class="field__label">店长员工审核提醒</span><span class="tag">WORKBENCH</span></div>
<p class="field__desc">店长登录小程序时提醒处理待审核员工申请。</p>
<div class="field__control">
<a-switch v-model:checked="reviewNoticeEnabled" checked-children="显示" un-checked-children="隐藏" />
<span class="control-note">登录时{{ reviewNoticeEnabled ? '显示' : '不显示' }}</span>
</div>
<div class="field__foot">
<span :class="['status-pill', { 'is-muted': !reviewNoticeEnabled }]">{{ reviewNoticeEnabled ? '启用' : '停用' }}</span>
<a-button class="field__save" size="small" type="primary" :loading="savingReviewNotice" @click="saveReviewNotice">保存提醒设置</a-button>
</div>
</article>
<article class="field">
<div class="field__head"><span class="field__label">内容审核通过后自动批准</span><span class="tag">WORKBENCH</span></div>
<p class="field__desc">开启后仅在店长申请绑定的门店资料内容审核通过时自动通过;关闭后由管理员人工复核。</p>
<div class="field__control">
<a-switch v-model:checked="managerAutoApproveEnabled" checked-children="自动" un-checked-children="人工" />
<span class="control-note">{{ managerAutoApproveEnabled ? '自动批准' : '人工复核' }}</span>
</div>
<div class="field__foot">
<span :class="['status-pill', { 'is-muted': !managerAutoApproveEnabled }]">{{ managerAutoApproveEnabled ? '自动审核' : '人工审核' }}</span>
<a-button class="field__save" size="small" type="primary" :loading="savingManagerReviewMode" @click="saveManagerReviewMode">保存审核模式</a-button>
</div>
</article>
</div>
<p class="settings-group__footnote">默认密码仍按后台账号接口校验;员工审核入口和数量角标不受登录提醒开关影响。</p>
</div>
</section>
<section id="settings-group-shop" class="settings-group">
<header class="settings-group__head">
<div class="settings-group__head-main">
<div class="settings-group__title"><h2>门店经营</h2><span class="tag">SHOP</span></div>
<p class="settings-group__desc">新门店默认经营有效期,按审核通过当天起算。</p>
</div>
<span class="meta">1 项参数</span>
</header>
<div class="settings-group__body">
<div class="inline-field">
<div class="inline-field__copy">
<strong>新门店默认有效期</strong>
<span>店长注册审核通过当天计为第 1 天;单个门店可在门店管理中单独调整到期日。</span>
</div>
<div class="inline-field__control">
<a-input v-model:value="shopDefaultValidDays" type="number" :min="1" :max="3650" addon-after="天" />
<span class="control-note">1–3650 天</span>
</div>
<div class="inline-field__foot">
<a-button size="small" type="primary" :loading="savingShopValidity" @click="saveShopValidity">保存有效期</a-button>
</div>
</div>
<p class="settings-group__footnote">门店到期只限制新增普通预约,不影响既有预约与历史数据。</p>
</div>
</section>
</div>
<div v-else-if="activeSection === 'services'" class="settings-groups">
<section id="settings-group-probe" class="settings-group">
<header class="settings-group__head">
<div class="settings-group__head-main">
<div class="settings-group__title"><h2>接入诊断</h2><span class="tag">TEST</span></div>
<p class="settings-group__desc">配置保存后再测试;点击状态芯片可展开检查项明细,真实发送会产生外部副作用。</p>
2026-10-26 22:11:03 +08:00
</div>
<div class="settings-group__actions">
<span v-if="probeFailCount" class="pill pill--fail">{{ probeFailCount }} 项失败</span>
<span v-if="probeWarnCount" class="pill pill--warn">{{ probeWarnCount }} 项需关注</span>
<a-button size="small" :loading="refreshingProbeResults" @click="refreshProbeResults">刷新最近结果</a-button>
2026-10-30 17:08:00 +08:00
</div>
</header>
<div class="settings-group__body">
2026-10-30 17:08:00 +08:00
<div class="svc-grid">
<article v-for="card in probeCardsView" :key="card.service" class="svc">
<div class="svc__head">
<span class="svc__name">{{ card.label }}</span>
<span class="svc__desc" :title="card.description">{{ card.description }}</span>
<span :class="['pill', `pill--${card.summary.kind}`]">{{ card.summary.text }}</span>
</div>
<div class="chips">
<button
v-for="operation in card.operations"
:key="operation.code"
type="button"
:class="['chip', `chip--${operation.status.kind}`, { 'is-open': expandedProbe === `${card.service}:${operation.code}` }]"
:aria-expanded="expandedProbe === `${card.service}:${operation.code}`"
@click="toggleProbeDetail(card.service, operation.code)"
>
<span :class="['chip__dot', `chip__dot--${operation.status.kind}`]" />
<span class="chip__label">{{ operation.label }}</span>
<span class="chip__status">{{ operation.status.label }}</span>
<span v-if="operation.result" class="chip__time">{{ formatProbeTime(operation.result.checkedAt) }}</span>
<DownOutlined class="chip__chev" />
</button>
</div>
<div v-if="card.operations.some(operation => expandedProbe === `${card.service}:${operation.code}`)" class="svc__detail">
<template v-for="operation in card.operations" :key="operation.code">
<div v-if="expandedProbe === `${card.service}:${operation.code}`" class="probe-detail">
<div class="probe-detail__head">
<span>{{ card.label }} · {{ operation.label }} · {{ formatProbeTime(operation.result?.checkedAt) }}</span>
<a-button size="small" :loading="testingProbe === `${card.service}:${operation.code}`" @click="runCardOperation(card.service, operation.code)">运行测试</a-button>
</div>
<p class="probe-detail__summary">{{ operation.result?.summary || '尚未测试,运行测试后可查看检查项。' }}</p>
<div v-for="check in operation.result?.checks || []" :key="`${check.name}-${check.status}`" class="check-row">
<span>{{ check.name }}</span>
<em :class="`check-row__status--${check.status.toLowerCase()}`">{{ probeStatusLabel(check.status) }}</em>
<small>{{ check.detail }}</small>
</div>
</div>
</template>
</div>
</article>
2026-10-30 22:04:38 +08:00
</div>
<p class="settings-group__footnote">短信和订阅消息默认只诊断,真实发送会产生外部副作用并要求二次确认;对象存储测试文件会自动清理。微信图片测试提交后显示等待回调,不会把异步结果误报为失败。</p>
2026-10-30 22:04:38 +08:00
</div>
</section>
<section id="settings-group-map" class="settings-group">
<header class="settings-group__head">
<div class="settings-group__head-main">
<div class="settings-group__title"><h2>地图服务</h2><span class="tag">安全接入</span></div>
<p class="settings-group__desc">密钥加密保存,接口不回传密钥;保存后再进行接入诊断。</p>
</div>
<div class="settings-group__actions">
<a-button size="small" type="primary" :loading="savingMap || confirmingMap" @click="saveMapConfig">保存地图设置</a-button>
</div>
</header>
<div class="settings-group__body">
<div class="field-grid cols-2">
<article class="field">
<div class="field__head"><span class="field__label">默认地图渠道</span></div>
<p class="field__desc">店铺选点和后台地图展示使用的默认渠道。</p>
<div class="field__control"><a-select v-model:value="mapProvider" :options="mapProviderOptions" /></div>
<div class="field__foot"><span class="status-pill" :class="{ 'is-muted': !mapEnabled }">{{ mapEnabled ? '启用' : '停用' }}</span></div>
</article>
<article v-for="item in mapKeyRows" :key="item.key" class="field">
<div class="field__head">
<span class="field__label">{{ item.label }}</span>
<a
class="setting-copy__link"
:href="item.url"
target="_blank"
rel="noopener noreferrer"
:aria-label="`前往${item.label}获取页面`"
>
获取 Key
<ExportOutlined />
</a>
</div>
<p class="field__desc">{{ item.description }}</p>
<div class="field__control field__control--password">
<a-input-password v-model:value="mapSecrets[item.key]" :placeholder="mapKeyPlaceholder(item.key, item.placeholder)" autocomplete="new-password" @update:value="clearMapSecrets[item.key] = false" />
<a-button v-if="mapKeyStoredConfigured(item.key)" size="small" type="text" danger @click="toggleMapSecretClear(item.key)">{{ clearMapSecrets[item.key] ? '撤销清除' : '清除' }}</a-button>
</div>
<div class="field__foot">
<span class="status-pill" :class="{ 'is-muted': !mapConfigured(item.key) || clearMapSecrets[item.key] }">{{ clearMapSecrets[item.key] ? '保存后清除' : mapConfigured(item.key) ? '已配置' : '待配置' }}</span>
</div>
</article>
<article class="field">
<div class="field__head"><span class="field__label">地图服务状态</span></div>
<p class="field__desc">停用后店铺地图选点不会调用已保存的渠道。</p>
<div class="field__control"><a-switch v-model:checked="mapEnabled" checked-children="启用" un-checked-children="停用" /></div>
<div class="field__foot"><span :class="['status-pill', { 'is-muted': !mapEnabled }]">{{ mapEnabled ? '启用' : '停用' }}</span></div>
</article>
</div>
<p class="secure-note">密钥以 AES-256-GCM 加密保存在当前环境数据库,设置接口不回传密钥。地图打开时才通过管理员认证接口按当前渠道读取;Web Key 会在浏览器地图 SDK 请求中使用,请在地图开放平台限制可用域名,并为 DEV、SIT、PROD 分别创建 Key。<span v-if="secureStatus && !secureStatus.encryptionKeyConfigured" class="secure-note__warning">服务端加密主密钥尚未配置,需先由部署维护人员设置后才能保存。</span><span v-else-if="secureStatus?.mapLegacyMigrationPending" class="secure-note__warning">检测到旧版地图参数尚未完成加密迁移;主密钥配置后重新打开本页,系统会自动转存并清空旧明文值,请核对各 Key 显示为已配置后再启用地图。</span></p>
</div>
</section>
<section id="settings-group-moderation" class="settings-group">
<header class="settings-group__head">
<div class="settings-group__head-main">
<div class="settings-group__title"><h2>微信内容审核</h2><span class="tag">安全回调</span></div>
<p class="settings-group__desc">回调凭据加密保存,改为完整配置后保存;填写顺序见下方指引。</p>
</div>
<div class="settings-group__actions">
<a-button size="small" type="primary" :loading="savingModeration || confirmingModeration" @click="saveModerationConfig">保存审核设置</a-button>
</div>
</header>
<div class="settings-group__body">
<div class="field-grid cols-2">
<article class="field">
<div class="field__head"><span class="field__label">审核渠道</span></div>
<p class="field__desc">未启用或配置不完整时,内容保持隔离,不会自动放行。</p>
<div class="field__control"><a-select v-model:value="moderationProvider" :options="moderationProviderOptions" /></div>
<div class="field__foot">
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.moderationReady }">{{ secureStatus?.moderationReady ? '已就绪' : '待配置' }}</span>
</div>
</article>
<article class="field">
<div class="field__head"><span class="field__label">小程序凭据</span></div>
<p class="field__desc">服务端需配置当前环境的 AppID 与 AppSecret,用于请求微信审核接口。</p>
<div class="field__control">
<span class="field__value">{{ secureStatus?.wechatMiniAppConfigured ? `${secureStatus.wechatMiniAppId} · AppSecret 已配置` : `${secureStatus?.wechatMiniAppId || 'AppID 未配置'} · AppSecret 待配置` }}</span>
</div>
<div class="field__foot">
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.wechatMiniAppConfigured }">{{ secureStatus?.wechatMiniAppConfigured ? '已就绪' : '待配置' }}</span>
</div>
</article>
<article class="field field--wide">
<div class="field__head"><span class="field__label">微信服务器回调 URL</span></div>
<p class="field__desc">复制到微信公众平台「开发管理 → 开发设置 → 消息推送」的 URL。</p>
<div class="field__control">
<a-input v-model:value="moderationCallbackUrl" :placeholder="defaultCallbackUrl()" />
<a-button @click="copyCallbackUrl"><CopyOutlined />复制</a-button>
</div>
<div class="field__foot">
<span class="status-pill" :class="{ 'is-muted': !isPublicHttpsCallback }">{{ isPublicHttpsCallback ? '公网 HTTPS' : '需填写公网地址' }}</span>
</div>
</article>
<article class="field">
<div class="field__head"><span class="field__label">回调 Token</span></div>
<p class="field__desc">3-32 位英文字母或数字;留空表示不修改已保存值。</p>
<div class="field__control field__control--password">
<a-input-password v-model:value="moderationSecrets.callbackToken" autocomplete="new-password" :placeholder="secureStatus?.moderationCallbackTokenConfigured && !clearModerationSecrets.callbackToken ? '••••••••' : '填写新的 Token,留空保持原值'" @update:value="clearModerationSecrets.callbackToken = false" />
<a-button v-if="secureStatus?.moderationCallbackTokenConfigured" size="small" type="text" danger @click="toggleModerationSecretClear('callbackToken')">{{ clearModerationSecrets.callbackToken ? '撤销清除' : '清除' }}</a-button>
</div>
<div class="field__foot">
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.moderationCallbackTokenConfigured || clearModerationSecrets.callbackToken }">{{ clearModerationSecrets.callbackToken ? '保存后清除' : secureStatus?.moderationCallbackTokenConfigured ? '已配置' : '待配置' }}</span>
</div>
</article>
<article class="field">
<div class="field__head"><span class="field__label">EncodingAESKey</span></div>
<p class="field__desc">微信平台生成的 43 位密钥;消息加密方式必须选择「安全模式」。</p>
<div class="field__control field__control--password">
<a-input-password v-model:value="moderationSecrets.encodingAesKey" autocomplete="new-password" :placeholder="secureStatus?.moderationEncodingAesKeyConfigured && !clearModerationSecrets.encodingAesKey ? '••••••••' : '填写 43 位 EncodingAESKey,留空保持原值'" @update:value="clearModerationSecrets.encodingAesKey = false" />
<a-button v-if="secureStatus?.moderationEncodingAesKeyConfigured" size="small" type="text" danger @click="toggleModerationSecretClear('encodingAesKey')">{{ clearModerationSecrets.encodingAesKey ? '撤销清除' : '清除' }}</a-button>
</div>
<div class="field__foot">
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.moderationEncodingAesKeyConfigured || clearModerationSecrets.encodingAesKey }">{{ clearModerationSecrets.encodingAesKey ? '保存后清除' : secureStatus?.moderationEncodingAesKeyConfigured ? '已配置' : '待配置' }}</span>
</div>
</article>
</div>
<div class="secure-guide">
<strong>微信平台填写指引</strong>
<ol>
<li>先在本页选择「未启用(失败关闭)」,填写 Token、EncodingAESKey 和公网 URL 后保存;再将相同信息填入微信公众平台。</li>
<li>在微信平台选择「安全模式」并完成 URL 验证;确认审核用 AppID 与本页显示的当前环境一致。</li>
<li>URL 验证通过后回到本页将审核渠道切换为「微信内容安全审核」并保存,内容审核才会调用微信接口。</li>
<li>将此环境 Core 的公网出口 IP 加入小程序接口 IP 白名单;图片审核还要求对象存储签名 URL 可由微信公网 HTTPS 访问。</li>
</ol>
<div class="secure-guide__links">
<a href="https://mp.weixin.qq.com/" target="_blank" rel="noopener noreferrer">打开微信公众平台 <ExportOutlined /></a>
<a href="https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/message-push.html" target="_blank" rel="noopener noreferrer">消息推送配置说明 <ExportOutlined /></a>
</div>
<span v-if="!isPublicHttpsCallback" class="secure-note__warning">请输入正式环境的公网 HTTPS 域名,并保留完整回调路径;本地地址、IP 地址或路径不匹配时无法验证。</span>
<span v-else-if="secureStatus && !secureStatus.moderationCallbackReady" class="control-note">回调资料仍不完整,暂时不能进行微信 URL 验证。</span>
<span v-if="secureStatus && !secureStatus.encryptionKeyConfigured" class="secure-note__warning">安全接入加密主密钥尚未配置,Token 与 AESKey 不会保存。</span>
</div>
</div>
</section>
<section id="settings-group-storage" class="settings-group">
<header class="settings-group__head">
<div class="settings-group__head-main">
<div class="settings-group__title"><h2>对象存储读取顺序</h2><span class="tag">FILE</span></div>
<p class="settings-group__desc">头像、作品等资源按此顺序生成签名访问地址并回退可用副本。</p>
</div>
<div class="settings-group__actions">
<a-button size="small" type="primary" :loading="savingStorageReadOrder" @click="saveStorageReadOrder">保存读取顺序</a-button>
</div>
</header>
<div class="settings-group__body">
<div class="storage-row">
<div class="inline-field__copy">
<strong>MinIO、七牛云、阿里云 OSS</strong>
<span>不改变上传首选、三副本要求和副本修复顺序;用上下按钮调整读取优先级。</span>
</div>
<div class="storage-order-list" aria-label="对象存储读取优先级">
<div v-for="(provider, index) in storageReadOrder" :key="provider.code" class="storage-order-item">
<span class="storage-order-index">{{ index + 1 }}</span>
<strong>{{ provider.label }}</strong>
<div class="storage-order-actions">
<a-button size="small" type="text" :disabled="index === 0" :aria-label="`上移${provider.label}`" @click="moveStorageProvider(index, -1)"><ArrowUpOutlined /></a-button>
<a-button size="small" type="text" :disabled="index === storageReadOrder.length - 1" :aria-label="`下移${provider.label}`" @click="moveStorageProvider(index, 1)"><ArrowDownOutlined /></a-button>
</div>
</div>
</div>
<span class="control-note">最多 30 秒同步至其他服务实例</span>
</div>
</div>
</section>
<section id="settings-group-sms" class="settings-group">
<header class="settings-group__head">
<div class="settings-group__head-main">
<div class="settings-group__title"><h2>短信服务</h2><span class="tag">SMS</span></div>
<p class="settings-group__desc">统一控制登录、绑定和找回密码的验证码通道。</p>
</div>
<div class="settings-group__actions">
<a-button size="small" type="primary" :loading="savingSmsProvider" @click="saveSmsProvider">保存短信设置</a-button>
</div>
</header>
<div class="settings-group__body">
<div class="inline-field">
<div class="inline-field__copy">
<strong>短信供应商</strong>
<span>保存后会同步全部短信验证码场景的模板、通道和发送方式。</span>
</div>
<div class="inline-field__control">
<a-select v-model:value="smsProviderForm.configValue" :options="smsProviderOptions" />
</div>
<div class="inline-field__foot">
<span class="warning-note">切换会影响全部验证码</span>
</div>
</div>
</div>
</section>
</div>
<div v-else class="settings-groups">
<section id="settings-group-account-info" class="settings-group">
<header class="settings-group__head">
<div class="settings-group__head-main">
<div class="settings-group__title"><h2>账号信息</h2><span class="tag">ACCOUNT</span></div>
<p class="settings-group__desc">查看后台登录账号与当前会话状态。</p>
</div>
<div class="settings-group__actions">
<span class="pill pill--pass">会话正常</span>
</div>
</header>
<div class="settings-group__body">
<div class="account-grid">
<div class="account-tile">
<span class="account-tile__label">登录账号</span>
<strong>{{ userInfo?.account || '--' }}</strong>
<div class="account-tile__foot"><span class="status-pill">当前账号</span></div>
</div>
<div class="account-tile">
<span class="account-tile__label">显示昵称</span>
<strong>{{ userInfo?.nickname || '未设置昵称' }}</strong>
<div class="account-tile__foot"><span class="control-note">只读</span></div>
</div>
<div class="account-tile">
<span class="account-tile__label">后台会话</span>
<strong>{{ userInfo?.id ? '已登录' : '状态未知' }}</strong>
<div class="account-tile__foot">
<span :class="['status-pill', { 'is-muted': !userInfo?.id }]">{{ userInfo?.id ? '正常' : '待验证' }}</span>
</div>
</div>
</div>
<p class="settings-group__footnote">后台请求使用管理员身份校验,退出登录后当前会话立即失效。</p>
</div>
</section>
</div>
</div>
</main>
2026-11-04 11:16:04 +08:00
<a-modal v-model:open="realProbeOpen" title="确认真实接入测试" :confirm-loading="realProbeLoading" :mask-closable="false" ok-text="确认发送" cancel-text="取消" @ok="submitRealProbe">
2026-11-04 11:16:04 +08:00
<template v-if="realProbeService === 'SMS'">
<p>将向指定手机号发送一条真实测试短信,可能产生费用。</p>
<a-input v-model:value="realProbePhone" placeholder="请输入接收手机号" :maxlength="11" />
<a-checkbox v-model:checked="realProbeConfirmed">我确认发送真实测试短信</a-checkbox>
2026-11-04 11:16:04 +08:00
</template>
<template v-else>
<p>将向当前环境已有微信绑定账号发送一条真实订阅消息,可能消耗订阅额度。</p>
<a-checkbox v-model:checked="realProbeConfirmed">我确认发送真实测试消息</a-checkbox>
</template>
</a-modal>
2026-09-05 23:46:35 +08:00
</div>
</template>
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
2026-11-03 11:09:38 +08:00
import { message, Modal } from 'ant-design-vue'
import { ArrowDownOutlined, ArrowUpOutlined, CopyOutlined, DownOutlined, ExportOutlined } from '@ant-design/icons-vue'
2026-11-04 11:16:04 +08:00
import { adminSecureIntegrationConfigApi, adminSystemParameterConfigApi, type IntegrationProbeResultVO, type SecureIntegrationConfigVO, type SystemParameterConfigVO } from '@/api/admin'
2026-10-30 22:04:38 +08:00
import { ADMIN_API_BASE_URL } from '@/config/api'
import { loadCachedAdminUserInfo } from '@/utils/admin-session'
2026-09-05 23:46:35 +08:00
type SettingsSection = 'runtime' | 'services' | 'account'
type MapKey = 'tencentWeb' | 'amapWeb' | 'amapMini'
const route = useRoute()
const activeSection = ref<SettingsSection>(route.query.section === 'account' ? 'account' : route.query.section === 'services' ? 'services' : 'runtime')
watch(() => route.query.section, section => {
activeSection.value = section === 'account' || section === 'services' ? section : 'runtime'
})
2026-09-05 23:46:35 +08:00
const loading = ref(false)
2026-11-04 11:16:04 +08:00
const testingProbe = ref('')
const refreshingProbeResults = ref(false)
2026-11-04 11:16:04 +08:00
const probeResults = ref<IntegrationProbeResultVO[]>([])
const realProbeOpen = ref(false)
const realProbeLoading = ref(false)
const realProbeService = ref<'SMS' | 'SUBSCRIBE_MESSAGE'>('SMS')
const realProbePhone = ref('')
const realProbeConfirmed = ref(false)
const savingDefaultPassword = ref(false)
const savingReviewNotice = ref(false)
const savingManagerReviewMode = ref(false)
const savingShopValidity = ref(false)
const savingMap = ref(false)
2026-10-30 17:08:00 +08:00
const savingModeration = ref(false)
2026-11-03 11:09:38 +08:00
const confirmingMap = ref(false)
const confirmingModeration = ref(false)
const savingSmsProvider = ref(false)
const savingStorageReadOrder = ref(false)
const storageReadOrder = ref([
{ code: 'MINIO', label: 'MinIO' },
{ code: 'QINIU_KODO', label: '七牛云' },
{ code: 'ALIYUN_OSS', label: '阿里云 OSS' }
])
const defaultPasswordEnabled = ref(true)
const reviewNoticeEnabled = ref(true)
const managerAutoApproveEnabled = ref(false)
const shopDefaultValidDays = ref('30')
const mapEnabled = ref(true)
2026-10-30 17:08:00 +08:00
const mapProvider = ref<'TENCENT' | 'AMAP'>('TENCENT')
const secureStatus = ref<SecureIntegrationConfigVO | null>(null)
const mapSecrets = reactive<Record<MapKey, string>>({ tencentWeb: '', amapWeb: '', amapMini: '' })
const clearMapSecrets = reactive<Record<MapKey, boolean>>({ tencentWeb: false, amapWeb: false, amapMini: false })
const moderationProvider = ref<'DISABLED' | 'MOCK' | 'WECHAT'>('DISABLED')
const moderationCallbackUrl = ref('')
const moderationSecrets = reactive({ callbackToken: '', encodingAesKey: '' })
const clearModerationSecrets = reactive({ callbackToken: false, encodingAesKey: false })
2026-09-06 21:41:09 +08:00
const smsProviderOptions = [
{ label: 'Spug 短信', value: 'SPUG' },
{ label: '阿里云短信认证服务', value: 'ALIYUN_SMS_VERIFY' }
]
const mapProviderOptions = [
{ label: '腾讯地图', value: 'TENCENT' },
{ label: '高德地图', value: 'AMAP' }
]
2026-10-30 17:08:00 +08:00
const moderationProviderOptions = computed(() => [
{ label: '未启用(失败关闭)', value: 'DISABLED' },
...(secureStatus.value?.mockProviderAllowed ? [{ label: '本地模拟审核', value: 'MOCK' as const }] : []),
{ label: '微信内容安全审核', value: 'WECHAT' }
])
2026-10-30 22:04:38 +08:00
const isPublicHttpsCallback = computed(() => {
try {
const url = new URL(moderationCallbackUrl.value)
const host = url.hostname.toLowerCase().replace(/\.$/, '')
const ipLiteral = host.includes(':') || /^\d{1,3}(\.\d{1,3}){3}$/.test(host)
return url.protocol === 'https:'
&& (!url.port || url.port === '443')
&& !url.username
&& !url.password
&& !url.search
&& !url.hash
&& url.pathname === callbackPath
&& !ipLiteral
&& host !== 'localhost'
&& !host.endsWith('.localhost')
&& !host.endsWith('.local')
&& !host.endsWith('.internal')
} catch {
return false
}
})
const sections = [
{ key: 'runtime' as const, label: '运行参数' },
{ key: 'services' as const, label: '服务接入' },
{ key: 'account' as const, label: '当前账号' }
]
2026-11-04 11:16:04 +08:00
const probeCards = [
{ service: 'CONTENT_MODERATION', label: '微信内容审核', description: '检查当前 Provider、凭据和回调;文本使用固定无害内容,图片需等待回调。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'TEXT', label: '文本接口测试' }, { code: 'IMAGE_CALLBACK', label: '图片回调测试' }] },
{ service: 'MAP', label: '地图服务', description: '同时查看 Web/小程序 Key 状态,并可请求固定地址验证当前 Web Key。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'REQUEST', label: '真实请求' }] },
{ service: 'OBJECT_STORAGE', label: '对象存储三副本', description: '逐渠道临时上传、读取并访问签名地址,完成后自动清理。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'ROUND_TRIP', label: '往返测试' }] },
{ service: 'SMS', label: '短信服务', description: '诊断 MessageHub 场景和渠道;真实短信需填写号码并确认。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'SEND', label: '真实发送', real: true }] },
{ service: 'SUBSCRIBE_MESSAGE', label: '微信订阅消息', description: '检查小程序凭据和固定模板;真实消息会消耗订阅额度。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'SEND', label: '真实发送', real: true }] }
2026-11-04 11:16:04 +08:00
]
2026-10-26 22:11:03 +08:00
const mapKeyRows: Array<{ key: MapKey; label: string; description: string; placeholder: string; url: string }> = [
2026-10-30 17:08:00 +08:00
{ key: 'tencentWeb', label: '腾讯 Web Key', description: '用于后台腾讯地图选点。', placeholder: '填写腾讯 Web Key;留空保持原值', url: 'https://lbs.qq.com/dev/console/key/manage' },
{ key: 'amapWeb', label: '高德 Web Key', description: '用于后台高德地图选点。', placeholder: '填写高德 Web Key;留空保持原值', url: 'https://console.amap.com/dev/key/app' },
{ key: 'amapMini', label: '高德小程序 Key', description: '供 Salon 小程序地图能力使用。', placeholder: '填写高德小程序 Key;留空保持原值', url: 'https://console.amap.com/dev/key/app' }
]
const defaultPasswordForm = reactive<SystemParameterConfigVO>({
configGroup: 'USER', configKey: 'DEFAULT_PASSWORD', configName: '后台新增用户默认密码', configValue: '', enabled: 1,
remark: '后台新增用户不填写密码时使用;需满足 8-32 位且至少包含数字、小写字母、大写字母、特殊符号中的 3 类'
})
const reviewNoticeForm = reactive<SystemParameterConfigVO>({
configGroup: 'WORKBENCH', configKey: 'MANAGER_REGISTRATION_REVIEW_NOTICE', configName: '店长员工审核提醒', configValue: 'true', enabled: 1,
remark: '控制店长登录小程序后是否显式提示当前门店的待审核员工申请'
})
const managerReviewModeForm = reactive<SystemParameterConfigVO>({
configGroup: 'WORKBENCH', configKey: 'MANAGER_REGISTRATION_AUTO_APPROVE', configName: '店长注册自动审核', configValue: 'false', enabled: 1,
remark: '开启后仅在店长申请关联的门店资料内容审核通过时自动批准;关闭后由管理员人工复核'
})
const shopValidityForm = reactive<SystemParameterConfigVO>({
configGroup: 'SHOP', configKey: 'SHOP_DEFAULT_VALID_DAYS', configName: '新门店默认有效期天数', configValue: '30', enabled: 1,
remark: '店长注册审核通过后新门店的默认经营有效期天数,范围1-3650'
})
2026-09-06 21:41:09 +08:00
const smsProviderForm = reactive<SystemParameterConfigVO>({
configGroup: 'SMS', configKey: 'SMS_PROVIDER', configName: '短信供应商', configValue: 'SPUG', enabled: 1,
remark: '全局切换短信供应商时同步验证码模板和 MessageHub 通道'
})
const userInfo = ref(loadCachedAdminUserInfo())
2026-10-30 17:08:00 +08:00
const callbackPath = '/api/integration/wechat/content-moderation/callback'
2026-10-30 22:04:38 +08:00
const defaultCallbackUrl = () => {
try {
const apiUrl = new URL(ADMIN_API_BASE_URL, window.location.origin)
return `${apiUrl.origin}${callbackPath}`
} catch {
return `${window.location.origin}${callbackPath}`
}
}
2026-10-30 17:08:00 +08:00
const mapConfigured = (key: MapKey) => {
if (clearMapSecrets[key]) return false
if (mapSecrets[key]) return true
2026-11-03 11:09:38 +08:00
return mapKeyStoredConfigured(key)
}
const mapKeyStoredConfigured = (key: MapKey) => {
2026-10-30 17:08:00 +08:00
if (!secureStatus.value) return false
return key === 'tencentWeb' ? secureStatus.value.tencentWebKeyConfigured
: key === 'amapWeb' ? secureStatus.value.amapWebKeyConfigured
: secureStatus.value.amapMiniKeyConfigured
}
2026-11-03 11:09:38 +08:00
const mapKeyPlaceholder = (key: MapKey, fallback: string) =>
mapKeyStoredConfigured(key) && !clearMapSecrets[key] ? '••••••••' : fallback
const confirmSecureKeyChanges = (title: string, changes: string[]) => new Promise<boolean>(resolve => {
Modal.confirm({
title,
content: `${changes.join(';')}。确认后将立即应用到当前环境。`,
okText: '确认保存',
cancelText: '取消',
onOk: () => resolve(true),
onCancel: () => resolve(false)
})
})
2026-10-30 17:08:00 +08:00
2026-09-05 23:46:35 +08:00
const load = async () => {
loading.value = true
try {
const [userConfigs, smsConfigs, workbenchConfigs, shopConfigs, fileConfigs, secureConfig] = await Promise.all([
2026-09-06 21:41:09 +08:00
adminSystemParameterConfigApi.listConfigs('USER'),
adminSystemParameterConfigApi.listConfigs('SMS'),
adminSystemParameterConfigApi.listConfigs('WORKBENCH'),
adminSystemParameterConfigApi.listConfigs('SHOP'),
adminSystemParameterConfigApi.listConfigs('FILE'),
adminSecureIntegrationConfigApi.getConfig()
2026-09-06 21:41:09 +08:00
])
const defaultPassword = userConfigs.find(item => item.configKey === 'DEFAULT_PASSWORD')
if (defaultPassword) {
Object.assign(defaultPasswordForm, defaultPassword)
defaultPasswordEnabled.value = defaultPassword.enabled === 1
2026-09-05 23:46:35 +08:00
}
2026-09-06 21:41:09 +08:00
const smsProvider = smsConfigs.find(item => item.configKey === 'SMS_PROVIDER')
if (smsProvider) Object.assign(smsProviderForm, smsProvider)
const reviewNotice = workbenchConfigs.find(item => item.configKey === 'MANAGER_REGISTRATION_REVIEW_NOTICE')
if (reviewNotice) {
Object.assign(reviewNoticeForm, reviewNotice)
reviewNoticeEnabled.value = reviewNotice.enabled === 1 && String(reviewNotice.configValue).toLowerCase() === 'true'
}
const managerReviewMode = workbenchConfigs.find(item => item.configKey === 'MANAGER_REGISTRATION_AUTO_APPROVE')
if (managerReviewMode) {
Object.assign(managerReviewModeForm, managerReviewMode)
managerAutoApproveEnabled.value = managerReviewMode.enabled === 1 && String(managerReviewMode.configValue).toLowerCase() === 'true'
}
const shopValidity = shopConfigs.find(item => item.configKey === 'SHOP_DEFAULT_VALID_DAYS')
if (shopValidity) {
Object.assign(shopValidityForm, shopValidity)
shopDefaultValidDays.value = String(shopValidity.configValue || '30')
}
const storageOrder = fileConfigs.find(item => item.configKey === 'IMAGE_READ_PROVIDER_ORDER')
if (storageOrder?.configValue) {
const labels = { MINIO: 'MinIO', QINIU_KODO: '七牛云', ALIYUN_OSS: '阿里云 OSS' } as const
const order = storageOrder.configValue.split(',').map(code => code.trim().toUpperCase())
const providers = order.flatMap(code => code in labels
? [{ code: code as keyof typeof labels, label: labels[code as keyof typeof labels] }]
: [])
if (order.length === 3 && new Set(order).size === 3 && providers.length === 3) {
storageReadOrder.value = providers
}
}
2026-10-30 17:08:00 +08:00
secureStatus.value = secureConfig
probeResults.value = secureConfig.probeResults || []
2026-10-30 17:08:00 +08:00
mapProvider.value = secureConfig.mapProvider === 'AMAP' ? 'AMAP' : 'TENCENT'
mapEnabled.value = Boolean(secureConfig.mapEnabled)
moderationProvider.value = secureConfig.moderationProvider || 'DISABLED'
moderationCallbackUrl.value = secureConfig.moderationCallbackUrl || defaultCallbackUrl()
mapSecrets.tencentWeb = ''
mapSecrets.amapWeb = ''
mapSecrets.amapMini = ''
moderationSecrets.callbackToken = ''
moderationSecrets.encodingAesKey = ''
userInfo.value = loadCachedAdminUserInfo()
2026-09-05 23:46:35 +08:00
} catch (error) {
message.error(error instanceof Error ? error.message : '系统设置加载失败')
2026-09-05 23:46:35 +08:00
} finally {
loading.value = false
}
}
const probeFor = (service: string, operation?: string) => probeResults.value
.filter(item => item.service === service && (!operation || item.operation === operation))
.sort((a, b) => String(b.checkedAt || '').localeCompare(String(a.checkedAt || '')))[0]
2026-11-04 11:16:04 +08:00
const formatProbeTime = (time?: string) => time ? new Date(time).toLocaleString('zh-CN', { hour12: false }) : '暂无时间'
const probeStatusLabel = (status?: string) => ({ PASS: '通过', WARN: '需关注', FAIL: '失败', PENDING: '等待回调' } as Record<string, string>)[status || ''] || '未知'
const probeStatusKind = (status?: string) => ({ PASS: 'pass', WARN: 'warn', FAIL: 'fail', PENDING: 'pending' } as Record<string, string>)[status || ''] || 'idle'
const probeCardsView = computed(() => probeCards.map(card => {
const operations = card.operations.map(operation => {
const result = probeFor(card.service, operation.code)
return { ...operation, result, status: { kind: probeStatusKind(result?.status), label: probeStatusLabel(result?.status) } }
})
let pass = 0, warn = 0, fail = 0, pending = 0, idle = 0
operations.forEach(operation => {
if (operation.status.kind === 'pass') pass += 1
else if (operation.status.kind === 'warn') warn += 1
else if (operation.status.kind === 'fail') fail += 1
else if (operation.status.kind === 'pending') pending += 1
else idle += 1
})
const parts = [pass ? `${pass} 通过` : '', warn ? `${warn} 需关注` : '', fail ? `${fail} 失败` : '', pending ? `${pending} 等待回调` : '', idle ? `${idle} 未测试` : ''].filter(Boolean)
return { ...card, operations, summary: { kind: fail ? 'fail' : warn ? 'warn' : pass ? 'pass' : 'idle', text: parts.join(' · ') } }
}))
const probeFailCount = computed(() => probeCardsView.value.reduce((total, card) => total + card.operations.filter(operation => operation.status.kind === 'fail').length, 0))
const probeWarnCount = computed(() => probeCardsView.value.reduce((total, card) => total + card.operations.filter(operation => operation.status.kind === 'warn').length, 0))
const expandedProbe = ref('')
const toggleProbeDetail = (service: string, operation: string) => {
const key = `${service}:${operation}`
expandedProbe.value = expandedProbe.value === key ? '' : key
}
const activeGroup = ref('')
const groupNavItems = computed<Array<{ id: string; label: string; badge?: string }>>(() => {
if (activeSection.value === 'runtime') {
return [{ id: 'settings-group-account', label: '账号与登录' }, { id: 'settings-group-shop', label: '门店经营' }]
}
if (activeSection.value === 'services') {
return [
{ id: 'settings-group-probe', label: '接入诊断', badge: String(probeCards.length) },
{ id: 'settings-group-map', label: '地图服务' },
{ id: 'settings-group-moderation', label: '微信内容审核' },
{ id: 'settings-group-storage', label: '对象存储读取顺序' },
{ id: 'settings-group-sms', label: '短信服务' }
]
}
return [{ id: 'settings-group-account-info', label: '账号信息' }]
})
const syncActiveGroup = () => {
const items = groupNavItems.value
if (!items.length) {
activeGroup.value = ''
return
}
let current = items[0]?.id || ''
items.forEach(item => {
const element = document.getElementById(item.id)
if (element && element.getBoundingClientRect().top <= 120) current = item.id
})
activeGroup.value = current
}
const scrollToGroup = (id: string) => {
const element = document.getElementById(id)
if (!element) return
window.scrollTo({ top: element.getBoundingClientRect().top + window.scrollY - 16, behavior: 'smooth' })
activeGroup.value = id
}
let scrollFrame = 0
const handleWindowScroll = () => {
if (scrollFrame) return
scrollFrame = window.requestAnimationFrame(() => {
scrollFrame = 0
syncActiveGroup()
})
}
2026-11-04 11:16:04 +08:00
const runProbe = async (service: string, operation: string) => {
const key = `${service}:${operation}`
testingProbe.value = key
try {
const result = await adminSecureIntegrationConfigApi.probe({ service, operation, mode: 'DIAGNOSTIC' })
probeResults.value = [...probeResults.value.filter(item => !(item.service === result.service && item.operation === result.operation)), result]
message[result.status === 'PASS' ? 'success' : result.status === 'WARN' ? 'warning' : 'error'](result.summary)
} catch (error) { message.error(error instanceof Error ? error.message : '接入测试失败') }
finally { testingProbe.value = '' }
}
const refreshProbeResults = async () => {
refreshingProbeResults.value = true
try {
const config = await adminSecureIntegrationConfigApi.getConfig()
secureStatus.value = config
probeResults.value = config.probeResults || []
message.success('最近接入测试结果已更新')
} catch (error) { message.error(error instanceof Error ? error.message : '刷新接入测试结果失败') }
finally { refreshingProbeResults.value = false }
}
const runCardOperation = (service: string, operation: string) => {
if (operation === 'IMAGE_CALLBACK') return confirmImageProbe()
if (operation === 'SEND') return openRealProbe(service as 'SMS' | 'SUBSCRIBE_MESSAGE')
return runProbe(service, operation)
}
const confirmImageProbe = () => {
Modal.confirm({
title: '确认进行图片回调测试?',
content: '将上传一张临时安全图片并提交微信异步审核,测试文件会自动清理;结果需要等待微信回调。',
okText: '提交测试',
cancelText: '取消',
onOk: () => runProbe('CONTENT_MODERATION', 'IMAGE_CALLBACK')
})
}
2026-11-04 11:16:04 +08:00
const openRealProbe = (service: 'SMS' | 'SUBSCRIBE_MESSAGE') => {
realProbeService.value = service
realProbePhone.value = ''
realProbeConfirmed.value = false
realProbeOpen.value = true
}
const submitRealProbe = async () => {
if (realProbeService.value === 'SMS' && !/^1[3-9]\d{9}$/.test(realProbePhone.value.trim())) { message.warning('请输入有效的接收手机号'); return }
if (!realProbeConfirmed.value) { message.warning('请先确认发送真实测试消息'); return }
2026-11-04 11:16:04 +08:00
realProbeLoading.value = true
try {
const result = await adminSecureIntegrationConfigApi.probe({
service: realProbeService.value,
operation: 'SEND',
mode: 'REAL',
targetPhone: realProbeService.value === 'SMS' ? realProbePhone.value.trim() : undefined,
confirmed: true
})
probeResults.value = [...probeResults.value.filter(item => !(item.service === result.service && item.operation === result.operation)), result]
message[result.status === 'PASS' ? 'success' : result.status === 'WARN' ? 'warning' : 'error'](result.summary)
realProbeOpen.value = false
} catch (error) { message.error(error instanceof Error ? error.message : '真实接入测试失败') }
finally { realProbeLoading.value = false }
}
const validateDefaultPassword = () => {
const password = defaultPasswordForm.configValue.trim()
if (password.length < 8 || password.length > 32) {
message.warning('默认密码长度需为 8-32 位')
return false
}
const categoryCount = [/[0-9]/.test(password), /[a-z]/.test(password), /[A-Z]/.test(password), /[^A-Za-z0-9]/.test(password)].filter(Boolean).length
if (categoryCount < 3) {
message.warning('默认密码需至少包含数字、小写字母、大写字母、特殊符号中的 3 类')
return false
}
return true
}
const saveDefaultPassword = async () => {
if (!validateDefaultPassword()) return
savingDefaultPassword.value = true
try {
await adminSystemParameterConfigApi.saveConfig({ ...defaultPasswordForm, configValue: defaultPasswordForm.configValue.trim(), enabled: defaultPasswordEnabled.value ? 1 : 0 })
message.success('账号默认密码已保存')
} catch (error) {
message.error(error instanceof Error ? error.message : '默认密码保存失败')
} finally {
savingDefaultPassword.value = false
}
}
const saveReviewNotice = async () => {
savingReviewNotice.value = true
try {
await adminSystemParameterConfigApi.saveConfig({ ...reviewNoticeForm, configValue: 'true', enabled: reviewNoticeEnabled.value ? 1 : 0 })
message.success(reviewNoticeEnabled.value ? '店长员工审核提醒已开启' : '店长员工审核提醒已关闭')
} catch (error) {
message.error(error instanceof Error ? error.message : '审核提醒设置保存失败')
} finally {
savingReviewNotice.value = false
}
}
const saveManagerReviewMode = async () => {
savingManagerReviewMode.value = true
try {
await adminSystemParameterConfigApi.saveConfig({
...managerReviewModeForm,
configValue: managerAutoApproveEnabled.value ? 'true' : 'false',
enabled: 1
})
message.success(managerAutoApproveEnabled.value ? '店长注册自动审核已开启' : '店长注册将由管理员人工复核')
} catch (error) {
message.error(error instanceof Error ? error.message : '审核模式保存失败')
} finally {
savingManagerReviewMode.value = false
}
}
const saveShopValidity = async () => {
const days = Number(shopDefaultValidDays.value)
if (!Number.isInteger(days) || days < 1 || days > 3650) {
message.warning('有效期请填写 1–3650 的整数天数')
return
}
savingShopValidity.value = true
try {
await adminSystemParameterConfigApi.saveConfig({ ...shopValidityForm, configValue: String(days), enabled: 1 })
message.success('新门店默认有效期已保存')
} catch (error) {
message.error(error instanceof Error ? error.message : '有效期设置保存失败')
} finally {
savingShopValidity.value = false
}
}
const saveMapConfig = async () => {
2026-10-30 22:04:38 +08:00
const activeSecretClear = mapProvider.value === 'AMAP' ? clearMapSecrets.amapWeb : clearMapSecrets.tencentWeb
if (mapEnabled.value && activeSecretClear) {
message.warning('当前默认渠道的 Key 已标记清除,请同时停用地图服务后再保存')
return
}
2026-11-03 11:09:38 +08:00
const secretChanges = mapKeyRows.flatMap(item => {
if (clearMapSecrets[item.key]) return [`${item.label}将被清除`]
if (!mapSecrets[item.key].trim()) return []
return [`${item.label}将${mapKeyStoredConfigured(item.key) ? '替换当前配置' : '保存新配置'}`]
})
if (secretChanges.length) {
confirmingMap.value = true
let confirmed = false
try {
confirmed = await confirmSecureKeyChanges('确认保存地图 Key', secretChanges)
} finally {
confirmingMap.value = false
}
if (!confirmed) return
}
savingMap.value = true
try {
2026-10-30 17:08:00 +08:00
const result = await adminSecureIntegrationConfigApi.saveMapConfig({
mapProvider: mapProvider.value,
mapEnabled: mapEnabled.value,
tencentWebKey: mapSecrets.tencentWeb,
amapWebKey: mapSecrets.amapWeb,
amapMiniKey: mapSecrets.amapMini,
clearTencentWebKey: clearMapSecrets.tencentWeb,
clearAmapWebKey: clearMapSecrets.amapWeb,
clearAmapMiniKey: clearMapSecrets.amapMini
})
secureStatus.value = result
Object.keys(mapSecrets).forEach(key => { mapSecrets[key as MapKey] = '' })
Object.keys(clearMapSecrets).forEach(key => { clearMapSecrets[key as MapKey] = false })
message.success('地图密钥已加密保存')
} catch (error) {
2026-10-30 17:08:00 +08:00
message.error(error instanceof Error ? error.message : '安全地图配置保存失败')
} finally {
savingMap.value = false
}
}
2026-10-30 17:08:00 +08:00
const saveModerationConfig = async () => {
if (moderationProvider.value === 'WECHAT') {
if (!isPublicHttpsCallback.value) {
message.warning('微信审核回调必须使用公网可访问的 HTTPS 地址')
return
}
const hasToken = secureStatus.value?.moderationCallbackTokenConfigured && !clearModerationSecrets.callbackToken
const hasAesKey = secureStatus.value?.moderationEncodingAesKeyConfigured && !clearModerationSecrets.encodingAesKey
if ((!hasToken && !moderationSecrets.callbackToken) || (!hasAesKey && !moderationSecrets.encodingAesKey)) {
message.warning('启用微信审核前,请填写回调 Token 和 EncodingAESKey')
return
}
}
2026-10-30 22:04:38 +08:00
if (moderationSecrets.callbackToken && !/^[A-Za-z0-9]{3,32}$/.test(moderationSecrets.callbackToken)) {
message.warning('回调 Token 需要为 3-32 位英文字母或数字')
return
}
if (moderationSecrets.encodingAesKey && !/^[A-Za-z0-9+/]{43}$/.test(moderationSecrets.encodingAesKey)) {
message.warning('EncodingAESKey 需要为 43 位字符')
return
}
2026-11-03 11:09:38 +08:00
const moderationSecretChanges = [
clearModerationSecrets.callbackToken ? '回调 Token 将被清除' : moderationSecrets.callbackToken.trim() ? `回调 Token 将${secureStatus.value?.moderationCallbackTokenConfigured ? '替换当前配置' : '保存新配置'}` : '',
clearModerationSecrets.encodingAesKey ? 'EncodingAESKey 将被清除' : moderationSecrets.encodingAesKey.trim() ? `EncodingAESKey 将${secureStatus.value?.moderationEncodingAesKeyConfigured ? '替换当前配置' : '保存新配置'}` : ''
].filter(Boolean)
if (moderationSecretChanges.length) {
confirmingModeration.value = true
let confirmed = false
try {
confirmed = await confirmSecureKeyChanges('确认保存微信审核密钥', moderationSecretChanges)
} finally {
confirmingModeration.value = false
}
if (!confirmed) return
}
2026-10-30 17:08:00 +08:00
savingModeration.value = true
try {
secureStatus.value = await adminSecureIntegrationConfigApi.saveModerationConfig({
moderationProvider: moderationProvider.value,
moderationCallbackUrl: moderationCallbackUrl.value,
moderationCallbackToken: moderationSecrets.callbackToken,
moderationEncodingAesKey: moderationSecrets.encodingAesKey,
clearModerationCallbackToken: clearModerationSecrets.callbackToken,
clearModerationEncodingAesKey: clearModerationSecrets.encodingAesKey
})
moderationSecrets.callbackToken = ''
moderationSecrets.encodingAesKey = ''
clearModerationSecrets.callbackToken = false
clearModerationSecrets.encodingAesKey = false
message.success('内容审核接入设置已保存')
} catch (error) {
message.error(error instanceof Error ? error.message : '内容审核设置保存失败')
} finally {
savingModeration.value = false
}
}
const toggleMapSecretClear = (key: MapKey) => { clearMapSecrets[key] = !clearMapSecrets[key] }
const toggleModerationSecretClear = (key: 'callbackToken' | 'encodingAesKey') => { clearModerationSecrets[key] = !clearModerationSecrets[key] }
const copyCallbackUrl = async () => {
try {
await navigator.clipboard.writeText(moderationCallbackUrl.value)
message.success('回调 URL 已复制')
} catch {
message.error('复制失败,请手动选择并复制回调 URL')
}
}
2026-09-06 21:41:09 +08:00
const saveSmsProvider = async () => {
const confirmed = window.confirm('保存后会同步全部短信验证码场景的模板、通道和发送方式,确认切换吗?')
if (!confirmed) return
savingSmsProvider.value = true
try {
await adminSystemParameterConfigApi.saveConfig({ ...smsProviderForm, configValue: smsProviderForm.configValue.toUpperCase(), enabled: 1 })
message.success('短信供应商已切换')
} catch (error) {
message.error(error instanceof Error ? error.message : '短信供应商保存失败')
2026-09-06 21:41:09 +08:00
} finally {
savingSmsProvider.value = false
}
}
const moveStorageProvider = (index: number, offset: number) => {
const targetIndex = index + offset
if (targetIndex < 0 || targetIndex >= storageReadOrder.value.length) return
const next = [...storageReadOrder.value]
const currentProvider = next[index]
const targetProvider = next[targetIndex]
if (!currentProvider || !targetProvider) return
next[index] = targetProvider
next[targetIndex] = currentProvider
storageReadOrder.value = next
}
const saveStorageReadOrder = async () => {
savingStorageReadOrder.value = true
try {
await adminSystemParameterConfigApi.saveConfig({
configGroup: 'FILE',
configKey: 'IMAGE_READ_PROVIDER_ORDER',
configName: '对象存储图片读取优先级',
configValue: storageReadOrder.value.map(provider => provider.code).join(','),
enabled: 1,
remark: '仅作用于签名访问 URL 生成和可用副本回退;不影响上传和副本修复顺序'
})
message.success('图片读取顺序已保存,其他服务实例将在 30 秒内同步')
} catch (error) {
message.error(error instanceof Error ? error.message : '图片读取顺序保存失败')
} finally {
savingStorageReadOrder.value = false
}
}
2026-09-05 23:46:35 +08:00
onMounted(() => {
void load().then(() => nextTick(syncActiveGroup))
nextTick(syncActiveGroup)
window.addEventListener('scroll', handleWindowScroll, { passive: true })
window.addEventListener('resize', syncActiveGroup)
})
onBeforeUnmount(() => {
window.removeEventListener('scroll', handleWindowScroll)
window.removeEventListener('resize', syncActiveGroup)
})
watch(activeSection, () => {
nextTick(() => {
activeGroup.value = groupNavItems.value[0]?.id || ''
syncActiveGroup()
})
2026-09-05 23:46:35 +08:00
})
</script>
<style scoped>
.system-settings { display: grid; gap: 14px; color: var(--admin-mobile-ink); }
.settings-topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 10px; border-bottom: 1px solid var(--admin-mobile-border); }
.settings-tabs { display: flex; align-items: center; gap: 26px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tab { position: relative; padding: 8px 1px 9px; border: 0; background: none; color: var(--admin-mobile-muted); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.settings-tab:hover { color: var(--theme-primary-action); }
.settings-tab.is-active { color: var(--admin-mobile-ink); font-weight: 600; }
.settings-tab.is-active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -11px; height: 2px; border-radius: 2px; background: var(--theme-primary); }
.settings-health { display: inline-flex; align-items: center; gap: 7px; color: var(--admin-mobile-muted); font-size: 12px; white-space: nowrap; }
.settings-health i { width: 7px; height: 7px; border-radius: 50%; background: var(--theme-primary); }
.settings-body { display: grid; grid-template-columns: 194px minmax(0, 1fr); gap: 18px; align-items: start; }
.settings-subnav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; padding: 8px; border: 1px solid var(--admin-mobile-border); border-radius: 12px; background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent); }
.settings-subnav__label { padding: 6px 8px 8px; color: var(--admin-mobile-muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.settings-subnav__item { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; padding: 7px 9px; border: 0; border-radius: 7px; background: none; color: var(--admin-mobile-muted); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.settings-subnav__item:hover { background: color-mix(in srgb, var(--theme-primary) 6%, transparent); color: var(--theme-primary-action); }
.settings-subnav__item.is-active { background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-weight: 700; }
.settings-subnav__item em { flex: none; min-width: 18px; height: 18px; padding: 0 5px; border: 1px solid var(--admin-mobile-border); border-radius: 9px; background: var(--theme-card-bg); color: var(--admin-mobile-muted); font-size: 10px; font-style: normal; line-height: 16px; text-align: center; }
.settings-content { min-width: 0; }
.settings-groups { display: flex; flex-direction: column; gap: 14px; }
.settings-group { min-width: 0; scroll-margin-top: 16px; border: 1px solid var(--admin-mobile-border); border-radius: 14px; background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent); box-shadow: 0 1px 2px rgba(23, 33, 31, .03); }
.settings-group__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 15px 18px 12px; border-bottom: 1px solid var(--admin-mobile-border); }
.settings-group__head-main { min-width: 0; }
.settings-group__title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.settings-group__title h2 { margin: 0; font-size: 15px; font-weight: 600; }
.settings-group__desc { margin: 4px 0 0; color: var(--admin-mobile-muted); font-size: 11.5px; line-height: 1.55; }
.settings-group__actions { display: flex; flex: none; flex-wrap: wrap; align-items: center; gap: 8px; }
.settings-group__body { padding: 15px 18px 17px; }
.settings-group__footnote { margin: 12px 0 0; color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.65; }
.tag { flex: none; padding: 1px 6px; border: 1px solid var(--admin-mobile-border); border-radius: 5px; background: color-mix(in srgb, var(--theme-primary) 5%, var(--theme-card-bg)); color: var(--admin-mobile-muted); font-size: 10px; font-weight: 600; letter-spacing: .08em; }
.meta { flex: none; color: var(--admin-mobile-muted); font-size: 11px; white-space: nowrap; }
.field-grid { display: grid; gap: 12px; }
.field-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; min-width: 0; padding: 12px 14px 11px; border: 1px solid var(--admin-mobile-border); border-radius: 10px; background: color-mix(in srgb, var(--theme-primary) 2%, var(--theme-card-bg)); }
.field--wide { grid-column: span 2; }
.field__head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.field__label { font-size: 13px; font-weight: 600; }
.field__desc { min-height: 32px; margin: 3px 0 10px; color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.5; overflow: hidden; }
.field__control { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; margin-top: auto; }
.field__control :deep(.ant-select) { width: 100%; }
.field__control--password > :deep(.ant-input-affix-wrapper) { flex: 1; width: auto; min-width: 100px; }
.field__value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--admin-mobile-ink); font-size: 13px; font-weight: 650; }
.field__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; padding-top: 9px; border-top: 1px dashed color-mix(in srgb, var(--admin-mobile-border) 80%, transparent); }
.field__save { margin-left: auto; }
.inline-field { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(220px, .85fr) auto; gap: 16px; align-items: center; }
.inline-field__copy { display: grid; gap: 3px; min-width: 0; }
.inline-field__copy strong { font-size: 13px; }
.inline-field__copy span { color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.5; }
.inline-field__control { display: flex; align-items: center; gap: 8px; min-width: 0; }
.inline-field__control :deep(.ant-select) { width: 100%; }
.inline-field__control > :deep(.ant-input-group-wrapper) { width: min(240px, 100%); }
.inline-field__foot { display: flex; align-items: center; gap: 8px; }
.setting-copy__link { display: inline-flex; align-items: center; gap: 3px; color: var(--theme-primary-action); font-size: 11px; font-weight: 650; text-decoration: none; white-space: nowrap; }
2026-10-26 22:11:03 +08:00
.setting-copy__link:hover { text-decoration: underline; }
.setting-copy__link:focus-visible { outline: 2px solid color-mix(in srgb, var(--theme-primary) 55%, transparent); outline-offset: 2px; border-radius: 3px; }
.setting-copy__link :deep(.anticon) { font-size: 10px; }
.control-note { color: var(--admin-mobile-muted); font-size: 11px; white-space: nowrap; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; color: var(--theme-primary-action); font-size: 11px; white-space: nowrap; }
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--theme-primary); }
.status-pill.is-muted { color: var(--admin-mobile-muted); }
.status-pill.is-muted::before { background: var(--admin-mobile-muted); }
.warning-note { display: inline-flex; align-items: center; gap: 5px; color: #a66d22; font-size: 11px; white-space: nowrap; }
.warning-note::before { content: '!'; display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: #fff3d9; font-size: 10px; font-weight: 800; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; background: color-mix(in srgb, var(--admin-mobile-muted) 8%, var(--theme-card-bg)); color: var(--admin-mobile-muted); font-size: 11px; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--pass { background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); }
.pill--warn, .pill--pending { background: #FFF7E6; color: #AD6800; }
.pill--fail { background: #FFF1F0; color: var(--ant-color-error); }
.pill--idle { background: color-mix(in srgb, var(--admin-mobile-muted) 8%, var(--theme-card-bg)); color: var(--admin-mobile-muted); }
.svc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.svc { display: flex; flex-direction: column; gap: 9px; min-width: 0; padding: 12px 14px; border: 1px solid var(--admin-mobile-border); border-radius: 10px; background: color-mix(in srgb, var(--theme-primary) 2%, var(--theme-card-bg)); }
.svc__head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.svc__name { flex: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.svc__desc { flex: 1 1 auto; min-width: 0; color: var(--admin-mobile-muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 29px; padding: 0 8px; border: 1px solid var(--admin-mobile-border); border-radius: 8px; background: var(--theme-card-bg); color: var(--admin-mobile-ink); font: inherit; font-size: 11px; cursor: pointer; transition: border-color .15s, background .15s; }
.chip:hover { border-color: color-mix(in srgb, var(--theme-primary) 40%, var(--admin-mobile-border)); background: color-mix(in srgb, var(--theme-primary) 4%, var(--theme-card-bg)); }
.chip.is-open { border-color: var(--theme-primary); background: var(--admin-mobile-accent-soft); }
.chip__dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #A9B4AE; }
.chip__dot--pass { background: var(--theme-primary); }
.chip__dot--warn, .chip__dot--pending { background: #D48806; }
.chip__dot--fail { background: var(--ant-color-error); }
.chip__dot--idle { background: #B7C1BC; }
.chip__status { font-weight: 600; }
.chip--pass .chip__status { color: var(--theme-primary-action); }
.chip--warn .chip__status, .chip--pending .chip__status { color: #AD6800; }
.chip--fail .chip__status { color: var(--ant-color-error); }
.chip--idle .chip__status { color: var(--admin-mobile-muted); font-weight: 500; }
.chip__time { color: var(--admin-mobile-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chip__chev { display: inline-flex; color: #9AA7A1; transition: transform .15s; }
.chip.is-open .chip__chev { transform: rotate(180deg); color: var(--theme-primary-action); }
.svc__detail { padding: 8px 10px 9px; border: 1px solid var(--admin-mobile-border); border-radius: 8px; background: color-mix(in srgb, var(--theme-primary) 3%, var(--theme-card-bg)); }
.probe-detail + .probe-detail { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--admin-mobile-border); }
.probe-detail__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--admin-mobile-muted); font-size: 10.5px; }
.probe-detail__summary { margin: 4px 0 0; color: var(--admin-mobile-muted); font-size: 11px; }
.check-row { display: grid; grid-template-columns: minmax(88px, 132px) 56px minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 5px 0; border-top: 1px dashed color-mix(in srgb, var(--admin-mobile-border) 80%, transparent); font-size: 11px; }
.check-row:first-of-type, .probe-detail__summary + .check-row { border-top: 0; }
.check-row em { font-style: normal; font-weight: 600; }
.check-row small { min-width: 0; color: var(--admin-mobile-muted); overflow-wrap: anywhere; }
.check-row__status--pass { color: var(--theme-primary-action); }
.check-row__status--warn, .check-row__status--pending { color: #AD6800; }
.check-row__status--fail { color: var(--ant-color-error); }
.secure-note { margin: 0; padding: 12px 14px; color: var(--admin-mobile-muted); font-size: 12px; line-height: 1.65; background: color-mix(in srgb, var(--theme-primary) 7%, var(--theme-card-bg)); border-radius: 8px; }
2026-10-30 17:08:00 +08:00
.secure-note__warning { display: block; margin-top: 6px; color: #8a4b0d; font-weight: 650; }
.secure-guide { margin: 14px 0 0; padding: 14px 16px; border-radius: 8px; background: color-mix(in srgb, var(--admin-mobile-accent-soft) 55%, var(--theme-card-bg)); color: var(--admin-mobile-ink); font-size: 12px; line-height: 1.65; }
2026-10-30 17:08:00 +08:00
.secure-guide > strong { font-size: 13px; }
.secure-guide ol { margin: 8px 0 10px; padding-left: 19px; color: var(--admin-mobile-muted); }
.secure-guide li + li { margin-top: 4px; }
.secure-guide__links { display: flex; flex-wrap: wrap; gap: 14px; }
.secure-guide__links a { display: inline-flex; align-items: center; gap: 5px; color: var(--theme-primary-action); text-decoration: none; }
.secure-guide__links a:hover { text-decoration: underline; }
.secure-guide__links a:focus-visible { outline: 2px solid color-mix(in srgb, var(--theme-primary) 55%, transparent); outline-offset: 2px; }
.storage-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 1.1fr) auto; gap: 18px; align-items: center; }
.storage-order-list { display: grid; gap: 5px; min-width: 0; }
.storage-order-item { display: flex; align-items: center; gap: 9px; min-height: 34px; padding: 3px 7px; border: 1px solid var(--admin-mobile-border); border-radius: 7px; background: var(--theme-card-bg); }
.storage-order-index { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; border-radius: 50%; background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-size: 11px; font-weight: 750; }
.storage-order-item strong { flex: 1; color: var(--admin-mobile-ink); font-size: 12px; }
.storage-order-actions { display: flex; }
.storage-order-actions :deep(.ant-btn) { width: 26px; height: 26px; padding: 0; }
.account-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.account-tile { display: flex; flex-direction: column; gap: 7px; min-width: 0; padding: 13px 15px; border: 1px solid var(--admin-mobile-border); border-radius: 10px; background: color-mix(in srgb, var(--theme-primary) 2%, var(--theme-card-bg)); }
.account-tile__label { color: var(--admin-mobile-muted); font-size: 11px; }
.account-tile strong { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-tile__foot { display: flex; align-items: center; gap: 8px; }
@media (max-width: 1280px) {
.field-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field--wide { grid-column: auto; }
}
@media (max-width: 1180px) {
.settings-body { grid-template-columns: 1fr; gap: 12px; }
.settings-subnav { position: static; flex-direction: row; align-items: center; gap: 4px; padding: 7px; overflow-x: auto; scrollbar-width: none; }
.settings-subnav::-webkit-scrollbar { display: none; }
.settings-subnav__label { display: none; }
.settings-subnav__item { width: auto; flex: none; min-height: 30px; padding: 5px 10px; white-space: nowrap; }
}
@media (max-width: 960px) {
.field-grid.cols-2, .field-grid.cols-3 { grid-template-columns: 1fr; }
.field__desc { min-height: 0; }
.svc-grid { grid-template-columns: 1fr; }
.inline-field { grid-template-columns: 1fr; gap: 10px; }
.inline-field__foot { justify-self: start; }
.storage-row { grid-template-columns: 1fr; gap: 10px; }
.account-grid { grid-template-columns: 1fr; }
.account-tile strong { font-size: 15px; }
.check-row { grid-template-columns: 1fr auto; }
.check-row small { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
.settings-health { display: none; }
.settings-tabs { gap: 18px; }
.settings-tab { font-size: 13px; }
.settings-group__head { flex-wrap: wrap; padding: 13px 14px 11px; }
.settings-group__actions { width: 100%; justify-content: flex-end; }
.settings-group__body { padding: 13px 14px 15px; }
.svc__desc { white-space: normal; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.field__save { margin-left: 0; }
2026-09-05 23:46:35 +08:00
}
</style>