@10yun/open-sdk 0.3.123 → 0.3.125
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{common/buildRbac.js → build/build-rbac.js} +7 -6
- package/build/common.js +9 -0
- package/build/plugin-common.js +124 -0
- package/build/plugin-html.js +16 -0
- package/common/rbac.js +9 -1
- package/common/router.js +3 -2
- package/dist/{404-C60P9a1v.cjs → 404-Bg-K1kuR.cjs} +1 -1
- package/dist/{404-B9GU-b7N.js → 404-D-CSYsEp.js} +1 -1
- package/dist/{alone_run-D0Lbuc9h.cjs → alone_run-BlefRFb8.cjs} +1 -1
- package/dist/{alone_run-DM0g1Rfb.js → alone_run-CRpgzb60.js} +1 -1
- package/dist/index-DmigSfXx.js +11430 -0
- package/dist/index-cXIUdiY2.cjs +30 -0
- package/dist/{open-sdk.cjs.js → index.cjs.js} +1 -1
- package/dist/index.es.js +28 -0
- package/dist/{login-CLxZ-SbY.js → login-eTcOceMG.js} +38 -35
- package/dist/{login-BVk2A5mA.cjs → login-z6R7WXOz.cjs} +1 -1
- package/dist/{none-D7cL7qb9.cjs → none-B_DVlv7i.cjs} +1 -1
- package/dist/{none-CaMalHPX.js → none-D3JIq_1z.js} +1 -1
- package/package.json +18 -5
- package/vite-plugin-qiankun/es/index-old.js +126 -0
- package/vite-plugin-qiankun/es/index.d.ts +7 -7
- package/vite-plugin-qiankun/es/index.js +155 -122
- package/vite-plugin-qiankun/es/info.md +3 -0
- package/vite-plugin-shiyun.js +4 -146
- package/common/common.js +0 -9
- package/dist/index-BWLMDM4T.cjs +0 -25
- package/dist/index-CK8iTQCN.js +0 -9616
- package/dist/open-sdk.es.js +0 -27
- /package/{common → build}/encipher.js +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* vite-plugin-qiankun.js v1.0.14
|
|
3
|
+
* (c) 2021-2022 Teng Mao Qing
|
|
4
|
+
* Released under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
// import cheerio from 'cheerio';
|
|
7
|
+
import * as cheerio from 'cheerio';
|
|
8
|
+
|
|
9
|
+
/*! *****************************************************************************
|
|
10
|
+
Copyright (c) Microsoft Corporation.
|
|
11
|
+
|
|
12
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
13
|
+
purpose with or without fee is hereby granted.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
16
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
17
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
18
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
19
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
20
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
21
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
22
|
+
***************************************************************************** */
|
|
23
|
+
|
|
24
|
+
function __spreadArray(to, from) {
|
|
25
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i];
|
|
26
|
+
return to;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var createQiankunHelper = function (qiankunName) {
|
|
30
|
+
return (
|
|
31
|
+
"\n const createDeffer = (hookName) => {\n const d = new Promise((resolve, reject) => {\n window.proxy && (window.proxy[`vite${hookName}`] = resolve)\n })\n return props => d.then(fn => fn(props));\n }\n const bootstrap = createDeffer('bootstrap');\n const mount = createDeffer('mount');\n const unmount = createDeffer('unmount');\n const update = createDeffer('update');\n\n ;(global => {\n global.qiankunName = '" +
|
|
32
|
+
qiankunName +
|
|
33
|
+
"';\n global['" +
|
|
34
|
+
qiankunName +
|
|
35
|
+
"'] = {\n bootstrap,\n mount,\n unmount,\n update\n };\n })(window);\n"
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
var createImportFinallyResolve = function (qiankunName) {
|
|
39
|
+
return (
|
|
40
|
+
"\n const qiankunLifeCycle = window.moudleQiankunAppLifeCycles && window.moudleQiankunAppLifeCycles['" +
|
|
41
|
+
qiankunName +
|
|
42
|
+
"'];\n if (qiankunLifeCycle) {\n window.proxy.vitemount((props) => qiankunLifeCycle.mount(props));\n window.proxy.viteunmount((props) => qiankunLifeCycle.unmount(props));\n window.proxy.vitebootstrap(() => qiankunLifeCycle.bootstrap());\n window.proxy.viteupdate((props) => qiankunLifeCycle.update(props));\n }\n "
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/* ---------------------------------- */
|
|
47
|
+
/* 主插件(逻辑严格对齐原版) */
|
|
48
|
+
/* ---------------------------------- */
|
|
49
|
+
var htmlPlugin = function (qiankunName, microOption) {
|
|
50
|
+
if (microOption === void 0) {
|
|
51
|
+
microOption = {};
|
|
52
|
+
}
|
|
53
|
+
var isProduction;
|
|
54
|
+
var base = '';
|
|
55
|
+
var module2DynamicImport = function ($, scriptTag) {
|
|
56
|
+
if (!scriptTag) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var script$ = $(scriptTag);
|
|
60
|
+
var moduleSrc = script$.attr('src');
|
|
61
|
+
var appendBase = '';
|
|
62
|
+
if (microOption.useDevMode && !isProduction) {
|
|
63
|
+
appendBase = "(window.proxy ? (window.proxy.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ + '..') : '') + ";
|
|
64
|
+
}
|
|
65
|
+
script$.removeAttr('src');
|
|
66
|
+
script$.removeAttr('type');
|
|
67
|
+
script$.html('import(' + appendBase + "'" + moduleSrc + "')");
|
|
68
|
+
return script$;
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
name: 'qiankun-html-transform',
|
|
72
|
+
configResolved: function (config) {
|
|
73
|
+
isProduction = config.command === 'build' || config.isProduction;
|
|
74
|
+
base = config.base;
|
|
75
|
+
},
|
|
76
|
+
configureServer: function (server) {
|
|
77
|
+
return function () {
|
|
78
|
+
server.middlewares.use(function (req, res, next) {
|
|
79
|
+
if (isProduction || !microOption.useDevMode) {
|
|
80
|
+
next();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
var end = res.end.bind(res);
|
|
84
|
+
res.end = function () {
|
|
85
|
+
var args = [];
|
|
86
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
87
|
+
args[_i] = arguments[_i];
|
|
88
|
+
}
|
|
89
|
+
var htmlStr = args[0],
|
|
90
|
+
rest = args.slice(1);
|
|
91
|
+
if (typeof htmlStr === 'string') {
|
|
92
|
+
var $ = cheerio.load(htmlStr);
|
|
93
|
+
module2DynamicImport($, $('script[src=' + base + '@vite/client]').get(0));
|
|
94
|
+
htmlStr = $.html();
|
|
95
|
+
}
|
|
96
|
+
end.apply(void 0, __spreadArray([htmlStr], rest));
|
|
97
|
+
};
|
|
98
|
+
next();
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
transformIndexHtml: function (html) {
|
|
103
|
+
var $ = cheerio.load(html);
|
|
104
|
+
var moduleTags = $('body script[type=module], head script[crossorigin=""]');
|
|
105
|
+
if (!moduleTags || !moduleTags.length) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
var len = moduleTags.length;
|
|
109
|
+
moduleTags.each(function (i, moduleTag) {
|
|
110
|
+
var script$ = module2DynamicImport($, moduleTag);
|
|
111
|
+
if (len - 1 === i) {
|
|
112
|
+
script$ === null || script$ === void 0
|
|
113
|
+
? void 0
|
|
114
|
+
: script$.html(
|
|
115
|
+
script$.html() + '.finally(() => {\n ' + createImportFinallyResolve(qiankunName) + '\n })'
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
$('body').append('<script>' + createQiankunHelper(qiankunName) + '</script>');
|
|
120
|
+
var output = $.html();
|
|
121
|
+
return output;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export default htmlPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PluginOption } from 'vite';
|
|
2
|
-
export declare type MicroOption = {
|
|
3
|
-
useDevMode?: boolean;
|
|
4
|
-
};
|
|
5
|
-
declare type PluginFn = (qiankunName: string, microOption?: MicroOption) => PluginOption;
|
|
6
|
-
declare const htmlPlugin: PluginFn;
|
|
7
|
-
export default htmlPlugin;
|
|
1
|
+
import { PluginOption } from 'vite';
|
|
2
|
+
export declare type MicroOption = {
|
|
3
|
+
useDevMode?: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare type PluginFn = (qiankunName: string, microOption?: MicroOption) => PluginOption;
|
|
6
|
+
declare const htmlPlugin: PluginFn;
|
|
7
|
+
export default htmlPlugin;
|
|
@@ -1,122 +1,155 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* vite-plugin-qiankun.js v1.0.14
|
|
3
|
-
* (c) 2021-2022 Teng Mao Qing
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
var
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* vite-plugin-qiankun.js v1.0.14 (no cheerio, equivalent)
|
|
3
|
+
* (c) 2021-2022 Teng Mao Qing
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
function __spreadArray(to, from) {
|
|
8
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i];
|
|
9
|
+
return to;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* ---------------------------------- */
|
|
13
|
+
/* qiankun helpers(原样保留) */
|
|
14
|
+
/* ---------------------------------- */
|
|
15
|
+
|
|
16
|
+
var createQiankunHelper = function (qiankunName) {
|
|
17
|
+
return (
|
|
18
|
+
"\n const createDeffer = (hookName) => {\n const d = new Promise((resolve, reject) => {\n window.proxy && (window.proxy[`vite${hookName}`] = resolve)\n })\n return props => d.then(fn => fn(props));\n }\n const bootstrap = createDeffer('bootstrap');\n const mount = createDeffer('mount');\n const unmount = createDeffer('unmount');\n const update = createDeffer('update');\n\n ;(global => {\n global.qiankunName = '" +
|
|
19
|
+
qiankunName +
|
|
20
|
+
"';\n global['" +
|
|
21
|
+
qiankunName +
|
|
22
|
+
"'] = {\n bootstrap,\n mount,\n unmount,\n update\n };\n })(window);\n"
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var createImportFinallyResolve = function (qiankunName) {
|
|
27
|
+
return (
|
|
28
|
+
"\n const qiankunLifeCycle = window.moudleQiankunAppLifeCycles && window.moudleQiankunAppLifeCycles['" +
|
|
29
|
+
qiankunName +
|
|
30
|
+
"'];\n if (qiankunLifeCycle) {\n window.proxy.vitemount((props) => qiankunLifeCycle.mount(props));\n window.proxy.viteunmount((props) => qiankunLifeCycle.unmount(props));\n window.proxy.vitebootstrap(() => qiankunLifeCycle.bootstrap());\n window.proxy.viteupdate((props) => qiankunLifeCycle.update(props));\n }\n "
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/* ---------------------------------- */
|
|
35
|
+
/* 等价 DOM 操作(替代 cheerio) */
|
|
36
|
+
/* ---------------------------------- */
|
|
37
|
+
|
|
38
|
+
function replaceScriptTag(html, matcher, replacer) {
|
|
39
|
+
var match;
|
|
40
|
+
var result = html;
|
|
41
|
+
while ((match = matcher.exec(html))) {
|
|
42
|
+
var original = match[0];
|
|
43
|
+
var replaced = replacer(match);
|
|
44
|
+
result = result.replace(original, replaced);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function transformSingleScript(scriptHtml, appendBase) {
|
|
50
|
+
var srcMatch = scriptHtml.match(/src=["']([^"']+)["']/);
|
|
51
|
+
if (!srcMatch) return scriptHtml;
|
|
52
|
+
|
|
53
|
+
var src = srcMatch[1];
|
|
54
|
+
var importCode = 'import(' + appendBase + "'" + src + "')";
|
|
55
|
+
|
|
56
|
+
return '<script>' + importCode + '</script>';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* ---------------------------------- */
|
|
60
|
+
/* 主插件(逻辑严格对齐原版) */
|
|
61
|
+
/* ---------------------------------- */
|
|
62
|
+
|
|
63
|
+
var htmlPlugin = function (qiankunName, microOption) {
|
|
64
|
+
if (microOption === void 0) microOption = {};
|
|
65
|
+
|
|
66
|
+
var isProduction;
|
|
67
|
+
var base = '';
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
name: 'qiankun-html-transform',
|
|
71
|
+
configResolved: function (config) {
|
|
72
|
+
isProduction = config.command === 'build' || config.isProduction;
|
|
73
|
+
base = config.base;
|
|
74
|
+
},
|
|
75
|
+
configureServer: function (server) {
|
|
76
|
+
return function () {
|
|
77
|
+
server.middlewares.use(function (req, res, next) {
|
|
78
|
+
if (isProduction || !microOption.useDevMode) {
|
|
79
|
+
next();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
var end = res.end.bind(res);
|
|
83
|
+
res.end = function () {
|
|
84
|
+
var args = [];
|
|
85
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
86
|
+
args[_i] = arguments[_i];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var htmlStr = args[0];
|
|
90
|
+
var rest = args.slice(1);
|
|
91
|
+
|
|
92
|
+
if (typeof htmlStr === 'string') {
|
|
93
|
+
var appendBase = "(window.proxy ? (window.proxy.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ + '..') : '') + ";
|
|
94
|
+
|
|
95
|
+
var viteClientRE = new RegExp('<script[^>]*src=["\']' + base + '@vite/client["\'][^>]*></script>');
|
|
96
|
+
|
|
97
|
+
htmlStr = htmlStr.replace(viteClientRE, function (script) {
|
|
98
|
+
return transformSingleScript(script, appendBase);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
end.apply(void 0, __spreadArray([htmlStr], rest));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
next();
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
transformIndexHtml: function (html) {
|
|
111
|
+
var appendBase =
|
|
112
|
+
microOption.useDevMode && !isProduction
|
|
113
|
+
? "(window.proxy ? (window.proxy.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ + '..') : '') + "
|
|
114
|
+
: '';
|
|
115
|
+
|
|
116
|
+
var scripts = [];
|
|
117
|
+
|
|
118
|
+
var scriptRE = /<(script)([^>]*?)>([\s\S]*?)<\/script>/gi;
|
|
119
|
+
|
|
120
|
+
var match;
|
|
121
|
+
while ((match = scriptRE.exec(html))) {
|
|
122
|
+
var full = match[0];
|
|
123
|
+
var attrs = match[2];
|
|
124
|
+
|
|
125
|
+
var isModule = /type=["']module["']/.test(attrs) || /crossorigin=["']["']/.test(attrs);
|
|
126
|
+
|
|
127
|
+
if (isModule && /src=["']/.test(attrs)) {
|
|
128
|
+
scripts.push({
|
|
129
|
+
original: full,
|
|
130
|
+
transformed: transformSingleScript(full, appendBase)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!scripts.length) return html;
|
|
136
|
+
|
|
137
|
+
scripts.forEach(function (item, index) {
|
|
138
|
+
var code = item.transformed;
|
|
139
|
+
if (index === scripts.length - 1) {
|
|
140
|
+
code = code.replace(
|
|
141
|
+
'</script>',
|
|
142
|
+
'.finally(() => {\n ' + createImportFinallyResolve(qiankunName) + '\n })</script>'
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
html = html.replace(item.original, code);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
html = html.replace('</body>', '<script>' + createQiankunHelper(qiankunName) + '</script></body>');
|
|
149
|
+
|
|
150
|
+
return html;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default htmlPlugin;
|
package/vite-plugin-shiyun.js
CHANGED
|
@@ -2,24 +2,7 @@ import { loadEnv } from 'vite';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import qiankun from './vite-plugin-qiankun/es/index.js';
|
|
4
4
|
export { qiankunWindow } from './vite-plugin-qiankun/es/helper.js';
|
|
5
|
-
|
|
6
|
-
import { buildRbac } from './common/buildRbac.js';
|
|
7
|
-
/**
|
|
8
|
-
* 使用 plugins: [shiyunInjectHtml({ key: 'value' })]
|
|
9
|
-
* @param {*} data
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
export function shiyunInjectHtml(data) {
|
|
13
|
-
return {
|
|
14
|
-
name: 'vite-plugin-shiyun-inject-html',
|
|
15
|
-
transformIndexHtml(html) {
|
|
16
|
-
Object.keys(data).forEach((key) => {
|
|
17
|
-
html = html.replace(`<!--%${key}%-->`, data[key]);
|
|
18
|
-
});
|
|
19
|
-
return html;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
5
|
+
import { shiyunReleaseCommon } from './build/plugin-common.js';
|
|
23
6
|
/**
|
|
24
7
|
*
|
|
25
8
|
* @param {*} params
|
|
@@ -33,143 +16,18 @@ export function shiyunRelease(params = { menu_arr: [] }) {
|
|
|
33
16
|
// 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
|
|
34
17
|
const ENV_ARR_VITE = loadEnv(ENV_MODE, PROCESS_CWD, 'VITE_');
|
|
35
18
|
const ENV_ARR_CICD = loadEnv(ENV_MODE, PROCESS_CWD, 'CICD_');
|
|
36
|
-
const { CICD_BUILD_DOMAIN_SCHEME, CICD_BUILD_DOMAIN_ALONE, CICD_BUILD_VERS_FULL, CICD_BUILD_VERS_CODE } = ENV_ARR_CICD;
|
|
37
|
-
// proPublicPath = `${}/`;
|
|
38
|
-
const {
|
|
39
|
-
VITE_SY_PRODUCT_PORT,
|
|
40
|
-
VITE_SY_PRODUCT_SIGN,
|
|
41
|
-
VITE_SY_API_DEV,
|
|
42
|
-
VITE_SY_APP_PROJECT_SIGN,
|
|
43
|
-
VITE_SY_APP_CONNECT_ID,
|
|
44
|
-
VITE_SY_APP_CONNECT_ROLE
|
|
45
|
-
} = ENV_ARR_VITE;
|
|
46
|
-
const LAST_PRODUCT_SIGN = VITE_SY_PRODUCT_SIGN || BASENAME_SIGN;
|
|
47
|
-
const LAST_BUILD_DOMAIN = CICD_BUILD_DOMAIN_SCHEME || '';
|
|
48
|
-
const LAST_BUILD_VERS_SIGN = CICD_BUILD_DOMAIN_ALONE == 'on' ? '' : LAST_PRODUCT_SIGN;
|
|
49
|
-
const LAST_BUILD_VERS_FULL = CICD_BUILD_VERS_FULL || '';
|
|
50
|
-
if (ENV_MODE == 'production') {
|
|
51
|
-
buildRbac(params.menu_arr, PROCESS_CWD, {
|
|
52
|
-
RBAC_BASE_SIGN: LAST_PRODUCT_SIGN
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// const sign_flag = `${VITE_SY_APP_PROJECT_SIGN}---${VITE_SY_APP_CONNECT_ID}---${VITE_SY_APP_CONNECT_ROLE}`;
|
|
57
|
-
// const sign_param = encryptStrEncode(sign_flag);
|
|
58
|
-
// const get_api = `${VITE_SY_API_DEV}/base.base_load/common`;
|
|
59
|
-
|
|
60
19
|
/**
|
|
61
20
|
* useDevMode 开启时与热更新插件冲突
|
|
62
21
|
* useDevMode = true 时不开启热更新
|
|
63
22
|
* 如果是在主应用中加载子应用vite,必须打开这个,否则vite加载不成功, 单独运行没影响
|
|
64
23
|
*/
|
|
24
|
+
console.log('--asd');
|
|
65
25
|
const useDevMode = true;
|
|
66
|
-
|
|
67
26
|
return [
|
|
68
27
|
// 微应用名字,与主应用注册的微应用名字保持一致
|
|
69
|
-
qiankun(
|
|
28
|
+
qiankun(ENV_ARR_VITE.VITE_SY_PRODUCT_SIGN || BASENAME_SIGN, {
|
|
70
29
|
useDevMode
|
|
71
30
|
}),
|
|
72
|
-
|
|
73
|
-
name: 'vite-plugin-shiyun-release',
|
|
74
|
-
// apply: 'build', // 'build' 或 'serve' ,在什么情况下使用
|
|
75
|
-
config: (config, { mode, command }) => {
|
|
76
|
-
let basePath = '/';
|
|
77
|
-
if (mode == 'production') {
|
|
78
|
-
let buildPath = `${LAST_BUILD_DOMAIN}/${LAST_BUILD_VERS_SIGN}/${LAST_BUILD_VERS_FULL}/`;
|
|
79
|
-
/**
|
|
80
|
-
* 使用正则表达式进行过滤
|
|
81
|
-
* 过滤除了 https:// 和 http:// 以外的 // 和 ///
|
|
82
|
-
*/
|
|
83
|
-
buildPath = buildPath.replace(/\/(undefined\/)+/g, '/');
|
|
84
|
-
buildPath = buildPath.replace(/([^:]\/)\/+/g, '$1');
|
|
85
|
-
basePath = buildPath;
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
base: basePath,
|
|
89
|
-
server: {
|
|
90
|
-
port: VITE_SY_PRODUCT_PORT
|
|
91
|
-
},
|
|
92
|
-
esbuild: {
|
|
93
|
-
drop: ['console', 'debugger']
|
|
94
|
-
},
|
|
95
|
-
optimizeDeps: {
|
|
96
|
-
esbuildOptions: {
|
|
97
|
-
target: 'esnext'
|
|
98
|
-
},
|
|
99
|
-
// 确保 open-sdk 包在依赖优化中
|
|
100
|
-
// include: ['@10yun/open-sdk']
|
|
101
|
-
exclude: ['@10yun/open-sdk/uncompiled']
|
|
102
|
-
/**
|
|
103
|
-
* TODO
|
|
104
|
-
* 确保 open-sdk 包不在依赖优化中,不然造成修改 【项目@/下的相关文件】,vite无法及时热更新响应
|
|
105
|
-
* 添加下列 exclude 会爆 dayjs 问题
|
|
106
|
-
*/
|
|
107
|
-
// exclude: ['@10yun/open-sdk']
|
|
108
|
-
},
|
|
109
|
-
build: {
|
|
110
|
-
// target: ['chrome89', 'edge89', 'firefox89', 'safari15', 'chrome87', 'edge88', 'es2020', 'firefox78', 'safari14'],
|
|
111
|
-
target: 'esnext',
|
|
112
|
-
sourcemap: false,
|
|
113
|
-
chunkSizeWarningLimit: 2000
|
|
114
|
-
},
|
|
115
|
-
output: {
|
|
116
|
-
// 把子应用打包成 umd 库格式
|
|
117
|
-
// library: `${子应用名}-[name]`,
|
|
118
|
-
// libraryTarget: 'umd',
|
|
119
|
-
// jsonpFunction: `webpackJsonp_${子应用名}`
|
|
120
|
-
library: `${BASENAME_SIGN}-[name]`,
|
|
121
|
-
libraryTarget: 'umd',
|
|
122
|
-
jsonpFunction: `webpackJsonp_${BASENAME_SIGN}`
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
},
|
|
126
|
-
configResolved(config) {
|
|
127
|
-
// console.log('---111---');
|
|
128
|
-
// console.log('configResolved', config.base, config.mode, config.command, config.esbuild);
|
|
129
|
-
// config.base = 'asdad';
|
|
130
|
-
// isProduction = config.command === 'build' || config.isProduction;
|
|
131
|
-
// base = config.base;
|
|
132
|
-
},
|
|
133
|
-
configureServer(server) {
|
|
134
|
-
// 在开发服务器配置时可以执行的逻辑
|
|
135
|
-
// console.log('开发的时候', server);
|
|
136
|
-
},
|
|
137
|
-
transformIndexHtml(html) {
|
|
138
|
-
if (ENV_MODE == 'development') {
|
|
139
|
-
// 删除带 mode="pro" 的标签
|
|
140
|
-
html = html.replace(/<(script)\b[^>]*?mode="pro"[^>]*>[\s\S]*?<\/script>/gi, '');
|
|
141
|
-
html = html.replace(/<(link|script)\b[^>]*?mode="pro"[^>]*>/gi, '');
|
|
142
|
-
}
|
|
143
|
-
if (ENV_MODE == 'production') {
|
|
144
|
-
// 删除带 mode="dev" 的标签
|
|
145
|
-
if (CICD_BUILD_DOMAIN_ALONE != 'on') {
|
|
146
|
-
html = html.replace(/<(script)\b[^>]*?mode="dev"[^>]*>[\s\S]*?<\/script>/gi, '');
|
|
147
|
-
html = html.replace(/<(link|script)\b[^>]*?mode="dev"[^>]*>/gi, '');
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* 新增十云相关信息
|
|
152
|
-
*/
|
|
153
|
-
const copyrightInfo = 'saas软件,软件开发,软件制定,公众号,小程序,app,十云,十云科技,福州十云,ctocode,10yun.com';
|
|
154
|
-
let shiyunInfo = `<meta name="description" content="${copyrightInfo}" />\n`;
|
|
155
|
-
shiyunInfo += `<meta name="keywords" content="${copyrightInfo}" />\n`;
|
|
156
|
-
shiyunInfo += `<meta name="author" content="十云_ctocode_技术支持_https://www.10yun.com" />\n`;
|
|
157
|
-
if (CICD_BUILD_VERS_FULL) {
|
|
158
|
-
shiyunInfo += `<meta name="version" content="${CICD_BUILD_VERS_FULL}_${CICD_BUILD_VERS_CODE}" />\n`;
|
|
159
|
-
}
|
|
160
|
-
// 将meta标签插入到head标签内(</head>闭合标签之前)
|
|
161
|
-
html = html.replace('</head>', `\n${shiyunInfo}\n</head>`);
|
|
162
|
-
// 删除空行
|
|
163
|
-
html = html.replace(/\n\s*\n/g, '\n');
|
|
164
|
-
return html;
|
|
165
|
-
}
|
|
166
|
-
// transform(code, id) {
|
|
167
|
-
// // console.log('transform');
|
|
168
|
-
// if (id.endsWith('.example')) {
|
|
169
|
-
// // 对特定文件进行转换逻辑
|
|
170
|
-
// return code + '\n// This is an example plugin transformation';
|
|
171
|
-
// }
|
|
172
|
-
// }
|
|
173
|
-
}
|
|
31
|
+
shiyunReleaseCommon(ENV_ARR_VITE, ENV_ARR_CICD, ENV_MODE, params)
|
|
174
32
|
];
|
|
175
33
|
}
|