2026-05-13 12:43:01 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="home">
|
|
|
|
|
|
<template v-if="!isMobile">
|
|
|
|
|
|
<a-page-header title="欢迎使用后台管理系统" :sub-title="welcomeMessage" />
|
|
|
|
|
|
|
|
|
|
|
|
<a-alert
|
|
|
|
|
|
v-if="isBootstrapAdmin"
|
|
|
|
|
|
class="bootstrap-alert"
|
2026-05-21 18:43:59 +08:00
|
|
|
|
type="info"
|
2026-05-13 12:43:01 +08:00
|
|
|
|
show-icon
|
2026-05-21 18:43:59 +08:00
|
|
|
|
message="当前处于平台总览模式"
|
|
|
|
|
|
description="可以查看总览、店铺列表和权限入口;用户、作品、订单、优惠券等店铺业务默认仅可查看,编辑操作已关闭。"
|
2026-05-13 12:43:01 +08:00
|
|
|
|
/>
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
<a-alert
|
|
|
|
|
|
v-if="isShopAuthorizationExpired"
|
|
|
|
|
|
class="bootstrap-alert"
|
|
|
|
|
|
type="error"
|
|
|
|
|
|
show-icon
|
|
|
|
|
|
message="授权已到期,请联系管理员"
|
|
|
|
|
|
description="当前店铺已超过授权有效期,后台业务功能已暂时禁用。"
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
2026-05-13 12:43:01 +08:00
|
|
|
|
<a-card class="time-card">
|
|
|
|
|
|
<a-statistic title="当前时间" :value="currentTime" />
|
|
|
|
|
|
</a-card>
|
|
|
|
|
|
|
|
|
|
|
|
<a-card class="info-card">
|
|
|
|
|
|
<a-descriptions bordered>
|
|
|
|
|
|
<a-descriptions-item label="用户信息">
|
|
|
|
|
|
<div class="user-info">
|
|
|
|
|
|
<a-avatar :size="64" :src="userInfo?.avatar || DEFAULT_AVATAR" />
|
|
|
|
|
|
<div class="user-details">
|
|
|
|
|
|
<h3>{{ userInfo?.nickname || '管理员' }}</h3>
|
|
|
|
|
|
<p>{{ getUserTypeText(userInfo?.type) }}</p>
|
|
|
|
|
|
<p v-if="userInfo?.shopName">所属店铺:{{ userInfo?.shopName }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</a-descriptions-item>
|
|
|
|
|
|
</a-descriptions>
|
|
|
|
|
|
</a-card>
|
|
|
|
|
|
|
|
|
|
|
|
<a-card class="permissions-card">
|
|
|
|
|
|
<template #title>
|
|
|
|
|
|
<div class="card-title">
|
|
|
|
|
|
<SafetyCertificateOutlined class="title-icon" />
|
|
|
|
|
|
<span>我的权限</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<div class="permissions-content" v-if="userPermissions.length > 0">
|
|
|
|
|
|
<div v-for="(group, groupName) in groupedPermissions" :key="groupName" class="permission-group">
|
|
|
|
|
|
<div class="group-title">{{ groupName }}</div>
|
|
|
|
|
|
<div class="permission-tags">
|
|
|
|
|
|
<a-tag v-for="permission in group" :key="permission.id" color="blue" class="permission-tag">
|
|
|
|
|
|
{{ permission.permissionName }}
|
|
|
|
|
|
</a-tag>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="no-permissions" v-else>
|
|
|
|
|
|
暂无权限信息
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</a-card>
|
|
|
|
|
|
|
|
|
|
|
|
<a-card class="quick-actions">
|
|
|
|
|
|
<template #title>
|
|
|
|
|
|
快捷操作
|
|
|
|
|
|
</template>
|
2026-05-24 18:09:11 +08:00
|
|
|
|
<a-row :gutter="[16, 16]">
|
|
|
|
|
|
<a-col v-for="item in quickActions" :key="item.key" :span="8">
|
2026-05-13 12:43:01 +08:00
|
|
|
|
<a-card hoverable @click="navigateTo(item.path, item.permissionCode)">
|
|
|
|
|
|
<template #cover>
|
|
|
|
|
|
<div class="action-icon">
|
|
|
|
|
|
<component :is="item.icon" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #title>
|
|
|
|
|
|
{{ item.title }}
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</a-card>
|
2026-05-24 18:09:11 +08:00
|
|
|
|
</a-col>
|
|
|
|
|
|
</a-row>
|
2026-05-13 12:43:01 +08:00
|
|
|
|
</a-card>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<section class="admin-page-intro">
|
|
|
|
|
|
<span class="admin-page-intro__eyebrow">{{ userInfo?.nickname || userInfo?.account || '后台账号' }}</span>
|
2026-05-21 18:43:59 +08:00
|
|
|
|
<h1 class="admin-page-intro__title">{{ userInfo?.shopName || (isBootstrapAdmin ? '平台总览模式' : '游客模式') }}</h1>
|
2026-05-13 12:43:01 +08:00
|
|
|
|
<div class="admin-page-intro__meta">
|
|
|
|
|
|
<span class="admin-page-chip">{{ currentTime }}</span>
|
|
|
|
|
|
<span class="admin-page-chip">{{ getUserTypeText(userInfo?.type) }}</span>
|
2026-05-21 18:43:59 +08:00
|
|
|
|
<span v-if="isBootstrapAdmin" class="admin-page-chip">平台总览</span>
|
2026-05-13 12:43:01 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<section v-if="isBootstrapAdmin" class="admin-mobile-section-card">
|
2026-05-21 18:43:59 +08:00
|
|
|
|
<div class="admin-mobile-section-card__title">平台总览模式</div>
|
2026-05-13 12:43:01 +08:00
|
|
|
|
<a-button type="primary" size="large" block @click="navigateTo('/admin/shops', 'shop:view')">进入店铺管理</a-button>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="admin-mobile-grid admin-mobile-grid--two">
|
|
|
|
|
|
<section class="admin-mobile-stat">
|
|
|
|
|
|
<div class="admin-mobile-stat__label">权限数量</div>
|
|
|
|
|
|
<div class="admin-mobile-stat__value">{{ userPermissions.length }}</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
<section class="admin-mobile-stat">
|
|
|
|
|
|
<div class="admin-mobile-stat__label">快捷入口</div>
|
|
|
|
|
|
<div class="admin-mobile-stat__value">{{ quickActions.length }}</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<section class="admin-mobile-section-card">
|
|
|
|
|
|
<div class="admin-mobile-section-card__title">快捷入口</div>
|
|
|
|
|
|
<div class="mobile-actions">
|
|
|
|
|
|
<button
|
|
|
|
|
|
v-for="item in quickActions"
|
|
|
|
|
|
:key="item.key"
|
|
|
|
|
|
class="mobile-action"
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
@click="navigateTo(item.path, item.permissionCode)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="mobile-action__icon">
|
|
|
|
|
|
<component :is="item.icon" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="mobile-action__body">
|
|
|
|
|
|
<div class="mobile-action__title">{{ item.title }}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<section class="admin-mobile-section-card">
|
|
|
|
|
|
<div class="admin-mobile-section-card__title">权限分组</div>
|
|
|
|
|
|
<div v-if="userPermissions.length > 0" class="mobile-permission-groups">
|
|
|
|
|
|
<div v-for="(group, groupName) in groupedPermissions" :key="groupName" class="mobile-permission-group">
|
|
|
|
|
|
<div class="mobile-permission-group__title">{{ groupName }}</div>
|
|
|
|
|
|
<div class="permission-tags">
|
|
|
|
|
|
<a-tag v-for="permission in group" :key="permission.id" color="blue" class="permission-tag">
|
|
|
|
|
|
{{ permission.permissionName }}
|
|
|
|
|
|
</a-tag>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<a-empty v-else description="暂无权限信息" />
|
|
|
|
|
|
</section>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 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.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
|
|
|
|
import { useRouter } from 'vue-router'
|
2026-05-21 18:43:59 +08:00
|
|
|
|
import {
|
|
|
|
|
|
DashboardOutlined,
|
|
|
|
|
|
FileProtectOutlined,
|
|
|
|
|
|
GiftOutlined,
|
|
|
|
|
|
HomeOutlined,
|
|
|
|
|
|
MessageOutlined,
|
|
|
|
|
|
SafetyCertificateOutlined,
|
|
|
|
|
|
SettingOutlined,
|
|
|
|
|
|
ShopOutlined,
|
|
|
|
|
|
ShoppingOutlined,
|
|
|
|
|
|
TagOutlined,
|
|
|
|
|
|
TeamOutlined,
|
|
|
|
|
|
UserOutlined
|
|
|
|
|
|
} from '@ant-design/icons-vue'
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: UserVO supports HomeView.vue by holding or executing the user vo page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
import { userApi, type UserVO } from '@/api/admin'
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: PermissionVO supports HomeView.vue by holding or executing the permission vo page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
import { permissionApi, type PermissionVO } from '@/api/permission'
|
|
|
|
|
|
import { DEFAULT_AVATAR } from '@/constants'
|
|
|
|
|
|
import { message } from 'ant-design-vue'
|
|
|
|
|
|
import { useAdminViewport } from '@/composables/useAdminViewport'
|
|
|
|
|
|
import { isBootstrapAdminUser } from './admin-helpers'
|
2026-05-21 18:43:59 +08:00
|
|
|
|
import { isAllowedForShoplessPlatformAdmin } from '@/utils/platform-admin-permissions'
|
2026-05-13 12:43:01 +08:00
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: router supports HomeView.vue by holding or executing the router page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
const { isMobile } = useAdminViewport()
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** currentTime is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const currentTime = ref('')
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: userInfo supports HomeView.vue by holding or executing the user info page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const userInfo = ref<UserVO | null>(null)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: userPermissions supports HomeView.vue by holding or executing the user permissions page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const userPermissions = ref<PermissionVO[]>([])
|
|
|
|
|
|
let timer: number | null = null
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** welcomeMessage is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const welcomeMessage = computed(() => {
|
|
|
|
|
|
const hour = new Date().getHours()
|
|
|
|
|
|
if (hour < 12) {
|
|
|
|
|
|
return '早上好!'
|
|
|
|
|
|
} else if (hour < 18) {
|
|
|
|
|
|
return '下午好!'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return '晚上好!'
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** isBootstrapAdmin is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const isBootstrapAdmin = computed(() => isBootstrapAdminUser(userInfo.value))
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** isShopAuthorizationExpired is a reactive state variable used by the template and event handlers. */
|
|
|
|
|
|
const isShopAuthorizationExpired = computed(() => Boolean(userInfo.value?.shopAuthorizationExpired) && userInfo.value?.type !== 4)
|
2026-05-13 12:43:01 +08:00
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** groupedPermissions is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const groupedPermissions = computed(() => {
|
|
|
|
|
|
const groups: Record<string, PermissionVO[]> = {}
|
|
|
|
|
|
userPermissions.value.forEach(permission => {
|
|
|
|
|
|
const groupName = permission.permissionGroup
|
|
|
|
|
|
if (!groups[groupName]) {
|
|
|
|
|
|
groups[groupName] = []
|
|
|
|
|
|
}
|
|
|
|
|
|
groups[groupName]!.push(permission)
|
|
|
|
|
|
})
|
|
|
|
|
|
return groups
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** quickActions is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const quickActions = computed(() => {
|
2026-05-18 09:46:11 +08:00
|
|
|
|
if (isShopAuthorizationExpired.value) {
|
|
|
|
|
|
return []
|
|
|
|
|
|
}
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const actions = [
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'dashboard',
|
|
|
|
|
|
title: '仪表盘',
|
|
|
|
|
|
path: '/admin/dashboard',
|
|
|
|
|
|
icon: DashboardOutlined,
|
|
|
|
|
|
permissionCode: 'dashboard:view'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'users',
|
|
|
|
|
|
title: '用户管理',
|
|
|
|
|
|
path: '/admin/users',
|
|
|
|
|
|
icon: UserOutlined,
|
|
|
|
|
|
permissionCode: 'user:view'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'products',
|
|
|
|
|
|
title: '作品管理',
|
|
|
|
|
|
path: '/admin/products',
|
|
|
|
|
|
icon: ShopOutlined,
|
|
|
|
|
|
permissionCode: 'product:view'
|
|
|
|
|
|
},
|
2026-05-21 18:43:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
key: 'coupons',
|
|
|
|
|
|
title: '优惠券',
|
|
|
|
|
|
path: '/admin/coupons',
|
|
|
|
|
|
icon: GiftOutlined,
|
|
|
|
|
|
permissionCode: 'coupon:view'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'orders',
|
|
|
|
|
|
title: '订单管理',
|
|
|
|
|
|
path: '/admin/orders',
|
|
|
|
|
|
icon: ShoppingOutlined,
|
|
|
|
|
|
permissionCode: 'order:view'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'tags',
|
|
|
|
|
|
title: '标签管理',
|
|
|
|
|
|
path: '/admin/tags',
|
|
|
|
|
|
icon: TagOutlined,
|
|
|
|
|
|
permissionCode: 'tag:view'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'artists',
|
|
|
|
|
|
title: '美甲师管理',
|
|
|
|
|
|
path: '/admin/nail-artists',
|
|
|
|
|
|
icon: TeamOutlined,
|
|
|
|
|
|
permissionCode: 'nail_artist:view'
|
|
|
|
|
|
},
|
2026-05-13 12:43:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
key: 'shops',
|
|
|
|
|
|
title: '店铺管理',
|
|
|
|
|
|
path: '/admin/shops',
|
|
|
|
|
|
icon: HomeOutlined,
|
|
|
|
|
|
permissionCode: 'shop:view'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'permissions',
|
|
|
|
|
|
title: '权限管理',
|
|
|
|
|
|
path: '/admin/permissions',
|
|
|
|
|
|
icon: SafetyCertificateOutlined,
|
|
|
|
|
|
permissionCode: 'permission:view'
|
2026-05-21 18:43:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'messages',
|
|
|
|
|
|
title: '消息发布',
|
|
|
|
|
|
path: '/admin/messages',
|
|
|
|
|
|
icon: MessageOutlined,
|
|
|
|
|
|
permissionCode: 'message:view'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'announcements',
|
|
|
|
|
|
title: '公告管理',
|
|
|
|
|
|
path: '/admin/announcements',
|
|
|
|
|
|
icon: MessageOutlined,
|
|
|
|
|
|
permissionCode: 'announcement:view'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'vip-plans',
|
|
|
|
|
|
title: 'VIP充值配置',
|
|
|
|
|
|
path: '/admin/vip-recharge-plans',
|
|
|
|
|
|
icon: GiftOutlined,
|
|
|
|
|
|
permissionCode: 'user:vip:manage'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'parameters',
|
|
|
|
|
|
title: '参数管理',
|
|
|
|
|
|
path: '/admin/messagehub-push-configs',
|
|
|
|
|
|
icon: SettingOutlined,
|
|
|
|
|
|
permissionCode: 'messagehub:config:manage'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'agreements',
|
|
|
|
|
|
title: '协议管理',
|
|
|
|
|
|
path: '/admin/legal-agreements',
|
|
|
|
|
|
icon: FileProtectOutlined,
|
|
|
|
|
|
permissionCode: 'legal_agreement:manage'
|
2026-05-13 12:43:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
const grantedPermissions = new Set(userPermissions.value.map(permission => permission.permissionCode))
|
2026-05-21 18:43:59 +08:00
|
|
|
|
if (isBootstrapAdmin.value) {
|
|
|
|
|
|
return actions.filter(item => isAllowedForShoplessPlatformAdmin(item.permissionCode))
|
|
|
|
|
|
}
|
2026-05-13 12:43:01 +08:00
|
|
|
|
return actions.filter(item => grantedPermissions.has(item.permissionCode))
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** getUserTypeText is a local helper used by this page script. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const getUserTypeText = (type: number | undefined) => {
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
return '平台管理员'
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
return '店长'
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
return '美甲师'
|
|
|
|
|
|
default:
|
|
|
|
|
|
return '后台账号'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** updateCurrentTime is a local helper used by this page script. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const updateCurrentTime = () => {
|
|
|
|
|
|
const now = new Date()
|
|
|
|
|
|
currentTime.value = now.toLocaleString('zh-CN', {
|
|
|
|
|
|
year: 'numeric',
|
|
|
|
|
|
month: '2-digit',
|
|
|
|
|
|
day: '2-digit',
|
|
|
|
|
|
hour: '2-digit',
|
|
|
|
|
|
minute: '2-digit',
|
|
|
|
|
|
second: '2-digit'
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** fetchUserInfo is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const fetchUserInfo = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const adminUserInfoStr = localStorage.getItem('adminUserInfo')
|
|
|
|
|
|
if (adminUserInfoStr) {
|
|
|
|
|
|
userInfo.value = JSON.parse(adminUserInfoStr)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const res = await userApi.getUserInfo()
|
|
|
|
|
|
userInfo.value = res as unknown as UserVO
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取用户信息失败:', error)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** fetchUserPermissions is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const fetchUserPermissions = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await permissionApi.getUserPermissions()
|
|
|
|
|
|
userPermissions.value = res as unknown as PermissionVO[]
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取用户权限失败:', error)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** navigateTo is a local helper used by this page script. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const navigateTo = (path: string, permissionCode?: string) => {
|
|
|
|
|
|
if (permissionCode) {
|
2026-05-21 18:43:59 +08:00
|
|
|
|
if (isBootstrapAdmin.value && isAllowedForShoplessPlatformAdmin(permissionCode)) {
|
|
|
|
|
|
router.push(path)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const hasPermission = userPermissions.value.some(p => p.permissionCode === permissionCode)
|
|
|
|
|
|
if (!hasPermission) {
|
|
|
|
|
|
message.warning('您没有该操作的权限')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
router.push(path)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
updateCurrentTime()
|
|
|
|
|
|
timer = window.setInterval(updateCurrentTime, 1000)
|
|
|
|
|
|
void fetchUserInfo()
|
|
|
|
|
|
void fetchUserPermissions()
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
|
if (timer !== null) {
|
|
|
|
|
|
window.clearInterval(timer)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.home {
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.time-card,
|
|
|
|
|
|
.bootstrap-alert,
|
|
|
|
|
|
.info-card,
|
|
|
|
|
|
.permissions-card {
|
|
|
|
|
|
margin-bottom: 24px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.user-info {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.user-details {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.user-details h3 {
|
|
|
|
|
|
margin: 0 0 8px 0;
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.user-details p {
|
|
|
|
|
|
margin: 4px 0;
|
2026-05-29 13:30:56 +08:00
|
|
|
|
color: var(--text-secondary);
|
2026-05-13 12:43:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.card-title {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: var(--admin-mobile-ink);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.title-icon {
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
color: var(--admin-mobile-accent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.permissions-content,
|
|
|
|
|
|
.mobile-permission-groups {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.permission-group,
|
|
|
|
|
|
.mobile-permission-group {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
gap: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.group-title,
|
|
|
|
|
|
.mobile-permission-group__title {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
font-weight: 600;
|
2026-05-29 13:30:56 +08:00
|
|
|
|
color: var(--theme-primary);
|
2026-05-13 12:43:01 +08:00
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.permission-tags {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.permission-tag {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
padding: 4px 12px;
|
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.no-permissions {
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
padding: 20px;
|
2026-05-29 13:30:56 +08:00
|
|
|
|
color: var(--text-secondary);
|
2026-05-13 12:43:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.quick-actions {
|
|
|
|
|
|
margin-top: 24px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.action-icon {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
height: 80px;
|
|
|
|
|
|
font-size: 32px;
|
2026-05-29 13:30:56 +08:00
|
|
|
|
color: var(--theme-primary);
|
2026-05-13 12:43:01 +08:00
|
|
|
|
background: var(--admin-mobile-accent-soft);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mobile-actions {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
margin-top: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mobile-action {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 14px;
|
|
|
|
|
|
padding: 14px 0;
|
|
|
|
|
|
border: 0;
|
|
|
|
|
|
border-bottom: 1px solid var(--admin-mobile-border);
|
|
|
|
|
|
background: transparent;
|
|
|
|
|
|
text-align: left;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mobile-action:last-child {
|
|
|
|
|
|
border-bottom: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mobile-action__icon {
|
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
width: 42px;
|
|
|
|
|
|
height: 42px;
|
|
|
|
|
|
border-radius: 14px;
|
|
|
|
|
|
background: var(--admin-mobile-accent-soft);
|
2026-05-29 13:30:56 +08:00
|
|
|
|
color: var(--theme-primary);
|
2026-05-13 12:43:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mobile-action__body {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mobile-action__title {
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: var(--admin-mobile-ink);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mobile-action__meta {
|
|
|
|
|
|
margin-top: 4px;
|
2026-05-29 13:30:56 +08:00
|
|
|
|
color: var(--text-secondary);
|
2026-05-13 12:43:01 +08:00
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|