vue-document-components
Version:
A collection of Vue.js components for document preview, file management, and media handling
55 lines (46 loc) • 1.26 kB
JavaScript
// 导入现代化主题样式
import './styles/theme.css';
import PdfPreviewDialog from './components/PdfPreviewDialog.vue';
import ImagePreviewDialog from './components/ImagePreviewDialog.vue';
import FileUploader from './components/FileUploader.vue';
// 所有组件
const components = {
PdfPreviewDialog,
ImagePreviewDialog,
FileUploader
};
// Vue 3 安装插件的方法
const install = (app, options = {}) => {
// 可以通过options控制要安装的组件
const { components: installComponents = Object.keys(components) } = options;
installComponents.forEach(name => {
if (components[name]) {
app.component(name, components[name]);
}
});
};
// 自动安装(当通过script标签引入时)
if (typeof window !== 'undefined' && window.Vue && window.Vue.createApp) {
// Vue 3 全局安装
const app = window.Vue.createApp({});
install(app);
}
// 默认导出
export default {
install,
...components
};
// 具名导出
export {
PdfPreviewDialog,
ImagePreviewDialog,
FileUploader,
install
};
// Vue 3 插件对象
const VueDocumentComponents = {
install,
...components
};
// 默认导出插件对象
export default VueDocumentComponents;