Explorar o código

refactor(resource): 清理未使用的导入和代码

移除未使用的vue-router相关导入和变量
简化资源详情页的状态获取逻辑,统一从store获取
使用emit替代直接路由操作
tanshanming hai 6 meses
pai
achega
5814075b30

+ 6 - 25
src/views/resourceDetails/index.vue

@@ -1,6 +1,4 @@
 <template>
-	<!-- <a-layout> -->
-	<!-- <Header @onChangeCurrent="onChangeCurrent" /> -->
 	<div class="resource-container">
 		<!-- <BreadCrumb /> -->
 		<div class="resource">
@@ -13,33 +11,23 @@
 		</div>
 		<!-- <ResourceDetails v-if="indexType == 'resourceDetails'" ref="ResourceDetailsRef" /> -->
 	</div>
-	<!-- </a-layout> -->
 </template>
 
 <script setup>
-	import Header from '@/views/portal/components/Header.vue'
-	import BreadCrumb from '@/views/portal/components/BreadCrumb.vue'
-	import Footer from '@/views/portal/components/Footer.vue'
 	import VideoDetails from './components/VideoDetails.vue'
-	import { useRoute, useRouter } from 'vue-router'
 	import TallList from './components/TallList.vue'
 	import { addViewCount, detail, add, queryList } from '@/api/portal'
 	import resourceAuditApi from '@/api/resourceAudit.js'
-	import EventBus from '@/utils/EventBus'
 	import { resourceAuditStore } from '@/store/resourceAudit'
 
-	const router = useRouter()
-	const route = useRoute()
 	const auditStore = resourceAuditStore()
-
-	const indexType = ref('resourceCenter')
 	const itemData = ref({})
 	const tallList = ref(null)
 	const VideoDetailsRef = ref(null)
-
+	const emit = defineEmits(['auditComplete'])
 	// 从store中获取参数,如果store中没有则从路由中获取
-	const isState = ref(auditStore.auditParams.state || route.query.state || null)
-	const isAudit = ref(auditStore.auditParams.audit || route.query.audit || null)
+	const isState = ref(auditStore.auditParams.state || null)
+	const isAudit = ref(auditStore.auditParams.audit || null)
 	//     {
 	//     "fileName": "Kettle文档",
 	//     "courseType": "0",
@@ -76,7 +64,7 @@
 	}
 	const handleAuditResult = (val) => {
 		// 优先从store中获取ID,如果没有则从路由中获取
-		const id = auditStore.auditParams.id || route.query.id
+		const id = auditStore.auditParams.id
 		const params = {
 			ids: id,
 			verifyStatus: val
@@ -87,20 +75,13 @@
 				if (res.code == 200) {
 					// 清空store中的审核参数
 					auditStore.clearAuditParams()
-					router.go(-1)
+					emit('auditComplete')
 				}
 			})
 			.catch((err) => {
 				console.error(err)
 			})
 	}
-	const onChangeCurrent = (current) => {
-		indexType.value = current
-
-		router.push({
-			path: '/' + current
-		})
-	}
 
 	const setData = (item) => {
 		// emit('handlerItemSidebar', item)
@@ -121,7 +102,7 @@
 
 	onMounted(() => {
 		// 优先从store中获取ID,如果没有则从路由中获取
-		const id = auditStore.auditParams.id || route.query.id
+		const id = auditStore.auditParams.id
 		if (id != undefined && id != '') {
 			addViewCount({ id: id })
 			getData({ id: id })

+ 0 - 2
src/views/resourceManagements/index.vue

@@ -13,10 +13,8 @@
 	import myResources from '../myResources/myResources.vue'
 	import resourceDetails from '@/views/resourceDetails/index.vue'
 	import { ref } from 'vue'
-	import { useRoute, useRouter } from 'vue-router'
 	import { resourceAuditStore } from '@/store/resourceAudit'
 
-	const router = useRouter()
 	const modalVisible = ref(false)
 	const resourceDetailsRef = ref(null)
 	const currentAuditData = ref(null)