feat: delete router

This commit is contained in:
Tim
2025-08-25 15:44:14 +08:00
parent 0ee58df868
commit 6c48a38212
3 changed files with 6 additions and 11 deletions

View File

@@ -115,7 +115,6 @@
<script setup> <script setup>
import { ref, onUnmounted, watch, onActivated } from 'vue' import { ref, onUnmounted, watch, onActivated } from 'vue'
import { useRouter } from 'vue-router'
import { getToken, fetchCurrentUser } from '~/utils/auth' import { getToken, fetchCurrentUser } from '~/utils/auth'
import { toast } from '~/main' import { toast } from '~/main'
import { useWebSocket } from '~/composables/useWebSocket' import { useWebSocket } from '~/composables/useWebSocket'
@@ -130,7 +129,6 @@ const config = useRuntimeConfig()
const conversations = ref([]) const conversations = ref([])
const loading = ref(true) const loading = ref(true)
const error = ref(null) const error = ref(null)
const router = useRouter()
const currentUser = ref(null) const currentUser = ref(null)
const API_BASE_URL = config.public.apiBaseUrl const API_BASE_URL = config.public.apiBaseUrl
const { connect, disconnect, subscribe, isConnected } = useWebSocket() const { connect, disconnect, subscribe, isConnected } = useWebSocket()
@@ -223,7 +221,7 @@ async function goToChannel(id) {
method: 'POST', method: 'POST',
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}) })
router.push(`/message-box/${id}`) navigateTo(`/message-box/${id}`)
} catch (e) { } catch (e) {
toast.error(e.message) toast.error(e.message)
} }
@@ -272,7 +270,7 @@ onUnmounted(() => {
}) })
function goToConversation(id) { function goToConversation(id) {
router.push(`/message-box/${id}`) navigateTo(`/message-box/${id}`)
} }
</script> </script>

View File

@@ -260,7 +260,6 @@ import { getMedalTitle } from '~/utils/medal'
import { toast } from '~/main' import { toast } from '~/main'
import { getToken, authState } from '~/utils/auth' import { getToken, authState } from '~/utils/auth'
import TimeManager from '~/utils/time' import TimeManager from '~/utils/time'
import { useRouter } from 'vue-router'
import { useIsMobile } from '~/utils/screen' import { useIsMobile } from '~/utils/screen'
import Dropdown from '~/components/Dropdown.vue' import Dropdown from '~/components/Dropdown.vue'
import { ClientOnly } from '#components' import { ClientOnly } from '#components'
@@ -272,7 +271,6 @@ const API_BASE_URL = config.public.apiBaseUrl
const route = useRoute() const route = useRoute()
const postId = route.params.id const postId = route.params.id
const router = useRouter()
const title = ref('') const title = ref('')
const author = ref('') const author = ref('')

View File

@@ -328,7 +328,7 @@
<script setup> <script setup>
import { computed, onMounted, ref, watch } from 'vue' import { computed, onMounted, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router' 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'
@@ -346,7 +346,6 @@ definePageMeta({
alias: ['/users/:id/'], alias: ['/users/:id/'],
}) })
const route = useRoute() const route = useRoute()
const router = useRouter()
const username = route.params.id const username = route.params.id
const user = ref({}) const user = ref({})
@@ -407,7 +406,7 @@ const fetchUser = async () => {
user.value = data user.value = data
subscribed.value = !!data.subscribed subscribed.value = !!data.subscribed
} else if (res.status === 404) { } else if (res.status === 404) {
router.replace('/404') navigateTo('/404')
} }
} }
@@ -558,7 +557,7 @@ const sendMessage = async () => {
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }, headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
}) })
const result = await response.json() const result = await response.json()
router.push(`/message-box/${result.conversationId}`) navigateTo(`/message-box/${result.conversationId}`)
} catch (e) { } catch (e) {
toast.error('无法发起私信') toast.error('无法发起私信')
console.error(e) console.error(e)
@@ -592,7 +591,7 @@ const init = async () => {
onMounted(init) onMounted(init)
watch(selectedTab, async (val) => { watch(selectedTab, async (val) => {
// router.replace({ query: { ...route.query, tab: val } }) // navigateTo({ query: { ...route.query, tab: val } }, { replace: true })
if (val === 'timeline' && timelineItems.value.length === 0) { if (val === 'timeline' && timelineItems.value.length === 0) {
await loadTimeline() await loadTimeline()
} else if (val === 'following' && followers.value.length === 0 && followings.value.length === 0) { } else if (val === 'following' && followers.value.length === 0 && followings.value.length === 0) {