添加部分钩子函数,便于代码维护
This commit is contained in:
+4
-22
@@ -29,30 +29,12 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useViewerStore } from '@/stores/useViewerStore';
|
||||
import { RouterView, useRoute } from 'vue-router';
|
||||
import { RouterView } from 'vue-router';
|
||||
import { backgroundImage, mainLogoImage } from '@/assets';
|
||||
import { useIndex } from '@/hooks/useIndex';
|
||||
|
||||
useViewerStore().setViewerLoadingCompleted(true);
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
const topNavMap = [
|
||||
{ title: '暴雨灾害链', name: 'rainstorm', query: { identification: 1 } },
|
||||
{ title: '地震灾害链', name: 'earthquake', query: { identification: 2 } },
|
||||
{ title: '多灾种灾害链分析', name: 'index', query: { identification: 3 } },
|
||||
{ title: '灾害链情景推演', name: 'index', query: { identification: 4 } },
|
||||
{ title: '数据管理', name: 'index', query: { identification: 5 } },
|
||||
{ title: '文件管理', name: 'index', query: { identification: 6 } },
|
||||
];
|
||||
|
||||
// 判断当前导航项是否激活
|
||||
const isActive = (identification: number) => {
|
||||
const targetId = identification.toString();
|
||||
let currentId = route.query.identification;
|
||||
if (!currentId) return targetId === '1';
|
||||
if (Array.isArray(currentId)) currentId = currentId[0];
|
||||
return currentId === targetId || route.query.identification === targetId;
|
||||
};
|
||||
// 获取钩子函数
|
||||
const { topNavMap, isActive } = useIndex();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -20,20 +20,16 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// 1. 只导入子组件
|
||||
import BasicComponent from '@/component/rain-earthquake/BasicComponent.vue';
|
||||
import DisasterChainPointComponent from '@/component/rain-earthquake/DisasterChainPointComponent.vue';
|
||||
import LegendComponent from '@/component/rain-earthquake/LegendComponent.vue';
|
||||
import { useRainDisasterChain } from '@/hooks/rainstorm/useRainDisasterChain';
|
||||
import { useRainLegend } from '@/hooks/rainstorm/useRainLegend';
|
||||
|
||||
// 2. 只导入核心类型/枚举
|
||||
import { DisasterType } from '@/types/common/DisasterType';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
// 4. 执行钩子,拿到所有需要的数据
|
||||
const {
|
||||
selectOptions,
|
||||
tableDatas,
|
||||
|
||||
Reference in New Issue
Block a user