Skip to content

Commit

Permalink
fix: 🐛 修复因VueRouter导致百度网盘PC端路由出错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteSevs committed May 21, 2024
1 parent 139e3ec commit 9e1449e
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 117 deletions.
4 changes: 2 additions & 2 deletions packages/【移动端】百度系优化/SCRIPT_VERSION.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"time": 1715932697767,
"version": "2024.5.17"
"time": 1716290495760,
"version": "2024.5.21"
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref } from 'vue';
import { UserInfo } from './data/TiebaHomeData';
import { router } from './router';
import { TiebaRouter } from './router';
const props = defineProps<{
UserData: UserInfo;
Expand All @@ -18,7 +18,7 @@ if (props.UserData.sex != null) {
* 箭头点击事件
*/
const arrowLeftClickEvent = () => {
router.back();
TiebaRouter.router.back();
}
</script>
<template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { VNodeRef, ref, watch } from 'vue';
import TemplateFollowUser from './Template/TemplateFollowUser.vue';
import { TiebaHomeData, UserInfo } from './data/TiebaHomeData';
import { TiebaHomeApi, UserFollowInfo } from './api/TiebaHomeApi';
import { router } from './router';
import { TiebaRouter } from './router';
import { DOMUtils, log, utils } from '@/env';
const props = defineProps<{
Expand Down Expand Up @@ -89,7 +89,7 @@ const loadMore = async () => {
* 箭头点击事件
*/
const arrowLeftClickEvent = () => {
router.back();
TiebaRouter.router.back();
}
const jumpToUserHome = (url: string) => {
window.open(url, "_blank")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { VNodeRef, ref, watch } from 'vue';
import TemplateFollowUser from './Template/TemplateFollowUser.vue';
import { TiebaHomeData, UserInfo } from './data/TiebaHomeData';
import { TiebaHomeApi, UserFollowInfo } from './api/TiebaHomeApi';
import { router } from './router';
import { TiebaRouter } from './router';
import { log } from '@/env';
const props = defineProps<{
Expand Down Expand Up @@ -81,7 +81,7 @@ const loadMore = async () => {
* 箭头点击事件
*/
const arrowLeftClickEvent = () => {
router.back();
TiebaRouter.router.back();
}
const jumpToUserHome = (url: string) => {
window.open(url, "_blank")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DOMUtils, Qmsg, utils } from "@/env";
import { onBeforeMount, onMounted, reactive, ref, watch } from 'vue';
import { TiebaHomeData, UserInfo } from "./data/TiebaHomeData";
import { ElMessage, ElMessageBox, ElRow, TabsPaneContext } from "element-plus";
import { router } from "./router"
import { TiebaRouter } from "./router"
const props = defineProps<{
UserData: UserInfo
Expand Down Expand Up @@ -91,18 +91,18 @@ const clickReceivedLikesEvent = () => {
}
const aboutUserEvent = function () {
router.push({
TiebaRouter.router.push({
path: "/about",
})
}
const clickFollowEvent = () => {
router.push({
TiebaRouter.router.push({
path: "/follow",
})
}
const clickFansEvent = () => {
router.push({
TiebaRouter.router.push({
path: "/fans",
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { GM_addStyle } from 'ViteGM';
import { MountVue, VUE_ELE_NAME_ID } from '@/env';
import App from './App.vue';
import { router } from './router';
import AppCSS from "./app.css?raw"
import { GM_addStyle } from "ViteGM";
import { MountVue, VUE_ELE_NAME_ID } from "@/env";
import App from "./App.vue";
import { TiebaRouter } from "./router";
import AppCSS from "./app.css?raw";

const TiebaHome = {
$data: {
appName: "vite-app",
},
init() {
MountVue(App, router);
GM_addStyle(`
$data: {
appName: "vite-app",
},
init() {
TiebaRouter.init();
MountVue(App, TiebaRouter.router);
GM_addStyle(`
#${VUE_ELE_NAME_ID}{
z-index: 1000;
}
Expand All @@ -22,11 +23,9 @@ const TiebaHome = {
#${VUE_ELE_NAME_ID} ~ *{
display: unset;
}
`)
GM_addStyle(AppCSS);
},
}
`);
GM_addStyle(AppCSS);
},
};

export {
TiebaHome
}
export { TiebaHome };
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import { createRouter, createWebHashHistory } from "vue-router";
import { createRouter, createWebHashHistory, type Router } from "vue-router";
import Home from "./Home.vue";
import About from "./About.vue";
import Follow from "./Follow.vue";
import Fans from "./Fans.vue";

const router = createRouter({
// 4. 内部提供了 history 模式的实现。为了简单起见,我们在这里使用 hash 模式。
history: createWebHashHistory(),
routes: [
{
path: '/',
name: "Home",
component: Home,
meta: {
keepAlive: true
},
},
{
path: "/about",
name: "About",
component: About
},
{
path: '/follow',
name: "Follow",
component: Follow
},
{
path: '/fans',
name: "Fans",
component: Fans,
},
],
})
const TiebaRouter = {
router: null as unknown as Router,
init() {
this.router = createRouter({
// 4. 内部提供了 history 模式的实现。为了简单起见,我们在这里使用 hash 模式。
history: createWebHashHistory(),
routes: [
{
path: "/",
name: "Home",
component: Home,
meta: {
keepAlive: true,
},
},
{
path: "/about",
name: "About",
component: About,
},
{
path: "/follow",
name: "Follow",
component: Follow,
},
{
path: "/fans",
name: "Fans",
component: Fans,
},
],
});
this.router.push("/");
},
};

router.push("/");

export {
router
}
export { TiebaRouter };

0 comments on commit 9e1449e

Please sign in to comment.