kn-cli 1.0.131 → 1.0.133
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/build/vite.config.js +1 -1
- package/package.json +2 -1
- package/src/create.js +2 -0
- package/templates/template_admin_antd5/.vscode/settings.json +28 -0
- package/templates/template_admin_antd5/build.sh +8 -0
- package/templates/template_admin_antd5/cli.config.js +35 -0
- package/templates/template_admin_antd5/dev.sh +33 -0
- package/templates/template_admin_antd5/frontend_build.sh +48 -0
- package/templates/template_admin_antd5/init/prepare-commit-msg +5 -0
- package/templates/template_admin_antd5/init.sh +24 -0
- package/templates/template_admin_antd5/jsconfig.json +17 -0
- package/templates/template_admin_antd5/package.json +27 -0
- package/templates/template_admin_antd5/public/404.html +26 -0
- package/templates/template_admin_antd5/public/favicon.png +0 -0
- package/templates/template_admin_antd5/public/index.html +48 -0
- package/templates/template_admin_antd5/public/src/_antd.less +37 -0
- package/templates/template_admin_antd5/public/src/_mixin.module.less +79 -0
- package/templates/template_admin_antd5/public/src/_reset.module.less +134 -0
- package/templates/template_admin_antd5/public/src/_variable.module.less +85 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.eot +0 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.module.less +109 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.svg +75 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.ttf +0 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.woff +0 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.woff2 +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/arrow.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/avatar.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/icon-notice.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/icon-user.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/loadFail.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/loading.svg +40 -0
- package/templates/template_admin_antd5/public/src/assets/images/login/bg.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/login/logo.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/login/slogan.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-dep-active.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-dep.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-log-active.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-log.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-loginlog-active.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-loginlog.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-role-active.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-role.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-user-active.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-user.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/nav-toggle.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/slogan.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/noData.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/noSelect.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/permission/403.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/permission/404.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/permission/503.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/play.png +0 -0
- package/templates/template_admin_antd5/public/src/components/_table/column.jsx +47 -0
- package/templates/template_admin_antd5/public/src/components/_table/column.module.less +12 -0
- package/templates/template_admin_antd5/public/src/components/_table/index.jsx +71 -0
- package/templates/template_admin_antd5/public/src/components/_table/index.module.less +15 -0
- package/templates/template_admin_antd5/public/src/components/antd/antProvider.jsx +21 -0
- package/templates/template_admin_antd5/public/src/components/antd/index.jsx +146 -0
- package/templates/template_admin_antd5/public/src/components/antd/select/index.jsx +296 -0
- package/templates/template_admin_antd5/public/src/components/antd/select/index.module.less +21 -0
- package/templates/template_admin_antd5/public/src/components/antd/theme.js +173 -0
- package/templates/template_admin_antd5/public/src/components/antd/tooltip/detail/index.jsx +70 -0
- package/templates/template_admin_antd5/public/src/components/antd/tooltip/detail/index.module.less +12 -0
- package/templates/template_admin_antd5/public/src/components/antd/tooltip/index.jsx +69 -0
- package/templates/template_admin_antd5/public/src/components/antd/tooltip/index.module.less +28 -0
- package/templates/template_admin_antd5/public/src/components/auth/index.jsx +123 -0
- package/templates/template_admin_antd5/public/src/components/auth/index.module.less +7 -0
- package/templates/template_admin_antd5/public/src/components/auth/navCheck.jsx +27 -0
- package/templates/template_admin_antd5/public/src/components/badge/index.jsx +47 -0
- package/templates/template_admin_antd5/public/src/components/badge/index.module.less +44 -0
- package/templates/template_admin_antd5/public/src/components/button/index.jsx +17 -0
- package/templates/template_admin_antd5/public/src/components/debug/index.jsx +28 -0
- package/templates/template_admin_antd5/public/src/components/debug/index.module.less +10 -0
- package/templates/template_admin_antd5/public/src/components/empty/index.jsx +28 -0
- package/templates/template_admin_antd5/public/src/components/empty/index.module.less +20 -0
- package/templates/template_admin_antd5/public/src/components/error/index.jsx +39 -0
- package/templates/template_admin_antd5/public/src/components/icon/index.jsx +128 -0
- package/templates/template_admin_antd5/public/src/components/icon/playVideo/index.jsx +21 -0
- package/templates/template_admin_antd5/public/src/components/icon/playVideo/index.module.less +16 -0
- package/templates/template_admin_antd5/public/src/components/iconFont/index.jsx +20 -0
- package/templates/template_admin_antd5/public/src/components/iconFont/index.module.less +5 -0
- package/templates/template_admin_antd5/public/src/components/image/index.jsx +73 -0
- package/templates/template_admin_antd5/public/src/components/image/index.module.less +117 -0
- package/templates/template_admin_antd5/public/src/components/image/preview.jsx +85 -0
- package/templates/template_admin_antd5/public/src/components/layout/basic/index.jsx +49 -0
- package/templates/template_admin_antd5/public/src/components/layout/basic/index.module.less +76 -0
- package/templates/template_admin_antd5/public/src/components/layout/index.jsx +39 -0
- package/templates/template_admin_antd5/public/src/components/layout/index.module.less +63 -0
- package/templates/template_admin_antd5/public/src/components/layout/provider/index.jsx +32 -0
- package/templates/template_admin_antd5/public/src/components/leftMenu/index.jsx +106 -0
- package/templates/template_admin_antd5/public/src/components/leftMenu/index.module.less +42 -0
- package/templates/template_admin_antd5/public/src/components/link/index.jsx +39 -0
- package/templates/template_admin_antd5/public/src/components/link/index.module.less +11 -0
- package/templates/template_admin_antd5/public/src/components/menuIcon/index.jsx +33 -0
- package/templates/template_admin_antd5/public/src/components/menuIcon/index.module.less +49 -0
- package/templates/template_admin_antd5/public/src/components/page/pageLoading/index.jsx +51 -0
- package/templates/template_admin_antd5/public/src/components/page/pageLoading/index.module.less +29 -0
- package/templates/template_admin_antd5/public/src/components/popup/index.jsx +60 -0
- package/templates/template_admin_antd5/public/src/components/popup/index.module.less +18 -0
- package/templates/template_admin_antd5/public/src/components/react/index.jsx +13 -0
- package/templates/template_admin_antd5/public/src/components/resizeBox/index.jsx +144 -0
- package/templates/template_admin_antd5/public/src/components/resizeBox/index.module.css +90 -0
- package/templates/template_admin_antd5/public/src/components/select/defaultServicesSelect/index.jsx +182 -0
- package/templates/template_admin_antd5/public/src/components/select/dictSelect/index.jsx +84 -0
- package/templates/template_admin_antd5/public/src/components/select/index.jsx +7 -0
- package/templates/template_admin_antd5/public/src/components/select/useSelectList.jsx +217 -0
- package/templates/template_admin_antd5/public/src/components/table/aliTable/index.jsx +250 -0
- package/templates/template_admin_antd5/public/src/components/table/aliTable/index.module.less +105 -0
- package/templates/template_admin_antd5/public/src/components/table/column.jsx +128 -0
- package/templates/template_admin_antd5/public/src/components/table/column.module.less +50 -0
- package/templates/template_admin_antd5/public/src/components/table/imageTable/index.jsx +302 -0
- package/templates/template_admin_antd5/public/src/components/table/imageTable/index.module.less +196 -0
- package/templates/template_admin_antd5/public/src/components/table/imageTable/radio.jsx +15 -0
- package/templates/template_admin_antd5/public/src/components/table/imageTable/radio.module.less +18 -0
- package/templates/template_admin_antd5/public/src/components/table/index.jsx +475 -0
- package/templates/template_admin_antd5/public/src/components/table/index.module.less +133 -0
- package/templates/template_admin_antd5/public/src/components/text/index.jsx +98 -0
- package/templates/template_admin_antd5/public/src/components/text/index.module.less +13 -0
- package/templates/template_admin_antd5/public/src/components/toast/index.jsx +79 -0
- package/templates/template_admin_antd5/public/src/components/toast/index.module.less +43 -0
- package/templates/template_admin_antd5/public/src/components/topMenu/index.jsx +102 -0
- package/templates/template_admin_antd5/public/src/components/topMenu/index.module.less +89 -0
- package/templates/template_admin_antd5/public/src/components/topMenu/topBar/index.jsx +81 -0
- package/templates/template_admin_antd5/public/src/components/topMenu/topBar/index.module.less +97 -0
- package/templates/template_admin_antd5/public/src/components/video/index.jsx +96 -0
- package/templates/template_admin_antd5/public/src/components/video/index.module.less +132 -0
- package/templates/template_admin_antd5/public/src/components/video/preview.jsx +38 -0
- package/templates/template_admin_antd5/public/src/config.js +31 -0
- package/templates/template_admin_antd5/public/src/declarations.d.ts +1 -0
- package/templates/template_admin_antd5/public/src/dictionary/dictionary.js +289 -0
- package/templates/template_admin_antd5/public/src/dictionary/index.jsx +64 -0
- package/templates/template_admin_antd5/public/src/enum.js +41 -0
- package/templates/template_admin_antd5/public/src/hooks/index.jsx +29 -0
- package/templates/template_admin_antd5/public/src/hooks/useDebounceFn.jsx +33 -0
- package/templates/template_admin_antd5/public/src/hooks/useDelay.jsx +34 -0
- package/templates/template_admin_antd5/public/src/hooks/useEsc.jsx +98 -0
- package/templates/template_admin_antd5/public/src/hooks/useImageLoader.jsx +26 -0
- package/templates/template_admin_antd5/public/src/hooks/useInToView.jsx +58 -0
- package/templates/template_admin_antd5/public/src/hooks/useLoading.jsx +46 -0
- package/templates/template_admin_antd5/public/src/hooks/usePreload.jsx +67 -0
- package/templates/template_admin_antd5/public/src/hooks/useRouteMenu.jsx +263 -0
- package/templates/template_admin_antd5/public/src/hooks/useScrollTop.jsx +44 -0
- package/templates/template_admin_antd5/public/src/hooks/useSearch.jsx +163 -0
- package/templates/template_admin_antd5/public/src/hooks/useTableRowSelect.jsx +310 -0
- package/templates/template_admin_antd5/public/src/hooks/useThrottole.jsx +68 -0
- package/templates/template_admin_antd5/public/src/hooks/useTimer.jsx +42 -0
- package/templates/template_admin_antd5/public/src/hooks/useUpdate.jsx +16 -0
- package/templates/template_admin_antd5/public/src/hooks/useWatchServices.jsx +124 -0
- package/templates/template_admin_antd5/public/src/index.jsx +89 -0
- package/templates/template_admin_antd5/public/src/menuConfig/auth.jsx +92 -0
- package/templates/template_admin_antd5/public/src/menuConfig/dashboard.jsx +25 -0
- package/templates/template_admin_antd5/public/src/menuConfig/dna.jsx +76 -0
- package/templates/template_admin_antd5/public/src/menuConfig/index.jsx +17 -0
- package/templates/template_admin_antd5/public/src/mock/auth.js +33 -0
- package/templates/template_admin_antd5/public/src/mock/demo.js +122 -0
- package/templates/template_admin_antd5/public/src/mock/index.js +65 -0
- package/templates/template_admin_antd5/public/src/mock/utils.js +33 -0
- package/templates/template_admin_antd5/public/src/pages/antdComponents/index.jsx +142 -0
- package/templates/template_admin_antd5/public/src/pages/auth/user/create/index.jsx +47 -0
- package/templates/template_admin_antd5/public/src/pages/auth/user/create/index.module.less +6 -0
- package/templates/template_admin_antd5/public/src/pages/auth/user/dialog/index.jsx +96 -0
- package/templates/template_admin_antd5/public/src/pages/auth/user/index.jsx +214 -0
- package/templates/template_admin_antd5/public/src/pages/components/layout/index.jsx +75 -0
- package/templates/template_admin_antd5/public/src/pages/components/layout/index.module.less +78 -0
- package/templates/template_admin_antd5/public/src/pages/components/layout/titleBar/index.jsx +28 -0
- package/templates/template_admin_antd5/public/src/pages/components/layout/titleBar/index.module.less +44 -0
- package/templates/template_admin_antd5/public/src/pages/components/select/user.jsx +18 -0
- package/templates/template_admin_antd5/public/src/pages/demo/page1.jsx +21 -0
- package/templates/template_admin_antd5/public/src/pages/demo/page2.jsx +21 -0
- package/templates/template_admin_antd5/public/src/pages/demo/page3.jsx +21 -0
- package/templates/template_admin_antd5/public/src/pages/error/403.jsx +15 -0
- package/templates/template_admin_antd5/public/src/pages/error/404.jsx +15 -0
- package/templates/template_admin_antd5/public/src/pages/error/503.jsx +15 -0
- package/templates/template_admin_antd5/public/src/pages/error/permission.jsx +40 -0
- package/templates/template_admin_antd5/public/src/pages/error/permission.module.less +16 -0
- package/templates/template_admin_antd5/public/src/pages/home.jsx +90 -0
- package/templates/template_admin_antd5/public/src/pages/home.module.less +6 -0
- package/templates/template_admin_antd5/public/src/pages/login/index.jsx +113 -0
- package/templates/template_admin_antd5/public/src/pages/login/index.module.less +153 -0
- package/templates/template_admin_antd5/public/src/pages/pageTemplate.jsx +28 -0
- package/templates/template_admin_antd5/public/src/provider/app.jsx +201 -0
- package/templates/template_admin_antd5/public/src/provider/loading.jsx +47 -0
- package/templates/template_admin_antd5/public/src/provider/menu.jsx +161 -0
- package/templates/template_admin_antd5/public/src/provider/menu.module.less +35 -0
- package/templates/template_admin_antd5/public/src/route.jsx +127 -0
- package/templates/template_admin_antd5/public/src/services/demo.js +85 -0
- package/templates/template_admin_antd5/public/src/services/excel.js +43 -0
- package/templates/template_admin_antd5/public/src/services/http/index.js +155 -0
- package/templates/template_admin_antd5/public/src/services/index.js +126 -0
- package/templates/template_admin_antd5/public/src/services/interceptor/index.js +67 -0
- package/templates/template_admin_antd5/public/src/services/login.js +37 -0
- package/templates/template_admin_antd5/public/src/services/socket/index.jsx +99 -0
- package/templates/template_admin_antd5/public/src/services/token/index.js +41 -0
- package/templates/template_admin_antd5/public/src/type.js +67 -0
- package/templates/template_admin_antd5/public/src/utils/event.js +58 -0
- package/templates/template_admin_antd5/public/src/utils/format.js +135 -0
- package/templates/template_admin_antd5/public/src/utils/index.js +727 -0
- package/templates/template_admin_antd5/public/src/utils/menu.js +33 -0
- package/templates/template_admin_antd5/public/src/utils/rule.js +277 -0
- package/templates/template_admin_antd5/public/src/utils/storage.js +30 -0
- package/templates/template_admin_antd5/public/static/about.html +1 -0
- package/templates/template_admin_antd5/public/static/kssoLogin.html +22 -0
- package/templates/template_admin_antd5/readme.md +84 -0
- package/templates/template_admin_antd5/renamejstojsx.js +45 -0
- package/templates/template_admin_antd5/renameless.js +53 -0
- package/templates/template_admin_antd5/report.sh +25 -0
- package/templates/template_admin_antd5/shellUtil.sh +110 -0
- package/templates/template_admin_antd5/versionPublish.sh +16 -0
- package/templates/template_admin_antd5/webpack.api.js +105 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const LoadComponent=(lazyComponent)=>{
|
|
5
|
+
return React.createElement(lazyComponent)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 自动计算菜单权限,使父级菜单权限包含所有子菜单的权限
|
|
10
|
+
* @param {RouteMenuItem} menu
|
|
11
|
+
* @returns {RouteMenuItem}
|
|
12
|
+
*/
|
|
13
|
+
export const UpdateAuth=(menu)=>{
|
|
14
|
+
if(menu.children){
|
|
15
|
+
|
|
16
|
+
let auths= menu.children.map(childMenu=>{
|
|
17
|
+
let _childMenu = UpdateAuth(childMenu);
|
|
18
|
+
if( Array.isArray(_childMenu.auth) ){
|
|
19
|
+
return [..._childMenu.auth];
|
|
20
|
+
}
|
|
21
|
+
return [];
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if( Array.isArray(menu.auth) ){
|
|
25
|
+
|
|
26
|
+
menu.auth = [...menu.auth,...auths.flat()];
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
menu.auth = [...new Set(menu.auth)];// 去重
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return menu;
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
//必填
|
|
2
|
+
const rule_required = { validator: async (rule,value)=>{
|
|
3
|
+
if(value===null||value===undefined||value===Number.NaN){
|
|
4
|
+
throw new Error('请填写');
|
|
5
|
+
}
|
|
6
|
+
if(!/\S+/.test(value)){
|
|
7
|
+
throw new Error('请填写');
|
|
8
|
+
}
|
|
9
|
+
return true;
|
|
10
|
+
}, message: '请填写' };
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
//整数
|
|
14
|
+
const rule_number = { pattern: /^\d*$/, message: '请填写整数数字' };
|
|
15
|
+
//可以带小数
|
|
16
|
+
const rule_float = {
|
|
17
|
+
pattern: /^([1-9]\d*$|\d+[.]\d{1,5}$)|0$/,
|
|
18
|
+
message: '请填写数字可以带小数,小数点后最长5位',
|
|
19
|
+
};
|
|
20
|
+
// pattern:/^\d+[.]{0,1}\d+$/};
|
|
21
|
+
|
|
22
|
+
const rule_xss = {
|
|
23
|
+
validator: async (rule, value) => {
|
|
24
|
+
if (/<script>/gi.test(value) || /%3Cscript/gi.test(value)) {
|
|
25
|
+
throw new Error('不能包含<script>');
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
},
|
|
29
|
+
message: '不能包含<script>',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const rule_max_title = { max: 32, message: '长度不能超过32位' };
|
|
33
|
+
const rule_max_normal = { max: 128, message: '长度不能超过128位'};
|
|
34
|
+
const rule_max_textarea = { max: 20480, message: '长度不能超过20480位' };
|
|
35
|
+
const rule_max_number = { pattern: /^\d{0,12}$/, message: '长度不能超过12位' };
|
|
36
|
+
const rule_max_weight = { pattern: /^\d{0,4}$/, message: '长度不能超过4位' };
|
|
37
|
+
const rule_max_numberStr = { pattern: /^\S{0,13}$/, message: '长度不能超过12位' };
|
|
38
|
+
|
|
39
|
+
const RULE_INPUT = [rule_required, rule_max_normal];
|
|
40
|
+
const RULE_INPUT_NR = [rule_max_normal];
|
|
41
|
+
|
|
42
|
+
const RULE_TITLE = [rule_required, rule_max_title];
|
|
43
|
+
const RULE_TEXTAREA = [rule_required, rule_max_textarea];
|
|
44
|
+
const RULE_INPUT_NUMBER = [rule_required, rule_number, rule_max_number];
|
|
45
|
+
const RULE_INPUT_NUMBER_NR = [rule_number, rule_max_number];
|
|
46
|
+
const RULE_INPUT_FLOAT = [rule_required, rule_float, rule_max_numberStr];
|
|
47
|
+
|
|
48
|
+
const RULE_INPUT_WEIGHT_NUMBER = [rule_required, rule_number, rule_max_weight];
|
|
49
|
+
const RULE_INPUT_WEIGHT_NUMBER_NR = [rule_number, rule_max_weight];
|
|
50
|
+
|
|
51
|
+
const RULE_SELECT = [{ required: true, message: '请选择' }];
|
|
52
|
+
const RULE_UPLOAD = [{ required: true, message: '请上传' }];
|
|
53
|
+
const rule_max_link = { max: 1024, message: '长度不能超过1024位' };
|
|
54
|
+
|
|
55
|
+
const RULE_LINK = [rule_required, rule_max_link];
|
|
56
|
+
const RULE_LINK_NR = [rule_max_link];
|
|
57
|
+
|
|
58
|
+
const rule_pwd = {
|
|
59
|
+
pattern: /^\w{6,16}$/,
|
|
60
|
+
type: 'string',
|
|
61
|
+
message: '请输入6-16位字母、下划线、数字任意组合的字符',
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const RULE_PWD = [rule_required, rule_pwd];
|
|
65
|
+
const RULE_PWD_NR = [rule_pwd];
|
|
66
|
+
|
|
67
|
+
const rule_account = {
|
|
68
|
+
pattern: /^\w{1,12}$/,
|
|
69
|
+
type: 'string',
|
|
70
|
+
message: '请输入1-12位字母、下划线、数字任意组合的字符',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const RULE_ACCOUNT = [rule_required, rule_account];
|
|
74
|
+
const RULE_ACCOUNT_NR = [rule_account];
|
|
75
|
+
|
|
76
|
+
const rule_nickname = {
|
|
77
|
+
pattern: /^[\u4E00-\u9FA5A-Za-z0-9`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、]{2,16}$/,
|
|
78
|
+
message: '请输入2-16为可见字符',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const RULE_NICKNAME = [rule_required, rule_nickname];
|
|
82
|
+
|
|
83
|
+
const RULE_NICKNAME_NR = [rule_nickname];
|
|
84
|
+
|
|
85
|
+
const rule_phone = { pattern: /^1\d{10}$/, message: '请输入正确的手机格式' };
|
|
86
|
+
const RULE_PHONE_NR = [rule_phone];
|
|
87
|
+
const RULE_PHONE = [rule_required, rule_phone];
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
export const CUSTOM={
|
|
91
|
+
INPUT:(options)=>{
|
|
92
|
+
const {required=true,max=false,min=false,noSpace=false} = options;
|
|
93
|
+
let ret=[];
|
|
94
|
+
if(required){ret.push(rule_required)}
|
|
95
|
+
|
|
96
|
+
if(noSpace){
|
|
97
|
+
ret.push({
|
|
98
|
+
validator:async (rule,value='')=>{
|
|
99
|
+
let temp = value.trim();
|
|
100
|
+
if (/\s+/g.test(temp)) {
|
|
101
|
+
throw new Error('字符串中间不能包含空格');
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
},
|
|
105
|
+
message:`字符串中间不能包含空格`
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
if(max===false){
|
|
109
|
+
ret.push(rule_max_normal);
|
|
110
|
+
}else{
|
|
111
|
+
ret.push({
|
|
112
|
+
validator:async (rule,value='')=>{
|
|
113
|
+
let temp = value.trim();
|
|
114
|
+
if(temp.length <= max) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
throw new Error(`最多不能超过${max}个字`);
|
|
118
|
+
},
|
|
119
|
+
message:`最多不能超过${max}个字`
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
if(min){
|
|
123
|
+
ret.push({
|
|
124
|
+
validator:async (rule,value='')=>{
|
|
125
|
+
let temp = value.trim();
|
|
126
|
+
if (temp.length>=min) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
throw new Error(`最少需要${min}个字`);
|
|
130
|
+
},
|
|
131
|
+
message:`最少需要${min}个字`
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
return ret;
|
|
135
|
+
},
|
|
136
|
+
NUMBER:(options)=>{
|
|
137
|
+
const {required=true,max=false,min=false} = options;
|
|
138
|
+
let ret=[];
|
|
139
|
+
if(required){ret.push(rule_required)}
|
|
140
|
+
if(max){
|
|
141
|
+
ret.push({
|
|
142
|
+
validator:async (rule,value='')=>{
|
|
143
|
+
if ( +value <= max ) {
|
|
144
|
+
return true
|
|
145
|
+
}
|
|
146
|
+
throw new Error(`数值必须小于${max}`);
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
if(min){
|
|
151
|
+
ret.push({
|
|
152
|
+
validator:async (rule,value='')=>{
|
|
153
|
+
if ( +value >= min ) {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
throw new Error(`数值必须大于${min}`);
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
return ret;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
const list = {
|
|
167
|
+
KEYWORDS:CUSTOM.INPUT({min:0,max:100,required:false}),
|
|
168
|
+
INPUT: RULE_INPUT,
|
|
169
|
+
INPUT_NR: RULE_INPUT_NR,
|
|
170
|
+
SELECT: RULE_SELECT,
|
|
171
|
+
UPLOAD: RULE_UPLOAD,
|
|
172
|
+
TEXTAREA: RULE_TEXTAREA,
|
|
173
|
+
NUMBER: RULE_INPUT_NUMBER,
|
|
174
|
+
NUMBER_NR: RULE_INPUT_NUMBER_NR,
|
|
175
|
+
TITLE: RULE_TITLE,
|
|
176
|
+
FLOAT: RULE_INPUT_FLOAT,
|
|
177
|
+
LINK: RULE_LINK,
|
|
178
|
+
LINK_NR: RULE_LINK_NR,
|
|
179
|
+
PWD: RULE_PWD,
|
|
180
|
+
PWD_NR: RULE_PWD_NR,
|
|
181
|
+
ACCOUNT: RULE_ACCOUNT,
|
|
182
|
+
ACCOUNT_NR: RULE_ACCOUNT_NR,
|
|
183
|
+
NICKNAME: RULE_NICKNAME,
|
|
184
|
+
NICKNAME_NR: RULE_NICKNAME_NR,
|
|
185
|
+
PHONE: RULE_PHONE,
|
|
186
|
+
PHONE_NR: RULE_PHONE_NR,
|
|
187
|
+
WEIGHT: RULE_INPUT_WEIGHT_NUMBER,
|
|
188
|
+
WEIGHT_NR: RULE_INPUT_WEIGHT_NUMBER_NR,
|
|
189
|
+
};
|
|
190
|
+
Object.keys(list).forEach((key) => {
|
|
191
|
+
const rule = list[key];
|
|
192
|
+
list[key] = [rule_xss, ...rule];
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
export const validate=async (value,rules)=>{
|
|
197
|
+
for(let i=0;i<rules.length;i++){
|
|
198
|
+
let rule = rules[i];
|
|
199
|
+
let type =rule.type||'string';
|
|
200
|
+
let pattern = rule.pattern||'';
|
|
201
|
+
|
|
202
|
+
let numberValue;
|
|
203
|
+
let textValue;
|
|
204
|
+
if(type=='number'){
|
|
205
|
+
numberValue = Number(value);
|
|
206
|
+
}else{
|
|
207
|
+
textValue= `${value}`.trim();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if(pattern){
|
|
211
|
+
if(!pattern.test(value)){
|
|
212
|
+
return {success:false,message:rule.message};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// 必填
|
|
216
|
+
if(rule.required){
|
|
217
|
+
pattern = /\S+/
|
|
218
|
+
if(!pattern.test(textValue)){
|
|
219
|
+
return {success:false,message:rule.message};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// 字符长度
|
|
223
|
+
if(rule.len && type == 'string'){
|
|
224
|
+
pattern = `^.{${rule.len}}$`;
|
|
225
|
+
pattern = new RegExp(pattern);
|
|
226
|
+
if(!pattern.test(textValue)){
|
|
227
|
+
return {success:false,message:rule.message};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if(rule.max){
|
|
232
|
+
if(type=='number'){ // 最大数值
|
|
233
|
+
if(numberValue > +rule.max){
|
|
234
|
+
return {success:false,message:rule.message};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else if(type=='string'){ // 最大字符串长度
|
|
238
|
+
pattern = `^.{0,${rule.max}}$`;
|
|
239
|
+
pattern = new RegExp(pattern);
|
|
240
|
+
if(!pattern.test(textValue)){
|
|
241
|
+
return {success:false,message:rule.message};
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if(rule.min){
|
|
246
|
+
if(type=='number'){
|
|
247
|
+
if(numberValue < +rule.min){ // 最小数值
|
|
248
|
+
return {success:false,message:rule.message};;
|
|
249
|
+
}
|
|
250
|
+
}else if(type=='string'){// 最小字符串长度
|
|
251
|
+
pattern = `^.{${rule.min},}$`;
|
|
252
|
+
pattern = new RegExp(pattern);
|
|
253
|
+
if(!pattern.test(textValue)){
|
|
254
|
+
return {success:false,message:rule.message};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if(rule.enum){
|
|
259
|
+
if(!rule.enum.includes(textValue)){
|
|
260
|
+
return {success:false,message:rule.message};
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if(rule.validator){
|
|
264
|
+
try{
|
|
265
|
+
let req = await rule.validator(null,value);
|
|
266
|
+
}catch(ex){
|
|
267
|
+
return {success:false,message:ex.message}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return {success:true};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
export default list;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
const prevName='admin';
|
|
3
|
+
const STORAGE_NAME={
|
|
4
|
+
user:'user',
|
|
5
|
+
dep:'dep',
|
|
6
|
+
redirect:'redirect'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const load=(name)=>{
|
|
10
|
+
let value = localStorage.getItem(prevName+name);
|
|
11
|
+
if(value){
|
|
12
|
+
value = JSON.parse(value);
|
|
13
|
+
}
|
|
14
|
+
let _value = value || null;
|
|
15
|
+
return _value;
|
|
16
|
+
}
|
|
17
|
+
const write=(name,data)=>{
|
|
18
|
+
if(!data){
|
|
19
|
+
localStorage.removeItem(prevName+name);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
data = JSON.stringify(data);
|
|
23
|
+
localStorage.setItem(prevName+name,data);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const remove=(name)=>{
|
|
27
|
+
localStorage.removeItem(prevName+name);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default {load,write,remove,NAME:STORAGE_NAME};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport"
|
|
7
|
+
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no,viewport-fit=cover" />
|
|
8
|
+
<meta name="format-detection" content="telephone=no,email=no,adress=no">
|
|
9
|
+
<meta name="apple-touch-fullscreen" content="yes">
|
|
10
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
11
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
12
|
+
<title></title>
|
|
13
|
+
<script>
|
|
14
|
+
var url = location.protocol + '//' + location.host+'/#/login';
|
|
15
|
+
location.replace('https://ksso.kingnet.com/oauth2/auth?client_id=30000716&response_type=code&redirect_uri=' + encodeURIComponent(url));
|
|
16
|
+
</script>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
</body>
|
|
21
|
+
|
|
22
|
+
</html>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# oa-app
|
|
2
|
+
|
|
3
|
+
### 初始化项目
|
|
4
|
+
git仓库建立完毕后,执行`sh init.sh`
|
|
5
|
+
|
|
6
|
+
### 本地调试
|
|
7
|
+
sh dev.sh
|
|
8
|
+
|
|
9
|
+
### 安装新的库
|
|
10
|
+
npm i 库名称 --save
|
|
11
|
+
### 模块构建报告
|
|
12
|
+
sh report.sh
|
|
13
|
+
|
|
14
|
+
### 测试环境部署
|
|
15
|
+
1. sh build.sh
|
|
16
|
+
|
|
17
|
+
### 生产环境部署
|
|
18
|
+
1. 向运维申请CICD环境,申请模板如下:
|
|
19
|
+
```
|
|
20
|
+
标题:应用申请
|
|
21
|
+
|
|
22
|
+
内容:
|
|
23
|
+
应用名称: 自定义名称
|
|
24
|
+
域名:自定义域名
|
|
25
|
+
用途:说明文本
|
|
26
|
+
|
|
27
|
+
仓库地址:项目仓库地址
|
|
28
|
+
环境要求:node 16.18.0
|
|
29
|
+
构建方式:执行仓库下 sh frontend_build.sh
|
|
30
|
+
部署方式:将构建完成的文件夹下的 `release` 内的内容部署到目标服务器
|
|
31
|
+
参考应用:oa-app
|
|
32
|
+
其它要求:nginx添加对index.html的缓存策略,配置如下:
|
|
33
|
+
expires 0;
|
|
34
|
+
add_header Cache-Control "max-age=0";
|
|
35
|
+
add_header Cache-Control "private";
|
|
36
|
+
add_header Cache-Control "no-store";
|
|
37
|
+
add_header Cache-Control "no-cache";
|
|
38
|
+
add_header Cache-Control "must-revalidate";
|
|
39
|
+
add_header Cache-Control "proxy-revalidate";
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
2. 进入CICD,构建相应环境
|
|
43
|
+
3. 快速发布
|
|
44
|
+
4. 进入域名访问
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### 版本发布Tag
|
|
49
|
+
执行 `sh versionPublish.sh` 给正式发布的版本打tag里程碑,便于查看及回滚
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### 构建辅助工具创建
|
|
53
|
+
kn-cli --tool
|
|
54
|
+
|
|
55
|
+
### 目录介绍
|
|
56
|
+
|
|
57
|
+
* static: 不参与打包,会在打包后将整个文件夹复制到站点根目录下
|
|
58
|
+
* src: 所有源码放在这个下面
|
|
59
|
+
* assets: 站点内用到的静态资源文件
|
|
60
|
+
* components: 通用性组件
|
|
61
|
+
* dictionary: 字典
|
|
62
|
+
* hooks: 所用的hooks
|
|
63
|
+
* mock: 接口mock配置
|
|
64
|
+
* pages: 所有页面源代码
|
|
65
|
+
* pageName: 每个页面自己名称的文件夹
|
|
66
|
+
* components: 页面自己的组件
|
|
67
|
+
* components: 跨页面使用的组件
|
|
68
|
+
* provider: 全局的provider通信组件
|
|
69
|
+
* services: 所有接口服务
|
|
70
|
+
* utils: 全局通用的工具类
|
|
71
|
+
* _variable.less: 全局通用less变量
|
|
72
|
+
* _reset.less: 站点初始化less配置
|
|
73
|
+
* index.jsx: 站点入口
|
|
74
|
+
* route.jsx: 站点路由配置
|
|
75
|
+
* pluginjs: 第三方静态引入的js库
|
|
76
|
+
* tools: 构建工具(通过kn-cli --tool可创建)
|
|
77
|
+
* iconfont: 构建Iconfont工具
|
|
78
|
+
* tinypng: 压缩png工具
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### ksso登录配置
|
|
82
|
+
1. 在`static/kssoLogin.html`内配置ksso登录的id配置
|
|
83
|
+
2. 访问`/static/kssoLogin.html`来触发ksso登录,登录完成会跳转到`/#/login`路由下进行校验
|
|
84
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
// --- 配置区 ---
|
|
6
|
+
// 将这里的 'public/src' 修改为你实际的源码目录
|
|
7
|
+
const TARGET_DIR = './public/src';
|
|
8
|
+
|
|
9
|
+
// 获取绝对路径
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const rootPath = path.resolve(__dirname, TARGET_DIR);
|
|
12
|
+
|
|
13
|
+
const FILE_LIST=[
|
|
14
|
+
'dictionary/index.js',
|
|
15
|
+
'pages/bullet/gdtAssets/audienceManage/targetTemplate/dxbTemplate/weiChatPcMarket/components/index.js',
|
|
16
|
+
'pages/bullet/kuaiShou/creativeTag/create/index.js',
|
|
17
|
+
'pages/bullet/material/word/wordManagement/create/index.js',
|
|
18
|
+
'utils/version.js',
|
|
19
|
+
'pages/components/select/userState/index.js',
|
|
20
|
+
'pages/bullet/material/word/wordManagement/index.js',
|
|
21
|
+
'pages/components/select/userZero/index.js',
|
|
22
|
+
'pages/bullet/selfLandingPage/landingPage/htmlModal/index.js',
|
|
23
|
+
'pages/dashboard/components/batchGlobalModal/formItemsConfig.js',
|
|
24
|
+
'pages/equipment/tag/create/index.js'
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
let count = 0;
|
|
28
|
+
FILE_LIST.forEach(file=>{
|
|
29
|
+
const filePath = rootPath+'/'+file;
|
|
30
|
+
console.log(`🚀 开始处理: ${filePath}`);
|
|
31
|
+
const stats = fs.statSync(filePath);
|
|
32
|
+
if (stats.isFile()) {
|
|
33
|
+
const newFilePath = filePath.replace(/\.js$/, '.jsx');
|
|
34
|
+
// 执行重命名
|
|
35
|
+
try {
|
|
36
|
+
// fs.renameSync(filePath, newFilePath);
|
|
37
|
+
console.log(`✅ Renamed: ${file} -> ${path.basename(newFilePath)}`);
|
|
38
|
+
count++;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error(`❌ Failed: ${file}`, err);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
console.log(`\n✨ 完成!共重命名了 ${count} 个文件。`);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
// --- 配置区 ---
|
|
6
|
+
// 将这里的 'public/src' 修改为你实际的源码目录
|
|
7
|
+
const TARGET_DIR = './public/src';
|
|
8
|
+
|
|
9
|
+
// 获取绝对路径
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const rootPath = path.resolve(__dirname, TARGET_DIR);
|
|
12
|
+
|
|
13
|
+
let count = 0;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 递归遍历并重命名
|
|
17
|
+
* @param {string} dir
|
|
18
|
+
*/
|
|
19
|
+
function walk(dir) {
|
|
20
|
+
const files = fs.readdirSync(dir);
|
|
21
|
+
|
|
22
|
+
files.forEach((file) => {
|
|
23
|
+
const filePath = path.join(dir, file);
|
|
24
|
+
const stats = fs.statSync(filePath);
|
|
25
|
+
|
|
26
|
+
if (stats.isDirectory()) {
|
|
27
|
+
// 递归进入子目录
|
|
28
|
+
walk(filePath);
|
|
29
|
+
} else if (stats.isFile()) {
|
|
30
|
+
// 匹配逻辑:以 .less 结尾,但不是以 .module.less 结尾
|
|
31
|
+
if (file.endsWith('.less') && !file.endsWith('.module.less')) {
|
|
32
|
+
const newFilePath = filePath.replace(/\.less$/, '.module.less');
|
|
33
|
+
|
|
34
|
+
// 执行重命名
|
|
35
|
+
try {
|
|
36
|
+
fs.renameSync(filePath, newFilePath);
|
|
37
|
+
console.log(`✅ Renamed: ${file} -> ${path.basename(newFilePath)}`);
|
|
38
|
+
count++;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error(`❌ Failed: ${file}`, err);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(`🚀 开始处理目录: ${rootPath}`);
|
|
48
|
+
if (fs.existsSync(rootPath)) {
|
|
49
|
+
walk(rootPath);
|
|
50
|
+
console.log(`\n✨ 完成!共重命名了 ${count} 个文件。`);
|
|
51
|
+
} else {
|
|
52
|
+
console.error(`❌ 错误:目录 ${rootPath} 不存在,请检查配置。`);
|
|
53
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
if [ -d "${HOME}/.nvm/" ]
|
|
2
|
+
then
|
|
3
|
+
. ${HOME}/.nvm/nvm.sh
|
|
4
|
+
fi
|
|
5
|
+
|
|
6
|
+
. ./shellUtil.sh
|
|
7
|
+
|
|
8
|
+
node_version="v16.18.0"
|
|
9
|
+
|
|
10
|
+
build(){
|
|
11
|
+
npm config delete registry -g
|
|
12
|
+
npm config delete registry
|
|
13
|
+
|
|
14
|
+
checkKnCli
|
|
15
|
+
checkResult "检查kn-cli"
|
|
16
|
+
|
|
17
|
+
kn-cli --report
|
|
18
|
+
checkResult "kn-cli --report"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
checkNode "${node_version}"
|
|
22
|
+
checkResult "检查node"
|
|
23
|
+
|
|
24
|
+
build
|
|
25
|
+
checkResult "build"
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
checkResult(){
|
|
5
|
+
ret=$?
|
|
6
|
+
if [ $ret != 0 ]
|
|
7
|
+
then
|
|
8
|
+
printf "\e[40;31m [$1] 执行失败 \e[0m\n"
|
|
9
|
+
exit 2
|
|
10
|
+
return 0
|
|
11
|
+
else
|
|
12
|
+
printf "\e[40;32m [$1] 执行成功\e[0m \n"
|
|
13
|
+
return 0
|
|
14
|
+
fi
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
checkKnCli(){
|
|
20
|
+
# 方案一:始终将kn-cli保持为最新版本
|
|
21
|
+
# npm i kn-cli -g
|
|
22
|
+
# return 0
|
|
23
|
+
|
|
24
|
+
# 方案二:保持kn-cli为固定某个版本
|
|
25
|
+
# npm i kn-cli@1.0.26 -g
|
|
26
|
+
# return 0
|
|
27
|
+
|
|
28
|
+
# 方案三:检测未安装时或版本不为最新版本时更新
|
|
29
|
+
if ! [ -x "$(command -v kn-cli)" ]
|
|
30
|
+
then
|
|
31
|
+
echo "安装kn-cli"
|
|
32
|
+
npm i kn-cli -g
|
|
33
|
+
return 0
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
for line in `npm view kn-cli version`
|
|
37
|
+
do
|
|
38
|
+
for line2 in `kn-cli -v`
|
|
39
|
+
do
|
|
40
|
+
if [ $line != $line2 ]
|
|
41
|
+
then
|
|
42
|
+
echo "升级kn-cli"
|
|
43
|
+
npm upgrade kn-cli -g
|
|
44
|
+
return 0
|
|
45
|
+
fi
|
|
46
|
+
done
|
|
47
|
+
done
|
|
48
|
+
return 0
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
showLog() {
|
|
53
|
+
local text="$1"
|
|
54
|
+
local color="$2"
|
|
55
|
+
local color_code=""
|
|
56
|
+
case "$color" in
|
|
57
|
+
"white") color_code="";;
|
|
58
|
+
"red") color_code="\e[40;31m";;
|
|
59
|
+
"green") color_code="\e[40;32m";;
|
|
60
|
+
"blue") color_code="\e[40;34m";;
|
|
61
|
+
"yellow") color_code="\e[40;33m";;
|
|
62
|
+
*) color_code="\e[40;30m";;
|
|
63
|
+
esac
|
|
64
|
+
printf "%b\n" "${color_code}${text}\e[0m"
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
showNormal(){
|
|
68
|
+
showLog "$1" "white"
|
|
69
|
+
}
|
|
70
|
+
showSuccess() {
|
|
71
|
+
showLog "$1" "green"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
showError() {
|
|
75
|
+
showLog "$1" "red"
|
|
76
|
+
}
|
|
77
|
+
showWarn() {
|
|
78
|
+
showLog "$1" "yellow"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
showInput(){
|
|
82
|
+
local text="$1"
|
|
83
|
+
printf "%b" "\e[40;35m${text}\e[0m" >&2
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
checkNode(){
|
|
90
|
+
local node_version="$1"
|
|
91
|
+
|
|
92
|
+
for line in `node -v`
|
|
93
|
+
do
|
|
94
|
+
if [ $line != $node_version ]
|
|
95
|
+
then
|
|
96
|
+
showWarn "change Node from ${line} to ${node_version}"
|
|
97
|
+
nvm use $node_version
|
|
98
|
+
ret=$?
|
|
99
|
+
if [ $ret != 0 ]
|
|
100
|
+
then
|
|
101
|
+
showError "Please run nvm install ${node_version}"
|
|
102
|
+
exit 3
|
|
103
|
+
else
|
|
104
|
+
return 0
|
|
105
|
+
fi
|
|
106
|
+
else
|
|
107
|
+
return 0
|
|
108
|
+
fi
|
|
109
|
+
done
|
|
110
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
. ./shellUtil.sh
|
|
3
|
+
|
|
4
|
+
# version=$(grep -m1 '"version":' package.json | awk -F'"' '{print $4}')
|
|
5
|
+
# checkResult "获取当前版本号"
|
|
6
|
+
|
|
7
|
+
read -p "版本发布备注:" message
|
|
8
|
+
npm version patch -m "[%s]version publish:$message"
|
|
9
|
+
checkResult "版本号升级"
|
|
10
|
+
git push
|
|
11
|
+
checkResult "git push"
|
|
12
|
+
|
|
13
|
+
git push origin --tags
|
|
14
|
+
checkResult "git push tags"
|
|
15
|
+
|
|
16
|
+
echo "版本Tag标记完毕"
|