mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
feat(route): isMain用于判断子窗口
This commit is contained in:
21
src/App.vue
21
src/App.vue
@@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div v-if="isMain">
|
||||||
<v-layout>
|
<v-layout>
|
||||||
<!-- 侧边栏菜单 -->
|
<!-- 侧边栏菜单 -->
|
||||||
<t-sidebar />
|
<t-sidebar />
|
||||||
@@ -9,11 +10,23 @@
|
|||||||
</v-container>
|
</v-container>
|
||||||
</v-main>
|
</v-main>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<v-layout>
|
||||||
|
<!-- 主体内容 -->
|
||||||
|
<v-main>
|
||||||
|
<v-container fluid>
|
||||||
|
<router-view />
|
||||||
|
</v-container>
|
||||||
|
</v-main>
|
||||||
|
</v-layout>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
// vue
|
// vue
|
||||||
import { onMounted } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
|
import { useRouter } from "vue-router";
|
||||||
import TSidebar from "./components/t-sidebar.vue";
|
import TSidebar from "./components/t-sidebar.vue";
|
||||||
// tauri
|
// tauri
|
||||||
import { fs } from "@tauri-apps/api";
|
import { fs } from "@tauri-apps/api";
|
||||||
@@ -25,9 +38,15 @@ import { InitTGData, DeleteTGData, WriteTGData } from "./utils/TGIndex";
|
|||||||
import { TGAppDataList, TGGetDataList } from "./data";
|
import { TGAppDataList, TGGetDataList } from "./data";
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
const isMain = ref(true as boolean);
|
||||||
|
const route = useRouter();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
// 判断路由meta.isMain
|
||||||
|
isMain.value = route.currentRoute.value.meta.isMain as boolean;
|
||||||
|
if (isMain.value) {
|
||||||
await checkLoad();
|
await checkLoad();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
async function checkLoad() {
|
async function checkLoad() {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Home from "../pages/Home.vue";
|
|||||||
import News from "../pages/News.vue";
|
import News from "../pages/News.vue";
|
||||||
// 数据交互
|
// 数据交互
|
||||||
import Achievements from "../pages/Achievements.vue";
|
import Achievements from "../pages/Achievements.vue";
|
||||||
|
import TPost from "../views/t-post.vue";
|
||||||
// 应用配置相关
|
// 应用配置相关
|
||||||
import Config from "../pages/Config.vue";
|
import Config from "../pages/Config.vue";
|
||||||
|
|
||||||
@@ -12,30 +13,56 @@ const routes = [
|
|||||||
path: "/",
|
path: "/",
|
||||||
name: "首页",
|
name: "首页",
|
||||||
component: Home,
|
component: Home,
|
||||||
|
meta: {
|
||||||
|
isMain: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/achievements",
|
path: "/achievements",
|
||||||
name: "成就",
|
name: "成就",
|
||||||
component: Achievements,
|
component: Achievements,
|
||||||
|
meta: {
|
||||||
|
isMain: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/config",
|
path: "/config",
|
||||||
name: "设置",
|
name: "设置",
|
||||||
component: Config,
|
component: Config,
|
||||||
|
meta: {
|
||||||
|
isMain: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/GCG",
|
path: "/GCG",
|
||||||
name: "卡牌",
|
name: "卡牌",
|
||||||
component: GCG,
|
component: GCG,
|
||||||
|
meta: {
|
||||||
|
isMain: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/home",
|
path: "/home",
|
||||||
redirect: "/",
|
redirect: "/",
|
||||||
|
meta: {
|
||||||
|
isMain: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/news",
|
path: "/news",
|
||||||
name: "咨讯",
|
name: "咨讯",
|
||||||
component: News,
|
component: News,
|
||||||
|
meta: {
|
||||||
|
isMain: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/post_detail/:post_id",
|
||||||
|
name: "帖子详情",
|
||||||
|
component: TPost,
|
||||||
|
meta: {
|
||||||
|
isMain: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
14
src/views/t-post.vue
Normal file
14
src/views/t-post.vue
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<template>
|
||||||
|
<div>TEST {{ $route.meta.isMain }}</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
// 获取路由传参
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
// 获取路由参数
|
||||||
|
const id = route.params.post_id;
|
||||||
|
console.log(id);
|
||||||
|
</script>
|
||||||
|
<style lang="css"></style>
|
||||||
Reference in New Issue
Block a user