kui-vue
Version:
A lightweight desktop UI component library suitable for Vue.js 2.
50 lines (43 loc) • 1.22 kB
JavaScript
import pkg from "../package.json";
import locale from "./utils/i18n";
import * as components from "./components";
import "./styles/index.less";
export * from "./components";
const UI = {
version: pkg.version,
locale: locale.use,
i18n: locale.i18n,
lang: {},
install: function (Vue, opts = {}) {
if (opts.locale) {
locale.use(opts.locale);
}
if (opts.i18n) {
locale.setI18n(opts.i18n);
}
Object.keys(components).forEach((key) => {
const component = components[key];
if (!key.startsWith("K")) {
const kebabName =
"k-" +
key
.replace(/([A-Z])/g, "-$1")
.replace(/^-/, "")
.toLowerCase();
Vue.component(kebabName, component);
}
Vue.component(key, component);
});
Vue.prototype.$message = components.message;
Vue.prototype.$notice = components.notice;
Vue.prototype.$modal = components.modal;
Vue.prototype.$loading = components.loading;
Vue.prototype.$image = components.KImage;
Vue.prototype.$theme = components.theme;
},
};
// auto install
// if (typeof window !== 'undefined' && window.Vue) {
// UI.install(window.Vue);
// }
export default UI;