功能:完善门店能力与用户安全配置

This commit is contained in:
xiaowang
2026-05-18 10:04:57 +08:00
parent 4563dd2538
commit 3797938616
356 changed files with 24983 additions and 1858 deletions
@@ -12,6 +12,15 @@
description="系统里还没有可用店铺。当前账号已允许登录后台先创建第一家店铺,其他后台模块会保持不可用,创建完成后请重新登录并选择店铺。"
/>
<a-alert
v-if="isShopAuthorizationExpired"
class="bootstrap-alert"
type="error"
show-icon
message="授权已到期,请联系管理员"
description="当前店铺已超过授权有效期,后台业务功能已暂时禁用。"
/>
<a-card class="time-card">
<a-statistic title="当前时间" :value="currentTime" />
</a-card>
@@ -140,6 +149,10 @@
</template>
<script setup lang="ts">
/**
* HomeView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { DashboardOutlined, HomeOutlined, SafetyCertificateOutlined, ShopOutlined, UserOutlined } from '@ant-design/icons-vue'
@@ -152,11 +165,13 @@ import { isBootstrapAdminUser } from './admin-helpers'
const router = useRouter()
const { isMobile } = useAdminViewport()
/** currentTime is a reactive state variable used by the template and event handlers. */
const currentTime = ref('')
const userInfo = ref<UserVO | null>(null)
const userPermissions = ref<PermissionVO[]>([])
let timer: number | null = null
/** welcomeMessage is a reactive state variable used by the template and event handlers. */
const welcomeMessage = computed(() => {
const hour = new Date().getHours()
if (hour < 12) {
@@ -168,8 +183,12 @@ const welcomeMessage = computed(() => {
}
})
/** isBootstrapAdmin is a reactive state variable used by the template and event handlers. */
const isBootstrapAdmin = computed(() => isBootstrapAdminUser(userInfo.value))
/** isShopAuthorizationExpired is a reactive state variable used by the template and event handlers. */
const isShopAuthorizationExpired = computed(() => Boolean(userInfo.value?.shopAuthorizationExpired) && userInfo.value?.type !== 4)
/** groupedPermissions is a reactive state variable used by the template and event handlers. */
const groupedPermissions = computed(() => {
const groups: Record<string, PermissionVO[]> = {}
userPermissions.value.forEach(permission => {
@@ -182,7 +201,11 @@ const groupedPermissions = computed(() => {
return groups
})
/** quickActions is a reactive state variable used by the template and event handlers. */
const quickActions = computed(() => {
if (isShopAuthorizationExpired.value) {
return []
}
const actions = [
{
key: 'dashboard',
@@ -225,6 +248,7 @@ const quickActions = computed(() => {
return actions.filter(item => grantedPermissions.has(item.permissionCode))
})
/** getUserTypeText is a local helper used by this page script. */
const getUserTypeText = (type: number | undefined) => {
switch (type) {
case 4:
@@ -238,6 +262,7 @@ const getUserTypeText = (type: number | undefined) => {
}
}
/** updateCurrentTime is a local helper used by this page script. */
const updateCurrentTime = () => {
const now = new Date()
currentTime.value = now.toLocaleString('zh-CN', {
@@ -250,6 +275,7 @@ const updateCurrentTime = () => {
})
}
/** fetchUserInfo is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const fetchUserInfo = async () => {
try {
const adminUserInfoStr = localStorage.getItem('adminUserInfo')
@@ -264,6 +290,7 @@ const fetchUserInfo = async () => {
}
}
/** fetchUserPermissions is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const fetchUserPermissions = async () => {
try {
const res = await permissionApi.getUserPermissions()
@@ -273,6 +300,7 @@ const fetchUserPermissions = async () => {
}
}
/** navigateTo is a local helper used by this page script. */
const navigateTo = (path: string, permissionCode?: string) => {
if (permissionCode) {
const hasPermission = userPermissions.value.some(p => p.permissionCode === permissionCode)