uepay-ops2 4.0.15 → 4.0.16-beta

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.
Files changed (41) hide show
  1. package/bin/uepay.js +0 -3
  2. package/index.d.ts +3 -1
  3. package/index.js +8 -5
  4. package/lib/components/application/optionsLoader.js +9 -22
  5. package/lib/components/application.js +41 -63
  6. package/lib/components/applicationLight.js +13 -40
  7. package/lib/components/auth/withOptions.js +4 -12
  8. package/lib/components/client.js +42 -34
  9. package/lib/components/home/home.js +13 -17
  10. package/lib/components/icon/captcha.js +13 -29
  11. package/lib/components/layout/menuAble/header.js +35 -38
  12. package/lib/components/layout/menuAble/multiPage.js +13 -43
  13. package/lib/components/layout/menuAble/sider.js +13 -26
  14. package/lib/components/layout/menuAble.js +8 -21
  15. package/lib/components/layout/mobileAble.d.ts +4 -0
  16. package/lib/components/layout/mobileAble.js +23 -0
  17. package/lib/components/layout/single.js +3 -10
  18. package/lib/components/layout.js +14 -31
  19. package/lib/components/locale/context.js +4 -11
  20. package/lib/components/locale/withLocale.js +2 -17
  21. package/lib/components/setting/userSetting.js +7 -27
  22. package/lib/components/spin/loading.js +2 -10
  23. package/lib/components/spinner/spinner.js +2 -14
  24. package/lib/components/userMgr/login.js +12 -35
  25. package/lib/components/userMgr/userInfo.js +5 -13
  26. package/lib/components/userMgr/userMgrLayout.js +8 -19
  27. package/lib/data/appUrl.js +7 -22
  28. package/lib/data/ctx.js +14 -32
  29. package/lib/data/localDefined.js +1 -3
  30. package/lib/util/apolloConfig.js +7 -17
  31. package/lib/util/authRoute.js +21 -47
  32. package/lib/util/establish.js +0 -3
  33. package/lib/util/express.js +12 -12
  34. package/lib/util/net.js +13 -37
  35. package/lib/util/state.js +2 -4
  36. package/lib/util/token.js +1 -7
  37. package/lib/util/tool.js +3 -21
  38. package/lib/util/uepayConfig.js +1 -7
  39. package/net.js +5 -12
  40. package/package.json +1 -1
  41. package/styles.css +1 -0
@@ -4,14 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.logout = exports.login = exports.getSts = exports.getMenus = exports.checkLogin = exports.changePassword = exports.captcha = void 0;
7
-
8
7
  var _ctx = require("./ctx");
9
-
10
8
  var _net = require("../util/net");
11
-
12
9
  /**
13
10
  * 系统级Url配置
14
11
  **/
12
+
15
13
  const getSts = async () => {
16
14
  return fetch("".concat((0, _ctx.getServerUrl)(), "/api/authority/service/signin/sts?cert=fRO4h1pqEKxzeSw45V18"), {
17
15
  method: 'Get',
@@ -29,17 +27,16 @@ const getSts = async () => {
29
27
  console.log('Fetch Error: ', error.message);
30
28
  });
31
29
  };
30
+
32
31
  /**
33
32
  * 獲取當前登錄人的權限菜單
34
33
  * @return {Promise<any>}
35
34
  */
36
-
37
-
38
35
  exports.getSts = getSts;
39
-
40
36
  const getMenus = () => {
41
37
  return (0, _net.get)("".concat((0, _ctx.getHost)(), "/api/uepay/assist/authority/runtimeserver/identitymgr/tree/menu/"));
42
38
  };
39
+
43
40
  /**
44
41
  * 登陸接口
45
42
  * @param account 用戶名
@@ -47,10 +44,7 @@ const getMenus = () => {
47
44
  * @param captcha 驗證碼
48
45
  * @returns {Promise<Response>}
49
46
  */
50
-
51
-
52
47
  exports.getMenus = getMenus;
53
-
54
48
  const login = (account, password, captcha) => {
55
49
  let params = {
56
50
  account,
@@ -59,48 +53,40 @@ const login = (account, password, captcha) => {
59
53
  };
60
54
  return (0, _net.post)("".concat((0, _ctx.getHost)(), "/api/authority/service/signin/login"), params);
61
55
  };
56
+
62
57
  /**
63
58
  * 通過token確認登陸狀態
64
59
  */
65
-
66
-
67
60
  exports.login = login;
68
-
69
61
  const checkLogin = () => {
70
62
  return (0, _net.get)("".concat((0, _ctx.getHost)(), "/api/authority/service/signin/token"));
71
63
  };
64
+
72
65
  /**
73
66
  * logout 登出
74
67
  * @return {Promise<Object>}
75
68
  */
76
-
77
-
78
69
  exports.checkLogin = checkLogin;
79
-
80
70
  const logout = () => {
81
71
  return (0, _net.remove)("".concat((0, _ctx.getHost)(), "/api/authority/service/signin/login-out"));
82
72
  };
73
+
83
74
  /**
84
75
  * 获取验证码
85
76
  * captcha 驗證碼
86
77
  * @returns {Promise<Response>}
87
78
  */
88
-
89
-
90
79
  exports.logout = logout;
91
-
92
80
  const captcha = code => {
93
81
  return (0, _net.get)("".concat((0, _ctx.getHost)(), "/api/authority/service/signin/captcha?code=").concat(code));
94
82
  };
83
+
95
84
  /**
96
85
  * 修改密碼
97
86
  * captcha 驗證碼
98
87
  * @returns {Promise<Response>}
99
88
  */
100
-
101
-
102
89
  exports.captcha = captcha;
103
-
104
90
  const changePassword = (oldPasswd, newPasswd, verifyPasswd, captcha) => {
105
91
  let params = {
106
92
  oldPasswd,
@@ -110,5 +96,4 @@ const changePassword = (oldPasswd, newPasswd, verifyPasswd, captcha) => {
110
96
  };
111
97
  return (0, _net.post)("".concat((0, _ctx.getHost)(), "/api/authority/service/usr/passwd"), params);
112
98
  };
113
-
114
99
  exports.changePassword = changePassword;
package/lib/data/ctx.js CHANGED
@@ -4,94 +4,77 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getTitleEn = exports.getTitleCn = exports.getServerUrl = exports.getHost = exports.getBpmFormPage = exports.get = exports.default = exports.PageOptType = void 0;
7
-
8
7
  var _config = _interopRequireDefault(require("next/config"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
9
  const {
13
- publicRuntimeConfig
14
- } = (0, _config.default)(),
15
- config = JSON.parse(publicRuntimeConfig.uepayConfig);
10
+ publicRuntimeConfig
11
+ } = (0, _config.default)(),
12
+ config = JSON.parse(publicRuntimeConfig.uepayConfig);
13
+
16
14
  /**
17
15
  * 前端訪問的URL
18
16
  * @return {*}
19
17
  */
20
-
21
18
  const getHost = () => {
22
19
  return config['module.site.url'];
23
20
  };
21
+
24
22
  /**
25
23
  * 服務端訪問的URL
26
24
  * @return {*}
27
25
  */
28
-
29
-
30
26
  exports.getHost = getHost;
31
-
32
27
  const getServerUrl = () => {
33
28
  return config['module.server.url'];
34
29
  };
30
+
35
31
  /**
36
32
  * 构建跳转对应流程表单的URL
37
33
  * @param insId {string|number} 流程实例Id
38
34
  * @return {*}
39
35
  */
40
-
41
-
42
36
  exports.getServerUrl = getServerUrl;
43
-
44
37
  const getBpmFormPage = insId => {
45
38
  return "".concat(config['module.bpm.form_page'], "?insId=").concat(insId);
46
39
  };
40
+
47
41
  /**
48
42
  * 获取项目中文名称
49
43
  * @return {*}
50
44
  */
51
-
52
-
53
45
  exports.getBpmFormPage = getBpmFormPage;
54
-
55
46
  const getTitleCn = () => {
56
47
  return config['module.current.title_cn'];
57
48
  };
49
+
58
50
  /**
59
51
  * 获取项目英文名
60
52
  * @return {*}
61
53
  */
62
-
63
-
64
54
  exports.getTitleCn = getTitleCn;
65
-
66
55
  const getTitleEn = () => {
67
56
  return config['module.current.title_en'];
68
57
  };
58
+
69
59
  /**
70
60
  * 获取指定名称的配置
71
61
  * @returns {any}
72
62
  */
73
-
74
-
75
63
  exports.getTitleEn = getTitleEn;
76
-
77
- const get = function get() {
64
+ const get = exports.get = function get() {
78
65
  let key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
79
66
  return key ? config[key] : config;
80
67
  };
68
+
81
69
  /**
82
70
  * Page的操作頁面
83
71
  * @type {{origin: string, new_window: string}}
84
72
  */
85
-
86
-
87
- exports.get = get;
88
- const PageOptType = {
73
+ const PageOptType = exports.PageOptType = {
89
74
  origin: 'origin',
90
75
  //原窗口控制
91
76
  new: 'new' //新窗口
92
-
93
77
  };
94
- exports.PageOptType = PageOptType;
95
78
  const Ctx = {
96
79
  getHost,
97
80
  getServerUrl,
@@ -100,5 +83,4 @@ const Ctx = {
100
83
  get,
101
84
  PageOptType
102
85
  };
103
- var _default = Ctx;
104
- exports.default = _default;
86
+ var _default = exports.default = Ctx;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  /**
9
8
  * 国际化语音设置数据
10
9
  * @type {*[]}
@@ -20,5 +19,4 @@ const Locale = [{
20
19
  icon: 'icon-uk',
21
20
  value: 'en'
22
21
  }];
23
- var _default = Locale;
24
- exports.default = _default;
22
+ var _default = exports.default = Locale;
@@ -1,46 +1,41 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es6.regexp.split.js");
4
-
5
4
  const apollo = require('node-apollo'),
6
- path = require('path'),
7
- fs = require('fs');
5
+ path = require('path'),
6
+ fs = require('fs');
7
+
8
8
  /**
9
9
  * Apollo配置的支持类,用于获取Apollo服务器的相关配置。
10
10
  * 因为执行过程涉及到异步转同步方法,因此在获取参数之前必须使用Init方法执行初始化,并且需要包装了async关键字后
11
11
  * @constructor
12
12
  */
13
-
14
-
15
13
  function ApolloConfig() {
16
14
  this.host = false;
17
15
  this.authHost = false;
18
16
  this.moduleId = false;
19
17
  this.port = false;
20
18
  }
19
+
21
20
  /**
22
21
  * 初始化异步参数
23
22
  * @param appId 当前模块的ApolloId
24
23
  * @returns {Promise<void>}
25
24
  */
26
-
27
-
28
25
  ApolloConfig.prototype.init = async function (appId) {
29
26
  const filepath = this.filePath();
30
27
  const url = await this.apolloUrl(filepath);
31
28
  this.config = await this.obtainConfig(url, appId);
32
29
  };
30
+
33
31
  /**
34
32
  * 获取Apollo配置文件的路径,目前win32环境在C:\opt\settings中,LIKE UNIX的操作系统在/opt/settings。
35
33
  * 苹果的MAC OS未测试
36
34
  * @returns {string}
37
35
  */
38
-
39
-
40
36
  ApolloConfig.prototype.filePath = function () {
41
37
  const platform = global.process.platform;
42
38
  let filePath = false;
43
-
44
39
  if (/windows|win32/i.test(platform)) {
45
40
  filePath = path.format({
46
41
  dir: 'C:\\opt\\settings',
@@ -54,16 +49,14 @@ ApolloConfig.prototype.filePath = function () {
54
49
  } else {
55
50
  throw "操作系统识别失败";
56
51
  }
57
-
58
52
  return filePath;
59
53
  };
54
+
60
55
  /**
61
56
  * 通过配置文件得到Apollo配置中心的访问路径。
62
57
  * @param filepath
63
58
  * @returns {Promise<unknown>}
64
59
  */
65
-
66
-
67
60
  ApolloConfig.prototype.apolloUrl = function (filepath) {
68
61
  return new Promise((success, error) => {
69
62
  fs.readFile(filepath, 'utf-8', function (err, data) {
@@ -73,7 +66,6 @@ ApolloConfig.prototype.apolloUrl = function (filepath) {
73
66
  } else {
74
67
  const split = data.split('=');
75
68
  const url = split && 2 === split.length ? split[1] : false;
76
-
77
69
  if (url) {
78
70
  success(url);
79
71
  } else {
@@ -83,14 +75,13 @@ ApolloConfig.prototype.apolloUrl = function (filepath) {
83
75
  });
84
76
  });
85
77
  };
78
+
86
79
  /**
87
80
  * 获取Apollo的配置
88
81
  * @param url
89
82
  * @param appId
90
83
  * @returns {*|Promise<*>}
91
84
  */
92
-
93
-
94
85
  ApolloConfig.prototype.obtainConfig = function (url, appId) {
95
86
  const config = {
96
87
  configServerUrl: url,
@@ -100,5 +91,4 @@ ApolloConfig.prototype.obtainConfig = function (url, appId) {
100
91
  };
101
92
  return apollo.remoteConfigServiceFromCache(config);
102
93
  };
103
-
104
94
  module.exports = new ApolloConfig();
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.setRoute = exports.setMenus = exports.getCurOption = exports.getCurMenu = exports.getAllMenus = exports.getAllMenuList = void 0;
7
-
8
7
  require("core-js/modules/web.dom.iterable.js");
9
-
10
8
  var _tool = require("../util/tool");
11
-
12
9
  /**
13
10
  * 首页标记
14
11
  * @type {{path: string, code: string, nameCn: string, id: number, nameEn: string, parentMenu: boolean}}
@@ -26,42 +23,42 @@ const homeMenu = {
26
23
  //首页英文名称
27
24
  parentMenu: false
28
25
  };
26
+
29
27
  /**
30
28
  * 权限数据结构
31
29
  * @type {{menuList: list 菜单列表, curMenu: boolean 当前菜单, route: boolean 当前路径, menus: {} 所有菜单, options: {} 頁面權限清單}}
32
30
  */
33
-
34
31
  const authData = {
35
32
  menuList: [],
36
33
  menus: {},
37
34
  route: '/',
38
35
  curMenu: false,
39
36
  options: {}
40
- }; //初始化时将默认菜单设置为首页
37
+ };
41
38
 
39
+ //初始化时将默认菜单设置为首页
42
40
  authData.menus['/'] = homeMenu;
41
+
43
42
  /**
44
43
  * 设置餐单,在菜单被初始化时调用
45
44
  * @param inputMenuList
46
45
  */
47
-
48
46
  const setMenus = inputMenuList => {
49
47
  let menuLevelList = [],
50
- menuList = [],
51
- menuDict = {};
48
+ menuList = [],
49
+ menuDict = {};
50
+
52
51
  /**
53
52
  * 迭代处理菜单树
54
53
  * @param list
55
54
  * @param dict
56
55
  * @param mod
57
56
  */
58
-
59
57
  function menuLevelBuild(list, dict) {
60
58
  let mod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
61
59
  const nextList = [],
62
- menuDict = {};
60
+ menuDict = {};
63
61
  let parentMenu;
64
-
65
62
  for (let menu of list) {
66
63
  if (!mod && !menu.pid) {
67
64
  menu.parentMenu = false;
@@ -73,53 +70,44 @@ const setMenus = inputMenuList => {
73
70
  nextList.push(menu);
74
71
  }
75
72
  }
76
-
77
73
  menuLevelList.push(menuDict);
78
-
79
74
  if (0 < nextList.length) {
80
75
  menuLevelBuild(nextList, menuDict, true);
81
76
  }
82
77
  }
83
-
84
78
  menuLevelBuild(inputMenuList, {}, false);
79
+
85
80
  /**
86
81
  * 处理单个菜单的转换信息
87
82
  * @param menu
88
83
  */
89
-
90
84
  function processOneMenu(menu) {
91
85
  menu.nameCn = menu.name;
92
-
93
86
  if (0 < menu.children && menu.children.length) {
94
87
  menu.path = false;
95
88
  } else {
96
89
  menuDict[menu.path] = menu;
97
90
  }
98
91
  }
92
+
99
93
  /**
100
94
  * 扁平化菜单结构
101
95
  */
102
-
103
-
104
96
  function flatMenus() {
105
97
  const childDict = menuLevelList.pop(),
106
- parentDict = menuLevelList[menuLevelList.length - 1],
107
- keys = Object.keys(childDict);
98
+ parentDict = menuLevelList[menuLevelList.length - 1],
99
+ keys = Object.keys(childDict);
108
100
  let child, parent;
109
-
110
101
  if (0 < menuLevelList.length) {
111
102
  for (let key of keys) {
112
103
  child = (0, _tool.encodeMeshPath)(childDict[key]);
113
104
  processOneMenu(child);
114
105
  parent = parentDict[child.pid];
115
-
116
106
  if (!parent.children) {
117
107
  parent.children = [];
118
108
  }
119
-
120
109
  parent.children.push(child);
121
110
  }
122
-
123
111
  flatMenus();
124
112
  } else {
125
113
  for (let key of keys) {
@@ -129,80 +117,66 @@ const setMenus = inputMenuList => {
129
117
  }
130
118
  }
131
119
  }
132
-
133
120
  flatMenus();
134
121
  authData.menuList = menuList;
135
122
  authData.menus = menuDict;
136
123
  buildId();
137
124
  };
125
+
138
126
  /**
139
127
  * 设置当前的路由地址
140
128
  * @param route
141
129
  */
142
-
143
-
144
130
  exports.setMenus = setMenus;
145
-
146
131
  const setRoute = route => {
147
132
  if (route) {
148
133
  authData.route = route;
149
134
  }
150
-
151
135
  buildId();
152
136
  };
137
+
153
138
  /**
154
139
  * 构建当前餐单Id
155
140
  */
156
-
157
-
158
141
  exports.setRoute = setRoute;
159
-
160
142
  const buildId = () => {
161
143
  const preMenu = authData.curMenu,
162
- curMenu = authData.menus[authData.route];
163
-
144
+ curMenu = authData.menus[authData.route];
164
145
  if (curMenu && curMenu !== preMenu) {
165
146
  authData.curMenu = curMenu;
166
147
  }
167
- }; //=================================get
148
+ };
149
+
150
+ //=================================get
168
151
 
169
152
  /**
170
153
  * 获取当前打开的menu。
171
154
  * @returns {boolean}
172
155
  */
173
-
174
-
175
156
  const getCurMenu = () => {
176
157
  return authData.curMenu;
177
158
  };
159
+
178
160
  /**
179
161
  * 獲取當前菜單的權限
180
162
  * @returns {*}
181
163
  */
182
-
183
-
184
164
  exports.getCurMenu = getCurMenu;
185
-
186
165
  const getCurOption = () => {
187
166
  return authData.options[authData.curMenu.id];
188
167
  };
168
+
189
169
  /**
190
170
  * 获取所有菜单
191
171
  * @returns {authData.menus|{}}
192
172
  */
193
-
194
-
195
173
  exports.getCurOption = getCurOption;
196
-
197
174
  const getAllMenus = () => authData.menus;
175
+
198
176
  /**
199
177
  * 獲取菜單列表
200
178
  * @returns {[]|*}
201
179
  */
202
-
203
-
204
180
  exports.getAllMenus = getAllMenus;
205
-
206
181
  const getAllMenuList = () => authData.menuList;
207
-
208
182
  exports.getAllMenuList = getAllMenuList;
@@ -2,18 +2,15 @@
2
2
 
3
3
  module.exports = async () => {
4
4
  const uepay = require('./uepayConfig');
5
-
6
5
  await uepay.init().catch(err => {
7
6
  console.log(err);
8
7
  });
9
-
10
8
  if (uepay.config.runtimeLocal) {
11
9
  // 读取本地数据
12
10
  process.env.uepayConfig = JSON.stringify(uepay.config.localConfig);
13
11
  } else {
14
12
  // 读取appolo
15
13
  const apollo = require('./apolloConfig');
16
-
17
14
  await apollo.init(uepay.config.appId);
18
15
  process.env.uepayConfig = JSON.stringify(Object.assign({
19
16
  style: uepay.css
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  const express = require('express'),
4
- next = require('next'),
5
- //建立Uepay初始化配置
6
- establish = require('./establish'),
7
- //环境指示器
8
- env = process.env.NODE_ENV !== 'production';
9
-
4
+ next = require('next'),
5
+ //建立Uepay初始化配置
6
+ establish = require('./establish'),
7
+ //环境指示器
8
+ env = process.env.NODE_ENV !== 'production';
10
9
  (async () => {
11
- await establish(); // 创建一个服务端运行的Next app
10
+ await establish();
12
11
 
12
+ // 创建一个服务端运行的Next app
13
13
  const app = next({
14
- env
15
- }),
16
- // 请求处理器
17
- handle = app.getRequestHandler(),
18
- config = JSON.parse(process.env.uepayConfig);
14
+ env
15
+ }),
16
+ // 请求处理器
17
+ handle = app.getRequestHandler(),
18
+ config = JSON.parse(process.env.uepayConfig);
19
19
  const port = config['module.current.port'] || 3000;
20
20
  app.prepare().then(() => {
21
21
  const server = express();