@cloud-app-dev/vidc 2.0.0-alpha.6 → 2.0.0-alpha.7

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.
@@ -1,4 +1,5 @@
1
1
  import produce from 'immer';
2
+ import { formartThemeConfig } from './utils';
2
3
  var Config = {
3
4
  app: produce({}, function () {}),
4
5
  bs: produce({}, function () {}),
@@ -29,8 +30,11 @@ var Config = {
29
30
  },
30
31
  registerThemeConfig: function registerThemeConfig(theme) {
31
32
  Config.theme = produce(Config.theme, function (draft) {
32
- draft = theme;
33
+ draft = formartThemeConfig(theme);
33
34
  });
35
+ },
36
+ getThemeVarValue: function getThemeVarValue(themeKey) {
37
+ return getComputedStyle(document.querySelector(':root')).getPropertyValue("--".concat(themeKey));
34
38
  }
35
39
  };
36
40
 
@@ -31,6 +31,14 @@ export type BSConfigType = {
31
31
  chromeDownloadUrl: string;
32
32
  };
33
33
 
34
+ export type ThemeInfoType = {
35
+ vars: { [key: string]: string[] };
36
+ style: {
37
+ menuType: 'inline' | 'horizontal';
38
+ hasTab: boolean;
39
+ };
40
+ };
41
+
34
42
  export type ConfigKey = 'app' | 'feature' | 'pFeature' | 'bs';
35
43
 
36
44
  export type ConfigJOSN = {
@@ -38,12 +46,12 @@ export type ConfigJOSN = {
38
46
  feature: FeatureItemType[];
39
47
  pFeature: FeatureItemType[];
40
48
  bs: BSConfigType;
41
- theme: any;
49
+ theme: ThemeInfoType;
42
50
  registerAppConfig: (conf: AppItemType[]) => void;
43
51
  registerFeatrue: (conf: FeatureItemType[]) => void;
44
52
  registerBSConfig: (conf: BSConfigType) => void;
45
53
  registerPlatformFeature: (conf: FeatureItemType[]) => void;
46
- registerThemeConfig: (conf: { [key: string]: any }) => void;
54
+ registerThemeConfig: (conf: ThemeInfoType) => void;
47
55
 
48
56
  [key: string]: any;
49
57
  };
@@ -1,18 +1,2 @@
1
- import { ConfigJOSN } from './interface';
2
- export declare function formartThemeConfig(options: ConfigJOSN): {
3
- [x: string]: any;
4
- app: {
5
- [key: string]: import("./interface").AppItemType;
6
- };
7
- feature: import("./interface").FeatureItemType[];
8
- pFeature: import("./interface").FeatureItemType[];
9
- bs: import("./interface").BSConfigType;
10
- theme: any;
11
- registerAppConfig: (conf: import("./interface").AppItemType[]) => void;
12
- registerFeatrue: (conf: import("./interface").FeatureItemType[]) => void;
13
- registerBSConfig: (conf: import("./interface").BSConfigType) => void;
14
- registerPlatformFeature: (conf: import("./interface").FeatureItemType[]) => void;
15
- registerThemeConfig: (conf: {
16
- [key: string]: any;
17
- }) => void;
18
- };
1
+ import { ThemeInfoType } from './interface';
2
+ export declare function formartThemeConfig(options: ThemeInfoType): ThemeInfoType;
@@ -24,9 +24,6 @@ export function formartThemeConfig(options) {
24
24
  var _ref;
25
25
 
26
26
  var tplStr = ':root{<content>}';
27
- var data = Object.assign({}, options);
28
- data.vars = {};
29
- data.style = {};
30
27
 
31
28
  var attrArr = (_ref = []).concat.apply(_ref, _toConsumableArray(Object.values(options.vars)));
32
29
 
@@ -44,11 +41,5 @@ export function formartThemeConfig(options) {
44
41
  document.head.appendChild(style);
45
42
  }
46
43
 
47
- if (options.style) {
48
- Object.keys(options.style).forEach(function (k) {
49
- data.style[k] = options.style[k];
50
- });
51
- }
52
-
53
- return data;
44
+ return options;
54
45
  }
@@ -1,3 +1,5 @@
1
+ import _nextTick from "@cloud-app-dev/utils/es/nextTick";
2
+
1
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
4
 
3
5
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -40,7 +42,7 @@ function InitialRequest(_ref) {
40
42
 
41
43
  var init = function init() {
42
44
  return __awaiter(_this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
43
- var _yield$initialization, userPrivileges, centerPrivileges, centerInfo, userInfo;
45
+ var _yield$initialization, userFeatures, operationInfo, systemFeatures, userInfo;
44
46
 
45
47
  return regeneratorRuntime.wrap(function _callee$(_context) {
46
48
  while (1) {
@@ -51,15 +53,19 @@ function InitialRequest(_ref) {
51
53
 
52
54
  case 2:
53
55
  _yield$initialization = _context.sent;
54
- userPrivileges = _yield$initialization.userPrivileges;
55
- centerPrivileges = _yield$initialization.centerPrivileges;
56
- centerInfo = _yield$initialization.centerInfo;
56
+ userFeatures = _yield$initialization.userFeatures;
57
+ operationInfo = _yield$initialization.operationInfo;
58
+ systemFeatures = _yield$initialization.systemFeatures;
57
59
  userInfo = _yield$initialization.userInfo;
58
60
  updateUser(userInfo);
59
- updateOperation(centerInfo);
60
- Config.registerFeatrue(userPrivileges);
61
- Config.registerPlatformFeature(centerPrivileges);
62
- setIsInit(true);
61
+ updateOperation(operationInfo);
62
+ Config.registerFeatrue(userFeatures);
63
+ Config.registerPlatformFeature(systemFeatures);
64
+
65
+ _nextTick(function () {
66
+ return setIsInit(true);
67
+ });
68
+
63
69
  _BASE_DATA_INIT = true;
64
70
 
65
71
  case 13:
@@ -2,7 +2,7 @@ import { UserInfoType, OperationInfoType } from '../AppContext/interface';
2
2
  import { FeatureItemType } from '../Config/interface';
3
3
  export declare function initialization(): Promise<{
4
4
  userInfo: UserInfoType;
5
- userPrivileges: FeatureItemType[];
6
- centerPrivileges: FeatureItemType[];
7
- centerInfo: OperationInfoType;
5
+ userFeatures: FeatureItemType[];
6
+ systemFeatures: FeatureItemType[];
7
+ operationInfo: OperationInfoType;
8
8
  }>;
@@ -29,8 +29,10 @@ function catchPromise(fn) {
29
29
 
30
30
  var method = 'post';
31
31
  export function initialization() {
32
+ var _a;
33
+
32
34
  return __awaiter(this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
33
- var headers, result, userInfo, userId, operationCenterId, data, data2, centerUrl, centerInfo, themeInfo, themeConfig, themeId, themeUrl, themeRes, userPrivilegesUrl, centerPrivilegesUrl, _yield$Promise$all, _yield$Promise$all2, _yield$Promise$all2$, userPrivileges, _yield$Promise$all2$2, centerPrivileges;
35
+ var headers, result, userInfo, userId, operationCenterId, data, data2, centerUrl, centerInfo, themeInfo, themeConfig, userPrivilegesUrl, systemFeatureUrl, _yield$Promise$all, _yield$Promise$all2, _yield$Promise$all2$, userFeatures, _yield$Promise$all2$2, systemFeatures;
34
36
 
35
37
  return regeneratorRuntime.wrap(function _callee$(_context) {
36
38
  while (1) {
@@ -43,8 +45,7 @@ export function initialization() {
43
45
  return Service.$http({
44
46
  url: '/api/user/v1/getUserByToken',
45
47
  method: method,
46
- headers: headers,
47
- requestId: 'getUserInfo'
48
+ headers: headers
48
49
  });
49
50
 
50
51
  case 3:
@@ -64,50 +65,31 @@ export function initialization() {
64
65
  data: data2,
65
66
  method: method,
66
67
  url: centerUrl,
67
- headers: headers,
68
- requestId: 'operationCenterInfo'
68
+ headers: headers
69
69
  });
70
70
 
71
71
  case 12:
72
72
  centerInfo = _context.sent;
73
73
  _context.next = 15;
74
74
  return Service.$http({
75
- url: "/api/micro/configureApplication/v1/queryConfigureApplicationById/".concat(operationCenterId)
75
+ url: '/api/system/config/type',
76
+ data: {
77
+ type: 'theme',
78
+ systemId: operationCenterId
79
+ }
76
80
  });
77
81
 
78
82
  case 15:
79
83
  themeInfo = _context.sent;
80
- themeConfig = themeInfo.data || {}; // eslint-disable-next-line no-eval
84
+ themeConfig = (_a = themeInfo === null || themeInfo === void 0 ? void 0 : themeInfo.data) === null || _a === void 0 ? void 0 : _a.content;
81
85
 
82
- themeId = themeConfig.themeId || centerInfo.data.hues;
83
-
84
- if (!themeId) {
85
- _context.next = 24;
86
- break;
86
+ if (themeConfig) {
87
+ Config.registerThemeConfig(themeConfig);
87
88
  }
88
89
 
89
- themeUrl = "/api/micro/configure/v1/queryConfigureByConfigureId/".concat(themeId);
90
- _context.next = 22;
91
- return Service.$http({
92
- data: data2,
93
- method: 'get',
94
- url: themeUrl,
95
- headers: headers
96
- });
97
-
98
- case 22:
99
- themeRes = _context.sent;
100
-
101
- try {
102
- Config.registerThemeConfig(themeRes.data);
103
- } catch (e) {
104
- console.error(e);
105
- }
106
-
107
- case 24:
108
90
  userPrivilegesUrl = "/api/user/role/v1/queryUserRoles/".concat(userId);
109
- centerPrivilegesUrl = "/api/micro/applicationSystemScene/v1/queryAllFunctionByApplicationSystemId/".concat(operationCenterId);
110
- _context.next = 28;
91
+ systemFeatureUrl = "/api/system/".concat(operationCenterId, "/list");
92
+ _context.next = 22;
111
93
  return Promise.all([catchPromise(Service.$http({
112
94
  data: data,
113
95
  method: method,
@@ -116,29 +98,29 @@ export function initialization() {
116
98
  })), catchPromise(Service.$http({
117
99
  data: data2,
118
100
  method: 'get',
119
- url: centerPrivilegesUrl,
101
+ url: systemFeatureUrl,
120
102
  headers: headers
121
103
  }))]);
122
104
 
123
- case 28:
105
+ case 22:
124
106
  _yield$Promise$all = _context.sent;
125
107
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
126
108
  _yield$Promise$all2$ = _yield$Promise$all2[0];
127
- userPrivileges = _yield$Promise$all2$ === void 0 ? {
109
+ userFeatures = _yield$Promise$all2$ === void 0 ? {
128
110
  data: []
129
111
  } : _yield$Promise$all2$;
130
112
  _yield$Promise$all2$2 = _yield$Promise$all2[1];
131
- centerPrivileges = _yield$Promise$all2$2 === void 0 ? {
113
+ systemFeatures = _yield$Promise$all2$2 === void 0 ? {
132
114
  data: []
133
115
  } : _yield$Promise$all2$2;
134
116
  return _context.abrupt("return", {
135
117
  userInfo: userInfo,
136
- userPrivileges: userPrivileges.data,
137
- centerPrivileges: centerPrivileges.data,
138
- centerInfo: centerInfo
118
+ userFeatures: userFeatures.data,
119
+ systemFeatures: systemFeatures.data,
120
+ operationInfo: centerInfo.data
139
121
  });
140
122
 
141
- case 35:
123
+ case 29:
142
124
  case "end":
143
125
  return _context.stop();
144
126
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "name": "@cloud-app-dev/vidc",
4
4
  "description": "Video Image Data Componennts",
5
- "version": "2.0.0-alpha.6",
5
+ "version": "2.0.0-alpha.7",
6
6
  "scripts": {
7
7
  "start": "dumi dev",
8
8
  "docs:build": "dumi build",