From 0fc1415a14707d332268124fc0ba78fa9abc087e Mon Sep 17 00:00:00 2001 From: Tim <135014430+nagisa77@users.noreply.github.com> Date: Wed, 27 Aug 2025 12:26:35 +0800 Subject: [PATCH] feat: create BaseTabs component --- frontend_nuxt/components/BaseTabs.vue | 50 ++++++++++ frontend_nuxt/pages/about/index.vue | 42 ++++---- frontend_nuxt/pages/message-box/index.vue | 39 ++++---- frontend_nuxt/pages/message.vue | 33 +++---- frontend_nuxt/pages/points.vue | 27 +++-- frontend_nuxt/pages/users/[id].vue | 114 ++++++++-------------- 6 files changed, 160 insertions(+), 145 deletions(-) create mode 100644 frontend_nuxt/components/BaseTabs.vue diff --git a/frontend_nuxt/components/BaseTabs.vue b/frontend_nuxt/components/BaseTabs.vue new file mode 100644 index 000000000..f90befed1 --- /dev/null +++ b/frontend_nuxt/components/BaseTabs.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/frontend_nuxt/pages/about/index.vue b/frontend_nuxt/pages/about/index.vue index 8d5aaa60f..23e7760ed 100644 --- a/frontend_nuxt/pages/about/index.vue +++ b/frontend_nuxt/pages/about/index.vue @@ -1,15 +1,16 @@ diff --git a/frontend_nuxt/pages/message-box/index.vue b/frontend_nuxt/pages/message-box/index.vue index ffb91ffb2..30c85f3b7 100644 --- a/frontend_nuxt/pages/message-box/index.vue +++ b/frontend_nuxt/pages/message-box/index.vue @@ -7,14 +7,13 @@
-
-
- 站内信 -
-
- 频道 -
-
+
@@ -132,6 +131,7 @@ import TimeManager from '~/utils/time' import { stripMarkdownLength } from '~/utils/markdown' import SearchPersonDropdown from '~/components/SearchPersonDropdown.vue' import BasePlaceholder from '~/components/BasePlaceholder.vue' +import BaseTabs from '~/components/BaseTabs.vue' const config = useRuntimeConfig() const conversations = ref([]) @@ -146,13 +146,24 @@ const { fetchUnreadCount: refreshGlobalUnreadCount } = useUnreadCount() const { fetchChannelUnread: refreshChannelUnread, setFromList: setChannelUnreadFromList } = useChannelsUnreadCount() let subscription = null - +const tabs = [ + { name: 'messages', label: '站内信' }, + { name: 'channels', label: '频道' }, +] const activeTab = ref('channels') const channels = ref([]) const loadingChannels = ref(false) const isFloatMode = computed(() => route.query.float === '1') const floatRoute = useState('messageFloatRoute') +watch(activeTab, (tab) => { + if (tab === 'messages') { + fetchConversations() + } else { + fetchChannels() + } +}) + async function fetchConversations() { const token = getToken() if (!token) { @@ -216,16 +227,6 @@ async function fetchChannels() { } } -function switchToMessage() { - activeTab.value = 'messages' - fetchConversations() -} - -function switchToChannels() { - activeTab.value = 'channels' - fetchChannels() -} - async function goToChannel(id) { const token = getToken() if (!token) { diff --git a/frontend_nuxt/pages/message.vue b/frontend_nuxt/pages/message.vue index d694b1b2d..8496e2ccc 100644 --- a/frontend_nuxt/pages/message.vue +++ b/frontend_nuxt/pages/message.vue @@ -1,26 +1,13 @@