feat 搭建架构骨架

This commit is contained in:
Ironsp
2026-09-24 09:09:47 +08:00
parent dd9f6b77a4
commit 7a2efa3fea
180 changed files with 18967 additions and 9 deletions

View File

@@ -0,0 +1,106 @@
<script setup lang="ts">
import type { Message, MessageType } from '@/types/business/message'
interface Props {
message: Message
}
defineProps<Props>()
const emit = defineEmits<{ view: [id: string] }>()
const emojiMap: Record<MessageType, string> = {
在线客服: '💬',
状态通知: '📢',
系统通知: '🔔',
}
</script>
<template>
<div
class="message-item"
:class="{ 'is-unread': !message.isRead }"
role="button"
tabindex="0"
@click="emit('view', message.id)"
@keydown.enter="emit('view', message.id)"
>
<span class="message-item__emoji">{{ emojiMap[message.type] }}</span>
<div class="message-item__body">
<div class="message-item__head">
<span class="message-item__title">{{ message.title }}</span>
<span class="message-item__time text-secondary">{{ message.publishTime }}</span>
</div>
<p class="message-item__summary text-secondary">
{{ message.summary }}
</p>
</div>
<span v-if="!message.isRead" class="message-item__dot" aria-label="未读" />
</div>
</template>
<style lang="less" scoped>
.message-item {
.flex(row, flex-start);
gap: @spacing-base;
padding: @spacing-base;
border-radius: @radius-base;
background: @white;
cursor: pointer;
transition: background 0.2s;
&:hover {
background: @bg-color-light;
}
&__emoji {
flex-shrink: 0;
font-size: @font-size-xl;
line-height: 1.4;
}
&__body {
.flex(column, flex-start);
gap: @spacing-xs;
flex: 1;
min-width: 0;
}
&__head {
.flex(row, space-between);
gap: @spacing-base;
width: 100%;
}
&__title {
font-size: @font-size-lg;
color: @heading-color;
.ellipsis();
}
&__time {
flex-shrink: 0;
font-size: @font-size-sm;
}
&__summary {
font-size: @font-size-base;
.ellipsis();
}
&__dot {
flex-shrink: 0;
align-self: center;
width: 8px;
height: 8px;
border-radius: @radius-round;
background: @danger-color;
}
&.is-unread {
.message-item__title {
font-weight: 600;
}
}
}
</style>

View File

@@ -0,0 +1,44 @@
<script setup lang="ts">
import type { Message } from '@/types/business/message'
import MessageItem from './MessageItem.vue'
interface Props {
messages: Message[]
}
defineProps<Props>()
const emit = defineEmits<{ view: [id: string] }>()
</script>
<template>
<div class="message-list">
<template v-if="messages.length > 0">
<MessageItem
v-for="item in messages"
:key="item.id"
:message="item"
@view="emit('view', $event)"
/>
</template>
<p v-else class="message-list__empty text-secondary">
暂无消息
</p>
</div>
</template>
<style lang="less" scoped>
.message-list {
.flex(column, flex-start);
gap: @spacing-sm;
padding: @spacing-sm;
border-radius: @radius-lg;
background: @bg-color;
&__empty {
padding: @spacing-xxl 0;
text-align: center;
font-size: @font-size-base;
}
}
</style>

View File

@@ -0,0 +1,95 @@
<script setup lang="ts">
import type { MessageType } from '@/types/business/message'
interface Counts {
all: number
在线客服: number
状态通知: number
系统通知: number
}
interface Props {
active: MessageType | 'all'
counts: Counts
}
defineProps<Props>()
const emit = defineEmits<{ tabChange: [type: MessageType | 'all'] }>()
const tabs: Array<{ label: string; value: MessageType | 'all' }> = [
{ label: '全部', value: 'all' },
{ label: '在线客服', value: '在线客服' },
{ label: '状态通知', value: '状态通知' },
{ label: '系统通知', value: '系统通知' },
]
function countOf(value: MessageType | 'all', counts: Counts): number {
return counts[value]
}
</script>
<template>
<div class="message-tabs">
<button
v-for="tab in tabs"
:key="tab.value"
class="message-tabs__tab"
:class="{ 'is-active': active === tab.value }"
@click="emit('tabChange', tab.value)"
>
{{ tab.label }}
<span class="message-tabs__count">{{ countOf(tab.value, counts) }}</span>
</button>
</div>
</template>
<style lang="less" scoped>
.message-tabs {
.flex(row, flex-start);
gap: @spacing-sm;
padding: @spacing-sm @spacing-base;
border-radius: @radius-lg;
background: @white;
box-shadow: @shadow-base;
&__tab {
.flex(row, center);
gap: @spacing-xs;
height: 32px;
padding: 0 @spacing-base;
border-radius: @radius-round;
background: transparent;
color: @text-color;
font-size: @font-size-base;
transition: all 0.2s;
&:hover {
color: @primary-color;
}
&.is-active {
background: @primary-light;
color: @primary-color;
font-weight: 600;
}
}
&__count {
min-width: 18px;
height: 18px;
padding: 0 5px;
border-radius: @radius-round;
background: @bg-color;
color: @text-color-secondary;
font-size: @font-size-sm;
line-height: 18px;
text-align: center;
}
.is-active &__count {
background: @primary-color;
color: @white;
}
}
</style>