增加前端格式检查配置
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
||||
User,
|
||||
UserFilled,
|
||||
Wallet,
|
||||
CreditCard
|
||||
CreditCard,
|
||||
} from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElSubMenu } from 'element-plus'
|
||||
import type { Component } from 'vue'
|
||||
@@ -70,7 +70,12 @@ const allNavGroups: NavGroup[] = [
|
||||
{ label: '用户管理', to: '/admin/users', icon: User, permission: 'user:view' },
|
||||
{ label: '订单管理', to: '/admin/orders', icon: Tickets, permission: 'order:view' },
|
||||
{ label: '商品管理', to: '/admin/listings', icon: Shop, permission: 'listing:view' },
|
||||
{ label: '商品审核', to: '/admin/listings/review', icon: DocumentChecked, permission: 'listing:approve' },
|
||||
{
|
||||
label: '商品审核',
|
||||
to: '/admin/listings/review',
|
||||
icon: DocumentChecked,
|
||||
permission: 'listing:approve',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -78,7 +83,12 @@ const allNavGroups: NavGroup[] = [
|
||||
index: 'support-risk',
|
||||
icon: Service,
|
||||
children: [
|
||||
{ label: '仲裁中心', to: '/admin/disputes', icon: ScaleToOriginal, permission: 'dispute:view' },
|
||||
{
|
||||
label: '仲裁中心',
|
||||
to: '/admin/disputes',
|
||||
icon: ScaleToOriginal,
|
||||
permission: 'dispute:view',
|
||||
},
|
||||
{ label: '客服群聊', to: '/admin/chats', icon: ChatDotRound, permission: 'chat:view' },
|
||||
],
|
||||
},
|
||||
@@ -89,7 +99,12 @@ const allNavGroups: NavGroup[] = [
|
||||
children: [
|
||||
{ label: '资金流水', to: '/admin/wallet-ledger', icon: Wallet, permission: 'wallet:view' },
|
||||
{ label: '提现审核', to: '/admin/withdrawals', icon: Money, permission: 'withdrawal:list' },
|
||||
{ label: '支付配置', to: '/admin/payment-configs', icon: CreditCard, permission: 'payment_config:list' },
|
||||
{
|
||||
label: '支付配置',
|
||||
to: '/admin/payment-configs',
|
||||
icon: CreditCard,
|
||||
permission: 'payment_config:list',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -97,8 +112,18 @@ const allNavGroups: NavGroup[] = [
|
||||
index: 'content-config',
|
||||
icon: Tools,
|
||||
children: [
|
||||
{ label: '公告管理', to: '/admin/announcements', icon: Bell, permission: 'announcement:view' },
|
||||
{ label: '系统配置', to: '/admin/system-configs', icon: Operation, permission: 'system_config:view' },
|
||||
{
|
||||
label: '公告管理',
|
||||
to: '/admin/announcements',
|
||||
icon: Bell,
|
||||
permission: 'announcement:view',
|
||||
},
|
||||
{
|
||||
label: '系统配置',
|
||||
to: '/admin/system-configs',
|
||||
icon: Operation,
|
||||
permission: 'system_config:view',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -107,13 +132,18 @@ const allNavGroups: NavGroup[] = [
|
||||
icon: Lock,
|
||||
children: [
|
||||
{ label: '审计日志', to: '/admin/audit-logs', icon: Document, permission: 'audit_log:view' },
|
||||
{ label: '管理员管理', to: '/admin/admin-users', icon: UserFilled, permission: 'admin_user:manage' },
|
||||
{
|
||||
label: '管理员管理',
|
||||
to: '/admin/admin-users',
|
||||
icon: UserFilled,
|
||||
permission: 'admin_user:manage',
|
||||
},
|
||||
{ label: '角色管理', to: '/admin/roles', icon: Setting, permission: 'role:manage' },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const allNavItems = allNavGroups.flatMap((group) => group.children)
|
||||
const allNavItems = allNavGroups.flatMap(group => group.children)
|
||||
|
||||
function canAccessNavItem(item: NavItem) {
|
||||
if (adminSession.isSuperAdmin) return true
|
||||
@@ -123,11 +153,11 @@ function canAccessNavItem(item: NavItem) {
|
||||
|
||||
const navGroups = computed(() => {
|
||||
return allNavGroups
|
||||
.map((group) => ({
|
||||
.map(group => ({
|
||||
...group,
|
||||
children: group.children.filter((item) => canAccessNavItem(item)),
|
||||
children: group.children.filter(item => canAccessNavItem(item)),
|
||||
}))
|
||||
.filter((group) => group.children.length > 0)
|
||||
.filter(group => group.children.length > 0)
|
||||
})
|
||||
|
||||
const activeMenu = computed(() => {
|
||||
@@ -135,14 +165,14 @@ const activeMenu = computed(() => {
|
||||
const matchedItem = allNavItems
|
||||
.slice()
|
||||
.sort((a, b) => b.to.length - a.to.length)
|
||||
.find((item) => currentPath === item.to || currentPath.startsWith(`${item.to}/`))
|
||||
.find(item => currentPath === item.to || currentPath.startsWith(`${item.to}/`))
|
||||
|
||||
return matchedItem?.to || currentPath
|
||||
})
|
||||
|
||||
const defaultOpeneds = computed(() => {
|
||||
const activeGroup = allNavGroups.find((group) =>
|
||||
group.children.some((item) => item.to === activeMenu.value)
|
||||
const activeGroup = allNavGroups.find(group =>
|
||||
group.children.some(item => item.to === activeMenu.value)
|
||||
)
|
||||
|
||||
return activeGroup ? [activeGroup.index] : []
|
||||
@@ -240,23 +270,31 @@ async function handleLogout() {
|
||||
</el-breadcrumb>
|
||||
</div>
|
||||
<div class="topbar-right">
|
||||
<el-dropdown v-if="hasChatPermission" trigger="click" @command="handleStatusChange" :disabled="updatingStatus">
|
||||
<el-dropdown
|
||||
v-if="hasChatPermission"
|
||||
trigger="click"
|
||||
@command="handleStatusChange"
|
||||
:disabled="updatingStatus"
|
||||
>
|
||||
<span class="status-badge" :style="{ borderColor: statusColors[supportStatus] }">
|
||||
<span class="status-dot" :style="{ backgroundColor: statusColors[supportStatus] }"></span>
|
||||
<span
|
||||
class="status-dot"
|
||||
:style="{ backgroundColor: statusColors[supportStatus] }"
|
||||
></span>
|
||||
<span class="status-text">{{ statusLabels[supportStatus] }}</span>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="online">
|
||||
<span class="status-dot" style="background-color: #10b981;"></span>
|
||||
<span class="status-dot" style="background-color: #10b981"></span>
|
||||
在线
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item command="busy">
|
||||
<span class="status-dot" style="background-color: #f59e0b;"></span>
|
||||
<span class="status-dot" style="background-color: #f59e0b"></span>
|
||||
忙碌
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item command="offline">
|
||||
<span class="status-dot" style="background-color: #9ca3af;"></span>
|
||||
<span class="status-dot" style="background-color: #9ca3af"></span>
|
||||
离线
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
@@ -269,7 +307,9 @@ async function handleLogout() {
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item :icon="SwitchButton" @click="handleLogout">退出登录</el-dropdown-item>
|
||||
<el-dropdown-item :icon="SwitchButton" @click="handleLogout"
|
||||
>退出登录</el-dropdown-item
|
||||
>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
ArrowDown,
|
||||
Bell,
|
||||
@@ -22,68 +22,68 @@ import {
|
||||
Van,
|
||||
VideoPlay,
|
||||
Wallet,
|
||||
} from "@element-plus/icons-vue";
|
||||
import { ensureSupportChat } from "@/features/chats/api/chats";
|
||||
import { useSessionStore } from "@/stores/session";
|
||||
} from '@element-plus/icons-vue'
|
||||
import { ensureSupportChat } from '@/features/chats/api/chats'
|
||||
import { useSessionStore } from '@/stores/session'
|
||||
|
||||
const session = useSessionStore();
|
||||
const router = useRouter();
|
||||
const session = useSessionStore()
|
||||
const router = useRouter()
|
||||
|
||||
const navItems = [
|
||||
{ label: "首页", to: "/", icon: House },
|
||||
{ label: "我的订单", to: "/orders", icon: Tickets },
|
||||
{ label: "消息", to: "/messages", icon: ChatDotRound },
|
||||
{ label: "钱包", to: "/wallet", icon: Wallet },
|
||||
{ label: "公告", to: "/announcements", icon: Bell },
|
||||
];
|
||||
{ label: '首页', to: '/', icon: House },
|
||||
{ label: '我的订单', to: '/orders', icon: Tickets },
|
||||
{ label: '消息', to: '/messages', icon: ChatDotRound },
|
||||
{ label: '钱包', to: '/wallet', icon: Wallet },
|
||||
{ label: '公告', to: '/announcements', icon: Bell },
|
||||
]
|
||||
const buyerServiceItems = [
|
||||
{ label: "待支付", icon: Coin, to: { path: "/orders", query: { tab: "pending_payment" } } },
|
||||
{ label: "待交接", icon: Van, to: { path: "/orders", query: { tab: "pending_handoff" } } },
|
||||
{ label: "使用中", icon: VideoPlay, to: { path: "/orders", query: { tab: "renting" } } },
|
||||
{ label: "已完成", icon: Finished, to: { path: "/orders", query: { tab: "completed" } } },
|
||||
];
|
||||
{ label: '待支付', icon: Coin, to: { path: '/orders', query: { tab: 'pending_payment' } } },
|
||||
{ label: '待交接', icon: Van, to: { path: '/orders', query: { tab: 'pending_handoff' } } },
|
||||
{ label: '使用中', icon: VideoPlay, to: { path: '/orders', query: { tab: 'renting' } } },
|
||||
{ label: '已完成', icon: Finished, to: { path: '/orders', query: { tab: 'completed' } } },
|
||||
]
|
||||
const sellerServiceItems = [
|
||||
{ label: "发布商品", icon: CirclePlus, to: "/seller/listings/create" },
|
||||
{ label: "我的商品", icon: Shop, to: "/seller/listings" },
|
||||
{ label: "提现/账单", icon: Wallet, to: "/wallet" },
|
||||
];
|
||||
{ label: '发布商品', icon: CirclePlus, to: '/seller/listings/create' },
|
||||
{ label: '我的商品', icon: Shop, to: '/seller/listings' },
|
||||
{ label: '提现/账单', icon: Wallet, to: '/wallet' },
|
||||
]
|
||||
|
||||
const showUserDropdown = ref(false);
|
||||
const supportLoading = ref(false);
|
||||
const showUserDropdown = ref(false)
|
||||
const supportLoading = ref(false)
|
||||
|
||||
const realnameBadge = computed(() => {
|
||||
switch (session.realnameStatus) {
|
||||
case "verified":
|
||||
return { text: "已实名", tone: "verified" };
|
||||
case "pending":
|
||||
return { text: "认证中", tone: "pending" };
|
||||
case "rejected":
|
||||
return { text: "认证失败", tone: "rejected" };
|
||||
case 'verified':
|
||||
return { text: '已实名', tone: 'verified' }
|
||||
case 'pending':
|
||||
return { text: '认证中', tone: 'pending' }
|
||||
case 'rejected':
|
||||
return { text: '认证失败', tone: 'rejected' }
|
||||
default:
|
||||
return { text: "未实名", tone: "unverified" };
|
||||
return { text: '未实名', tone: 'unverified' }
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
function handleLogout() {
|
||||
session.logout();
|
||||
showUserDropdown.value = false;
|
||||
router.replace("/");
|
||||
session.logout()
|
||||
showUserDropdown.value = false
|
||||
router.replace('/')
|
||||
}
|
||||
|
||||
async function handleSupportClick() {
|
||||
if (!session.isLoggedIn) {
|
||||
router.push({ path: "/login", query: { redirect: router.currentRoute.value.fullPath } });
|
||||
return;
|
||||
router.push({ path: '/login', query: { redirect: router.currentRoute.value.fullPath } })
|
||||
return
|
||||
}
|
||||
if (supportLoading.value) return;
|
||||
supportLoading.value = true;
|
||||
if (supportLoading.value) return
|
||||
supportLoading.value = true
|
||||
try {
|
||||
const chat = await ensureSupportChat();
|
||||
router.push(`/messages/${chat.id}`);
|
||||
const chat = await ensureSupportChat()
|
||||
router.push(`/messages/${chat.id}`)
|
||||
} catch {
|
||||
ElMessage.error("联系客服失败,请稍后重试");
|
||||
ElMessage.error('联系客服失败,请稍后重试')
|
||||
} finally {
|
||||
supportLoading.value = false;
|
||||
supportLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -100,12 +100,7 @@ async function handleSupportClick() {
|
||||
</RouterLink>
|
||||
|
||||
<nav class="pc-nav">
|
||||
<RouterLink
|
||||
v-for="item in navItems"
|
||||
:key="item.to"
|
||||
class="pc-nav-link"
|
||||
:to="item.to"
|
||||
>
|
||||
<RouterLink v-for="item in navItems" :key="item.to" class="pc-nav-link" :to="item.to">
|
||||
<el-icon><component :is="item.icon" /></el-icon>
|
||||
<span>{{ item.label }}</span>
|
||||
</RouterLink>
|
||||
@@ -117,12 +112,20 @@ async function handleSupportClick() {
|
||||
</div>
|
||||
|
||||
<div class="pc-user-actions">
|
||||
<button class="pc-icon-link service-link" type="button" title="联系客服" @click="handleSupportClick">
|
||||
<button
|
||||
class="pc-icon-link service-link"
|
||||
type="button"
|
||||
title="联系客服"
|
||||
@click="handleSupportClick"
|
||||
>
|
||||
<el-icon><Service /></el-icon>
|
||||
<span>{{ supportLoading ? "接入中" : "客服" }}</span>
|
||||
<span>{{ supportLoading ? '接入中' : '客服' }}</span>
|
||||
</button>
|
||||
|
||||
<RouterLink class="pc-post-link" :to="session.isLoggedIn ? '/seller/listings/create' : '/login'">
|
||||
<RouterLink
|
||||
class="pc-post-link"
|
||||
:to="session.isLoggedIn ? '/seller/listings/create' : '/login'"
|
||||
>
|
||||
<el-icon><CirclePlus /></el-icon>
|
||||
<span>发布账号</span>
|
||||
</RouterLink>
|
||||
@@ -157,33 +160,23 @@ async function handleSupportClick() {
|
||||
<span class="pc-realname-badge" :class="`is-${realnameBadge.tone}`">
|
||||
{{ realnameBadge.text }}
|
||||
</span>
|
||||
<el-icon class="arrow-icon" :class="{ rotated: showUserDropdown }"><ArrowDown /></el-icon>
|
||||
<el-icon class="arrow-icon" :class="{ rotated: showUserDropdown }"
|
||||
><ArrowDown
|
||||
/></el-icon>
|
||||
</button>
|
||||
|
||||
<Transition name="dropdown">
|
||||
<div v-if="showUserDropdown" class="pc-user-dropdown-container">
|
||||
<div class="pc-user-dropdown">
|
||||
<RouterLink
|
||||
class="dropdown-item"
|
||||
to="/profile"
|
||||
@click="showUserDropdown = false"
|
||||
>
|
||||
<RouterLink class="dropdown-item" to="/profile" @click="showUserDropdown = false">
|
||||
<el-icon><EditPen /></el-icon>
|
||||
<span>个人资料</span>
|
||||
</RouterLink>
|
||||
<RouterLink
|
||||
class="dropdown-item"
|
||||
to="/orders"
|
||||
@click="showUserDropdown = false"
|
||||
>
|
||||
<RouterLink class="dropdown-item" to="/orders" @click="showUserDropdown = false">
|
||||
<el-icon><Tickets /></el-icon>
|
||||
<span>我的订单</span>
|
||||
</RouterLink>
|
||||
<RouterLink
|
||||
class="dropdown-item"
|
||||
to="/wallet"
|
||||
@click="showUserDropdown = false"
|
||||
>
|
||||
<RouterLink class="dropdown-item" to="/wallet" @click="showUserDropdown = false">
|
||||
<el-icon><Wallet /></el-icon>
|
||||
<span>我的钱包</span>
|
||||
</RouterLink>
|
||||
@@ -808,7 +801,9 @@ async function handleSupportClick() {
|
||||
/* 下拉动画 */
|
||||
.dropdown-enter-active,
|
||||
.dropdown-leave-active {
|
||||
transition: opacity 0.2s ease, transform 0.2s ease;
|
||||
transition:
|
||||
opacity 0.2s ease,
|
||||
transform 0.2s ease;
|
||||
}
|
||||
.dropdown-enter-from {
|
||||
opacity: 0;
|
||||
|
||||
Reference in New Issue
Block a user