增加前端格式检查配置
This commit is contained in:
@@ -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