mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
修改样式细节,修改utils
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
import { Component, DefineComponent } from "vue";
|
||||
import { App, Plugin, getCurrentInstance } from "vue";
|
||||
|
||||
interface Registed {
|
||||
[key: string]: boolean;
|
||||
}
|
||||
let registed: Registed = {};
|
||||
|
||||
interface Comp {
|
||||
displayName?: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
type RegisteComp = (comp: Comp & Plugin) => void;
|
||||
|
||||
const registeComp: RegisteComp = comp => {
|
||||
const name = comp.displayName || comp.name;
|
||||
|
||||
if (name && !registed[name]) {
|
||||
const instance = getCurrentInstance();
|
||||
const app = instance?.appContext.app;
|
||||
if (app) {
|
||||
app.use(comp);
|
||||
registed[name] = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const regComp: (comp: any) => void = comp => {
|
||||
const instance = getCurrentInstance();
|
||||
const app = instance?.appContext.app;
|
||||
app?.component(comp?.name, comp);
|
||||
};
|
||||
export { registeComp, regComp };
|
||||
@@ -1,8 +1,5 @@
|
||||
import { h } from 'vue';
|
||||
import { NIcon } from 'naive-ui';
|
||||
import { ResultEnum } from "@/enums/httpEnum"
|
||||
import { ErrorPageNameMap } from "@/enums/pageEnum"
|
||||
import router from '@/router';
|
||||
|
||||
/**
|
||||
* * 生成一个用不重复的ID
|
||||
@@ -24,14 +21,4 @@ export const renderIcon = (icon: any) => {
|
||||
return () => h(NIcon, null, { default: () => h(icon) });
|
||||
}
|
||||
|
||||
/**
|
||||
* * 错误页重定向
|
||||
* @param icon
|
||||
* @returns
|
||||
*/
|
||||
export const redirectErrorPage = (code: ResultEnum) => {
|
||||
router.push({
|
||||
name: ErrorPageNameMap.get(code)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { ResultEnum } from "@/enums/httpEnum"
|
||||
import { ErrorPageNameMap } from "@/enums/pageEnum"
|
||||
import router from '@/router';
|
||||
|
||||
/**
|
||||
* * 错误页重定向
|
||||
* @param icon
|
||||
* @returns
|
||||
*/
|
||||
export const redirectErrorPage = (code: ResultEnum) => {
|
||||
if(!code) return false
|
||||
const pageName = ErrorPageNameMap.get(code)
|
||||
if(!pageName) return false
|
||||
routerTurnByName(pageName)
|
||||
}
|
||||
|
||||
/**
|
||||
* * 根据名字跳转路由
|
||||
* @param pageName
|
||||
*/
|
||||
export const routerTurnByName = (pageName: string) => {
|
||||
router.push({
|
||||
name: pageName
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user