feat(salon): 支持散客预约拨号并发布协议新版本强制重新同意
自动发布开发环境 Nacos 配置 / publish (push) Successful in 23s

This commit is contained in:
2026-11-04 23:38:42 +08:00
parent 114a8a423c
commit 88589e2575
22 changed files with 602 additions and 44 deletions
@@ -70,6 +70,25 @@
</a-button>
</div>
</a-drawer>
<a-modal
v-model:open="agreementModalOpen"
title="用户协议与隐私政策已更新"
:closable="false"
:maskClosable="false"
:keyboard="false"
:footer="null"
>
<div class="agreement-gate">
<p>新版本{{ agreementVersionText ? `(${agreementVersionText})` : '' }}已发布,请阅读并同意后继续使用后台。</p>
<p class="agreement-gate__links">
<a href="/legal/user-terms.html" target="_blank" rel="noopener">查看用户协议</a>
<span> · </span>
<a href="/legal/privacy-policy.html" target="_blank" rel="noopener">查看隐私政策</a>
</p>
<a-button type="primary" block :loading="agreementAccepting" @click="acceptAgreements">同意并继续</a-button>
</div>
</a-modal>
</div>
</template>
@@ -84,6 +103,8 @@ import { DEFAULT_AVATAR } from '@/constants'
import { completeAdminLogout } from '@/utils/admin-logout'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { useAdminViewport } from '@/composables/useAdminViewport'
import { legalAgreementApi, type AgreementPending } from '@/api/auth'
import { setAgreementPending } from '@/utils/agreement-gate'
const router = useRouter()
const route = useRoute()
@@ -92,6 +113,9 @@ const collapsed = ref(false)
const mobileDrawerOpen = ref(false)
const selectedKeys = ref<string[]>([route.path])
const userInfo = ref<any>(null)
const agreementModalOpen = ref(false)
const agreementAccepting = ref(false)
const agreementVersionText = ref('')
const iconMap: Record<AdminNavIconKey, Component> = { home: HomeOutlined, user: UserOutlined, shop: HomeOutlined, security: SafetyCertificateOutlined, tool: ToolOutlined, team: TeamOutlined, dashboard: HomeOutlined, gift: HomeOutlined, message: HomeOutlined, tag: HomeOutlined, shopping: HomeOutlined, calendar: HomeOutlined }
const menuItems = adminNavigationItems.map(item => ({ key: item.path, label: item.label, icon: iconMap[item.iconKey] }))
@@ -99,9 +123,43 @@ const handleMenuClick = ({ key }: { key: string | number }) => router.push(Strin
const openMobileMenu = ({ key }: { key: string | number }) => { mobileDrawerOpen.value = false; router.push(String(key)) }
const handleLogout = () => Modal.confirm({ title: '确认退出登录', content: '退出后需要重新登录后台。', okText: '确认', cancelText: '取消', onOk: async () => { await runWithGlobalLoading(() => completeAdminLogout(router)); message.success('已退出登录') } })
const checkAgreementGate = async () => {
try {
const result = await legalAgreementApi.getPending() as unknown as AgreementPending
if (result?.pending) {
agreementVersionText.value = result.currentVersions?.USER_TERMS || ''
setAgreementPending(true)
agreementModalOpen.value = true
} else {
setAgreementPending(false)
}
} catch (error) {
// 查询失败不阻塞后台使用,协议接口仍由服务端登录态校验保护
}
}
const acceptAgreements = async () => {
if (agreementAccepting.value) return
agreementAccepting.value = true
try {
const result = await legalAgreementApi.accept('WEB') as unknown as AgreementPending
if (result?.pending === true) {
throw new Error('协议同意状态未更新,请稍后重试')
}
setAgreementPending(false)
agreementModalOpen.value = false
message.success('已同意最新版协议')
} catch (error: any) {
message.error(error?.message || '同意协议失败')
} finally {
agreementAccepting.value = false
}
}
watch(() => route.path, path => { selectedKeys.value = [path] }, { immediate: true })
onMounted(() => {
try { userInfo.value = JSON.parse(localStorage.getItem('adminUserInfo') || 'null') } catch { userInfo.value = null }
checkAgreementGate()
})
</script>
@@ -419,6 +477,22 @@ onMounted(() => {
color: #fff;
}
.agreement-gate {
display: grid;
gap: 14px;
color: #315650;
line-height: 1.7;
}
.agreement-gate p {
margin: 0;
}
.agreement-gate__links a {
color: var(--theme-primary-action);
font-weight: 700;
}
@media (max-width: 960px) {
.header,
.content {