@titaui/pc 1.9.90 → 1.9.94

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.
@@ -21,10 +21,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
21
21
 
22
22
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
23
23
 
24
- // @ts-ignore
25
- var tenantId = BSGlobal && BSGlobal.tenantInfo.Id || 0; // @ts-ignore
26
-
27
- var userId = BSGlobal && BSGlobal.loginUserInfo.Id || 0;
24
+ var tenantId = window.BSGlobal && window.BSGlobal.tenantInfo.Id || 0;
25
+ var userId = window.BSGlobal && window.BSGlobal.loginUserInfo.Id || 0;
28
26
 
29
27
  var requestDomain = function requestDomain() {
30
28
  if (!window.location.hostname.match(/dev/)) return "";
@@ -86,7 +84,9 @@ var getKrAnalysisInfos = /*#__PURE__*/function () {
86
84
  switch (_context2.prev = _context2.next) {
87
85
  case 0:
88
86
  url = "".concat(requestDomain(), "/api/v1/").concat(tenantId, "/").concat(userId, "/okr/create/analys");
89
- return _context2.abrupt("return", _axios["default"].post(url, params));
87
+ return _context2.abrupt("return", _axios["default"].post(url, params).then(function (res) {
88
+ return res.data.Data;
89
+ }));
90
90
 
91
91
  case 2:
92
92
  case "end":
@@ -170,6 +170,8 @@ var getOAnalysisInfos = /*#__PURE__*/function () {
170
170
  if (resp.status === 200 && resp.data.Code === 1) {
171
171
  return resp.data.Data;
172
172
  }
173
+
174
+ return {};
173
175
  }));
174
176
 
175
177
  case 2:
@@ -48,7 +48,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
48
48
  var DemoMenus = function DemoMenus(props) {
49
49
  var _props$onSelect = props.onSelect,
50
50
  onSelect = _props$onSelect === void 0 ? function () {} : _props$onSelect,
51
- history = props.history;
51
+ history = props.history,
52
+ isManager = props.isManager;
52
53
  var menuRef = (0, _react.useRef)();
53
54
  var okrMenusData = (0, _react.useRef)(_menus.defaultRefObject);
54
55
 
@@ -66,9 +67,15 @@ var DemoMenus = function DemoMenus(props) {
66
67
  okrMenusData.current = new _menus["default"]();
67
68
  return okrMenusData.current.getMenus();
68
69
  }),
69
- _useState6 = _slicedToArray(_useState5, 1),
70
- menus = _useState6[0];
70
+ _useState6 = _slicedToArray(_useState5, 2),
71
+ menus = _useState6[0],
72
+ setMenus = _useState6[1];
71
73
 
74
+ (0, _react.useEffect)(function () {
75
+ okrMenusData.current = new _menus["default"](isManager === 1);
76
+ setMenus(okrMenusData.current.getMenus());
77
+ setExpandedKeys(["demofree"]);
78
+ }, [isManager]);
72
79
  var flipRef = (0, _react.useRef)({
73
80
  next: function next() {},
74
81
  goback: function goback() {}
@@ -114,7 +121,7 @@ var DemoMenus = function DemoMenus(props) {
114
121
  }, /*#__PURE__*/_react["default"].createElement(_scrollbar["default"], null, /*#__PURE__*/_react["default"].createElement(_menuTree["default"], {
115
122
  data: menus,
116
123
  selectedKeys: selectedMenuKeys,
117
- expandedKeys: expandedKeys,
124
+ defaultExpandedKeys: expandedKeys,
118
125
  onExpand: onExpandHandler,
119
126
  onSelect: onSelectHandler
120
127
  }))), /*#__PURE__*/_react["default"].createElement("div", null)));
@@ -31,9 +31,11 @@ exports.PAGE_IGNORED_DEMOFREE = PAGE_IGNORED_DEMOFREE;
31
31
 
32
32
  var DemoMenuData = /*#__PURE__*/function () {
33
33
  function DemoMenuData() {
34
+ var isManager = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
35
+
34
36
  _classCallCheck(this, DemoMenuData);
35
37
 
36
- this.isManager = localStorage.getItem("DEMO_USER_IS_MANAGER") === "1";
38
+ this.isManager = isManager;
37
39
  this.menus = [{
38
40
  icon: "kaohe",
39
41
  label: "任务状态",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titaui/pc",
3
- "version": "1.9.90",
3
+ "version": "1.9.94",
4
4
  "nameCN": "",
5
5
  "description": "",
6
6
  "main": "src/index.js",
@@ -6,10 +6,8 @@ import {
6
6
  UpdateOkrVisibilityParams,
7
7
  } from "./interface";
8
8
 
9
- // @ts-ignore
10
- const tenantId = (BSGlobal && BSGlobal.tenantInfo.Id) || 0;
11
- // @ts-ignore
12
- const userId = (BSGlobal && BSGlobal.loginUserInfo.Id) || 0;
9
+ const tenantId = (window.BSGlobal && window.BSGlobal.tenantInfo.Id) || 0;
10
+ const userId = (window.BSGlobal && window.BSGlobal.loginUserInfo.Id) || 0;
13
11
 
14
12
  const requestDomain = () => {
15
13
  if (!window.location.hostname.match(/dev/)) return "";
@@ -23,7 +21,7 @@ export const getImageBase64ByUrl = (toUserId) => axios
23
21
  )
24
22
  .then((getBase64Str) => getBase64Str.data);
25
23
 
26
- export const createWidthKr = async function (data: any) {
24
+ export const createWidthKr = async (data: any) => {
27
25
  const url = `${requestDomain()}/api/v2/${tenantId}/${userId}/work/createWithKr`;
28
26
  const res = await axios.post(
29
27
  url,
@@ -39,19 +37,19 @@ export const createWidthKr = async function (data: any) {
39
37
  return res.data.Data;
40
38
  };
41
39
 
42
- export const getKrAnalysisInfos = async function (params) {
40
+ export const getKrAnalysisInfos = async (params) => {
43
41
  const url = `${requestDomain()}/api/v1/${tenantId}/${userId}/okr/create/analys`;
44
- return axios.post(url, params);
42
+ return axios.post(url, params).then((res) => res.data.Data);
45
43
  };
46
44
 
47
- export const updateOkrVisibility = async function (
45
+ export const updateOkrVisibility = async (
48
46
  params: UpdateOkrVisibilityParams,
49
- ) {
47
+ ) => {
50
48
  const url = `${requestDomain()}/api/v2/${tenantId}/${userId}/work/visiblity`;
51
49
  return axios.post(url, params);
52
50
  };
53
51
 
54
- export const updateOCommitType = async function (params: UpdateOkrTypeParams) {
52
+ export const updateOCommitType = async (params: UpdateOkrTypeParams) => {
55
53
  const url = `${requestDomain()}/api/v1/${tenantId}/${userId}/okr/update/okrType?okrId=${
56
54
  params.okrId
57
55
  }`;
@@ -61,16 +59,17 @@ export const updateOCommitType = async function (params: UpdateOkrTypeParams) {
61
59
  });
62
60
  };
63
61
 
64
- export const getOAnalysisInfos = async function (params) {
62
+ export const getOAnalysisInfos = async (params) => {
65
63
  const url = `${requestDomain()}/api/v1/${tenantId}/${userId}/okr/create/analys`;
66
64
  return axios.post(url, params).then((resp) => {
67
65
  if (resp.status === 200 && resp.data.Code === 1) {
68
66
  return resp.data.Data;
69
67
  }
68
+ return {};
70
69
  });
71
70
  };
72
71
 
73
- export const getCycleSetting = async function (): Promise<GetCycleSettingParams> {
72
+ export const getCycleSetting = async (): Promise<GetCycleSettingParams> => {
74
73
  const url = `${requestDomain()}/api/v1/${tenantId}/${userId}/okr/cycleSetting`;
75
74
  const res = await axios.get(url);
76
75
  return res.data.Data;
@@ -14,18 +14,23 @@ import { isEn } from "../../../../utils/getLocale";
14
14
  interface DemoMenusProps {
15
15
  onSelect: (node: any) => void;
16
16
  history: any;
17
+ isManager: number
17
18
  }
18
19
  const DemoMenus: React.FC<DemoMenusProps> = (props) => {
19
- const { onSelect = () => { }, history } = props;
20
-
20
+ const { onSelect = () => { }, history, isManager } = props;
21
21
  const menuRef = useRef<any>();
22
22
  const okrMenusData = useRef<DemoMenusInt>(defaultRefObject);
23
23
  const [selectedMenuKeys, setSelectedMenuKeys] = useState<string[]>([]);
24
24
  const [expandedKeys, setExpandedKeys] = useState(["demofree"]);
25
- const [menus] = useState(() => {
25
+ const [menus, setMenus] = useState(() => {
26
26
  okrMenusData.current = new DemoMenuData();
27
- return okrMenusData.current.getMenus();
27
+ return okrMenusData.current.getMenus()
28
28
  });
29
+ useEffect(() => {
30
+ okrMenusData.current = new DemoMenuData(isManager === 1);
31
+ setMenus(okrMenusData.current.getMenus())
32
+ setExpandedKeys(["demofree"]);
33
+ }, [isManager])
29
34
  const flipRef = useRef<flipRefIns>({
30
35
  next: () => { },
31
36
  goback: () => { },
@@ -66,7 +71,7 @@ const DemoMenus: React.FC<DemoMenusProps> = (props) => {
66
71
  <MenuTree
67
72
  data={menus}
68
73
  selectedKeys={selectedMenuKeys}
69
- expandedKeys={expandedKeys}
74
+ defaultExpandedKeys={expandedKeys}
70
75
  onExpand={onExpandHandler}
71
76
  onSelect={onSelectHandler}
72
77
  />
@@ -26,8 +26,8 @@ export default class DemoMenuData {
26
26
 
27
27
  public isManager;
28
28
 
29
- constructor() {
30
- this.isManager = localStorage.getItem("DEMO_USER_IS_MANAGER") === "1";
29
+ constructor(isManager = false) {
30
+ this.isManager = isManager;
31
31
  this.menus = [
32
32
  {
33
33
  icon: "kaohe",