feat: withInstall (#275)

This commit is contained in:
一万 2022-05-19 12:31:42 +08:00 committed by GitHub
parent b6ed8b40d1
commit 1f8e50f482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 34 additions and 81 deletions

View File

@ -1,11 +1,7 @@
import { App } from "vue";
import { withInstall } from "/@/utils";
import reBarcode from "./src/index.vue";
/** 条形码组件 */
export const ReBarcode = Object.assign(reBarcode, {
install(app: App) {
app.component(reBarcode.name, reBarcode);
}
});
export const ReBarcode = withInstall(reBarcode);
export default ReBarcode;

View File

@ -1,19 +1,11 @@
import { App } from "vue";
import { withInstall } from "/@/utils";
import reNormalCountTo from "./src/normal";
import reboundCountTo from "./src/rebound";
/** 普通数字动画组件 */
const ReNormalCountTo = Object.assign(reNormalCountTo, {
install(app: App) {
app.component(reNormalCountTo.name, reNormalCountTo);
}
});
const ReNormalCountTo = withInstall(reNormalCountTo);
/** 回弹式数字动画组件 */
const ReboundCountTo = Object.assign(reboundCountTo, {
install(app: App) {
app.component(reboundCountTo.name, reboundCountTo);
}
});
const ReboundCountTo = withInstall(reboundCountTo);
export { ReNormalCountTo, ReboundCountTo };

View File

@ -1,11 +1,7 @@
import { App } from "vue";
import reCropper from "./src";
import { withInstall } from "/@/utils";
/** 图片裁剪组件 */
export const ReCropper = Object.assign(reCropper, {
install(app: App) {
app.component(reCropper.name, reCropper);
}
});
export const ReCropper = withInstall(reCropper);
export default ReCropper;

View File

@ -1,11 +1,7 @@
import { App } from "vue";
import reFlop from "./src/index.vue";
import { withInstall } from "/@/utils";
/** 时间翻牌组件 */
export const ReFlop = Object.assign(reFlop, {
install(app: App) {
app.component(reFlop.name, reFlop);
}
});
export const ReFlop = withInstall(reFlop);
export default ReFlop;

View File

@ -1,28 +1,16 @@
import { App } from "vue";
import { withInstall } from "/@/utils";
import control from "./src/Control.vue";
import nodePanel from "./src/NodePanel.vue";
import dataDialog from "./src/DataDialog.vue";
/** LogicFlow流程图-控制面板 */
const Control = Object.assign(control, {
install(app: App) {
app.component(control.name, control);
}
});
const Control = withInstall(control);
/** LogicFlow流程图-拖拽面板 */
const NodePanel = Object.assign(nodePanel, {
install(app: App) {
app.component(nodePanel.name, nodePanel);
}
});
const NodePanel = withInstall(nodePanel);
/** LogicFlow流程图-查看数据 */
const DataDialog = Object.assign(dataDialog, {
install(app: App) {
app.component(dataDialog.name, dataDialog);
}
});
const DataDialog = withInstall(dataDialog);
export { Control, NodePanel, DataDialog };

View File

@ -1,11 +1,7 @@
import { App } from "vue";
import { withInstall } from "/@/utils";
import reImageVerify from "./src/index.vue";
/** 图形验证码组件 */
export const ReImageVerify = Object.assign(reImageVerify, {
install(app: App) {
app.component(reImageVerify.name, reImageVerify);
}
});
export const ReImageVerify = withInstall(reImageVerify);
export default ReImageVerify;

View File

@ -1,11 +1,7 @@
import { App } from "vue";
import amap from "./src/Amap.vue";
import { withInstall } from "/@/utils";
/** 高德地图组件 */
export const Amap = Object.assign(amap, {
install(app: App) {
app.component(amap.name, amap);
}
});
export const Amap = withInstall(amap);
export default Amap;

View File

@ -1,11 +1,7 @@
import { App } from "vue";
import reQrcode from "./src/index";
import { withInstall } from "/@/utils";
/** 二维码组件 */
export const ReQrcode = Object.assign(reQrcode, {
install(app: App) {
app.component(reQrcode.name, reQrcode);
}
});
export const ReQrcode = withInstall(reQrcode);
export default ReQrcode;

View File

@ -1,11 +1,7 @@
import { App } from "vue";
import { withInstall } from "/@/utils";
import reSeamlessScroll from "./src/index.vue";
/** 无缝滚动组件 */
export const ReSeamlessScroll = Object.assign(reSeamlessScroll, {
install(app: App) {
app.component(reSeamlessScroll.name, reSeamlessScroll);
}
});
export const ReSeamlessScroll = withInstall(reSeamlessScroll);
export default ReSeamlessScroll;

View File

@ -1,11 +1,7 @@
import { App } from "vue";
import reSelector from "./src";
import { withInstall } from "/@/utils";
/** 选择器组件 */
export const ReSelector = Object.assign(reSelector, {
install(app: App) {
app.component(reSelector.name, reSelector);
}
});
export const ReSelector = withInstall(reSelector);
export default ReSelector;

View File

@ -1,9 +1,5 @@
import { App } from "vue";
import epTableProBar from "./src/bar";
import { withInstall } from "/@/utils";
/** table-crud组件 */
export const EpTableProBar = Object.assign(epTableProBar, {
install(app: App) {
app.component(epTableProBar.name, epTableProBar);
}
});
export const EpTableProBar = withInstall(epTableProBar);

9
src/utils/index.ts Normal file
View File

@ -0,0 +1,9 @@
import type { App, Plugin } from "vue";
export const withInstall = <T>(component: T) => {
const comp = component as any;
comp.install = (app: App) => {
app.component(comp.name, component);
};
return component as T & Plugin;
};