From 87231fdb1f26cfe312631c029ccbf9a858eb5d3b Mon Sep 17 00:00:00 2001 From: aixianling Date: Fri, 25 Mar 2022 14:36:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?dvui=E6=9B=B4=E6=8D=A2=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/allProject.js | 7 +++++-- project/build.js | 7 +++++-- project/dvui/entries.js | 30 ++++++++++++++++++++++++++++++ project/dvui/package.json | 2 +- 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 project/dvui/entries.js diff --git a/project/allProject.js b/project/allProject.js index 747f297d..442bd7f0 100644 --- a/project/allProject.js +++ b/project/allProject.js @@ -114,6 +114,9 @@ const generateMain = project => { }) }) return Promise.all([getCores, getApps]).then(() => new Promise(resolve => { + if (project == 'dvui') { + return resolve() + } chalkTag.info(project + '正在生成打包文件...') let bin = path.join(__dirname, project.toString(), 'index.js'), coreApps = cores.map(e => `{name:'${e.name}',component:require('../../${e.component}').default}`), @@ -124,7 +127,7 @@ const generateMain = project => { const install = function (Vue) { if (install.installed) return Promise.resolve() else{ - let contexts = require.context('.', true, /(\\/.+)[\\\/]${project=='dvui'?'Ai':'App'}[^\\\/]+\\.vue$/) + let contexts = require.context('.', true, /(\\/.+)[\\\/]App[^\\\/]+\\.vue$/) if (contexts) { contexts.keys().map(e => { if (contexts(e).default) { @@ -158,7 +161,7 @@ const generateMain = project => { }) })).then(() => { fsExtra.readJson(path.join(__dirname, project.toString(), 'package.json'), (err, json) => { - let cmd = `vue-cli-service build --target lib --dest project/${project}/dist project/${project}/index.js --name ${json.name}` + let cmd = `vue-cli-service build --target lib --dest project/${project}/dist project/${project}/${project == 'dvui' ? 'entries' : 'index'}.js --name ${json.name}` chalkTag.info(project + '正在压缩文件中...') exec(cmd, { cwd: path.join(__dirname, '..') diff --git a/project/build.js b/project/build.js index 06f862ce..0da1c102 100644 --- a/project/build.js +++ b/project/build.js @@ -114,6 +114,9 @@ const start = () => { } }) })).then(prj => new Promise(resolve => { + if (prj == 'dvui') { + return resolve(prj) + } chalkTag.info('正在生成打包文件...') let bin = path.join(__dirname, prj.toString(), 'index.js'), coreApps = cores.map(e => `{name:'${e.name}',component:require('../../${e.component}').default}`), @@ -124,7 +127,7 @@ const start = () => { const install = function (Vue) { if (install.installed) return Promise.resolve() else{ - let contexts = require.context('.', true, /(\\/.+)\\/${prj == 'dvui' ? 'Ai' : 'App'}[^\\/]+\\.vue$/) + let contexts = require.context('.', true, /(\\/.+)\\/App[^\\/]+\\.vue$/) if (contexts) { contexts.keys().map(e => { if (contexts(e).default) { @@ -160,7 +163,7 @@ const start = () => { }) })).then(project => new Promise((resolve, reject) => { fsExtra.readJson(path.join(__dirname, project.toString(), 'package.json'), (err, json) => { - let cmd = `vue-cli-service build --target lib --dest project/${project}/dist project/${project}/index.js --name ${json.name}` + let cmd = `vue-cli-service build --target lib --dest project/${project}/dist project/${project}/${project == 'dvui' ? 'entries' : 'index'}.js --name ${json.name}` chalkTag.info('正在压缩文件中...') exec(cmd, { cwd: path.join(__dirname, '..') diff --git a/project/dvui/entries.js b/project/dvui/entries.js new file mode 100644 index 00000000..0f9fa4ce --- /dev/null +++ b/project/dvui/entries.js @@ -0,0 +1,30 @@ +const apps = [] +const install = function (Vue) { + if (install.installed) return Promise.resolve() + else { + let contexts = require.context('.', true, /(\/.+)\/Ai[^\/]+\.vue$/) + if (contexts) { + contexts.keys().map(e => { + if (contexts(e).default) { + let mod = apps.find(a => a.name == contexts(e).default.name) + if (mod) { + mod.component = contexts(e).default + } else { + apps.push({name: contexts(e).default.name, component: contexts(e).default}) + } + } + }) + } + apps.map(e => { + Vue.component(e.name, e.component) + }) + } +} +// 判断是否是直接引入文件 +if (typeof window !== 'undefined' && window.Vue) { + install(window.Vue) +} +export default { + // 导出的对象必须具有 install,才能被 Vue.use() 方法安装 + install +} diff --git a/project/dvui/package.json b/project/dvui/package.json index 0dc33ec6..a5420118 100644 --- a/project/dvui/package.json +++ b/project/dvui/package.json @@ -3,7 +3,7 @@ "author": "kubbo", "version": "2.0.1", "description": "数据大屏UI库", - "main": "dist/index.js", + "main": "dist/dvcp-dv-ui.common.js", "publishConfig": { "registry": "http://192.168.1.87:4873/" }, From 208e6de3e457a942521f435c93cbb132a194739f Mon Sep 17 00:00:00 2001 From: aixianling Date: Fri, 25 Mar 2022 16:04:19 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E8=AE=BE=E8=AE=A1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/entries.js | 22 --------------------- examples/main.js | 1 - packages/bigscreen/designer/AppDesigner.vue | 4 ++-- 3 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 examples/entries.js diff --git a/examples/entries.js b/examples/entries.js deleted file mode 100644 index 3d7290b4..00000000 --- a/examples/entries.js +++ /dev/null @@ -1,22 +0,0 @@ -//引入当前工程所有的应用 -const install = function(Vue) { - if (install.installed) return Promise.resolve(); - else { - let contexts = require.context('../packages', true, /(\/.+)\/App[^\/]+\.vue$/); - if (contexts) { - contexts.keys().map((e) => { - if (contexts(e).default) { - Vue.component(contexts(e).default.name, contexts(e).default); - } - }); - } - } -}; -// 判断是否是直接引入文件 -if (typeof window !== 'undefined' && window.Vue) { - install(window.Vue); -} -export default { - // 导出的对象必须具有 install,才能被 Vue.use() 方法安装 - install -}; diff --git a/examples/main.js b/examples/main.js index 43715077..1772d983 100644 --- a/examples/main.js +++ b/examples/main.js @@ -11,7 +11,6 @@ import store from './store'; import dataV from '@jiaminghi/data-view'; Vue.use(dataV); - Vue.use(ui); Vue.use(vcUI); //富文本编辑器配置 diff --git a/packages/bigscreen/designer/AppDesigner.vue b/packages/bigscreen/designer/AppDesigner.vue index ca598ddf..8b69a7cc 100644 --- a/packages/bigscreen/designer/AppDesigner.vue +++ b/packages/bigscreen/designer/AppDesigner.vue @@ -22,14 +22,14 @@