@teamias/pro-layout 0.0.1 → 0.0.3
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/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/markdowns/example1/{BasicRexProLayout → BasicProLayout}/index.d.ts +0 -1
- package/dist/markdowns/example1/{BasicRexProLayout → BasicProLayout}/index.js +3 -1
- package/dist/markdowns/example1/BasicProLayoutBusiness/index.d.ts +2 -0
- package/dist/markdowns/example1/BasicProLayoutBusiness/index.js +85 -0
- package/dist/markdowns/example1/BasicProLayoutBusiness/pages/Home.d.ts +1 -0
- package/dist/markdowns/example1/BasicProLayoutBusiness/pages/Home.js +21 -0
- package/dist/markdowns/example1/BasicProLayoutBusiness/pages/Level1.d.ts +1 -0
- package/dist/markdowns/example1/BasicProLayoutBusiness/pages/Level1.js +21 -0
- package/dist/markdowns/example1/BasicProLayoutBusiness/pages/Level2.d.ts +1 -0
- package/dist/markdowns/example1/BasicProLayoutBusiness/pages/Level2.js +21 -0
- package/dist/markdowns/example1/BasicProLayoutBusiness/testData.d.ts +53 -0
- package/dist/markdowns/example1/BasicProLayoutBusiness/testData.js +82 -0
- package/dist/markdowns/example1/RoleSelectDemo/index.d.ts +3 -0
- package/dist/markdowns/example1/RoleSelectDemo/index.js +151 -0
- package/dist/pro-layout/components/KeepAlive/KeepAliveClass.d.ts +2 -2
- package/dist/pro-layout/components/KeepAlive/index.d.ts +1 -1
- package/dist/pro-layout/components/Login/index.js +5 -5
- package/dist/pro-layout/components/TabsLayout/index.js +5 -12
- package/dist/pro-layout/core/index.js +27 -9
- package/dist/pro-layout/hooks/index.js +6 -1
- package/dist/pro-layout/index.d.ts +8 -1
- package/dist/pro-layout/index.js +30 -2
- package/dist/pro-layout/style/index.js +2 -2
- package/dist/pro-layout/types/index.d.ts +16 -4
- package/dist/pro-layout-business/components/RoleSelect.d.ts +1 -0
- package/dist/pro-layout-business/components/RoleSelect.js +203 -0
- package/dist/pro-layout-business/hooks/use-service.d.ts +36 -0
- package/dist/pro-layout-business/hooks/use-service.js +64 -0
- package/dist/pro-layout-business/index.d.ts +7 -0
- package/dist/pro-layout-business/index.js +81 -0
- package/package.json +1 -1
- /package/dist/markdowns/example1/{BasicRexProLayout → BasicProLayout}/pages/Home.d.ts +0 -0
- /package/dist/markdowns/example1/{BasicRexProLayout → BasicProLayout}/pages/Home.js +0 -0
- /package/dist/markdowns/example1/{BasicRexProLayout → BasicProLayout}/pages/Level1.d.ts +0 -0
- /package/dist/markdowns/example1/{BasicRexProLayout → BasicProLayout}/pages/Level1.js +0 -0
- /package/dist/markdowns/example1/{BasicRexProLayout → BasicProLayout}/pages/Level2.d.ts +0 -0
- /package/dist/markdowns/example1/{BasicRexProLayout → BasicProLayout}/pages/Level2.js +0 -0
- /package/dist/markdowns/example1/{BasicRexProLayout → BasicProLayout}/testData.d.ts +0 -0
- /package/dist/markdowns/example1/{BasicRexProLayout → BasicProLayout}/testData.js +0 -0
|
@@ -2,14 +2,11 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
2
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
4
|
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); }); }; }
|
|
5
|
-
|
|
6
|
-
* @Description: 自定义多标签页
|
|
7
|
-
* @Version: 2.0
|
|
8
|
-
*/
|
|
9
|
-
import { Icons, useStateData } from '@teamias/rex-design';
|
|
5
|
+
import { useStateData } from '@teamias/rex-design';
|
|
10
6
|
import { Badge, Dropdown, Space, Tabs, message } from 'antd';
|
|
11
7
|
import { eq } from 'lodash-es';
|
|
12
8
|
import { useEffect } from 'react';
|
|
9
|
+
import { SwapOutlined, SyncOutlined } from '@ant-design/icons';
|
|
13
10
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
14
11
|
import { TABS_LAYOUT } from "../../constant";
|
|
15
12
|
import { useLayoutContext } from "../../context";
|
|
@@ -87,11 +84,7 @@ export var TabsLayout = function TabsLayout() {
|
|
|
87
84
|
var renderMenuItem = function renderMenuItem(key, label, icon) {
|
|
88
85
|
return {
|
|
89
86
|
label: label,
|
|
90
|
-
icon:
|
|
91
|
-
type: "iconify",
|
|
92
|
-
name: icon,
|
|
93
|
-
size: 16
|
|
94
|
-
}),
|
|
87
|
+
icon: icon,
|
|
95
88
|
key: key
|
|
96
89
|
};
|
|
97
90
|
};
|
|
@@ -168,7 +161,7 @@ export var TabsLayout = function TabsLayout() {
|
|
|
168
161
|
menu: {
|
|
169
162
|
items: [
|
|
170
163
|
// 重新加载
|
|
171
|
-
renderMenuItem(TABS_LAYOUT.REFRESH, '重新加载',
|
|
164
|
+
renderMenuItem(TABS_LAYOUT.REFRESH, '重新加载', /*#__PURE__*/_jsx(SyncOutlined, {})), {
|
|
172
165
|
type: 'divider'
|
|
173
166
|
},
|
|
174
167
|
// 关闭右侧
|
|
@@ -177,7 +170,7 @@ export var TabsLayout = function TabsLayout() {
|
|
|
177
170
|
// renderMenuItem(TABS_LAYOUT.LEFT, 'ri:skip-left-line'),
|
|
178
171
|
// {type: 'divider'},
|
|
179
172
|
// 关闭其它
|
|
180
|
-
renderMenuItem(TABS_LAYOUT.OTHERS, '关闭其它',
|
|
173
|
+
renderMenuItem(TABS_LAYOUT.OTHERS, '关闭其它', /*#__PURE__*/_jsx(SwapOutlined, {}))],
|
|
181
174
|
onClick: function onClick(_ref4) {
|
|
182
175
|
var key = _ref4.key;
|
|
183
176
|
return handleClickMenu(key, pathname);
|
|
@@ -34,6 +34,7 @@ var InlineProLayout = function InlineProLayout(_ref) {
|
|
|
34
34
|
childrens = _ref.childrens,
|
|
35
35
|
projectTitle = _ref.projectTitle,
|
|
36
36
|
loginBgImg = _ref.loginBgImg,
|
|
37
|
+
renderTopRightContent = _ref.renderTopRightContent,
|
|
37
38
|
requestUserInfoMenuData = _ref.requestUserInfoMenuData,
|
|
38
39
|
renderSelectLang = _ref.renderSelectLang,
|
|
39
40
|
onLogin = _ref.onLogin,
|
|
@@ -131,14 +132,27 @@ var InlineProLayout = function InlineProLayout(_ref) {
|
|
|
131
132
|
style: {
|
|
132
133
|
height: layoutContext.headerHeight
|
|
133
134
|
},
|
|
134
|
-
children: [/*#__PURE__*/_jsx(TabsLayout, {}),
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
children: [/*#__PURE__*/_jsx(TabsLayout, {}), function () {
|
|
136
|
+
var rawAvatarNode = /*#__PURE__*/_jsx(TopHoverBox, {
|
|
137
|
+
children: /*#__PURE__*/_jsx(AvatarItem, {
|
|
138
|
+
onLogout: onLogout
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
var rawSelectLang = renderSelectLang ? /*#__PURE__*/_jsx(TopHoverBox, {
|
|
142
|
+
"data-lang": true,
|
|
143
|
+
children: renderSelectLang()
|
|
144
|
+
}) : undefined;
|
|
145
|
+
if (renderTopRightContent) {
|
|
146
|
+
return renderTopRightContent({
|
|
147
|
+
PackageHoverBox: TopHoverBox,
|
|
148
|
+
rawAvatarNode: rawAvatarNode,
|
|
149
|
+
rawSelectLang: rawSelectLang
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
153
|
+
children: [rawAvatarNode, rawSelectLang || /*#__PURE__*/_jsx(_Fragment, {})]
|
|
154
|
+
});
|
|
155
|
+
}()]
|
|
142
156
|
})]
|
|
143
157
|
}), /*#__PURE__*/_jsxs(Main, {
|
|
144
158
|
children: [/*#__PURE__*/_jsx(Aside, {
|
|
@@ -190,8 +204,10 @@ export var ProLayout = function ProLayout(_ref4) {
|
|
|
190
204
|
childrens = _ref4.childrens,
|
|
191
205
|
pageComponentMap = _ref4.pageComponentMap,
|
|
192
206
|
access = _ref4.access,
|
|
193
|
-
|
|
207
|
+
placeholderElement = _ref4.placeholderElement,
|
|
208
|
+
renderTopRightContent = _ref4.renderTopRightContent,
|
|
194
209
|
renderSelectLang = _ref4.renderSelectLang,
|
|
210
|
+
requestUserInfoMenuData = _ref4.requestUserInfoMenuData,
|
|
195
211
|
onLogin = _ref4.onLogin,
|
|
196
212
|
onLogout = _ref4.onLogout;
|
|
197
213
|
return useMemo(function () {
|
|
@@ -206,8 +222,10 @@ export var ProLayout = function ProLayout(_ref4) {
|
|
|
206
222
|
collapsed: collapsed,
|
|
207
223
|
access: access,
|
|
208
224
|
basename: basename,
|
|
225
|
+
placeholderElement: placeholderElement,
|
|
209
226
|
children: /*#__PURE__*/_jsx(InlineProLayout, {
|
|
210
227
|
renderSelectLang: renderSelectLang,
|
|
228
|
+
renderTopRightContent: renderTopRightContent,
|
|
211
229
|
projectTitle: projectTitle,
|
|
212
230
|
smallLogoImg: smallLogoImg,
|
|
213
231
|
loginBgImg: loginBgImg,
|
|
@@ -3,6 +3,7 @@ import { NoFoundPage } from "../components/NoFoundPage";
|
|
|
3
3
|
import { useLayoutContext } from "../context";
|
|
4
4
|
|
|
5
5
|
/** 这里初始化获取后,除了initialState 变化,会发生更新,其余的 pathname 不会变化 */
|
|
6
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
export var useApiRouter = function useApiRouter() {
|
|
8
9
|
var _layoutContext$routeM;
|
|
@@ -34,7 +35,11 @@ export var useAccessRouter = function useAccessRouter() {
|
|
|
34
35
|
// 路由不存在, 但有菜单, 使用默认页面
|
|
35
36
|
if (!currentPage && fullPathDataMap[location.pathname]) {
|
|
36
37
|
// TODO: 需要注入低代码功能
|
|
37
|
-
|
|
38
|
+
currentPage = {
|
|
39
|
+
element: layoutContext.placeholderElement || /*#__PURE__*/_jsx(_Fragment, {
|
|
40
|
+
children: "\u8BF7\u521B\u5EFA\u8DEF\u7531\u5BF9\u5E94\u7684\u7EC4\u4EF6"
|
|
41
|
+
})
|
|
42
|
+
};
|
|
38
43
|
// currentPage = { element: <>低代码页面</> };
|
|
39
44
|
}
|
|
40
45
|
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { PageLoading } from './components/PageLoading';
|
|
2
|
+
export { LayoutContextProvide, useLayoutContext } from './context';
|
|
2
3
|
export * from './core';
|
|
3
4
|
export * from './hooks';
|
|
4
5
|
export * from './types';
|
|
6
|
+
export { KeepAliveRoot, keepAliveControl, useKeepAlivePages, useLifeCycle } from './components/KeepAlive';
|
|
7
|
+
export { ELifeCycleType } from './components/KeepAlive/types';
|
|
8
|
+
export type { IPageData, IPageLifeCycleCallback } from './components/KeepAlive/types';
|
|
9
|
+
export { useAccessRouter, useApiRouter } from './hooks';
|
|
10
|
+
export { NoFoundPage } from './components/NoFoundPage';
|
|
11
|
+
export { LOCAL_STORAGE } from './constant';
|
package/dist/pro-layout/index.js
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { PageLoading } from "./components/PageLoading";
|
|
2
|
+
export { LayoutContextProvide, useLayoutContext } from "./context";
|
|
2
3
|
export * from "./core";
|
|
3
4
|
export * from "./hooks";
|
|
4
|
-
export * from "./types";
|
|
5
|
+
export * from "./types";
|
|
6
|
+
|
|
7
|
+
// KeepAlive 相关(非常实用)
|
|
8
|
+
export { KeepAliveRoot, keepAliveControl, useKeepAlivePages, useLifeCycle } from "./components/KeepAlive";
|
|
9
|
+
export { ELifeCycleType } from "./components/KeepAlive/types";
|
|
10
|
+
// Hooks
|
|
11
|
+
export { useAccessRouter, useApiRouter } from "./hooks";
|
|
12
|
+
|
|
13
|
+
// 工具函数
|
|
14
|
+
// export {
|
|
15
|
+
// getLocalStorageItem,
|
|
16
|
+
// getSessionStorageItem,
|
|
17
|
+
// removeLocalStorageItem,
|
|
18
|
+
// removeSessionStorageItem,
|
|
19
|
+
// setLocalStorageItem,
|
|
20
|
+
// setSessionStorageItem,
|
|
21
|
+
// } from './utils';
|
|
22
|
+
// export { handleMenuData } from './utils/menu';
|
|
23
|
+
|
|
24
|
+
// 组件
|
|
25
|
+
// export { AvatarItem } from './components/AvatarItem';
|
|
26
|
+
// export { Login } from './components/Login';
|
|
27
|
+
// export { Menu } from './components/Menu';
|
|
28
|
+
export { NoFoundPage } from "./components/NoFoundPage";
|
|
29
|
+
// export { TabsLayout } from './components/TabsLayout';
|
|
30
|
+
|
|
31
|
+
// 常量
|
|
32
|
+
export { LOCAL_STORAGE } from "./constant";
|
|
@@ -42,7 +42,7 @@ export var TopBox = styled.div.attrs({
|
|
|
42
42
|
}).withConfig({
|
|
43
43
|
displayName: "TopBox",
|
|
44
44
|
componentId: "pro-layout-aaf4__sc-12ppwnu-5"
|
|
45
|
-
})(["display:flex;align-items:flex-end;overflow:hidden;margin-left:-1px;position:sticky;top:0;z-index:2;width:100%;background:#001529;.ant-tabs{flex:1;width:0;color:#fff;}.ant-tabs-nav{margin:0;}.ant-tabs-nav::before{content:initial;}.ant-tabs-tab-remove{display:none;}.ant-tabs-tab{margin:0 6px !important;border-bottom:none !important;color:#fff;border-color:transparent !important;}.ant-tabs-tab-active{.ant-tabs-tab-remove{display:block;}}.ant-tabs-tab:first-child{margin-left:0 !important;}.ant-tabs-ink-bar,.ant-tabs-content-holder{display:none;}.ant-tabs-nav-more{padding:0 6px !important;color:#fff !important;}"]);
|
|
45
|
+
})(["display:flex;align-items:flex-end;overflow:hidden;margin-left:-1px;position:sticky;top:0;z-index:2;width:100%;background:#001529;font-size:14px;.ant-tabs{flex:1;width:0;color:#fff;}.ant-tabs-nav{margin:0;}.ant-tabs-nav::before{content:initial;}.ant-tabs-tab-remove{display:none;}.ant-tabs-tab{margin:0 6px !important;border-bottom:none !important;color:#fff;border-color:transparent !important;}.ant-tabs-tab-active{.ant-tabs-tab-remove{display:block;}}.ant-tabs-tab:first-child{margin-left:0 !important;}.ant-tabs-ink-bar,.ant-tabs-content-holder{display:none;}.ant-tabs-nav-more{padding:0 6px !important;color:#fff !important;}"]);
|
|
46
46
|
export var ContentBox = styled.div.attrs({
|
|
47
47
|
className: 'pro-content-box'
|
|
48
48
|
}).withConfig({
|
|
@@ -54,4 +54,4 @@ export var TopHoverBox = styled.div.attrs({
|
|
|
54
54
|
}).withConfig({
|
|
55
55
|
displayName: "TopHoverBox",
|
|
56
56
|
componentId: "pro-layout-aaf4__sc-12ppwnu-7"
|
|
57
|
-
})(["padding-inline:8px;display:flex;align-items:center;gap:8px;border-radius:6px;cursor:pointer;height:40px;overflow:hidden;.ant-dropdown-trigger{display:flex;align-items:center;gap:8px;}&[data-lang]:has(.ant-dropdown-trigger){padding:0;}&[data-lang] .ant-dropdown-trigger{padding-inline:8px !important;height:40px;}&:hover{background:rgba(
|
|
57
|
+
})(["padding-inline:8px;display:flex;align-items:center;gap:8px;border-radius:6px;cursor:pointer;height:40px;overflow:hidden;.ant-dropdown-trigger{display:flex;align-items:center;gap:8px;}&[data-lang]:has(.ant-dropdown-trigger){padding:0;}&[data-lang] .ant-dropdown-trigger{padding-inline:8px !important;height:40px;}&:hover{background:rgba(255,255,255,0.04);}> div,> span{height:100%;display:flex;align-items:center;}"]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
export interface IProLayoutProps extends Pick<TLayoutContext, 'projectId' | 'pageComponentMap' | 'access' | 'basename'> {
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
export interface IProLayoutProps extends Pick<TLayoutContext, 'projectId' | 'pageComponentMap' | 'access' | 'basename' | 'placeholderElement'> {
|
|
3
3
|
/** title */
|
|
4
4
|
projectTitle?: string;
|
|
5
5
|
/** logo img */
|
|
@@ -37,6 +37,15 @@ export interface IProLayoutProps extends Pick<TLayoutContext, 'projectId' | 'pag
|
|
|
37
37
|
};
|
|
38
38
|
/** 渲染多语言选择控件 */
|
|
39
39
|
renderSelectLang?: () => ReactNode;
|
|
40
|
+
/** 渲染左上角内容 */
|
|
41
|
+
renderTopRightContent?: (data: {
|
|
42
|
+
PackageHoverBox: FC<{
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
}>;
|
|
45
|
+
rawAvatarNode: ReactNode;
|
|
46
|
+
/** 前提需要实现 renderSelectLang */
|
|
47
|
+
rawSelectLang?: ReactNode;
|
|
48
|
+
}) => ReactNode;
|
|
40
49
|
/** 用户信息+菜单数据 */
|
|
41
50
|
requestUserInfoMenuData: () => Promise<Pick<TLayoutContext, 'userInfo'> & {
|
|
42
51
|
menuData: TApiMenuManagement[];
|
|
@@ -51,6 +60,8 @@ export interface IProLayoutProps extends Pick<TLayoutContext, 'projectId' | 'pag
|
|
|
51
60
|
}
|
|
52
61
|
/** context 数据 */
|
|
53
62
|
export type TLayoutContext = {
|
|
63
|
+
/** 存在路由,但没有组件时候,提供的占位元素 */
|
|
64
|
+
placeholderElement?: ReactNode;
|
|
54
65
|
/** 路由基础路径 */
|
|
55
66
|
basename: string;
|
|
56
67
|
/** 项目 id */
|
|
@@ -144,11 +155,12 @@ export type TApiMenuManagement = {
|
|
|
144
155
|
/** 菜单类型 */
|
|
145
156
|
menu_type: 'dir' | 'menu' | 'button';
|
|
146
157
|
};
|
|
147
|
-
type TApiUserInfo = {
|
|
158
|
+
export type TApiUserInfo = {
|
|
148
159
|
/** 用户名 */
|
|
149
160
|
username?: string;
|
|
150
161
|
/** 用户ID */
|
|
151
162
|
id?: string;
|
|
163
|
+
job_id?: number;
|
|
164
|
+
model_id?: string | number;
|
|
152
165
|
[key: string]: any;
|
|
153
166
|
};
|
|
154
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RoleSelect: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
import { useLayoutContext } from "../../pro-layout/context";
|
|
6
|
+
import { ProjectOutlined, RightOutlined, SearchOutlined } from '@ant-design/icons';
|
|
7
|
+
import { useStateData } from '@teamias/rex-design';
|
|
8
|
+
import { useDebounceEffect } from 'ahooks';
|
|
9
|
+
import { Empty, Flex, Input, Menu, Modal, Popover, Spin } from 'antd';
|
|
10
|
+
import { useEffect, useMemo } from 'react';
|
|
11
|
+
import styled from 'styled-components';
|
|
12
|
+
import { useService } from "../hooks/use-service";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
|
+
export var RoleSelect = function RoleSelect() {
|
|
17
|
+
var service = useService();
|
|
18
|
+
var _useLayoutContext = useLayoutContext(),
|
|
19
|
+
userInfo = _useLayoutContext.userInfo;
|
|
20
|
+
var _useStateData = useStateData(function () {
|
|
21
|
+
return {
|
|
22
|
+
loading: false,
|
|
23
|
+
searchText: '',
|
|
24
|
+
modelId: userInfo !== null && userInfo !== void 0 && userInfo.model_id ? [String(userInfo.model_id)] : [],
|
|
25
|
+
jobId: userInfo !== null && userInfo !== void 0 && userInfo.job_id ? [String(userInfo.job_id)] : [],
|
|
26
|
+
rawDataMap: {},
|
|
27
|
+
modelList: [],
|
|
28
|
+
jobList: [],
|
|
29
|
+
searchList: []
|
|
30
|
+
};
|
|
31
|
+
}),
|
|
32
|
+
state = _useStateData.state,
|
|
33
|
+
update = _useStateData.update;
|
|
34
|
+
var findLabel = useMemo(function () {
|
|
35
|
+
if (state.loading) return '';
|
|
36
|
+
var jobId = state.jobId[0];
|
|
37
|
+
if (!jobId) {
|
|
38
|
+
return '未选择角色';
|
|
39
|
+
}
|
|
40
|
+
for (var _i = 0, _Object$values = Object.values(state.rawDataMap); _i < _Object$values.length; _i++) {
|
|
41
|
+
var model = _Object$values[_i];
|
|
42
|
+
var job = model === null || model === void 0 ? void 0 : model.childs.find(function (ii) {
|
|
43
|
+
return String(ii.id) === jobId;
|
|
44
|
+
});
|
|
45
|
+
if (job) {
|
|
46
|
+
return job.title;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return '未知角色';
|
|
50
|
+
}, [state.jobId, state.rawDataMap, state.loading]);
|
|
51
|
+
var updateDataAndJobList = function updateDataAndJobList(modelId) {
|
|
52
|
+
var _state$rawDataMap;
|
|
53
|
+
state.modelId = modelId;
|
|
54
|
+
state.jobList = ((_state$rawDataMap = state.rawDataMap) === null || _state$rawDataMap === void 0 || (_state$rawDataMap = _state$rawDataMap[modelId[0]]) === null || _state$rawDataMap === void 0 ? void 0 : _state$rawDataMap.childs.map(function (ii) {
|
|
55
|
+
return {
|
|
56
|
+
label: ii.title,
|
|
57
|
+
key: String(ii.id)
|
|
58
|
+
};
|
|
59
|
+
})) || [];
|
|
60
|
+
// state.jobId = state.jobList.length ? [state.jobList[0].key] : [];
|
|
61
|
+
update();
|
|
62
|
+
};
|
|
63
|
+
var getData = /*#__PURE__*/function () {
|
|
64
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
65
|
+
var res, data;
|
|
66
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
67
|
+
while (1) switch (_context.prev = _context.next) {
|
|
68
|
+
case 0:
|
|
69
|
+
state.loading = true;
|
|
70
|
+
update();
|
|
71
|
+
_context.prev = 2;
|
|
72
|
+
_context.next = 5;
|
|
73
|
+
return service.getCanJobsApi();
|
|
74
|
+
case 5:
|
|
75
|
+
res = _context.sent;
|
|
76
|
+
data = Array.isArray(res.data) ? res.data : [res.data];
|
|
77
|
+
state.rawDataMap = data.reduce(function (acc, item) {
|
|
78
|
+
acc[String(item.id)] = item;
|
|
79
|
+
return acc;
|
|
80
|
+
}, {});
|
|
81
|
+
state.modelList = data.map(function (ii) {
|
|
82
|
+
return {
|
|
83
|
+
label: /*#__PURE__*/_jsxs(Flex, {
|
|
84
|
+
justify: "space-between",
|
|
85
|
+
align: "center",
|
|
86
|
+
style: {
|
|
87
|
+
width: '100%'
|
|
88
|
+
},
|
|
89
|
+
children: [ii.title, /*#__PURE__*/_jsx(RightOutlined, {
|
|
90
|
+
style: {
|
|
91
|
+
zoom: 0.8
|
|
92
|
+
}
|
|
93
|
+
})]
|
|
94
|
+
}),
|
|
95
|
+
key: String(ii.id)
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
updateDataAndJobList(state.modelId);
|
|
99
|
+
_context.next = 15;
|
|
100
|
+
break;
|
|
101
|
+
case 12:
|
|
102
|
+
_context.prev = 12;
|
|
103
|
+
_context.t0 = _context["catch"](2);
|
|
104
|
+
console.error(_context.t0);
|
|
105
|
+
case 15:
|
|
106
|
+
state.loading = false;
|
|
107
|
+
update();
|
|
108
|
+
case 17:
|
|
109
|
+
case "end":
|
|
110
|
+
return _context.stop();
|
|
111
|
+
}
|
|
112
|
+
}, _callee, null, [[2, 12]]);
|
|
113
|
+
}));
|
|
114
|
+
return function getData() {
|
|
115
|
+
return _ref.apply(this, arguments);
|
|
116
|
+
};
|
|
117
|
+
}();
|
|
118
|
+
useEffect(function () {
|
|
119
|
+
getData();
|
|
120
|
+
}, []);
|
|
121
|
+
useDebounceEffect(function () {
|
|
122
|
+
if (!state.searchText) {
|
|
123
|
+
state.searchList = state.jobList;
|
|
124
|
+
update();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
var keyword = state.searchText.toLowerCase();
|
|
128
|
+
state.searchList = state.jobList.filter(function (ii) {
|
|
129
|
+
return ii.label.toLowerCase().includes(keyword);
|
|
130
|
+
});
|
|
131
|
+
update();
|
|
132
|
+
}, [state.searchText, state.jobList], {
|
|
133
|
+
wait: 16
|
|
134
|
+
});
|
|
135
|
+
return /*#__PURE__*/_jsx(Popover, {
|
|
136
|
+
placement: "bottomRight",
|
|
137
|
+
styles: {
|
|
138
|
+
body: {
|
|
139
|
+
padding: 6
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
content: /*#__PURE__*/_jsx(Spin, {
|
|
143
|
+
spinning: state.loading,
|
|
144
|
+
children: /*#__PURE__*/_jsx(BoxDiv, {
|
|
145
|
+
children: state.modelList.length === 0 ? /*#__PURE__*/_jsx(Empty, {
|
|
146
|
+
description: "\u6682\u65E0\u53EF\u5207\u6362\u89D2\u8272",
|
|
147
|
+
style: {
|
|
148
|
+
margin: 'auto'
|
|
149
|
+
}
|
|
150
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
151
|
+
children: [/*#__PURE__*/_jsx(Menu, {
|
|
152
|
+
className: "left",
|
|
153
|
+
selectedKeys: state.modelId,
|
|
154
|
+
items: state.modelList,
|
|
155
|
+
onSelect: function onSelect(key) {
|
|
156
|
+
updateDataAndJobList(key.selectedKeys);
|
|
157
|
+
}
|
|
158
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
159
|
+
className: "right",
|
|
160
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
161
|
+
className: "input-box",
|
|
162
|
+
children: /*#__PURE__*/_jsx(Input, {
|
|
163
|
+
placeholder: "\u641C\u7D22...",
|
|
164
|
+
prefix: /*#__PURE__*/_jsx(SearchOutlined, {}),
|
|
165
|
+
value: state.searchText,
|
|
166
|
+
onChange: function onChange(e) {
|
|
167
|
+
state.searchText = e.target.value || '';
|
|
168
|
+
update();
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
}), /*#__PURE__*/_jsx(Menu, {
|
|
172
|
+
selectedKeys: state.jobId,
|
|
173
|
+
items: state.searchList,
|
|
174
|
+
onSelect: function onSelect(info) {
|
|
175
|
+
console.log(info);
|
|
176
|
+
|
|
177
|
+
// state.jobId = key.selectedKeys;
|
|
178
|
+
// update();
|
|
179
|
+
Modal.confirm({
|
|
180
|
+
title: '切换角色确认',
|
|
181
|
+
content: '切换角色后需要刷新页面,是否确认?',
|
|
182
|
+
onOk: function onOk() {
|
|
183
|
+
service.toggleJobApi(state.modelId[0], Number(info.selectedKeys[0])).then(function () {
|
|
184
|
+
window.location.reload();
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
})]
|
|
190
|
+
})]
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
}),
|
|
194
|
+
children: /*#__PURE__*/_jsxs(Flex, {
|
|
195
|
+
gap: 4,
|
|
196
|
+
children: [/*#__PURE__*/_jsx(ProjectOutlined, {}), findLabel]
|
|
197
|
+
})
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
var BoxDiv = styled.div.withConfig({
|
|
201
|
+
displayName: "BoxDiv",
|
|
202
|
+
componentId: "pro-layout-aaf4__sc-15rr1b5-0"
|
|
203
|
+
})(["width:420px;height:300px;max-height:300px;display:flex;.left{width:160px;max-height:inherit;overflow:auto;}.right{flex:1;max-height:inherit;overflow:auto;position:relative;.input-box{width:auto;position:sticky;top:0;padding:5px;margin-bottom:5px;background-color:#fff;z-index:2;}.ant-menu{border:none;}}"]);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TApiMenuManagement, TApiUserInfo } from "../..";
|
|
2
|
+
export declare const useService: () => {
|
|
3
|
+
/** 登录接口 */
|
|
4
|
+
loginApi: (params: {
|
|
5
|
+
username?: string;
|
|
6
|
+
password?: string;
|
|
7
|
+
}) => Promise<{
|
|
8
|
+
data: {
|
|
9
|
+
token: string;
|
|
10
|
+
userInfo: TApiUserInfo;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
/** 退出接口 */
|
|
14
|
+
logoutApi: () => Promise<unknown>;
|
|
15
|
+
/** 获取用户信息接口 */
|
|
16
|
+
getUserInfoApi: () => Promise<{
|
|
17
|
+
data: TApiUserInfo;
|
|
18
|
+
}>;
|
|
19
|
+
/** 获取菜单数据接口 */
|
|
20
|
+
getMenuDataApi: () => Promise<{
|
|
21
|
+
data: TApiMenuManagement[];
|
|
22
|
+
}>;
|
|
23
|
+
/** 获取可用角色接口 */
|
|
24
|
+
getCanJobsApi: () => Promise<{
|
|
25
|
+
data: {
|
|
26
|
+
id: string;
|
|
27
|
+
title: string;
|
|
28
|
+
childs: {
|
|
29
|
+
id: number;
|
|
30
|
+
title: string;
|
|
31
|
+
}[];
|
|
32
|
+
}[];
|
|
33
|
+
}>;
|
|
34
|
+
/** 切换角色接口 */
|
|
35
|
+
toggleJobApi: (model_id: string, job_id: number) => Promise<unknown>;
|
|
36
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
import { useRexProConfigProvider } from '@teamias/rex-design';
|
|
6
|
+
export var useService = function useService() {
|
|
7
|
+
var _useRexProConfigProvi = useRexProConfigProvider(),
|
|
8
|
+
apiClient = _useRexProConfigProvi.apiClient;
|
|
9
|
+
|
|
10
|
+
/** 兼容有无 data 问题 */
|
|
11
|
+
var packageApiClient = /*#__PURE__*/function () {
|
|
12
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13
|
+
var res,
|
|
14
|
+
_args = arguments;
|
|
15
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
16
|
+
while (1) switch (_context.prev = _context.next) {
|
|
17
|
+
case 0:
|
|
18
|
+
_context.next = 2;
|
|
19
|
+
return apiClient.apply(void 0, _args);
|
|
20
|
+
case 2:
|
|
21
|
+
res = _context.sent;
|
|
22
|
+
return _context.abrupt("return", 'data' in res ? res : {
|
|
23
|
+
data: res
|
|
24
|
+
});
|
|
25
|
+
case 4:
|
|
26
|
+
case "end":
|
|
27
|
+
return _context.stop();
|
|
28
|
+
}
|
|
29
|
+
}, _callee);
|
|
30
|
+
}));
|
|
31
|
+
return function packageApiClient() {
|
|
32
|
+
return _ref.apply(this, arguments);
|
|
33
|
+
};
|
|
34
|
+
}();
|
|
35
|
+
return {
|
|
36
|
+
/** 登录接口 */
|
|
37
|
+
loginApi: function loginApi(params) {
|
|
38
|
+
return packageApiClient('/grpc/auth/login', params);
|
|
39
|
+
},
|
|
40
|
+
/** 退出接口 */
|
|
41
|
+
logoutApi: function logoutApi() {
|
|
42
|
+
return packageApiClient('/grpc/auth/logout');
|
|
43
|
+
},
|
|
44
|
+
/** 获取用户信息接口 */
|
|
45
|
+
getUserInfoApi: function getUserInfoApi() {
|
|
46
|
+
return packageApiClient('/grpc/auth/user_info');
|
|
47
|
+
},
|
|
48
|
+
/** 获取菜单数据接口 */
|
|
49
|
+
getMenuDataApi: function getMenuDataApi() {
|
|
50
|
+
return packageApiClient('/grpc/menu/tree');
|
|
51
|
+
},
|
|
52
|
+
/** 获取可用角色接口 */
|
|
53
|
+
getCanJobsApi: function getCanJobsApi() {
|
|
54
|
+
return packageApiClient('/grpc/auth/canjobs');
|
|
55
|
+
},
|
|
56
|
+
/** 切换角色接口 */
|
|
57
|
+
toggleJobApi: function toggleJobApi(model_id, job_id) {
|
|
58
|
+
return packageApiClient('/grpc/auth/do_job', {
|
|
59
|
+
model_id: model_id,
|
|
60
|
+
job_id: job_id
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProLayout } from "..";
|
|
2
|
+
import { GetProps } from 'antd';
|
|
3
|
+
import { FC } from 'react';
|
|
4
|
+
import { RoleSelect } from './components/RoleSelect';
|
|
5
|
+
export declare const ProLayoutBusiness: FC<IProLayoutBusinessProps>;
|
|
6
|
+
export { RoleSelect };
|
|
7
|
+
type IProLayoutBusinessProps = Omit<GetProps<typeof ProLayout>, 'renderTopRightContent' | 'requestUserInfoMenuData' | 'onLogin' | 'onLogout'>;
|