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

106 lines
5.1 KiB
Vue
Raw Normal View History

<template>
<div class="admin-profile">
<section class="profile-head">
<div>
<span class="profile-eyebrow">后台账号</span>
<h1>{{ userInfo?.nickname || '未设置昵称' }}</h1>
<p>{{ userInfo?.account || '当前登录账号' }} · {{ roleLabel }}</p>
</div>
<span class="profile-chip">{{ isPlatformOverview ? '平台总览' : currentShopName }}</span>
</section>
<section class="profile-section">
<div class="profile-section__head">
<div>
<h2>账号与门店</h2>
<p>账号资料、权限范围和门店切换已集中到系统设置。</p>
</div>
</div>
<button class="profile-link" type="button" @click="router.push({ path: '/admin/settings', query: { section: 'account' } })">
<span class="profile-link__icon">◎</span>
<span class="profile-link__body"><strong>打开当前账号设置</strong><small>查看后台账号、权限范围和可用门店</small></span>
<span class="profile-link__arrow">›</span>
</button>
</section>
<section class="profile-section">
<div class="profile-section__head">
<div>
<h2>常用入口</h2>
<p>继续处理日常经营工作。</p>
</div>
</div>
<div class="profile-actions">
<a-button type="default" size="large" @click="router.push('/admin/orders')">查看订单</a-button>
<a-button type="default" size="large" @click="router.push('/admin/manage')">进入经营模块</a-button>
</div>
</section>
<section class="profile-section profile-section--logout">
<div class="profile-section__head">
<div>
<h2>退出登录</h2>
<p>退出后需要重新登录后台。</p>
</div>
</div>
<a-button danger size="large" block @click="handleLogout">退出当前账号</a-button>
</section>
</div>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useRouter } from 'vue-router'
import { message, Modal } from 'ant-design-vue'
import { completeAdminLogout } from '@/utils/admin-logout'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { getAdminCurrentShopName, getAdminRoleLabel, isBootstrapAdminUser, loadCachedAdminUserInfo } from './admin-helpers'
const router = useRouter()
const userInfo = ref(loadCachedAdminUserInfo())
const roleLabel = computed(() => getAdminRoleLabel(userInfo.value?.type))
const currentShopName = computed(() => getAdminCurrentShopName(userInfo.value))
const isPlatformOverview = computed(() => isBootstrapAdminUser(userInfo.value))
const handleLogout = () => {
Modal.confirm({
title: '确认退出登录',
content: '退出后需要重新登录后台。',
okText: '确认',
cancelText: '取消',
onOk: async () => {
await runWithGlobalLoading(async () => {
await completeAdminLogout(router)
message.success('已退出登录')
})
}
})
}
</script>
<style scoped>
.admin-profile { display: grid; gap: 18px; color: var(--admin-mobile-ink); }
.profile-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--admin-mobile-border); }
.profile-eyebrow { color: var(--theme-primary-action); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.profile-head h1 { margin: 7px 0 4px; font-size: 27px; }
.profile-head p, .profile-section__head p { margin: 0; color: var(--admin-mobile-muted); font-size: 13px; }
.profile-chip { padding: 7px 10px; border-radius: 999px; background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-size: 12px; font-weight: 700; white-space: nowrap; }
.profile-section { padding-top: 16px; border-top: 1px solid var(--admin-mobile-border); }
.profile-section__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.profile-section__head h2 { margin: 0 0 4px; font-size: 15px; }
.profile-link { display: flex; width: 100%; align-items: center; gap: 12px; padding: 14px 2px; border: 0; border-bottom: 1px solid var(--admin-mobile-border); background: transparent; color: inherit; text-align: left; cursor: pointer; }
.profile-link:hover { color: var(--theme-primary-action); }
.profile-link__icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 12px; background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-size: 20px; }
.profile-link__body { display: grid; flex: 1; gap: 3px; min-width: 0; }
.profile-link__body strong { font-size: 14px; }
.profile-link__body small { color: var(--admin-mobile-muted); font-size: 12px; }
.profile-link__arrow { color: var(--admin-mobile-muted); font-size: 24px; line-height: 1; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.profile-actions .ant-btn { flex: 1 1 180px; }
.profile-section--logout .ant-btn { max-width: 240px; }
@media (max-width: 560px) {
.profile-head { align-items: flex-start; flex-direction: column; }
.profile-section--logout .ant-btn { max-width: none; }
}
</style>