From e8a162d8599e306fe4d0052c57223d6c4c9f4ebb Mon Sep 17 00:00:00 2001 From: Tim <135014430+nagisa77@users.noreply.github.com> Date: Wed, 27 Aug 2025 12:22:22 +0800 Subject: [PATCH] feat: add reusable multi-tabs component --- frontend_nuxt/components/MultiTabs.vue | 82 ++ frontend_nuxt/pages/about/index.vue | 50 +- frontend_nuxt/pages/message-box/index.vue | 220 ++--- frontend_nuxt/pages/message.vue | 1060 ++++++++++----------- frontend_nuxt/pages/points.vue | 332 ++++--- 5 files changed, 908 insertions(+), 836 deletions(-) create mode 100644 frontend_nuxt/components/MultiTabs.vue diff --git a/frontend_nuxt/components/MultiTabs.vue b/frontend_nuxt/components/MultiTabs.vue new file mode 100644 index 000000000..e67fc6994 --- /dev/null +++ b/frontend_nuxt/components/MultiTabs.vue @@ -0,0 +1,82 @@ + + + + + diff --git a/frontend_nuxt/pages/about/index.vue b/frontend_nuxt/pages/about/index.vue index 8d5aaa60f..38da4c5a6 100644 --- a/frontend_nuxt/pages/about/index.vue +++ b/frontend_nuxt/pages/about/index.vue @@ -1,29 +1,29 @@ diff --git a/frontend_nuxt/pages/message-box/index.vue b/frontend_nuxt/pages/message-box/index.vue index ffb91ffb2..523f03d45 100644 --- a/frontend_nuxt/pages/message-box/index.vue +++ b/frontend_nuxt/pages/message-box/index.vue @@ -7,116 +7,118 @@
-
-
- 站内信 -
-
- 频道 -
-
- -
-
- -
- -
-
{{ error }}
-
- -
- -
- -
- -
- -
-
- -
- -
-
-
- {{ getOtherParticipant(convo)?.username || '未知用户' }} -
-
- {{ formatTime(convo.lastMessage?.createdAt || convo.createdAt) }} -
+ + +
@@ -147,6 +149,10 @@ const { fetchChannelUnread: refreshChannelUnread, setFromList: setChannelUnreadF useChannelsUnreadCount() let subscription = null +const tabs = [ + { name: 'messages', label: '站内信' }, + { name: 'channels', label: '频道' }, +] const activeTab = ref('channels') const channels = ref([]) const loadingChannels = ref(false) @@ -216,15 +222,13 @@ async function fetchChannels() { } } -function switchToMessage() { - activeTab.value = 'messages' - fetchConversations() -} - -function switchToChannels() { - activeTab.value = 'channels' - fetchChannels() -} +watch(activeTab, (val) => { + if (val === 'messages') { + fetchConversations() + } else { + fetchChannels() + } +}) async function goToChannel(id) { const token = getToken() diff --git a/frontend_nuxt/pages/message.vue b/frontend_nuxt/pages/message.vue index d694b1b2d..ad4b6dbdb 100644 --- a/frontend_nuxt/pages/message.vue +++ b/frontend_nuxt/pages/message.vue @@ -1,542 +1,529 @@ @@ -566,6 +553,11 @@ import BaseSwitch from '~/components/BaseSwitch.vue' const config = useRuntimeConfig() const API_BASE_URL = config.public.apiBaseUrl const route = useRoute() +const tabs = [ + { name: 'all', label: '消息' }, + { name: 'unread', label: '未读' }, + { name: 'control', label: '消息设置' }, +] const selectedTab = ref( ['all', 'unread', 'control'].includes(route.query.tab) ? route.query.tab : 'unread', ) diff --git a/frontend_nuxt/pages/points.vue b/frontend_nuxt/pages/points.vue index 0c3e64616..175507387 100644 --- a/frontend_nuxt/pages/points.vue +++ b/frontend_nuxt/pages/points.vue @@ -1,177 +1,166 @@ @@ -188,6 +177,11 @@ import TimeManager from '~/utils/time' const config = useRuntimeConfig() const API_BASE_URL = config.public.apiBaseUrl +const tabs = [ + { name: 'mall', label: '积分兑换' }, + { name: 'history', label: '积分历史' }, +] + const selectedTab = ref('mall') const point = ref(null) const isLoading = ref(false)