统一甲屿云命名体系
This commit is contained in:
@@ -0,0 +1,278 @@
|
||||
<template>
|
||||
<a-layout class="bottom-nav">
|
||||
<a-layout-content class="nav-content">
|
||||
<button class="nav-item" :class="{ active: currentRoute === 'home' }" type="button" @click="handleNavClick('home')">
|
||||
<a-badge :count="0" :offset="[0, 0]">
|
||||
<div class="nav-icon">
|
||||
<HomeOutlined :style="{ fontSize: '25px' }" />
|
||||
</div>
|
||||
</a-badge>
|
||||
<span class="nav-label">首页</span>
|
||||
</button>
|
||||
|
||||
<button class="nav-item" :class="{ active: currentRoute === 'products' }" type="button" @click="handleNavClick('products')">
|
||||
<a-badge :count="0" :offset="[0, 0]">
|
||||
<div class="nav-icon">
|
||||
<ShoppingOutlined :style="{ fontSize: '25px' }" />
|
||||
</div>
|
||||
</a-badge>
|
||||
<span class="nav-label">作品集</span>
|
||||
</button>
|
||||
|
||||
<button class="nav-item" :class="{ active: currentRoute === 'cart' }" type="button" @click="handleNavClick('cart')">
|
||||
<a-badge :count="cartCount" :offset="[0, 0]">
|
||||
<div class="nav-icon">
|
||||
<ShoppingCartOutlined :style="{ fontSize: '25px' }" />
|
||||
</div>
|
||||
</a-badge>
|
||||
<span class="nav-label">购物车</span>
|
||||
</button>
|
||||
|
||||
<button class="nav-item" :class="{ active: currentRoute === 'profile' }" type="button" @click="handleNavClick('profile')">
|
||||
<a-badge :dot="hasNotification" :offset="[0, 0]">
|
||||
<div class="nav-icon">
|
||||
<UserOutlined :style="{ fontSize: '25px' }" />
|
||||
</div>
|
||||
</a-badge>
|
||||
<span class="nav-label">我的</span>
|
||||
</button>
|
||||
</a-layout-content>
|
||||
</a-layout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* BottomNav 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, inject, onMounted, ref } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { HomeOutlined, ShoppingOutlined, ShoppingCartOutlined, UserOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
/**
|
||||
* Purpose: router supports BottomNav.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.
|
||||
*/
|
||||
const router = useRouter()
|
||||
/**
|
||||
* Purpose: route supports BottomNav.vue by holding or executing the route 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.
|
||||
*/
|
||||
const route = useRoute()
|
||||
|
||||
// 注入全局购物车数量状态
|
||||
const cartCount = inject('cartCount', ref(0))
|
||||
|
||||
// 注入更新购物车数量的方法
|
||||
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
|
||||
|
||||
// 是否有未读通知
|
||||
/** hasNotification is a reactive state variable used by the template and event handlers. */
|
||||
const hasNotification = computed(() => true)
|
||||
|
||||
// 加载购物车数量
|
||||
/** loadCartCount is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const loadCartCount = async () => {
|
||||
// 这里我们不需要做任何事情,因为全局状态会自动更新
|
||||
// 但我们仍然需要这个方法,因为 App.vue 会调用它
|
||||
}
|
||||
|
||||
// 页面加载时获取购物车数量
|
||||
onMounted(() => {
|
||||
// 检查当前是否是后台页面,如果是则不加载购物车数据
|
||||
const isAdminPage = window.location.pathname.startsWith('/admin')
|
||||
if (!isAdminPage) {
|
||||
// 调用全局更新方法
|
||||
updateCartCount()
|
||||
}
|
||||
})
|
||||
|
||||
// 提供一个方法让其他组件调用更新购物车数量
|
||||
defineExpose({
|
||||
loadCartCount
|
||||
})
|
||||
|
||||
// 根据当前路由判断激活的导航项
|
||||
/** currentRoute is a reactive state variable used by the template and event handlers. */
|
||||
const currentRoute = computed(() => {
|
||||
if (!route || !route.path) return 'home'
|
||||
const path = route.path
|
||||
if (path === '/') return 'home'
|
||||
if (path === '/products') return 'products'
|
||||
if (path === '/product') return 'products'
|
||||
if (path === '/cart') return 'cart'
|
||||
if (path === '/profile') return 'profile'
|
||||
if (path === '/wishlist') return 'profile'
|
||||
return 'home'
|
||||
})
|
||||
|
||||
// 处理导航点击事件
|
||||
/** handleNavClick is a local helper used by this page script. */
|
||||
const handleNavClick = (tab: string) => {
|
||||
if (tab === 'home') {
|
||||
router.push('/home')
|
||||
} else if (tab === 'products') {
|
||||
router.push('/products')
|
||||
} else if (tab === 'cart') {
|
||||
router.push('/cart')
|
||||
} else if (tab === 'profile') {
|
||||
router.push('/profile')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.bottom-nav {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 64px;
|
||||
background: color-mix(in srgb, var(--theme-card-bg) 96%, transparent);
|
||||
border-top: 1px solid var(--theme-border);
|
||||
box-shadow: 0 -14px 34px color-mix(in srgb, var(--theme-neutral) 10%, transparent);
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
backdrop-filter: blur(18px);
|
||||
backface-visibility: hidden;
|
||||
will-change: transform;
|
||||
transform: translateZ(0);
|
||||
transition: none !important;
|
||||
}
|
||||
|
||||
.nav-content {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: 0 auto;
|
||||
padding: 0 12px calc(env(safe-area-inset-bottom, 0px) / 2);
|
||||
transition: none !important;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
appearance: none;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 3px;
|
||||
min-width: 58px;
|
||||
min-height: 54px;
|
||||
padding: 6px 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.nav-item:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.nav-item.active {
|
||||
color: var(--theme-primary-action);
|
||||
}
|
||||
|
||||
.nav-item.active .nav-icon {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 40px;
|
||||
height: 34px;
|
||||
margin-bottom: 0;
|
||||
border-radius: 18px 18px 16px 16px;
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
color: var(--text-secondary);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.nav-item.active .nav-icon {
|
||||
color: var(--theme-primary-action);
|
||||
background: color-mix(in srgb, var(--theme-primary) 34%, var(--theme-card-bg));
|
||||
}
|
||||
|
||||
.nav-label {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
color: var(--text-secondary);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.nav-item.active .nav-label {
|
||||
color: var(--theme-primary-action);
|
||||
}
|
||||
|
||||
.nav-item :deep(.ant-badge-count) {
|
||||
min-width: 16px;
|
||||
height: 16px;
|
||||
line-height: 16px;
|
||||
background: var(--theme-primary-action);
|
||||
box-shadow: 0 0 0 1px var(--theme-card-bg);
|
||||
}
|
||||
|
||||
.nav-item :deep(.ant-badge-dot) {
|
||||
background: var(--theme-secondary);
|
||||
box-shadow: 0 0 0 1px var(--theme-card-bg);
|
||||
}
|
||||
|
||||
@media (max-width: 359px) {
|
||||
.bottom-nav {
|
||||
height: 56px;
|
||||
}
|
||||
|
||||
.nav-content {
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
min-width: 0;
|
||||
padding: 8px 4px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.nav-icon :deep(.anticon) {
|
||||
font-size: 22px !important;
|
||||
}
|
||||
|
||||
.nav-label {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.nav-content {
|
||||
max-width: var(--frontend-page-max-width);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
@media (min-width: 768px) {
|
||||
.jayu-cloud-phone-frame > .bottom-nav {
|
||||
right: auto;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
width: var(--frontend-page-max-width);
|
||||
max-width: calc(100vw - 48px);
|
||||
border-bottom-right-radius: 32px;
|
||||
border-bottom-left-radius: 32px;
|
||||
transform: translateX(-50%) translateZ(0);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<div class="draft-actions">
|
||||
<a-space wrap>
|
||||
<a-button size="small" @click="$emit('save')" :disabled="disabled">
|
||||
暂存
|
||||
</a-button>
|
||||
<a-button v-if="showClear" size="small" type="link" @click="$emit('clear')" :disabled="disabled">
|
||||
清除暂存
|
||||
</a-button>
|
||||
<span v-if="savedAt" class="draft-saved-at">
|
||||
上次暂存:{{ formattedSavedAt }}
|
||||
</span>
|
||||
<span v-else class="draft-saved-at">
|
||||
暂存仅保存在当前浏览器中
|
||||
</span>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* DraftActions 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 } from 'vue'
|
||||
|
||||
/**
|
||||
* Purpose: props supports DraftActions.vue by holding or executing the props 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.
|
||||
*/
|
||||
const props = withDefaults(defineProps<{
|
||||
savedAt?: number | null
|
||||
disabled?: boolean
|
||||
showClear?: boolean
|
||||
}>(), {
|
||||
savedAt: null,
|
||||
disabled: false,
|
||||
showClear: true
|
||||
})
|
||||
|
||||
defineEmits<{
|
||||
(event: 'save'): void
|
||||
(event: 'clear'): void
|
||||
}>()
|
||||
|
||||
/** formattedSavedAt is a reactive state variable used by the template and event handlers. */
|
||||
const formattedSavedAt = computed(() => {
|
||||
if (!props.savedAt) {
|
||||
return ''
|
||||
}
|
||||
const date = new Date(props.savedAt)
|
||||
const year = date.getFullYear()
|
||||
const month = `${date.getMonth() + 1}`.padStart(2, '0')
|
||||
const day = `${date.getDate()}`.padStart(2, '0')
|
||||
const hour = `${date.getHours()}`.padStart(2, '0')
|
||||
const minute = `${date.getMinutes()}`.padStart(2, '0')
|
||||
return `${year}-${month}-${day} ${hour}:${minute}`
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.draft-actions {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.draft-saved-at {
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 24px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,280 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { BellOutlined, ClockCircleOutlined } from '@ant-design/icons-vue'
|
||||
import { renderRichContent } from '@/utils/rich-content'
|
||||
|
||||
/**
|
||||
* Purpose: props supports SystemMessageCard.vue by holding or executing the props 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.
|
||||
*/
|
||||
const props = withDefaults(defineProps<{
|
||||
title?: string
|
||||
content?: string
|
||||
imageUrl?: string
|
||||
imageAlt?: string
|
||||
meta?: string
|
||||
badge?: string
|
||||
auxiliaryBadge?: string
|
||||
surface?: 'modal' | 'preview'
|
||||
footerAlign?: 'between' | 'end'
|
||||
}>(), {
|
||||
title: '系统消息',
|
||||
content: '',
|
||||
imageUrl: '',
|
||||
imageAlt: '消息图片',
|
||||
meta: '',
|
||||
badge: '',
|
||||
auxiliaryBadge: '',
|
||||
surface: 'preview',
|
||||
footerAlign: 'between'
|
||||
})
|
||||
|
||||
/**
|
||||
* Purpose: hasImage supports SystemMessageCard.vue by holding or executing the has image 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.
|
||||
*/
|
||||
const hasImage = computed(() => Boolean(props.imageUrl))
|
||||
/**
|
||||
* Purpose: displayTitle supports SystemMessageCard.vue by holding or executing the display title 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.
|
||||
*/
|
||||
const displayTitle = computed(() => props.title?.trim() || '系统消息')
|
||||
/**
|
||||
* Purpose: displayContent supports SystemMessageCard.vue by holding or executing the display content 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.
|
||||
*/
|
||||
const displayContent = computed(() => props.content?.trim() || (hasImage.value ? '' : '你收到了一条新的系统消息。'))
|
||||
const displayContentHtml = computed(() => renderRichContent(displayContent.value))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<article
|
||||
class="system-message-card"
|
||||
:class="[
|
||||
`system-message-card--${surface}`,
|
||||
`system-message-card--footer-${footerAlign}`,
|
||||
{ 'system-message-card--with-image': hasImage }
|
||||
]"
|
||||
>
|
||||
<div v-if="hasImage" class="system-message-card__media">
|
||||
<img :src="imageUrl" :alt="imageAlt" />
|
||||
</div>
|
||||
|
||||
<div v-else class="system-message-card__icon">
|
||||
<BellOutlined />
|
||||
</div>
|
||||
|
||||
<section class="system-message-card__main">
|
||||
<div v-if="badge || auxiliaryBadge" class="system-message-card__badges">
|
||||
<span v-if="auxiliaryBadge" class="system-message-card__badge system-message-card__badge--soft">{{ auxiliaryBadge }}</span>
|
||||
<span v-if="badge" class="system-message-card__badge">{{ badge }}</span>
|
||||
</div>
|
||||
|
||||
<h2 class="system-message-card__title">{{ displayTitle }}</h2>
|
||||
|
||||
<div v-if="meta" class="system-message-card__meta">
|
||||
<ClockCircleOutlined />
|
||||
<span>{{ meta }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="displayContentHtml" class="system-message-card__content" v-html="displayContentHtml"></div>
|
||||
</section>
|
||||
|
||||
<footer v-if="$slots.footer" class="system-message-card__footer">
|
||||
<slot name="footer" />
|
||||
</footer>
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.system-message-card {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--theme-border);
|
||||
border-radius: 8px;
|
||||
background: var(--theme-card-bg);
|
||||
}
|
||||
|
||||
.system-message-card--preview {
|
||||
box-shadow: 0 20px 54px rgba(77, 50, 62, 0.16);
|
||||
}
|
||||
|
||||
.system-message-card--modal {
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.system-message-card__media {
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 9;
|
||||
padding: 12px 12px 0;
|
||||
background: var(--theme-gradient-soft);
|
||||
}
|
||||
|
||||
.system-message-card__media img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.system-message-card__icon {
|
||||
display: grid;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
margin: 28px auto 0;
|
||||
place-items: center;
|
||||
border-radius: 8px;
|
||||
color: #ffffff;
|
||||
font-size: 20px;
|
||||
background: var(--theme-gradient);
|
||||
box-shadow: var(--theme-button-shadow);
|
||||
}
|
||||
|
||||
.system-message-card__main {
|
||||
padding: 20px 30px 28px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.system-message-card--with-image .system-message-card__main {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.system-message-card__badges {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
justify-content: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.system-message-card__badge {
|
||||
display: inline-flex;
|
||||
min-height: 24px;
|
||||
align-items: center;
|
||||
padding: 0 10px;
|
||||
border-radius: 8px;
|
||||
color: #ffffff;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
background: var(--theme-gradient);
|
||||
}
|
||||
|
||||
.system-message-card__badge--soft {
|
||||
color: var(--theme-primary);
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.system-message-card__title {
|
||||
margin: 0;
|
||||
color: var(--text-primary);
|
||||
font-size: 19px;
|
||||
font-weight: 800;
|
||||
line-height: 1.35;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.system-message-card__meta {
|
||||
display: inline-flex;
|
||||
max-width: 100%;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 10px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.system-message-card__content {
|
||||
margin: 20px 0 0;
|
||||
color: var(--text-primary);
|
||||
font-size: 15px;
|
||||
line-height: 1.75;
|
||||
text-align: left;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.system-message-card__content :deep(*) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.system-message-card__content :deep(p),
|
||||
.system-message-card__content :deep(ul),
|
||||
.system-message-card__content :deep(ol),
|
||||
.system-message-card__content :deep(blockquote),
|
||||
.system-message-card__content :deep(pre),
|
||||
.system-message-card__content :deep(table) {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.system-message-card__content :deep(p:last-child),
|
||||
.system-message-card__content :deep(ul:last-child),
|
||||
.system-message-card__content :deep(ol:last-child),
|
||||
.system-message-card__content :deep(blockquote:last-child),
|
||||
.system-message-card__content :deep(pre:last-child),
|
||||
.system-message-card__content :deep(table:last-child) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.system-message-card__content :deep(ul),
|
||||
.system-message-card__content :deep(ol) {
|
||||
padding-left: 1.25em;
|
||||
}
|
||||
|
||||
.system-message-card__content :deep(a) {
|
||||
color: var(--theme-primary);
|
||||
}
|
||||
|
||||
.system-message-card__content :deep(img) {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.system-message-card__content :deep(pre) {
|
||||
overflow-x: auto;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.system-message-card__footer {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 18px 30px;
|
||||
border-top: 1px solid var(--theme-border);
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
background: var(--theme-card-bg);
|
||||
}
|
||||
|
||||
.system-message-card--footer-end .system-message-card__footer {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.system-message-card {
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.system-message-card__main,
|
||||
.system-message-card__footer {
|
||||
padding-left: 22px;
|
||||
padding-right: 22px;
|
||||
}
|
||||
|
||||
.system-message-card__title {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.system-message-card__footer {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<span v-if="!displayText" class="empty-text">{{ emptyText }}</span>
|
||||
<a-tooltip v-else :title="displayText" placement="topLeft">
|
||||
<div class="ellipsis-text" :class="lineClass">
|
||||
{{ displayText }}
|
||||
</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* TableEllipsisText 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 } from 'vue'
|
||||
|
||||
/**
|
||||
* Purpose: props supports TableEllipsisText.vue by holding or executing the props 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.
|
||||
*/
|
||||
const props = withDefaults(defineProps<{
|
||||
text?: string | number | null
|
||||
lines?: 1 | 2 | 3
|
||||
emptyText?: string
|
||||
}>(), {
|
||||
lines: 1,
|
||||
emptyText: '--'
|
||||
})
|
||||
|
||||
/** displayText is a reactive state variable used by the template and event handlers. */
|
||||
const displayText = computed(() => {
|
||||
if (props.text === undefined || props.text === null) {
|
||||
return ''
|
||||
}
|
||||
const value = String(props.text).trim()
|
||||
return value
|
||||
})
|
||||
|
||||
/** lineClass is a reactive state variable used by the template and event handlers. */
|
||||
const lineClass = computed(() => {
|
||||
return props.lines > 1 ? `lines-${props.lines}` : ''
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.ellipsis-text {
|
||||
display: inline-block;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
line-height: 1.5;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.lines-2,
|
||||
.lines-3 {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
white-space: normal;
|
||||
word-break: normal;
|
||||
overflow-wrap: normal;
|
||||
}
|
||||
|
||||
.lines-2 {
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
.lines-3 {
|
||||
-webkit-line-clamp: 3;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,120 @@
|
||||
<script setup lang="ts">
|
||||
import { shallowRef } from 'vue'
|
||||
import { DownOutlined, FilterOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
activeCount?: number
|
||||
label?: string
|
||||
}>(), {
|
||||
activeCount: 0,
|
||||
label: '筛选'
|
||||
})
|
||||
|
||||
const filtersOpen = shallowRef(false)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="admin-filter-panel">
|
||||
<div class="mobile-filter-toggle">
|
||||
<button
|
||||
class="mobile-filter-toggle__button"
|
||||
type="button"
|
||||
:aria-expanded="filtersOpen"
|
||||
@click="filtersOpen = !filtersOpen"
|
||||
>
|
||||
<FilterOutlined />
|
||||
<span>{{ props.activeCount ? `${props.label} ${props.activeCount}` : props.label }}</span>
|
||||
<DownOutlined class="mobile-filter-toggle__chevron" :class="{ 'is-open': filtersOpen }" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="admin-filter-bar admin-filter-bar--mobile"
|
||||
:class="{ 'admin-filter-bar--collapsed': !filtersOpen }"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.admin-filter-panel {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.admin-filter-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.mobile-filter-toggle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.admin-filter-panel {
|
||||
gap: 8px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.mobile-filter-toggle {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.mobile-filter-toggle__button {
|
||||
width: 100%;
|
||||
min-height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid var(--admin-mobile-border);
|
||||
border-radius: 12px;
|
||||
background: var(--theme-card-bg);
|
||||
color: var(--admin-mobile-ink);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.mobile-filter-toggle__chevron {
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.mobile-filter-toggle__chevron.is-open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.admin-filter-bar--mobile {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
max-height: 560px;
|
||||
overflow: hidden;
|
||||
opacity: 1;
|
||||
transition: max-height 0.22s ease, opacity 0.18s ease;
|
||||
}
|
||||
|
||||
.admin-filter-bar--mobile.admin-filter-bar--collapsed {
|
||||
max-height: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.admin-filter-bar--mobile :deep(.ant-input),
|
||||
.admin-filter-bar--mobile :deep(.ant-input-affix-wrapper),
|
||||
.admin-filter-bar--mobile :deep(.ant-input-number),
|
||||
.admin-filter-bar--mobile :deep(.ant-picker),
|
||||
.admin-filter-bar--mobile :deep(.ant-select),
|
||||
.admin-filter-bar--mobile :deep(.ant-btn) {
|
||||
width: 100% !important;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.admin-filter-bar--mobile :deep(.ant-picker) {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<div class="admin-mobile-card-list">
|
||||
<template v-if="items.length">
|
||||
<slot
|
||||
v-for="(item, index) in items"
|
||||
:key="resolveItemKey(item, index)"
|
||||
name="item"
|
||||
:item="item"
|
||||
:index="index"
|
||||
/>
|
||||
</template>
|
||||
<a-empty v-else :description="emptyDescription" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* AdminMobileCardList page script.
|
||||
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
||||
*/
|
||||
const props = withDefaults(defineProps<{
|
||||
items?: any[]
|
||||
emptyDescription?: string
|
||||
itemKey?: string
|
||||
}>(), {
|
||||
items: () => [],
|
||||
emptyDescription: '暂无数据',
|
||||
itemKey: 'id'
|
||||
})
|
||||
|
||||
/** resolveItemKey is a local helper used by this page script. */
|
||||
const resolveItemKey = (item: Record<string, any> | undefined, index: number) => {
|
||||
if (item && props.itemKey in item && item[props.itemKey] !== undefined) {
|
||||
return item[props.itemKey]
|
||||
}
|
||||
return index
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<button
|
||||
v-if="visible"
|
||||
class="admin-mobile-fab"
|
||||
type="button"
|
||||
:aria-label="label"
|
||||
:title="label"
|
||||
@click="$emit('click')"
|
||||
>
|
||||
<PlusOutlined />
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* AdminMobileFab 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 { PlusOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
withDefaults(defineProps<{
|
||||
visible?: boolean
|
||||
label?: string
|
||||
}>(), {
|
||||
visible: false,
|
||||
label: '新增'
|
||||
})
|
||||
|
||||
defineEmits<{
|
||||
(event: 'click'): void
|
||||
}>()
|
||||
</script>
|
||||
@@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<a-modal
|
||||
v-bind="$attrs"
|
||||
:open="open"
|
||||
:title="title"
|
||||
:width="mergedWidth"
|
||||
:mask-closable="false"
|
||||
:centered="!isMobile"
|
||||
:wrap-class-name="mergedWrapClassName"
|
||||
:style="mergedStyle"
|
||||
:body-style="mergedBodyStyle"
|
||||
@update:open="handleOpenChange"
|
||||
@cancel="handleCancel"
|
||||
@ok="handleOk"
|
||||
>
|
||||
<slot />
|
||||
<template v-if="$slots.footer" #footer>
|
||||
<slot name="footer" />
|
||||
</template>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* AdminResponsiveModal 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 type { CSSProperties } from 'vue'
|
||||
import { computed, useAttrs } from 'vue'
|
||||
import { useAdminViewport } from '@/composables/useAdminViewport'
|
||||
import { CONFIRM_ENTER_DISABLED_CLASS } from '@/composables/useConfirmEnter'
|
||||
|
||||
/**
|
||||
* Purpose: modalInstanceSeed supports AdminResponsiveModal.vue by holding or executing the modal instance seed page or API role.
|
||||
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
let modalInstanceSeed = 0
|
||||
|
||||
/**
|
||||
* Purpose: props supports AdminResponsiveModal.vue by holding or executing the props 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.
|
||||
*/
|
||||
const props = withDefaults(defineProps<{
|
||||
open: boolean
|
||||
title?: string
|
||||
desktopWidth?: string | number
|
||||
mobileBodyPadding?: string
|
||||
confirmOnEnter?: boolean
|
||||
}>(), {
|
||||
title: '',
|
||||
desktopWidth: 720,
|
||||
mobileBodyPadding: '16px 16px 104px',
|
||||
confirmOnEnter: true
|
||||
})
|
||||
|
||||
/**
|
||||
* Purpose: emit supports AdminResponsiveModal.vue by holding or executing the emit 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.
|
||||
*/
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:open', value: boolean): void
|
||||
(event: 'cancel', value?: unknown): void
|
||||
(event: 'ok', value?: unknown): void
|
||||
}>()
|
||||
|
||||
const { isMobile } = useAdminViewport()
|
||||
/**
|
||||
* Purpose: attrs supports AdminResponsiveModal.vue by holding or executing the attrs 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.
|
||||
*/
|
||||
const attrs = useAttrs()
|
||||
/**
|
||||
* Purpose: modalInstanceClass supports AdminResponsiveModal.vue by holding or executing the modal instance class 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.
|
||||
*/
|
||||
const modalInstanceClass = `admin-responsive-modal-${modalInstanceSeed++}`
|
||||
|
||||
/** mergedWidth is a reactive state variable used by the template and event handlers. */
|
||||
const mergedWidth = computed(() => (isMobile.value ? '100dvw' : props.desktopWidth))
|
||||
/** mergedStyle is a reactive state variable used by the template and event handlers. */
|
||||
const mergedStyle = computed(() => (
|
||||
isMobile.value
|
||||
? {
|
||||
top: '0px',
|
||||
maxWidth: '100dvw',
|
||||
paddingBottom: '0px'
|
||||
}
|
||||
: undefined
|
||||
))
|
||||
/**
|
||||
* Purpose: mergedWrapClassName supports AdminResponsiveModal.vue by holding or executing the merged wrap class name 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.
|
||||
*/
|
||||
const mergedWrapClassName = computed(() => (
|
||||
[
|
||||
attrs.wrapClassName || attrs['wrap-class-name'],
|
||||
isMobile.value ? 'admin-mobile-modal' : '',
|
||||
props.confirmOnEnter ? '' : CONFIRM_ENTER_DISABLED_CLASS,
|
||||
modalInstanceClass
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
))
|
||||
/** mergedBodyStyle is a reactive state variable used by the template and event handlers. */
|
||||
const mergedBodyStyle = computed(() => (
|
||||
isMobile.value
|
||||
? ({
|
||||
maxHeight: 'calc(100vh - 124px)',
|
||||
overflowY: 'auto',
|
||||
padding: props.mobileBodyPadding
|
||||
} as CSSProperties)
|
||||
: undefined
|
||||
))
|
||||
|
||||
/** handleOpenChange is a local helper used by this page script. */
|
||||
const handleOpenChange = (value: boolean) => {
|
||||
emit('update:open', value)
|
||||
}
|
||||
|
||||
/** handleCancel is a local helper used by this page script. */
|
||||
const handleCancel = (event?: unknown) => {
|
||||
emit('update:open', false)
|
||||
emit('cancel', event)
|
||||
}
|
||||
|
||||
/** handleOk is a local helper used by this page script. */
|
||||
const handleOk = (event?: unknown) => {
|
||||
emit('ok', event)
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user