fix: 解决gitee绑定url替换后,路由参数未清空问题

This commit is contained in:
qiufeng
2025-10-27 12:01:20 +08:00
parent 84e25e4037
commit 74a697d478
2 changed files with 9 additions and 10 deletions
+1 -1
View File
@@ -120,7 +120,7 @@ export const useMultipleTabStore = defineStore("app-multiple-tab", {
// Existing pages, do not add tabs repeatedly
const tabHasExits = this.tabList.some((tab, index) => {
updateIndex = index;
return (tab.fullPath || tab.path) === (fullPath || path);
return tab.fullPath === fullPath || tab.path === path;
});
// If the tab already exists, perform the update operation
if (tabHasExits) {
@@ -35,6 +35,9 @@
import { getSecureSetting, SsoUser, unbindGitee, unbindGithub } from "@mfish/core/api";
import { giteeConfig, githubConfig } from "@mfish/core/settings/LoginSetting";
import { defHttp } from "@mfish/core/utils/http/axios";
import { useRoute } from "vue-router";
import { router } from "@mfish/core/router";
import { CollapseContainer } from "@mfish/core/components/Container";
const AListItem = AList.Item;
const AListItemMeta = AListItem.Meta;
@@ -83,14 +86,11 @@
icon: userInfo.value?.github ? "ant-design:stop-outlined" : "ant-design:link-outlined"
}
]);
const route = useRoute();
onBeforeMount(() => {
//此处不从路由取参数,而是从url参数取callback和code
//因为后面clearUrl只修改了链接未清除路由参数,如果清除路由参数会造成页面刷新,无法返回安全设置页面
const params = new URLSearchParams(globalThis.location.search);
const callback = params.get("callback");
const callback = route.query?.callback as string;
if (callback === "gitee") {
const code = params.get("code");
const code = route.query?.code as string;
defHttp
.put<boolean>({ url: `/oauth2/gitee/bind/${code}` })
.then((res) => {
@@ -104,7 +104,7 @@
return;
}
if (callback === "github") {
const code = params.get("code");
const code = route.query?.code as string;
defHttp
.put<boolean>({ url: `/oauth2/github/bind/${code}` })
.then((res) => {
@@ -119,8 +119,7 @@
});
function clearUrl() {
const { pathname } = globalThis.location;
globalThis.history.replaceState({}, "", pathname);
router.replace({ query: {} });
}
onMounted(() => {