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 @@