杂务:整理文档并收口 YumiNail 修复

This commit is contained in:
xiaowang
2026-05-21 18:43:59 +08:00
parent 3797938616
commit 9227ec6175
362 changed files with 8358 additions and 19928 deletions
+134 -27
View File
@@ -1,6 +1,6 @@
<template>
<el-config-provider>
<ConfigProvider :locale="antdLocale">
<ConfigProvider :locale="antdLocale" :theme="antdTheme">
<div class="app-container">
<BottomNav v-if="!isHiddenNav" />
<div class="page-content" :class="{ 'no-nav-padding': isHiddenNav }">
@@ -18,18 +18,27 @@
* App 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, h, onMounted, provide, ref, watch } from 'vue'
import { computed, h, onMounted, onUnmounted, provide, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ConfigProvider, Modal } from 'ant-design-vue'
import type { ButtonProps } from 'ant-design-vue/es/button/buttonTypes'
import type { ThemeConfig } from 'ant-design-vue/es/config-provider/context'
import { CheckOutlined } from '@ant-design/icons-vue'
import BottomNav from './components/BottomNav.vue'
import SystemMessageCard from './components/SystemMessageCard.vue'
import { cartApi } from './api/cart'
import { userApi, type SystemMessageVO } from './api/user'
import antdLocale from './config/antdv-locale'
import { useShopTheme } from './composables/useShopTheme'
const route = useRoute()
const router = useRouter()
const { currentTheme, refreshShopTheme, resetShopTheme, setupShopThemeSync } = useShopTheme()
type ButtonPropsWithClass = ButtonProps & { class?: string }
const popupMessageOkButtonProps: ButtonPropsWithClass = { class: 'popup-message-ok-button' }
/** routerReady is a reactive state variable used by the template and event handlers. */
const routerReady = ref(false)
let stopThemeSync: (() => void) | undefined
/** isHiddenNav is a reactive state variable used by the template and event handlers. */
const isHiddenNav = computed(() => {
@@ -44,6 +53,28 @@ const isHiddenNav = computed(() => {
return route.matched.some(r => r.meta.hideNav) || route.matched.some(r => r.meta.isAdmin)
})
const antdTheme = computed<ThemeConfig>(() => ({
token: {
colorPrimary: currentTheme.value.primaryColor,
colorLink: currentTheme.value.primaryColor,
borderRadius: 8
},
components: {
Button: {
colorPrimary: currentTheme.value.primaryColor,
colorPrimaryHover: currentTheme.value.accentColor,
colorPrimaryActive: currentTheme.value.accentColor
},
Radio: {
colorPrimary: currentTheme.value.primaryColor
},
Input: {
activeBorderColor: currentTheme.value.primaryColor,
hoverBorderColor: currentTheme.value.primaryColor
}
}
}))
// 全局购物车数量状态
/** cartCount is a reactive state variable used by the template and event handlers. */
const cartCount = ref(0)
@@ -90,13 +121,25 @@ const showPopupMessage = (item: SystemMessageVO) => {
await userApi.markMessagePopupShown(item.id)
resolve()
}
const metaText = `${item.publisherName || '系统消息'} · ${item.publishTime || item.createTime || '刚刚'}`
Modal.info({
title: item.title,
content: h('div', { class: 'popup-message-body' }, [
item.content ? h('div', { class: 'popup-message-content' }, item.content) : null,
item.imageUrl ? h('img', { class: 'popup-message-image', src: item.imageUrl, alt: '消息图片' }) : null
icon: null,
centered: true,
width: 560,
class: 'yumi-system-message-dialog',
wrapClassName: 'yumi-system-message-wrap',
content: h(SystemMessageCard, {
title: item.title || '系统消息',
content: item.content || '',
imageUrl: item.imageUrl || '',
meta: metaText,
surface: 'modal'
}),
okText: h('span', { class: 'popup-message-ok-text' }, [
h(CheckOutlined),
h('span', '我知道了')
]),
okText: '我知道了',
okButtonProps: popupMessageOkButtonProps,
async onOk() {
await markShownAndResolve()
},
@@ -134,6 +177,11 @@ provide('cartCount', cartCount)
watch(() => route.path, async () => {
// 检查当前是否是后台页面,如果是则不加载购物车数据
const isAdminPage = route.matched.some(r => r.meta.isAdmin)
if (isAdminPage) {
resetShopTheme()
} else {
await refreshShopTheme()
}
if (!isAdminPage) {
await loadCartCount()
await checkPopupMessages()
@@ -144,10 +192,20 @@ watch(() => route.path, async () => {
loadCartCount()
onMounted(async () => {
stopThemeSync = setupShopThemeSync()
await router.isReady()
routerReady.value = true
if (route.matched.some(r => r.meta.isAdmin)) {
resetShopTheme()
} else {
await refreshShopTheme()
}
await checkPopupMessages()
})
onUnmounted(() => {
stopThemeSync?.()
})
</script>
<style>
@@ -155,7 +213,7 @@ onMounted(async () => {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
color: var(--text-primary);
}
.app-container {
@@ -226,14 +284,14 @@ onMounted(async () => {
}
.yumi-date-picker-panel .ant-picker-cell:hover .ant-picker-cell-inner {
background: #eef6ff;
background: var(--theme-primary-soft);
transform: translateY(-1px);
}
.yumi-date-picker-panel .ant-picker-cell-selected .ant-picker-cell-inner,
.yumi-date-picker-panel .ant-picker-cell-range-start .ant-picker-cell-inner,
.yumi-date-picker-panel .ant-picker-cell-range-end .ant-picker-cell-inner {
background: #1677ff;
background: var(--theme-primary);
color: #fff;
font-weight: 700;
}
@@ -263,8 +321,8 @@ onMounted(async () => {
.yumi-date-time-panel .ant-picker-time-panel-cell-selected .ant-picker-time-panel-cell-inner,
.yumi-time-panel .ant-picker-time-panel-cell-selected .ant-picker-time-panel-cell-inner {
background: #eef6ff;
color: #1677ff;
background: var(--theme-primary-soft);
color: var(--theme-primary);
font-weight: 700;
}
@@ -274,25 +332,74 @@ onMounted(async () => {
.ant-picker-focused,
.ant-picker:hover {
border-color: #1677ff;
box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
border-color: var(--theme-primary);
box-shadow: var(--theme-focus-shadow);
}
.popup-message-body {
display: grid;
gap: 12px;
.yumi-system-message-wrap .ant-modal {
max-width: calc(100vw - 32px);
}
.popup-message-content {
white-space: pre-wrap;
line-height: 1.8;
}
.popup-message-image {
width: 100%;
max-height: 360px;
object-fit: contain;
.yumi-system-message-dialog .ant-modal-content {
overflow: hidden;
padding: 0;
border-radius: 8px;
background: #fff7f8;
background: var(--theme-card-bg);
box-shadow: 0 24px 70px rgba(38, 31, 36, 0.32);
}
.yumi-system-message-dialog .ant-modal-confirm-body-wrapper {
margin: 0;
}
.yumi-system-message-dialog .ant-modal-confirm-body {
display: block;
}
.yumi-system-message-dialog .ant-modal-confirm-content {
max-width: none;
margin: 0 !important;
color: inherit;
}
.yumi-system-message-dialog .ant-modal-confirm-btns {
display: flex;
justify-content: stretch;
margin: 0;
padding: 0 30px 30px;
background: var(--theme-card-bg);
}
.yumi-system-message-dialog .popup-message-ok-button {
width: 100%;
height: 44px;
border: 0;
border-radius: 8px;
color: #ffffff;
font-weight: 700;
background: var(--theme-gradient);
box-shadow: var(--theme-button-shadow);
}
.yumi-system-message-dialog .popup-message-ok-button:hover,
.yumi-system-message-dialog .popup-message-ok-button:focus {
color: #ffffff;
background: linear-gradient(135deg, var(--theme-accent) 0%, var(--theme-secondary) 100%);
}
.popup-message-ok-text {
display: inline-flex;
gap: 8px;
align-items: center;
}
@media (max-width: 640px) {
.yumi-system-message-dialog .ant-modal-content {
border-radius: 8px;
}
.yumi-system-message-dialog .popup-message-ok-button {
width: 100%;
}
}
</style>