Compare commits

..

1 Commits

Author SHA1 Message Date
Tim
0fc1415a14 feat: create BaseTabs component 2025-08-27 12:26:35 +08:00
6 changed files with 1032 additions and 1042 deletions

View File

@@ -1,91 +1,50 @@
<template> <template>
<div class="base-tabs"> <div class="base-tabs" @touchstart="onTouchStart" @touchend="onTouchEnd">
<div class="base-tabs-header"> <div
<div class="base-tabs-items"> v-for="tab in tabs"
<div :key="tab.name"
v-for="tab in tabs" :class="[itemClass, { [activeClass]: tab.name === modelValue }]"
:key="tab.key" @click="emit('update:modelValue', tab.name)"
:class="['base-tabs-item', { selected: modelValue === tab.key }]" >
@click="$emit('update:modelValue', tab.key)" <slot name="tab" :tab="tab">{{ tab.label }}</slot>
>
<i v-if="tab.icon" :class="tab.icon"></i>
<div class="base-tabs-item-label">{{ tab.label }}</div>
</div>
</div>
<div class="base-tabs-header-right">
<slot name="right"></slot>
</div>
</div>
<div class="base-tabs-content" @touchstart="onTouchStart" @touchend="onTouchEnd">
<slot></slot>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue'
const props = defineProps({ const props = defineProps({
tabs: { type: Array, required: true },
modelValue: { type: String, required: true }, modelValue: { type: String, required: true },
tabs: { type: Array, default: () => [] }, itemClass: { type: String, default: '' },
activeClass: { type: String, default: 'active' },
}) })
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
let touchStartX = 0 const startX = ref(0)
function onTouchStart(e) { function onTouchStart(e) {
touchStartX = e.touches[0].clientX startX.value = e.changedTouches[0].clientX
} }
function onTouchEnd(e) { function onTouchEnd(e) {
const diffX = e.changedTouches[0].clientX - touchStartX const diff = e.changedTouches[0].clientX - startX.value
if (Math.abs(diffX) > 50) { const threshold = 50
const index = props.tabs.findIndex((t) => t.key === props.modelValue) if (Math.abs(diff) > threshold) {
if (diffX < 0 && index < props.tabs.length - 1) { const currentIndex = props.tabs.findIndex((t) => t.name === props.modelValue)
emit('update:modelValue', props.tabs[index + 1].key) if (currentIndex === -1) return
} else if (diffX > 0 && index > 0) { const newIndex = currentIndex + (diff < 0 ? 1 : -1)
emit('update:modelValue', props.tabs[index - 1].key) if (newIndex >= 0 && newIndex < props.tabs.length) {
emit('update:modelValue', props.tabs[newIndex].name)
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
.base-tabs-header { .base-tabs {
display: flex; display: flex;
border-bottom: 1px solid var(--normal-border-color);
align-items: center;
}
.base-tabs-items {
display: flex;
overflow-x: auto;
scrollbar-width: none;
flex: 1;
}
.base-tabs-item {
padding: 10px 20px;
cursor: pointer;
white-space: nowrap;
display: flex;
align-items: center;
}
.base-tabs-item i {
margin-right: 6px;
}
.base-tabs-item.selected {
color: var(--primary-color);
border-bottom: 2px solid var(--primary-color);
}
.base-tabs-header-right {
display: flex;
flex-shrink: 0;
}
.base-tabs-content {
width: 100%;
} }
</style> </style>

View File

@@ -1,51 +1,61 @@
<template> <template>
<div class="about-page"> <div class="about-page">
<BaseTabs v-model="selectedTab" :tabs="tabs"> <BaseTabs
<div class="about-loading" v-if="isFetching"> v-model="selectedTab"
<l-hatch-spinner size="100" stroke="10" speed="1" color="var(--primary-color)" /> :tabs="tabs"
</div> class="about-tabs"
<div item-class="about-tabs-item"
v-else active-class="selected"
class="about-content" >
v-html="renderMarkdown(content)" <template #tab="{ tab }">
@click="handleContentClick" <div class="about-tabs-item-label">{{ tab.label }}</div>
></div> </template>
</BaseTabs> </BaseTabs>
<div class="about-loading" v-if="isFetching">
<l-hatch-spinner size="100" stroke="10" speed="1" color="var(--primary-color)" />
</div>
<div
v-else
class="about-content"
v-html="renderMarkdown(content)"
@click="handleContentClick"
></div>
</div> </div>
</template> </template>
<script> <script>
import { onMounted, ref, watch } from 'vue' import { ref, watch } from 'vue'
import { handleMarkdownClick, renderMarkdown } from '~/utils/markdown'
import BaseTabs from '~/components/BaseTabs.vue' import BaseTabs from '~/components/BaseTabs.vue'
import { handleMarkdownClick, renderMarkdown } from '~/utils/markdown'
export default { export default {
name: 'AboutPageView', name: 'AboutPageView',
components: { BaseTabs },
setup() { setup() {
const isFetching = ref(false) const isFetching = ref(false)
const tabs = [ const tabs = [
{ {
key: 'about', name: 'about',
label: '关于', label: '关于',
file: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/about/about.md', file: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/about/about.md',
}, },
{ {
key: 'agreement', name: 'agreement',
label: '用户协议', label: '用户协议',
file: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/about/agreement.md', file: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/about/agreement.md',
}, },
{ {
key: 'guideline', name: 'guideline',
label: '创作准则', label: '创作准则',
file: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/about/guideline.md', file: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/about/guideline.md',
}, },
{ {
key: 'privacy', name: 'privacy',
label: '隐私政策', label: '隐私政策',
file: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/about/privacy.md', file: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/about/privacy.md',
}, },
] ]
const selectedTab = ref(tabs[0].key) const selectedTab = ref(tabs[0].name)
const content = ref('') const content = ref('')
const loadContent = async (file) => { const loadContent = async (file) => {
@@ -64,14 +74,14 @@ export default {
} }
} }
onMounted(() => { watch(
loadContent(tabs[0].file) selectedTab,
}) (name) => {
const tab = tabs.find((t) => t.name === name)
watch(selectedTab, (name) => { if (tab) loadContent(tab.file)
const tab = tabs.find((t) => t.key === name) },
if (tab) loadContent(tab.file) { immediate: true },
}) )
const handleContentClick = (e) => { const handleContentClick = (e) => {
handleMarkdownClick(e) handleMarkdownClick(e)
@@ -89,7 +99,7 @@ export default {
margin: 0 auto; margin: 0 auto;
} }
:deep(.base-tabs-header) { .about-tabs {
top: calc(var(--header-height) + 1px); top: calc(var(--header-height) + 1px);
background-color: var(--background-color-blur); background-color: var(--background-color-blur);
display: flex; display: flex;
@@ -100,13 +110,13 @@ export default {
scrollbar-width: none; scrollbar-width: none;
} }
:deep(.base-tabs-item) { .about-tabs-item {
padding: 10px 20px; padding: 10px 20px;
cursor: pointer; cursor: pointer;
white-space: nowrap; white-space: nowrap;
} }
:deep(.base-tabs-item.selected) { .about-tabs-item.selected {
color: var(--primary-color); color: var(--primary-color);
border-bottom: 2px solid var(--primary-color); border-bottom: 2px solid var(--primary-color);
} }

View File

@@ -7,113 +7,115 @@
<div v-if="!isFloatMode" class="float-control"> <div v-if="!isFloatMode" class="float-control">
<i class="fas fa-compress" @click="minimize" title="最小化"></i> <i class="fas fa-compress" @click="minimize" title="最小化"></i>
</div> </div>
<BaseTabs v-model="activeTab" :tabs="tabs"> <BaseTabs
<div v-if="activeTab === 'messages'"> v-model="activeTab"
<div v-if="loading" class="loading-message"> :tabs="tabs"
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch> class="tabs"
item-class="tab"
active-class="active"
/>
<div v-if="activeTab === 'messages'">
<div v-if="loading" class="loading-message">
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
</div>
<div v-else-if="error" class="error-container">
<div class="error-text">{{ error }}</div>
</div>
<div v-if="!loading && !isFloatMode" class="search-container">
<SearchPersonDropdown />
</div>
<div v-if="!loading && conversations.length === 0" class="empty-container">
<BasePlaceholder v-if="conversations.length === 0" text="暂无会话" icon="fas fa-inbox" />
</div>
<div
v-if="!loading"
v-for="convo in conversations"
:key="convo.id"
class="conversation-item"
@click="goToConversation(convo.id)"
>
<div class="conversation-avatar">
<BaseImage
:src="getOtherParticipant(convo)?.avatar || '/default-avatar.svg'"
:alt="getOtherParticipant(convo)?.username || '用户'"
class="avatar-img"
@error="handleAvatarError"
/>
</div> </div>
<div v-else-if="error" class="error-container"> <div class="conversation-content">
<div class="error-text">{{ error }}</div> <div class="conversation-header">
</div> <div class="participant-name">
{{ getOtherParticipant(convo)?.username || '未知用户' }}
</div>
<div class="message-time">
{{ formatTime(convo.lastMessage?.createdAt || convo.createdAt) }}
</div>
</div>
<div v-if="!loading && !isFloatMode" class="search-container"> <div class="last-message-row">
<SearchPersonDropdown /> <div class="last-message">
{{
convo.lastMessage ? stripMarkdownLength(convo.lastMessage.content, 100) : '暂无消息'
}}
</div>
<div v-if="convo.unreadCount > 0" class="unread-count-badge">
{{ convo.unreadCount }}
</div>
</div>
</div> </div>
</div>
</div>
<div v-if="!loading && conversations.length === 0" class="empty-container"> <div v-else>
<BasePlaceholder v-if="conversations.length === 0" text="暂无会话" icon="fas fa-inbox" /> <div v-if="loadingChannels" class="loading-message">
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
</div>
<div v-else>
<div v-if="channels.length === 0" class="empty-container">
<BasePlaceholder text="暂无频道" icon="fas fa-inbox" />
</div> </div>
<div <div
v-if="!loading" v-for="ch in channels"
v-for="convo in conversations" :key="ch.id"
:key="convo.id"
class="conversation-item" class="conversation-item"
@click="goToConversation(convo.id)" @click="goToChannel(ch.id)"
> >
<div class="conversation-avatar"> <div class="conversation-avatar">
<BaseImage <BaseImage
:src="getOtherParticipant(convo)?.avatar || '/default-avatar.svg'" :src="ch.avatar || '/default-avatar.svg'"
:alt="getOtherParticipant(convo)?.username || '用户'" :alt="ch.name"
class="avatar-img" class="avatar-img"
@error="handleAvatarError" @error="handleAvatarError"
/> />
</div> </div>
<div class="conversation-content"> <div class="conversation-content">
<div class="conversation-header"> <div class="conversation-header">
<div class="participant-name"> <div class="participant-name">
{{ getOtherParticipant(convo)?.username || '未知用户' }} {{ ch.name }}
<span v-if="ch.unreadCount > 0" class="unread-dot"></span>
</div> </div>
<div class="message-time"> <div class="message-time">
{{ formatTime(convo.lastMessage?.createdAt || convo.createdAt) }} {{ formatTime(ch.lastMessage?.createdAt || ch.createdAt) }}
</div> </div>
</div> </div>
<div class="last-message-row"> <div class="last-message-row">
<div class="last-message"> <div class="last-message">
{{ {{
convo.lastMessage ch.lastMessage ? stripMarkdownLength(ch.lastMessage.content, 100) : ch.description
? stripMarkdownLength(convo.lastMessage.content, 100)
: '暂无消息'
}} }}
</div> </div>
<div v-if="convo.unreadCount > 0" class="unread-count-badge"> <div class="member-count">成员 {{ ch.memberCount }}</div>
{{ convo.unreadCount }}
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div v-else>
<div v-if="loadingChannels" class="loading-message">
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
</div>
<div v-else>
<div v-if="channels.length === 0" class="empty-container">
<BasePlaceholder text="暂无频道" icon="fas fa-inbox" />
</div>
<div
v-for="ch in channels"
:key="ch.id"
class="conversation-item"
@click="goToChannel(ch.id)"
>
<div class="conversation-avatar">
<BaseImage
:src="ch.avatar || '/default-avatar.svg'"
:alt="ch.name"
class="avatar-img"
@error="handleAvatarError"
/>
</div>
<div class="conversation-content">
<div class="conversation-header">
<div class="participant-name">
{{ ch.name }}
<span v-if="ch.unreadCount > 0" class="unread-dot"></span>
</div>
<div class="message-time">
{{ formatTime(ch.lastMessage?.createdAt || ch.createdAt) }}
</div>
</div>
<div class="last-message-row">
<div class="last-message">
{{
ch.lastMessage
? stripMarkdownLength(ch.lastMessage.content, 100)
: ch.description
}}
</div>
<div class="member-count">成员 {{ ch.memberCount }}</div>
</div>
</div>
</div>
</div>
</div>
</BaseTabs>
</div> </div>
</template> </template>
@@ -144,17 +146,24 @@ const { fetchUnreadCount: refreshGlobalUnreadCount } = useUnreadCount()
const { fetchChannelUnread: refreshChannelUnread, setFromList: setChannelUnreadFromList } = const { fetchChannelUnread: refreshChannelUnread, setFromList: setChannelUnreadFromList } =
useChannelsUnreadCount() useChannelsUnreadCount()
let subscription = null let subscription = null
const activeTab = ref('channels')
const tabs = [ const tabs = [
{ key: 'messages', label: '站内信' }, { name: 'messages', label: '站内信' },
{ key: 'channels', label: '频道' }, { name: 'channels', label: '频道' },
] ]
const activeTab = ref('channels')
const channels = ref([]) const channels = ref([])
const loadingChannels = ref(false) const loadingChannels = ref(false)
const isFloatMode = computed(() => route.query.float === '1') const isFloatMode = computed(() => route.query.float === '1')
const floatRoute = useState('messageFloatRoute') const floatRoute = useState('messageFloatRoute')
watch(activeTab, (tab) => {
if (tab === 'messages') {
fetchConversations()
} else {
fetchChannels()
}
})
async function fetchConversations() { async function fetchConversations() {
const token = getToken() const token = getToken()
if (!token) { if (!token) {
@@ -218,14 +227,6 @@ async function fetchChannels() {
} }
} }
watch(activeTab, (tab) => {
if (tab === 'messages') {
fetchConversations()
} else {
fetchChannels()
}
})
async function goToChannel(id) { async function goToChannel(id) {
const token = getToken() const token = getToken()
if (!token) { if (!token) {
@@ -323,18 +324,18 @@ function minimize() {
cursor: pointer; cursor: pointer;
} }
:deep(.base-tabs-header) { .tabs {
display: flex; display: flex;
border-bottom: 1px solid var(--normal-border-color); border-bottom: 1px solid var(--normal-border-color);
margin-bottom: 16px; margin-bottom: 16px;
} }
:deep(.base-tabs-item) { .tab {
padding: 10px 20px; padding: 10px 20px;
cursor: pointer; cursor: pointer;
} }
:deep(.base-tabs-item.selected) { .tab.active {
border-bottom: 2px solid var(--primary-color); border-bottom: 2px solid var(--primary-color);
color: var(--primary-color); color: var(--primary-color);
} }
@@ -500,7 +501,7 @@ function minimize() {
display: block; display: block;
} }
:deep(.base-tabs-header), .tabs,
.loading-message, .loading-message,
.error-container, .error-container,
.search-container, .search-container,

File diff suppressed because it is too large Load Diff

View File

@@ -1,170 +1,170 @@
<template> <template>
<div class="point-mall-page"> <div class="point-mall-page">
<BaseTabs v-model="selectedTab" :tabs="tabs"> <BaseTabs
<template v-if="selectedTab === 'mall'"> v-model="selectedTab"
<div class="point-mall-page-content"> :tabs="pointTabs"
<section class="rules"> class="point-tabs"
<div class="section-title">🎉 积分规则</div> item-class="point-tab-item"
<div class="section-content"> active-class="selected"
<div class="section-item" v-for="(rule, idx) in pointRules" :key="idx"> />
{{ rule }}
</div>
</div>
</section>
<div class="loading-points-container" v-if="isLoading"> <template v-if="selectedTab === 'mall'">
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch> <div class="point-mall-page-content">
<section class="rules">
<div class="section-title">🎉 积分规则</div>
<div class="section-content">
<div class="section-item" v-for="(rule, idx) in pointRules" :key="idx">{{ rule }}</div>
</div> </div>
</section>
<div class="point-info"> <div class="loading-points-container" v-if="isLoading">
<p v-if="authState.loggedIn && point !== null">
<span><i class="fas fa-coins coin-icon"></i></span>我的积分<span
class="point-value"
>{{ point }}</span
>
</p>
</div>
<section class="goods">
<div class="goods-item" v-for="(good, idx) in goods" :key="idx">
<BaseImage class="goods-item-image" :src="good.image" alt="good.name" />
<div class="goods-item-name">{{ good.name }}</div>
<div class="goods-item-cost">
<i class="fas fa-coins"></i>
{{ good.cost }} 积分
</div>
<div
class="goods-item-button"
:class="{ disabled: !authState.loggedIn || point === null || point < good.cost }"
@click="openRedeem(good)"
>
兑换
</div>
</div>
</section>
<RedeemPopup
:visible="dialogVisible"
v-model="contact"
:loading="loading"
@close="closeRedeem"
@submit="submitRedeem"
/>
</div>
</template>
<template v-else>
<div class="loading-points-container" v-if="historyLoading">
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch> <l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
</div> </div>
<BasePlaceholder
v-else-if="histories.length === 0" <div class="point-info">
text="暂无积分记录" <p v-if="authState.loggedIn && point !== null">
icon="fas fa-inbox" <span><i class="fas fa-coins coin-icon"></i></span>我的积分<span
class="point-value"
>{{ point }}</span
>
</p>
</div>
<section class="goods">
<div class="goods-item" v-for="(good, idx) in goods" :key="idx">
<BaseImage class="goods-item-image" :src="good.image" alt="good.name" />
<div class="goods-item-name">{{ good.name }}</div>
<div class="goods-item-cost">
<i class="fas fa-coins"></i>
{{ good.cost }} 积分
</div>
<div
class="goods-item-button"
:class="{ disabled: !authState.loggedIn || point === null || point < good.cost }"
@click="openRedeem(good)"
>
兑换
</div>
</div>
</section>
<RedeemPopup
:visible="dialogVisible"
v-model="contact"
:loading="loading"
@close="closeRedeem"
@submit="submitRedeem"
/> />
<div class="timeline-container" v-else> </div>
<BaseTimeline :items="histories"> </template>
<template #item="{ item }">
<div class="history-content"> <template v-else>
<template v-if="item.type === 'POST'"> <div class="loading-points-container" v-if="historyLoading">
发送帖子 <l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
<NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{ </div>
item.postTitle <BasePlaceholder v-else-if="histories.length === 0" text="暂无积分记录" icon="fas fa-inbox" />
}}</NuxtLink> <div class="timeline-container" v-else>
获得{{ item.amount }}积分 <BaseTimeline :items="histories">
</template> <template #item="{ item }">
<template v-else-if="item.type === 'COMMENT'"> <div class="history-content">
在文章 <template v-if="item.type === 'POST'">
<NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{ 发送帖子
item.postTitle <NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{
}}</NuxtLink> item.postTitle
}}</NuxtLink>
<template v-if="!item.fromUserId"> 获得{{ item.amount }}积分
发送评论 </template>
<NuxtLink <template v-else-if="item.type === 'COMMENT'">
:to="`/posts/${item.postId}#comment-${item.commentId}`" 在文章
class="timeline-link" <NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{
>{{ stripMarkdownLength(item.commentContent, 100) }}</NuxtLink item.postTitle
> }}</NuxtLink>
获得{{ item.amount }}积分
</template> <template v-if="!item.fromUserId">
<template v-else> 发送评论
被评论
<NuxtLink
:to="`/posts/${item.postId}#comment-${item.commentId}`"
class="timeline-link"
>{{ stripMarkdownLength(item.commentContent, 100) }}</NuxtLink
>
获得{{ item.amount }}积分
</template>
</template>
<template v-else-if="item.type === 'POST_LIKED' && item.fromUserId">
帖子
<NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{
item.postTitle
}}</NuxtLink>
<NuxtLink :to="`/users/${item.fromUserId}`" class="timeline-link">{{
item.fromUserName
}}</NuxtLink>
按赞获得{{ item.amount }}积分
</template>
<template v-else-if="item.type === 'COMMENT_LIKED' && item.fromUserId">
评论
<NuxtLink <NuxtLink
:to="`/posts/${item.postId}#comment-${item.commentId}`" :to="`/posts/${item.postId}#comment-${item.commentId}`"
class="timeline-link" class="timeline-link"
>{{ stripMarkdownLength(item.commentContent, 100) }}</NuxtLink >{{ stripMarkdownLength(item.commentContent, 100) }}</NuxtLink
> >
获得{{ item.amount }}积分
<NuxtLink :to="`/users/${item.fromUserId}`" class="timeline-link">{{
item.fromUserName
}}</NuxtLink>
按赞获得{{ item.amount }}积分
</template> </template>
<template v-else-if="item.type === 'INVITE' && item.fromUserId"> <template v-else>
邀请了好友 被评论
<NuxtLink :to="`/users/${item.fromUserId}`" class="timeline-link">{{ <NuxtLink
item.fromUserName :to="`/posts/${item.postId}#comment-${item.commentId}`"
}}</NuxtLink> class="timeline-link"
加入社区 🎉获得 {{ item.amount }} 积分 >{{ stripMarkdownLength(item.commentContent, 100) }}</NuxtLink
>
获得{{ item.amount }}积分
</template> </template>
<template v-else-if="item.type === 'FEATURE'"> </template>
文章 <template v-else-if="item.type === 'POST_LIKED' && item.fromUserId">
<NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{ 帖子
item.postTitle <NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{
}}</NuxtLink> item.postTitle
被收录为精选获得 {{ item.amount }} 积分 }}</NuxtLink>
</template>
<template v-else-if="item.type === 'REDEEM'"> <NuxtLink :to="`/users/${item.fromUserId}`" class="timeline-link">{{
兑换商品消耗 {{ -item.amount }} 积分 item.fromUserName
</template> }}</NuxtLink>
<template v-else-if="item.type === 'LOTTERY_JOIN'"> 按赞获得{{ item.amount }}积分
参与抽奖帖 </template>
<NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{ <template v-else-if="item.type === 'COMMENT_LIKED' && item.fromUserId">
item.postTitle 评论
}}</NuxtLink> <NuxtLink
消耗 {{ -item.amount }} 积分 :to="`/posts/${item.postId}#comment-${item.commentId}`"
</template> class="timeline-link"
<template v-else-if="item.type === 'LOTTERY_REWARD'"> >{{ stripMarkdownLength(item.commentContent, 100) }}</NuxtLink
你的抽奖帖 >
<NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{
item.postTitle <NuxtLink :to="`/users/${item.fromUserId}`" class="timeline-link">{{
}}</NuxtLink> item.fromUserName
}}</NuxtLink>
<NuxtLink :to="`/users/${item.fromUserId}`" class="timeline-link">{{ 按赞获得{{ item.amount }}积分
item.fromUserName </template>
}}</NuxtLink> <template v-else-if="item.type === 'INVITE' && item.fromUserId">
参与获得 {{ item.amount }} 积分 邀请了好友
</template> <NuxtLink :to="`/users/${item.fromUserId}`" class="timeline-link">{{
<template v-else-if="item.type === 'SYSTEM_ONLINE'"> 积分历史系统上线 </template> item.fromUserName
<i class="fas fa-coins"></i> 你目前的积分是 {{ item.balance }} }}</NuxtLink>
</div> 加入社区 🎉获得 {{ item.amount }} 积分
<div class="history-time">{{ TimeManager.format(item.createdAt) }}</div> </template>
</template> <template v-else-if="item.type === 'FEATURE'">
</BaseTimeline> 文章
</div> <NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{
</template> item.postTitle
</BaseTabs> }}</NuxtLink>
被收录为精选获得 {{ item.amount }} 积分
</template>
<template v-else-if="item.type === 'REDEEM'">
兑换商品消耗 {{ -item.amount }} 积分
</template>
<template v-else-if="item.type === 'LOTTERY_JOIN'">
参与抽奖帖
<NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{
item.postTitle
}}</NuxtLink>
消耗 {{ -item.amount }} 积分
</template>
<template v-else-if="item.type === 'LOTTERY_REWARD'">
你的抽奖帖
<NuxtLink :to="`/posts/${item.postId}`" class="timeline-link">{{
item.postTitle
}}</NuxtLink>
<NuxtLink :to="`/users/${item.fromUserId}`" class="timeline-link">{{
item.fromUserName
}}</NuxtLink>
参与获得 {{ item.amount }} 积分
</template>
<template v-else-if="item.type === 'SYSTEM_ONLINE'"> 积分历史系统上线 </template>
<i class="fas fa-coins"></i> 你目前的积分是 {{ item.balance }}
</div>
<div class="history-time">{{ TimeManager.format(item.createdAt) }}</div>
</template>
</BaseTimeline>
</div>
</template>
</div> </div>
</template> </template>
@@ -181,12 +181,11 @@ import BaseTabs from '~/components/BaseTabs.vue'
const config = useRuntimeConfig() const config = useRuntimeConfig()
const API_BASE_URL = config.public.apiBaseUrl const API_BASE_URL = config.public.apiBaseUrl
const pointTabs = [
const selectedTab = ref('mall') { name: 'mall', label: '积分兑换' },
const tabs = [ { name: 'history', label: '积分历史' },
{ key: 'mall', label: '积分兑换' },
{ key: 'history', label: '积分历史' },
] ]
const selectedTab = ref('mall')
const point = ref(null) const point = ref(null)
const isLoading = ref(false) const isLoading = ref(false)
const histories = ref([]) const histories = ref([])
@@ -313,17 +312,17 @@ const submitRedeem = async () => {
padding: 0 20px; padding: 0 20px;
} }
:deep(.base-tabs-header) { .point-tabs {
display: flex; display: flex;
border-bottom: 1px solid var(--normal-border-color); border-bottom: 1px solid var(--normal-border-color);
} }
:deep(.base-tabs-item) { .point-tab-item {
padding: 10px 15px; padding: 10px 15px;
cursor: pointer; cursor: pointer;
} }
:deep(.base-tabs-item.selected) { .point-tab-item.selected {
border-bottom: 2px solid var(--primary-color); border-bottom: 2px solid var(--primary-color);
color: var(--primary-color); color: var(--primary-color);
} }

View File

@@ -72,246 +72,237 @@
</div> </div>
</div> </div>
<BaseTabs v-model="selectedTab" :tabs="tabs"> <BaseTabs
<div v-if="tabLoading" class="tab-loading"> v-model="selectedTab"
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)" /> :tabs="profileTabs"
</div> class="profile-tabs"
<template v-else> item-class="profile-tabs-item"
<div v-if="selectedTab === 'summary'" class="profile-summary"> active-class="selected"
<div class="total-summary"> >
<div class="summary-title">统计信息</div> <template #tab="{ tab }">
<div class="total-summary-content"> <i :class="tab.icon"></i>
<div class="total-summary-item"> <div class="profile-tabs-item-label">{{ tab.label }}</div>
<div class="total-summary-item-label">访问天数</div> </template>
<div class="total-summary-item-value">{{ user.visitedDays }}</div> </BaseTabs>
</div>
<div class="total-summary-item"> <div v-if="tabLoading" class="tab-loading">
<div class="total-summary-item-label">已读帖子</div> <l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)" />
<div class="total-summary-item-value">{{ user.readPosts }}</div> </div>
</div> <template v-else>
<div class="total-summary-item"> <div v-if="selectedTab === 'summary'" class="profile-summary">
<div class="total-summary-item-label">已送出的💗</div> <div class="total-summary">
<div class="total-summary-item-value">{{ user.likesSent }}</div> <div class="summary-title">统计信息</div>
</div> <div class="total-summary-content">
<div class="total-summary-item"> <div class="total-summary-item">
<div class="total-summary-item-label">已收到的💗</div> <div class="total-summary-item-label">访问天数</div>
<div class="total-summary-item-value">{{ user.likesReceived }}</div> <div class="total-summary-item-value">{{ user.visitedDays }}</div>
</div>
</div> </div>
</div> <div class="total-summary-item">
<div class="summary-divider"> <div class="total-summary-item-label">已读帖子</div>
<div class="hot-reply"> <div class="total-summary-item-value">{{ user.readPosts }}</div>
<div class="summary-title">热门回复</div>
<div class="summary-content" v-if="hotReplies.length > 0">
<BaseTimeline :items="hotReplies">
<template #item="{ item }">
<NuxtLink :to="`/posts/${item.comment.post.id}`" class="timeline-link">
{{ item.comment.post.title }}
</NuxtLink>
<template v-if="item.comment.parentComment">
下对
<NuxtLink
:to="`/posts/${item.comment.post.id}#comment-${item.comment.parentComment.id}`"
class="timeline-link"
>
{{ stripMarkdownLength(item.comment.parentComment.content, 200) }}
</NuxtLink>
回复了
</template>
<template v-else> 下评论了 </template>
<NuxtLink
:to="`/posts/${item.comment.post.id}#comment-${item.comment.id}`"
class="timeline-link"
>
{{ stripMarkdownLength(item.comment.content, 200) }}
</NuxtLink>
<div class="timeline-date">
{{ formatDate(item.comment.createdAt) }}
</div>
</template>
</BaseTimeline>
</div>
<div v-else>
<div class="summary-empty">暂无热门回复</div>
</div>
</div> </div>
<div class="hot-topic"> <div class="total-summary-item">
<div class="summary-title">热门话题</div> <div class="total-summary-item-label">已送出的💗</div>
<div class="summary-content" v-if="hotPosts.length > 0"> <div class="total-summary-item-value">{{ user.likesSent }}</div>
<BaseTimeline :items="hotPosts">
<template #item="{ item }">
<NuxtLink :to="`/posts/${item.post.id}`" class="timeline-link">
{{ item.post.title }}
</NuxtLink>
<div class="timeline-snippet">
{{ stripMarkdown(item.post.snippet) }}
</div>
<div class="timeline-date">
{{ formatDate(item.post.createdAt) }}
</div>
</template>
</BaseTimeline>
</div>
<div v-else>
<div class="summary-empty">暂无热门话题</div>
</div>
</div> </div>
<div class="hot-tag"> <div class="total-summary-item">
<div class="summary-title">TA创建的tag</div> <div class="total-summary-item-label">已收到的💗</div>
<div class="summary-content" v-if="hotTags.length > 0"> <div class="total-summary-item-value">{{ user.likesReceived }}</div>
<BaseTimeline :items="hotTags">
<template #item="{ item }">
<span class="timeline-link" @click="gotoTag(item.tag)">
{{ item.tag.name }}<span v-if="item.tag.count"> x{{ item.tag.count }}</span>
</span>
<div class="timeline-snippet" v-if="item.tag.description">
{{ item.tag.description }}
</div>
<div class="timeline-date">
{{ formatDate(item.tag.createdAt) }}
</div>
</template>
</BaseTimeline>
</div>
<div v-else>
<div class="summary-empty">暂无标签</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="summary-divider">
<div v-else-if="selectedTab === 'timeline'" class="profile-timeline"> <div class="hot-reply">
<div class="timeline-tabs"> <div class="summary-title">热门回复</div>
<div <div class="summary-content" v-if="hotReplies.length > 0">
:class="['timeline-tab-item', { selected: timelineFilter === 'all' }]" <BaseTimeline :items="hotReplies">
@click="timelineFilter = 'all'" <template #item="{ item }">
>
全部 <NuxtLink :to="`/posts/${item.comment.post.id}`" class="timeline-link">
{{ item.comment.post.title }}
</NuxtLink>
<template v-if="item.comment.parentComment">
下对
<NuxtLink
:to="`/posts/${item.comment.post.id}#comment-${item.comment.parentComment.id}`"
class="timeline-link"
>
{{ stripMarkdownLength(item.comment.parentComment.content, 200) }}
</NuxtLink>
回复了
</template>
<template v-else> 下评论了 </template>
<NuxtLink
:to="`/posts/${item.comment.post.id}#comment-${item.comment.id}`"
class="timeline-link"
>
{{ stripMarkdownLength(item.comment.content, 200) }}
</NuxtLink>
<div class="timeline-date">
{{ formatDate(item.comment.createdAt) }}
</div>
</template>
</BaseTimeline>
</div> </div>
<div <div v-else>
:class="['timeline-tab-item', { selected: timelineFilter === 'articles' }]" <div class="summary-empty">暂无热门回复</div>
@click="timelineFilter = 'articles'"
>
文章
</div>
<div
:class="['timeline-tab-item', { selected: timelineFilter === 'comments' }]"
@click="timelineFilter = 'comments'"
>
评论和回复
</div> </div>
</div> </div>
<BasePlaceholder <div class="hot-topic">
v-if="filteredTimelineItems.length === 0" <div class="summary-title">热门话题</div>
text="暂无时间线" <div class="summary-content" v-if="hotPosts.length > 0">
icon="fas fa-inbox" <BaseTimeline :items="hotPosts">
/> <template #item="{ item }">
<div class="timeline-list">
<BaseTimeline :items="filteredTimelineItems">
<template #item="{ item }">
<template v-if="item.type === 'post'">
发布了文章
<NuxtLink :to="`/posts/${item.post.id}`" class="timeline-link"> <NuxtLink :to="`/posts/${item.post.id}`" class="timeline-link">
{{ item.post.title }} {{ item.post.title }}
</NuxtLink> </NuxtLink>
<div class="timeline-date">{{ formatDate(item.createdAt) }}</div> <div class="timeline-snippet">
{{ stripMarkdown(item.post.snippet) }}
</div>
<div class="timeline-date">
{{ formatDate(item.post.createdAt) }}
</div>
</template> </template>
<template v-else-if="item.type === 'comment'"> </BaseTimeline>
</div>
<NuxtLink :to="`/posts/${item.comment.post.id}`" class="timeline-link"> <div v-else>
{{ item.comment.post.title }} <div class="summary-empty">暂无热门话题</div>
</NuxtLink> </div>
下评论了 </div>
<NuxtLink <div class="hot-tag">
:to="`/posts/${item.comment.post.id}#comment-${item.comment.id}`" <div class="summary-title">TA创建的tag</div>
class="timeline-link" <div class="summary-content" v-if="hotTags.length > 0">
> <BaseTimeline :items="hotTags">
{{ stripMarkdownLength(item.comment.content, 200) }} <template #item="{ item }">
</NuxtLink>
<div class="timeline-date">{{ formatDate(item.createdAt) }}</div>
</template>
<template v-else-if="item.type === 'reply'">
<NuxtLink :to="`/posts/${item.comment.post.id}`" class="timeline-link">
{{ item.comment.post.title }}
</NuxtLink>
下对
<NuxtLink
:to="`/posts/${item.comment.post.id}#comment-${item.comment.parentComment.id}`"
class="timeline-link"
>
{{ stripMarkdownLength(item.comment.parentComment.content, 200) }}
</NuxtLink>
回复了
<NuxtLink
:to="`/posts/${item.comment.post.id}#comment-${item.comment.id}`"
class="timeline-link"
>
{{ stripMarkdownLength(item.comment.content, 200) }}
</NuxtLink>
<div class="timeline-date">{{ formatDate(item.createdAt) }}</div>
</template>
<template v-else-if="item.type === 'tag'">
创建了标签
<span class="timeline-link" @click="gotoTag(item.tag)"> <span class="timeline-link" @click="gotoTag(item.tag)">
{{ item.tag.name }}<span v-if="item.tag.count"> x{{ item.tag.count }}</span> {{ item.tag.name }}<span v-if="item.tag.count"> x{{ item.tag.count }}</span>
</span> </span>
<div class="timeline-snippet" v-if="item.tag.description"> <div class="timeline-snippet" v-if="item.tag.description">
{{ item.tag.description }} {{ item.tag.description }}
</div> </div>
<div class="timeline-date">{{ formatDate(item.createdAt) }}</div> <div class="timeline-date">
{{ formatDate(item.tag.createdAt) }}
</div>
</template> </template>
</template> </BaseTimeline>
</BaseTimeline>
</div>
</div>
<div v-else-if="selectedTab === 'following'" class="follow-container">
<div class="follow-tabs">
<div
:class="['follow-tab-item', { selected: followTab === 'followers' }]"
@click="followTab = 'followers'"
>
关注者
</div> </div>
<div <div v-else>
:class="['follow-tab-item', { selected: followTab === 'following' }]" <div class="summary-empty">暂无标签</div>
@click="followTab = 'following'"
>
正在关注
</div> </div>
</div> </div>
<div class="follow-list">
<UserList v-if="followTab === 'followers'" :users="followers" />
<UserList v-else :users="followings" />
</div>
</div> </div>
</div>
<div v-else-if="selectedTab === 'favorites'" class="favorites-container"> <div v-else-if="selectedTab === 'timeline'" class="profile-timeline">
<div v-if="favoritePosts.length > 0"> <BaseTabs
<BaseTimeline :items="favoritePosts"> v-model="timelineFilter"
<template #item="{ item }"> :tabs="timelineTabs"
class="timeline-tabs"
item-class="timeline-tab-item"
active-class="selected"
/>
<BasePlaceholder
v-if="filteredTimelineItems.length === 0"
text="暂无时间线"
icon="fas fa-inbox"
/>
<div class="timeline-list">
<BaseTimeline :items="filteredTimelineItems">
<template #item="{ item }">
<template v-if="item.type === 'post'">
发布了文章
<NuxtLink :to="`/posts/${item.post.id}`" class="timeline-link"> <NuxtLink :to="`/posts/${item.post.id}`" class="timeline-link">
{{ item.post.title }} {{ item.post.title }}
</NuxtLink> </NuxtLink>
<div class="timeline-snippet"> <div class="timeline-date">{{ formatDate(item.createdAt) }}</div>
{{ stripMarkdown(item.post.snippet) }}
</div>
<div class="timeline-date">{{ formatDate(item.post.createdAt) }}</div>
</template> </template>
</BaseTimeline> <template v-else-if="item.type === 'comment'">
</div>
<div v-else> <NuxtLink :to="`/posts/${item.comment.post.id}`" class="timeline-link">
<BasePlaceholder text="暂无收藏文章" icon="fas fa-inbox" /> {{ item.comment.post.title }}
</div> </NuxtLink>
下评论了
<NuxtLink
:to="`/posts/${item.comment.post.id}#comment-${item.comment.id}`"
class="timeline-link"
>
{{ stripMarkdownLength(item.comment.content, 200) }}
</NuxtLink>
<div class="timeline-date">{{ formatDate(item.createdAt) }}</div>
</template>
<template v-else-if="item.type === 'reply'">
<NuxtLink :to="`/posts/${item.comment.post.id}`" class="timeline-link">
{{ item.comment.post.title }}
</NuxtLink>
下对
<NuxtLink
:to="`/posts/${item.comment.post.id}#comment-${item.comment.parentComment.id}`"
class="timeline-link"
>
{{ stripMarkdownLength(item.comment.parentComment.content, 200) }}
</NuxtLink>
回复了
<NuxtLink
:to="`/posts/${item.comment.post.id}#comment-${item.comment.id}`"
class="timeline-link"
>
{{ stripMarkdownLength(item.comment.content, 200) }}
</NuxtLink>
<div class="timeline-date">{{ formatDate(item.createdAt) }}</div>
</template>
<template v-else-if="item.type === 'tag'">
创建了标签
<span class="timeline-link" @click="gotoTag(item.tag)">
{{ item.tag.name }}<span v-if="item.tag.count"> x{{ item.tag.count }}</span>
</span>
<div class="timeline-snippet" v-if="item.tag.description">
{{ item.tag.description }}
</div>
<div class="timeline-date">{{ formatDate(item.createdAt) }}</div>
</template>
</template>
</BaseTimeline>
</div> </div>
</div>
<div v-else-if="selectedTab === 'achievements'" class="achievements-container"> <div v-else-if="selectedTab === 'following'" class="follow-container">
<AchievementList :medals="medals" :can-select="isMine" /> <BaseTabs
v-model="followTab"
:tabs="followTabs"
class="follow-tabs"
item-class="follow-tab-item"
active-class="selected"
/>
<div class="follow-list">
<UserList v-if="followTab === 'followers'" :users="followers" />
<UserList v-else :users="followings" />
</div> </div>
</template> </div>
</BaseTabs>
<div v-else-if="selectedTab === 'favorites'" class="favorites-container">
<div v-if="favoritePosts.length > 0">
<BaseTimeline :items="favoritePosts">
<template #item="{ item }">
<NuxtLink :to="`/posts/${item.post.id}`" class="timeline-link">
{{ item.post.title }}
</NuxtLink>
<div class="timeline-snippet">
{{ stripMarkdown(item.post.snippet) }}
</div>
<div class="timeline-date">{{ formatDate(item.post.createdAt) }}</div>
</template>
</BaseTimeline>
</div>
<div v-else>
<BasePlaceholder text="暂无收藏文章" icon="fas fa-inbox" />
</div>
</div>
<div v-else-if="selectedTab === 'achievements'" class="achievements-container">
<AchievementList :medals="medals" :can-select="isMine" />
</div>
</template>
</div> </div>
</div> </div>
</template> </template>
@@ -322,7 +313,6 @@ import { useRoute } from 'vue-router'
import AchievementList from '~/components/AchievementList.vue' import AchievementList from '~/components/AchievementList.vue'
import BasePlaceholder from '~/components/BasePlaceholder.vue' import BasePlaceholder from '~/components/BasePlaceholder.vue'
import BaseTimeline from '~/components/BaseTimeline.vue' import BaseTimeline from '~/components/BaseTimeline.vue'
import BaseTabs from '~/components/BaseTabs.vue'
import LevelProgress from '~/components/LevelProgress.vue' import LevelProgress from '~/components/LevelProgress.vue'
import UserList from '~/components/UserList.vue' import UserList from '~/components/UserList.vue'
import { toast } from '~/main' import { toast } from '~/main'
@@ -330,6 +320,7 @@ import { authState, getToken } from '~/utils/auth'
import { prevLevelExp } from '~/utils/level' import { prevLevelExp } from '~/utils/level'
import { stripMarkdown, stripMarkdownLength } from '~/utils/markdown' import { stripMarkdown, stripMarkdownLength } from '~/utils/markdown'
import TimeManager from '~/utils/time' import TimeManager from '~/utils/time'
import BaseTabs from '~/components/BaseTabs.vue'
const config = useRuntimeConfig() const config = useRuntimeConfig()
const API_BASE_URL = config.public.apiBaseUrl const API_BASE_URL = config.public.apiBaseUrl
@@ -345,6 +336,22 @@ const hotReplies = ref([])
const hotTags = ref([]) const hotTags = ref([])
const favoritePosts = ref([]) const favoritePosts = ref([])
const timelineItems = ref([]) const timelineItems = ref([])
const profileTabs = [
{ name: 'summary', label: '总结', icon: 'fas fa-chart-line' },
{ name: 'timeline', label: '时间线', icon: 'fas fa-clock' },
{ name: 'following', label: '关注', icon: 'fas fa-user-plus' },
{ name: 'favorites', label: '收藏', icon: 'fas fa-bookmark' },
{ name: 'achievements', label: '勋章', icon: 'fas fa-medal' },
]
const timelineTabs = [
{ name: 'all', label: '全部' },
{ name: 'articles', label: '文章' },
{ name: 'comments', label: '评论和回复' },
]
const followTabs = [
{ name: 'followers', label: '关注者' },
{ name: 'following', label: '正在关注' },
]
const timelineFilter = ref('all') const timelineFilter = ref('all')
const filteredTimelineItems = computed(() => { const filteredTimelineItems = computed(() => {
if (timelineFilter.value === 'articles') { if (timelineFilter.value === 'articles') {
@@ -365,13 +372,6 @@ const selectedTab = ref(
? route.query.tab ? route.query.tab
: 'summary', : 'summary',
) )
const tabs = [
{ key: 'summary', label: '总结', icon: 'fas fa-chart-line' },
{ key: 'timeline', label: '时间线', icon: 'fas fa-clock' },
{ key: 'following', label: '关注', icon: 'fas fa-user-plus' },
{ key: 'favorites', label: '收藏', icon: 'fas fa-bookmark' },
{ key: 'achievements', label: '勋章', icon: 'fas fa-medal' },
]
const followTab = ref('followers') const followTab = ref('followers')
const levelInfo = computed(() => { const levelInfo = computed(() => {
@@ -768,7 +768,7 @@ watch(selectedTab, async (val) => {
font-size: 14px; font-size: 14px;
} }
:deep(.base-tabs-header) { .profile-tabs {
position: sticky; position: sticky;
top: calc(var(--header-height) + 1px); top: calc(var(--header-height) + 1px);
z-index: 200; z-index: 200;
@@ -782,7 +782,7 @@ watch(selectedTab, async (val) => {
backdrop-filter: var(--blur-10); backdrop-filter: var(--blur-10);
} }
:deep(.base-tabs-item) { .profile-tabs-item {
display: flex; display: flex;
flex: 0 0 auto; flex: 0 0 auto;
flex-direction: row; flex-direction: row;
@@ -795,7 +795,7 @@ watch(selectedTab, async (val) => {
white-space: nowrap; white-space: nowrap;
} }
:deep(.base-tabs-item.selected) { .profile-tabs-item.selected {
color: var(--primary-color); color: var(--primary-color);
border-bottom: 2px solid var(--primary-color); border-bottom: 2px solid var(--primary-color);
} }
@@ -954,7 +954,7 @@ watch(selectedTab, async (val) => {
height: 100px; height: 100px;
} }
:deep(.base-tabs-item) { .profile-tabs-item {
width: 100px; width: 100px;
} }