diff --git a/src/tis_app_template_kt/bus.min.js b/src/tis_app_template_kt/bus.min.js new file mode 100644 index 0000000..5de2404 --- /dev/null +++ b/src/tis_app_template_kt/bus.min.js @@ -0,0 +1 @@ +!function(t,e,o){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=n(e),s=n(o);const a=document.querySelector("body");async function i(t){if(t.length)for(const e of t)a.appendChild(e),await function(n){return new Promise((e,o)=>{n.onload=n.onreadystatechange=function(){var t=n.readyState;void 0!==t&&!/^(loaded|complete)$/.test(t)||(e(),n.onload=n.onerror=n.onreadystatechange=null)},n.onerror=function(){var t=n.readyState;void 0!==t&&!/^(loaded|complete)$/.test(t)||(console.log("load js resources failed"),o({error:"load js resources failed"}),n.onload=n.onerror=n.onreadystatechange=null)}})}(e).catch(()=>{a.removeChild(e)})}function c(t){const e=document.createElement("link");return e.setAttribute("rel","stylesheet"),e.setAttribute("href",t),e}function l(t){const e=document.createElement("script");return e.setAttribute("type","text/javascript"),/require.min.js/.test(t)?(e.setAttribute("src","/TIS_DLTS_WEB/esapp-map/Build/Js/require.min.js"),e.setAttribute("data-main","/TIS_DLTS_WEB/esapp-map/Build/Js/main.js")):e.setAttribute("src",t.src||t),e}const p=new Set,u="development"===process.env.NODE_ENV?process.env.BASE_URL:"";let m="";async function d(t,e){var o;if(m=/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)/.test(e)?e:"",void 0===t||null==t)return Promise.resolve("[所加载资源为null]");o=t,await async function(){if(void 0!==o&&null!=o){const{cssFiles:t,jsFiles:e}=o;t?await i([...t.filter(y).map(h).map(c),...e.filter(y).map(h).map(l)]):await i([...e.filter(y).map(h).map(l)])}}()}function h(t){return(m||u)+t}function y(t){var e=p.has(t);return p.add(t),!e}let f="";const g=new r.default({data:{components:[],asserts:{},deviceType:"pc",actives:[],layouts:[],widgets:[]},methods:{setVueInstance(t){},getDeviceType(){return this.deviceType},getTemplateLayouts(){return this.layouts},menuStatusUpdate(){var t=this.getTemplateLayouts().filter(t=>!t.lazy).map(t=>t.component.name||t.component);console.log("============>",""),this.$emit("TIS_TEMPLATE_MENU_ACTIVE",{appId:"",onActives:t,system:!0})},async loadComponent(s){const a=this.components.find(t=>t.component===s)||{};console.log("所有组件...",this.components),console.log("所有资源...",this.asserts),console.log("当前加载组件...",s),console.log("匹配到的组件...",a);let i=null,t=[],c=!1;try{var e=a.segprefix;i=this.asserts[e],t=a.dependencies||[],c=a.lib}catch(t){console.error(t)}for(const o of t)await d(this.asserts[o]||null,f);return new Promise((o,n)=>{console.log("开始加载组件资源",i,f),d(i,f).then(()=>{if(c)o(a);else{let t=(new Date).getTime();const e=setInterval(()=>{r.default.component(`${s}`)?(o(a),clearInterval(e)):2e3<(new Date).getTime()-t&&(i?n(`[loading error:${s}]:loading component timed out`):n(`[loading error:${s}]:组件资源加载失败`),clearInterval(e))},300)}}).catch(t=>{i?n(`[loading error:${s}]:${t}`):n(`[loading error:${s}]:组件资源加载失败`)})})},openComponentByMenu(o){this.components.filter(t=>{var e=t.component.name||t.component,e=o.includes(e);if(e)return t.lazy=!e,t}).forEach(e=>{this.layouts.some(t=>(t.component.name||t.component)===e.component)?this.layouts.forEach(t=>{(t.component.name||t.component)===e.component&&(t.lazy=!1)}):this.layouts.push(e),this.actives.some(t=>t.component===e.component)||("dialog"===e.type?this.actives=[e]:this.actives.push(e))}),console.log("layouts变化状态",this.layouts),console.log("actives变化状态",this.actives),this.menuStatusUpdate()},closeComponent(o){this.layouts.forEach(t=>{var e=t.component.name||t.component,e=o.includes(e);e&&(t.lazy=e)}),console.log("待删除组件",o),o.forEach(e=>{var t=this.actives.findIndex(t=>t.component===e);console.log("aaaaaa",t),0<=t&&this.actives.splice(t,1)}),console.log("layouts变化状态",this.layouts),console.log("actives变化状态",this.actives),this.menuStatusUpdate()},initLayouts(t=[]){this.layouts.push(...t.filter(t=>!t.lazy))},getWidgetsByType(e){return this.layouts.filter(t=>(t.type===e||t.position===e)&&!t.lazy).map(t=>"string"==typeof t.component?(console.log("下载component资源",t.component),this.loadComponent(t.component)):t)},getActivesByType(e){return this.actives.filter(t=>t.type===e)},async initData(t){var e="development"===process.env.NODE_ENV;f=t.tis?t.tis.entry:baseUrl;var o=await s.default.get(`${f}/esplug.json`).catch(t=>console.error(t)),n=await s.default.get(`${f}/tisplatform.json`).catch(t=>console.error(t));try{t.tis&&!e?(console.log("框架传入的components:",t.tis.components),this.components=t.tis.components?[...t.tis.components,...o.data.components]:o.data.components,this.asserts=0!==Object.keys(t.tis.asserts).length?t.tis.asserts:n.data,this.widgets=t.tis.widgets||o.data.widgets):(this.components=o.data.components,this.asserts=n.data,this.widgets=o.data.widgets),this.components=this.components.map(t=>(Object.prototype.hasOwnProperty.call(t,"lazy")||"background"===t.type||(t.lazy=!0),t))}catch(t){console.error(t)}}}});t.default=g,t.onMount=async function(t){await g.initData(t),g.initLayouts(g.components),g.initLayouts(g.widgets)},t.onSetup=function(t={}){g.layouts=t.layout},Object.defineProperty(t,"__esModule",{value:!0})}({},Vue,axios); diff --git a/src/tis_app_template_kt/package.json b/src/tis_app_template_kt/package.json index 8d4b304..ea80b14 100644 --- a/src/tis_app_template_kt/package.json +++ b/src/tis_app_template_kt/package.json @@ -5,7 +5,7 @@ "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", - "build:dev":"vue-cli-service build --mode dev", + "build:dev": "vue-cli-service build --mode dev", "lint": "vue-cli-service lint" }, "dependencies": { @@ -26,10 +26,11 @@ "lint-staged": "^9.5.0", "postcss-px-to-viewport": "git+https://git.inscloudtech.com/mirrors/postcss-px-to-viewport.git", "prettier": "^1.19.1", + "rollup-plugin-uglify": "^6.0.4", "sass": "^1.26.5", "sass-loader": "^8.0.2", - "vue-template-compiler": "^2.6.11", - "vue-async-computed": "^3.9.0" + "vue-async-computed": "^3.9.0", + "vue-template-compiler": "^2.6.11" }, "gitHooks": { "pre-commit": "lint-staged" diff --git a/src/tis_app_template_kt/rollup.config.js b/src/tis_app_template_kt/rollup.config.js new file mode 100644 index 0000000..534bc22 --- /dev/null +++ b/src/tis_app_template_kt/rollup.config.js @@ -0,0 +1,29 @@ +import { uglify } from 'rollup-plugin-uglify' + +export default { + input: 'src/tis/bus.js', + output: { + file: 'bus.min.js', + format: 'iife' + }, + external: [ + 'vue', + 'axios' + ], + plugins: [ + uglify() + /* + babel({ + exclude: ["node_modules/**"], + presets: [ + [ + "@babel/env", { + modules: false, + targets: "last 2 versions, ie >= 10" + } + ] + ] + }) + */ + ] +} diff --git a/src/tis_app_template_kt/yarn.lock b/src/tis_app_template_kt/yarn.lock index 3221ce2..4f50ddf 100644 --- a/src/tis_app_template_kt/yarn.lock +++ b/src/tis_app_template_kt/yarn.lock @@ -5266,6 +5266,14 @@ javascript-stringify@^2.0.1: resolved "https://registry.npm.taobao.org/javascript-stringify/download/javascript-stringify-2.1.0.tgz?cache=0&sync_timestamp=1618360134745&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjavascript-stringify%2Fdownload%2Fjavascript-stringify-2.1.0.tgz#27c76539be14d8bd128219a2d731b09337904e79" integrity sha1-J8dlOb4U2L0Sghmi1zGwkzeQTnk= +jest-worker@^24.0.0: + version "24.9.0" + resolved "https://registry.npmmirror.com/jest-worker/download/jest-worker-24.9.0.tgz?cache=0&sync_timestamp=1634626737887&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fjest-worker%2Fdownload%2Fjest-worker-24.9.0.tgz#5dbfdb5b2d322e98567898238a9697bcce67b3e5" + integrity sha1-Xb/bWy0yLphWeJgjipaXvM5ns+U= + dependencies: + merge-stream "^2.0.0" + supports-color "^6.1.0" + js-message@1.0.7: version "1.0.7" resolved "https://registry.npm.taobao.org/js-message/download/js-message-1.0.7.tgz#fbddd053c7a47021871bb8b2c95397cc17c20e47" @@ -7450,6 +7458,16 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^3.0.0" inherits "^2.0.1" +rollup-plugin-uglify@^6.0.4: + version "6.0.4" + resolved "https://registry.npm.taobao.org/rollup-plugin-uglify/download/rollup-plugin-uglify-6.0.4.tgz#65a0959d91586627f1e46a7db966fd504ec6c4e6" + integrity sha1-ZaCVnZFYZifx5Gp9uWb9UE7GxOY= + dependencies: + "@babel/code-frame" "^7.0.0" + jest-worker "^24.0.0" + serialize-javascript "^2.1.2" + uglify-js "^3.4.9" + run-async@^2.4.0: version "2.4.1" resolved "https://registry.npm.taobao.org/run-async/download/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" @@ -7590,6 +7608,11 @@ send@0.17.1: range-parser "~1.2.1" statuses "~1.5.0" +serialize-javascript@^2.1.2: + version "2.1.2" + resolved "https://registry.nlark.com/serialize-javascript/download/serialize-javascript-2.1.2.tgz#ecec53b0e0317bdc95ef76ab7074b7384785fa61" + integrity sha1-7OxTsOAxe9yV73arcHS3OEeF+mE= + serialize-javascript@^4.0.0: version "4.0.0" resolved "https://registry.nlark.com/serialize-javascript/download/serialize-javascript-4.0.0.tgz#b525e1238489a5ecfc42afacc3fe99e666f4b1aa" @@ -8426,6 +8449,11 @@ uglify-js@3.4.x: commander "~2.19.0" source-map "~0.6.1" +uglify-js@^3.4.9: + version "3.14.2" + resolved "https://registry.nlark.com/uglify-js/download/uglify-js-3.14.2.tgz?cache=0&sync_timestamp=1631026519465&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fuglify-js%2Fdownload%2Fuglify-js-3.14.2.tgz#d7dd6a46ca57214f54a2d0a43cad0f35db82ac99" + integrity sha1-191qRspXIU9UotCkPK0PNduCrJk= + unbox-primitive@^1.0.1: version "1.0.1" resolved "https://registry.npm.taobao.org/unbox-primitive/download/unbox-primitive-1.0.1.tgz?cache=0&sync_timestamp=1616706302651&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Funbox-primitive%2Fdownload%2Funbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471"