mirror of
https://github.com/certd/certd.git
synced 2026-05-15 12:37:30 +08:00
perf: 优化菜单
This commit is contained in:
@@ -3,10 +3,12 @@ import * as sites from "./util.site";
|
||||
import * as storages from "./util.storage";
|
||||
import commons from "./util.common";
|
||||
import * as mitt from "./util.mitt";
|
||||
import router from "/util.router";
|
||||
export const util = {
|
||||
...envs,
|
||||
...sites,
|
||||
...storages,
|
||||
...commons,
|
||||
...mitt
|
||||
...mitt,
|
||||
...router
|
||||
};
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import router from "/@/router";
|
||||
|
||||
async function open(path: any) {
|
||||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
if (path.startsWith("http://") || path.startsWith("https://")) {
|
||||
window.open(path);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const navigationResult = await router.push(path);
|
||||
if (navigationResult) {
|
||||
// 导航被阻止
|
||||
} else {
|
||||
// 导航成功 (包括重新导航的情况)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("导航失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
export const routerUtils = {
|
||||
open
|
||||
};
|
||||
Reference in New Issue
Block a user