🐛: 修复 withInstall

This commit is contained in:
sight
2022-05-15 03:17:00 +08:00
parent f972c94f55
commit 334699b210
82 changed files with 238 additions and 241 deletions

View File

@@ -1,3 +1,3 @@
export * from "./domUtil";
export * from "./guidUtil";
export * from "./install";
export * from "./withInstall";

View File

@@ -1,17 +0,0 @@
import type { App } from "vue";
import i18n from "../language";
export const withInstall = (comp: any) => {
comp.install = (app: App | any) => {
if (
!app._instance?.isCE &&
!app._instance?.appContext?.app?.__VUE_I18N_SYMBOL__
) {
app.use(i18n);
}
app.component(comp.name, comp);
};
return comp;
};

View File

@@ -0,0 +1,17 @@
import type { App, Plugin } from "vue";
import i18n from "../language";
export type WithInstallType<T> = T & Plugin;
export const withInstall = <T>(comp: T): T & Plugin => {
const component = comp as any;
component.install = (app: App | any) => {
if (!app.__VUE_I18N_SYMBOL__) {
app.use(i18n);
}
app.component(component.name, comp);
};
return component as T & Plugin;
};