Commit 031a28de by lijiabin

【需求 20331】 perf: 系统内的跳转全部改为单tab路由跳转

parent d283d499
...@@ -188,9 +188,11 @@ import type { ...@@ -188,9 +188,11 @@ import type {
BackendCarouselListItemDto, BackendCarouselListItemDto,
} from '@/api/backend' } from '@/api/backend'
import { ArticleTypeEnum, articleTypeListOptions } from '@/constants' import { ArticleTypeEnum, articleTypeListOptions } from '@/constants'
import { usePageSearch } from '@/hooks' import { usePageSearch, useNavigation } from '@/hooks'
import dayjs from 'dayjs' import dayjs from 'dayjs'
const router = useRouter()
const { jumpToArticleDetailPage } = useNavigation()
// 列表数据 // 列表数据
const loading = ref(false) const loading = ref(false)
const list = ref<BackendCarouselListItemDto[]>([]) const list = ref<BackendCarouselListItemDto[]>([])
...@@ -317,15 +319,11 @@ const handleSearchArticle = async () => { ...@@ -317,15 +319,11 @@ const handleSearchArticle = async () => {
} }
const handleOpenNewTab = (url: string) => { const handleOpenNewTab = (url: string) => {
window.open(url) router.push(url)
} }
const handlePreviewArticle = (row: BackendArticleListItemDto) => { const handlePreviewArticle = (row: BackendArticleListItemDto) => {
if (row.type === ArticleTypeEnum.VIDEO) { jumpToArticleDetailPage({ type: row.type, id: row.id })
window.open(`/videoDetail/${row.id}`)
} else {
window.open(`/articleDetail/${row.id}`)
}
} }
const handleSelectArticle = (row: BackendArticleListItemDto) => { const handleSelectArticle = (row: BackendArticleListItemDto) => {
......
...@@ -179,7 +179,7 @@ ...@@ -179,7 +179,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { articleTypeListOptions } from '@/constants' import { articleTypeListOptions } from '@/constants'
import { getColumnListViewMore } from '@/api' import { getColumnListViewMore } from '@/api'
import { usePageSearch, useScrollTop } from '@/hooks' import { usePageSearch, useScrollTop, useNavigation } from '@/hooks'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import type { SearchMoreColumnItemDto } from '@/api' import type { SearchMoreColumnItemDto } from '@/api'
...@@ -187,7 +187,7 @@ const router = useRouter() ...@@ -187,7 +187,7 @@ const router = useRouter()
const route = useRoute() const route = useRoute()
const searchPageRef = ref<HTMLElement | null>(null) const searchPageRef = ref<HTMLElement | null>(null)
const { handleBackTop } = useScrollTop(searchPageRef) const { handleBackTop } = useScrollTop(searchPageRef)
const { jumpToArticleDetailPage } = useNavigation()
const columnTitle = route.query.columnTitle || '' const columnTitle = route.query.columnTitle || ''
const sortOptions = [ const sortOptions = [
...@@ -219,7 +219,7 @@ const handleSearch = () => { ...@@ -219,7 +219,7 @@ const handleSearch = () => {
} }
const handleClick = (item: SearchMoreColumnItemDto) => { const handleClick = (item: SearchMoreColumnItemDto) => {
window.open(`/articleDetail/${item.articleId}`) jumpToArticleDetailPage({ type: item.type, id: item.articleId })
} }
onActivated(() => {}) onActivated(() => {})
......
...@@ -214,6 +214,7 @@ import { parseEmoji } from '@/utils/emoji' ...@@ -214,6 +214,7 @@ import { parseEmoji } from '@/utils/emoji'
const { fetchUserQestionNum } = useQuestionStore() const { fetchUserQestionNum } = useQuestionStore()
const route = useRoute() const route = useRoute()
const router = useRouter()
const open = ref(false) const open = ref(false)
const publishBoxRef = useTemplateRef('publishBoxRef') const publishBoxRef = useTemplateRef('publishBoxRef')
const commentDialogRef = useTemplateRef<typeof CommentDialog>('commentDialogRef') const commentDialogRef = useTemplateRef<typeof CommentDialog>('commentDialogRef')
...@@ -321,7 +322,7 @@ const handleExpand = (item: ArticleItemDto) => { ...@@ -321,7 +322,7 @@ const handleExpand = (item: ArticleItemDto) => {
} }
const openNewPage = (path: string) => { const openNewPage = (path: string) => {
window.open(path) router.push(path)
} }
// 是否打开漫游 // 是否打开漫游
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<div v-else class="space-y-4"> <div v-else class="space-y-4">
<div <div
@click="handleOpenArticle(item)" @click="jumpToArticleDetailPage({ type: item.type, id: item.id })"
v-for="item in list" v-for="item in list"
:key="item.id" :key="item.id"
class="flex items-center p-2 rounded-lg hover:bg-gray-100 transition-colors cursor-pointer px-6" class="flex items-center p-2 rounded-lg hover:bg-gray-100 transition-colors cursor-pointer px-6"
...@@ -96,12 +96,12 @@ ...@@ -96,12 +96,12 @@
import { hasOfficialAccount, getOtherUserData, getOtherUserPostData } from '@/api' import { hasOfficialAccount, getOtherUserData, getOtherUserPostData } from '@/api'
import type { OfficialAccountItemDto } from '@/api/user/types' import type { OfficialAccountItemDto } from '@/api/user/types'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { usePageSearch } from '@/hooks' import { usePageSearch, useNavigation } from '@/hooks'
import { ArticleTypeEnum, articleTypeListOptions } from '@/constants' import { articleTypeListOptions } from '@/constants'
import type { OtherUserInfoDto } from '@/api/otherUserPage/types' import type { OtherUserInfoDto } from '@/api/otherUserPage/types'
const route = useRoute() const route = useRoute()
const { jumpToArticleDetailPage } = useNavigation()
const { list, total, searchParams, goToPage, changePageSize } = usePageSearch( const { list, total, searchParams, goToPage, changePageSize } = usePageSearch(
getOtherUserPostData, getOtherUserPostData,
{ {
...@@ -127,14 +127,6 @@ onMounted(async () => { ...@@ -127,14 +127,6 @@ onMounted(async () => {
userInfo.value = data userInfo.value = data
}) })
const handleOpenArticle = (item: any) => {
if (item.type === ArticleTypeEnum.VIDEO) {
window.open(`/videoDetail/${item.id}`)
} else {
window.open(`/articleDetail/${item.id}`)
}
}
onMounted(() => { onMounted(() => {
getIsOfficial() getIsOfficial()
}) })
......
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
v-for="item in list" v-for="item in list"
:key="item.id" :key="item.id"
class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer" class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer"
@click="handleClick(item)" @click="jumpToArticleDetailPage({ type: item.type, id: item.id })"
> >
<!-- 封面图 --> <!-- 封面图 -->
<div <div
...@@ -237,9 +237,8 @@ ...@@ -237,9 +237,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { ArticleTypeEnum, articleTypeListOptions } from '@/constants' import { ArticleTypeEnum, articleTypeListOptions } from '@/constants'
import { getPracticeList } from '@/api' import { getPracticeList } from '@/api'
import { usePageSearch, useScrollTop } from '@/hooks' import { usePageSearch, useScrollTop, useNavigation } from '@/hooks'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import type { PracticeItemDto } from '@/api'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useTagsStore } from '@/stores/tags' import { useTagsStore } from '@/stores/tags'
const tagsStore = useTagsStore() const tagsStore = useTagsStore()
...@@ -249,7 +248,7 @@ const router = useRouter() ...@@ -249,7 +248,7 @@ const router = useRouter()
const route = useRoute() const route = useRoute()
const searchPageRef = ref<HTMLElement | null>(null) const searchPageRef = ref<HTMLElement | null>(null)
const { handleBackTop } = useScrollTop(searchPageRef) const { handleBackTop } = useScrollTop(searchPageRef)
const { jumpToArticleDetailPage } = useNavigation()
const firstDepList = ref([ const firstDepList = ref([
{ id: '1825', name: 'Amazon产品开发部' }, { id: '1825', name: 'Amazon产品开发部' },
{ id: '76', name: 'Amazon销售部' }, { id: '76', name: 'Amazon销售部' },
...@@ -292,10 +291,6 @@ const handleSearch = () => { ...@@ -292,10 +291,6 @@ const handleSearch = () => {
refresh() refresh()
} }
const handleClick = (item: PracticeItemDto) => {
window.open(`/articleDetail/${item.id}`)
}
onActivated(() => { onActivated(() => {
searchParams.value.sortLogic = Number(route.query.sortLogic) || 0 searchParams.value.sortLogic = Number(route.query.sortLogic) || 0
searchParams.value.tagIdList = searchParams.value.tagIdList =
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
v-for="item in list" v-for="item in list"
:key="item.id" :key="item.id"
class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer" class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer"
@click="handleClick(item)" @click="jumpToArticleDetailPage({ type: item.type, id: item.id })"
> >
<!-- 封面图 --> <!-- 封面图 -->
<div <div
...@@ -208,16 +208,15 @@ ...@@ -208,16 +208,15 @@
<script setup lang="ts"> <script setup lang="ts">
import { articleTypeListOptions } from '@/constants' import { articleTypeListOptions } from '@/constants'
import { getArticleList } from '@/api/article' import { getArticleList } from '@/api/article'
import { usePageSearch, useScrollTop } from '@/hooks' import { usePageSearch, useScrollTop, useNavigation } from '@/hooks'
import { ArticleTypeEnum } from '@/constants' import { ArticleTypeEnum } from '@/constants'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import type { ArticleItemDto } from '@/api'
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const searchPageRef = ref<HTMLElement | null>(null) const searchPageRef = ref<HTMLElement | null>(null)
const { handleBackTop } = useScrollTop(searchPageRef) const { handleBackTop } = useScrollTop(searchPageRef)
const { jumpToArticleDetailPage } = useNavigation()
const queryType = (route.query.type as ArticleTypeEnum) || '' const queryType = (route.query.type as ArticleTypeEnum) || ''
const querySearchTitle = (route.query.title as string) || '' const querySearchTitle = (route.query.title as string) || ''
...@@ -251,14 +250,6 @@ const handleSearch = () => { ...@@ -251,14 +250,6 @@ const handleSearch = () => {
refresh() refresh()
} }
const handleClick = (item: ArticleItemDto) => {
if (item.type === ArticleTypeEnum.VIDEO) {
window.open(`/videoDetail/${item.id}`)
} else {
window.open(`/articleDetail/${item.id}`)
}
}
onActivated(() => { onActivated(() => {
searchParams.value.title = (route.query.title as string) || '' searchParams.value.title = (route.query.title as string) || ''
searchParams.value.type = (route.query.type as ArticleTypeEnum) || '' searchParams.value.type = (route.query.type as ArticleTypeEnum) || ''
......
...@@ -99,7 +99,12 @@ ...@@ -99,7 +99,12 @@
v-if="searchParams.isAudit === AuditStatusEnum.AGREED" v-if="searchParams.isAudit === AuditStatusEnum.AGREED"
class="flex items-center text-gray-400 text-sm ml-4" class="flex items-center text-gray-400 text-sm ml-4"
> >
<el-button type="info" link @click="handleView(item)">查看</el-button> <el-button
type="info"
link
@click="jumpToArticleDetailPage({ type: item.type, id: item.id })"
>查看</el-button
>
</div> </div>
</div> </div>
</div> </div>
...@@ -127,14 +132,15 @@ ...@@ -127,14 +132,15 @@
<script lang="ts" setup> <script lang="ts" setup>
import { getAuditList, auditArticle } from '@/api' import { getAuditList, auditArticle } from '@/api'
import { usePageSearch } from '@/hooks' import { usePageSearch, useNavigation } from '@/hooks'
import { auditTypeListOptions, articleTypeListOptions } from '@/constants/options' import { auditTypeListOptions, articleTypeListOptions } from '@/constants/options'
import { AuditStatusEnum } from '@/constants' import { AuditStatusEnum } from '@/constants'
import type { AuditArticleDto, AuditListItemDto } from '@/api' import type { AuditArticleDto } from '@/api'
import type { TabPaneName } from 'element-plus' import type { TabPaneName } from 'element-plus'
import { ArticleTypeEnum } from '@/constants'
import dayjs from 'dayjs'
import dayjs from 'dayjs'
const router = useRouter()
const { jumpToArticleDetailPage } = useNavigation()
const toggleTab = (key: TabPaneName) => { const toggleTab = (key: TabPaneName) => {
searchParams.value.isAudit = key as AuditStatusEnum searchParams.value.isAudit = key as AuditStatusEnum
refresh() refresh()
...@@ -186,16 +192,8 @@ const handleAudit = async (data: AuditArticleDto) => { ...@@ -186,16 +192,8 @@ const handleAudit = async (data: AuditArticleDto) => {
refresh() refresh()
} }
const handleView = (item: AuditListItemDto) => {
if (item.type === ArticleTypeEnum.VIDEO) {
window.open(`/videoDetail/${item.id}`)
} else {
window.open(`/articleDetail/${item.id}`)
}
}
const openArticleDetail = (id: number) => { const openArticleDetail = (id: number) => {
window.open(`/auditArticle/${id}`) router.push(`/auditArticle/${id}`)
} }
onActivated(() => { onActivated(() => {
refresh() refresh()
......
...@@ -395,7 +395,7 @@ const handleBackUser = () => { ...@@ -395,7 +395,7 @@ const handleBackUser = () => {
} }
const handleAdmin = () => { const handleAdmin = () => {
window.open('/backend') router.push('/backend')
} }
const handleClearCache = async () => { const handleClearCache = async () => {
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
v-for="item in list" v-for="item in list"
:key="item.articleId" :key="item.articleId"
class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer" class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer"
@click="handleClick(item)" @click="jumpToArticleDetailPage({ type: item.type, id: item.articleId })"
> >
<!-- 封面图 --> <!-- 封面图 -->
<div <div
...@@ -179,15 +179,14 @@ ...@@ -179,15 +179,14 @@
<script setup lang="ts"> <script setup lang="ts">
import { articleTypeListOptions } from '@/constants' import { articleTypeListOptions } from '@/constants'
import { getVideoListViewMore } from '@/api' import { getVideoListViewMore } from '@/api'
import { usePageSearch, useScrollTop } from '@/hooks' import { usePageSearch, useScrollTop, useNavigation } from '@/hooks'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import type { SearchMoreVideoItemDto } from '@/api'
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const searchPageRef = ref<HTMLElement | null>(null) const searchPageRef = ref<HTMLElement | null>(null)
const { handleBackTop } = useScrollTop(searchPageRef) const { handleBackTop } = useScrollTop(searchPageRef)
const { jumpToArticleDetailPage } = useNavigation()
const columnTitle = (route.query.columnTitle as string) || '' const columnTitle = (route.query.columnTitle as string) || ''
const sortOptions = [ const sortOptions = [
...@@ -217,10 +216,6 @@ const changeSort = (value: number) => { ...@@ -217,10 +216,6 @@ const changeSort = (value: number) => {
const handleSearch = () => { const handleSearch = () => {
refresh() refresh()
} }
const handleClick = (item: SearchMoreVideoItemDto) => {
window.open(`/videoDetail/${item.articleId}`)
}
</script> </script>
<style scoped></style> <style scoped></style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment