th-design 1.0.3 → 1.0.5
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.
|
@@ -24,7 +24,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
24
24
|
* @Author: luohq luohq@2345.com
|
|
25
25
|
* @Date: 2025-10-14 14:02:00
|
|
26
26
|
* @LastEditors: luohq luohq@2345.com
|
|
27
|
-
* @LastEditTime: 2026-01-
|
|
27
|
+
* @LastEditTime: 2026-01-14 19:52:31
|
|
28
28
|
* @FilePath: /tellhowComponent/src/components/ThSelect/index.tsx
|
|
29
29
|
* @Description: 选择器组件
|
|
30
30
|
*/
|
|
@@ -94,7 +94,10 @@ var ThSelect = function ThSelect(props) {
|
|
|
94
94
|
_props$responseField = props.responseField,
|
|
95
95
|
responseField = _props$responseField === void 0 ? 'records' : _props$responseField,
|
|
96
96
|
_props$needInput = props.needInput,
|
|
97
|
-
needInput = _props$needInput === void 0 ? false : _props$needInput
|
|
97
|
+
needInput = _props$needInput === void 0 ? false : _props$needInput,
|
|
98
|
+
accessToken = props.accessToken,
|
|
99
|
+
_props$accessTokenKey = props.accessTokenKey,
|
|
100
|
+
accessTokenKey = _props$accessTokenKey === void 0 ? 'accessToken' : _props$accessTokenKey;
|
|
98
101
|
var _tableProps$dataSourc = tableProps.dataSource,
|
|
99
102
|
dataSource = _tableProps$dataSourc === void 0 ? [] : _tableProps$dataSourc,
|
|
100
103
|
_tableProps$columns = tableProps.columns,
|
|
@@ -103,7 +106,6 @@ var ThSelect = function ThSelect(props) {
|
|
|
103
106
|
restProps = _objectWithoutProperties(tableProps, _excluded);
|
|
104
107
|
var pagination = paginationProp === false ? false : _objectSpread(_objectSpread({}, defaultPagination), paginationProp || {});
|
|
105
108
|
var location = useLocation();
|
|
106
|
-
console.log('location===', location, window.location);
|
|
107
109
|
// 下拉框是否展开
|
|
108
110
|
var _useState = useState(false),
|
|
109
111
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -246,7 +248,7 @@ var ThSelect = function ThSelect(props) {
|
|
|
246
248
|
query = _objectSpread(_objectSpread({}, searchParams), requestProps.params);
|
|
247
249
|
}
|
|
248
250
|
_context.next = 5;
|
|
249
|
-
return getList(requestProps, query);
|
|
251
|
+
return getList(requestProps, query, accessToken, accessTokenKey);
|
|
250
252
|
case 5:
|
|
251
253
|
res = _context.sent;
|
|
252
254
|
if (res.code === Number(200)) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { ThSelectRequestProps } from './typing';
|
|
2
2
|
export declare const transformParams: (params: Record<string, any>, transformSearchKey?: string, searchOpt?: unknown) => Record<string, any> | undefined;
|
|
3
|
-
export declare function getList(requestProps?: ThSelectRequestProps, query?: Record<string, any
|
|
4
|
-
export declare function getTransDict(data: Record<string, any>): Promise<any>;
|
|
3
|
+
export declare function getList(requestProps?: ThSelectRequestProps, query?: Record<string, any>, accessToken?: string, accessTokenKey?: string): Promise<any>;
|
|
@@ -10,34 +10,55 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
10
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
11
|
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); } }
|
|
12
12
|
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); }); }; }
|
|
13
|
+
/*
|
|
14
|
+
* @Author: luohq luohq@2345.com
|
|
15
|
+
* @Date: 2025-12-29 16:03:10
|
|
16
|
+
* @LastEditors: luohq luohq@2345.com
|
|
17
|
+
* @LastEditTime: 2026-01-14 19:53:25
|
|
18
|
+
* @FilePath: /tellhowComponent/src/components/ThSelect/service.ts
|
|
19
|
+
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
20
|
+
*/
|
|
13
21
|
import axios from 'axios';
|
|
22
|
+
// 获取 Cookie 中的 Token
|
|
23
|
+
var getAccessTokenFromCookie = function getAccessTokenFromCookie(accessTokenKey) {
|
|
24
|
+
var match = document.cookie.match(new RegExp("".concat(accessTokenKey || 'accessToken', "[^=]*=([^;]+)")));
|
|
25
|
+
return match ? match[1] : '';
|
|
26
|
+
};
|
|
14
27
|
var request = /*#__PURE__*/function () {
|
|
15
|
-
var
|
|
16
|
-
var response;
|
|
28
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, config, _ref) {
|
|
29
|
+
var accessToken, accessTokenKey, token, headers, response;
|
|
17
30
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18
31
|
while (1) switch (_context.prev = _context.next) {
|
|
19
32
|
case 0:
|
|
20
|
-
|
|
21
|
-
_context.
|
|
22
|
-
|
|
33
|
+
accessToken = _ref.accessToken, accessTokenKey = _ref.accessTokenKey;
|
|
34
|
+
_context.prev = 1;
|
|
35
|
+
token = accessToken || getAccessTokenFromCookie(accessTokenKey);
|
|
36
|
+
headers = _objectSpread({}, config.headers); // 如果提取到了 Token,则注入到 Access-Token 中
|
|
37
|
+
if (token) {
|
|
38
|
+
headers['Access-Token'] = token;
|
|
39
|
+
}
|
|
40
|
+
_context.next = 7;
|
|
41
|
+
return axios(_objectSpread(_objectSpread({
|
|
23
42
|
url: url
|
|
24
|
-
}, config)
|
|
25
|
-
|
|
43
|
+
}, config), {}, {
|
|
44
|
+
headers: headers
|
|
45
|
+
}));
|
|
46
|
+
case 7:
|
|
26
47
|
response = _context.sent;
|
|
27
48
|
return _context.abrupt("return", response.data);
|
|
28
|
-
case
|
|
29
|
-
_context.prev =
|
|
30
|
-
_context.t0 = _context["catch"](
|
|
49
|
+
case 11:
|
|
50
|
+
_context.prev = 11;
|
|
51
|
+
_context.t0 = _context["catch"](1);
|
|
31
52
|
console.error('Request Error:', _context.t0);
|
|
32
53
|
throw _context.t0;
|
|
33
|
-
case
|
|
54
|
+
case 15:
|
|
34
55
|
case "end":
|
|
35
56
|
return _context.stop();
|
|
36
57
|
}
|
|
37
|
-
}, _callee, null, [[
|
|
58
|
+
}, _callee, null, [[1, 11]]);
|
|
38
59
|
}));
|
|
39
|
-
return function request(_x, _x2) {
|
|
40
|
-
return
|
|
60
|
+
return function request(_x, _x2, _x3) {
|
|
61
|
+
return _ref2.apply(this, arguments);
|
|
41
62
|
};
|
|
42
63
|
}();
|
|
43
64
|
export var transformParams = function transformParams(params, transformSearchKey, searchOpt) {
|
|
@@ -70,23 +91,23 @@ export var transformParams = function transformParams(params, transformSearchKey
|
|
|
70
91
|
});
|
|
71
92
|
return params;
|
|
72
93
|
};
|
|
73
|
-
export function getList(
|
|
94
|
+
export function getList(_x4, _x5, _x6, _x7) {
|
|
74
95
|
return _getList.apply(this, arguments);
|
|
75
96
|
}
|
|
76
97
|
function _getList() {
|
|
77
|
-
_getList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(requestProps, query) {
|
|
78
|
-
var
|
|
98
|
+
_getList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(requestProps, query, accessToken, accessTokenKey) {
|
|
99
|
+
var _ref3, url, _ref3$method, method, transformSearchKey, searchOpt, _ref4, queryParams, searchParams, clonedQueryParams, transformedQueryParams, params;
|
|
79
100
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
80
101
|
while (1) switch (_context2.prev = _context2.next) {
|
|
81
102
|
case 0:
|
|
82
|
-
|
|
103
|
+
_ref3 = requestProps || {}, url = _ref3.url, _ref3$method = _ref3.method, method = _ref3$method === void 0 ? 'POST' : _ref3$method, transformSearchKey = _ref3.transformSearchKey, searchOpt = _ref3.searchOpt;
|
|
83
104
|
if (url) {
|
|
84
105
|
_context2.next = 3;
|
|
85
106
|
break;
|
|
86
107
|
}
|
|
87
108
|
throw new Error('url is required');
|
|
88
109
|
case 3:
|
|
89
|
-
|
|
110
|
+
_ref4 = query || {}, queryParams = _ref4.queryParams, searchParams = _objectWithoutProperties(_ref4, _excluded); // 避免修改原始 queryParams
|
|
90
111
|
clonedQueryParams = queryParams ? JSON.parse(JSON.stringify(queryParams)) : {};
|
|
91
112
|
transformedQueryParams = transformParams(clonedQueryParams, transformSearchKey, searchOpt) || {};
|
|
92
113
|
if (!(method.toUpperCase() === 'POST')) {
|
|
@@ -99,6 +120,9 @@ function _getList() {
|
|
|
99
120
|
data: _objectSpread(_objectSpread({}, searchParams), {}, {
|
|
100
121
|
queryPrams: transformedQueryParams
|
|
101
122
|
})
|
|
123
|
+
}, {
|
|
124
|
+
accessToken: accessToken,
|
|
125
|
+
accessTokenKey: accessTokenKey
|
|
102
126
|
});
|
|
103
127
|
case 9:
|
|
104
128
|
return _context2.abrupt("return", _context2.sent);
|
|
@@ -115,6 +139,9 @@ function _getList() {
|
|
|
115
139
|
return request(url, {
|
|
116
140
|
method: method,
|
|
117
141
|
params: params
|
|
142
|
+
}, {
|
|
143
|
+
accessToken: accessToken,
|
|
144
|
+
accessTokenKey: accessTokenKey
|
|
118
145
|
});
|
|
119
146
|
case 16:
|
|
120
147
|
return _context2.abrupt("return", _context2.sent);
|
|
@@ -125,27 +152,4 @@ function _getList() {
|
|
|
125
152
|
}, _callee2);
|
|
126
153
|
}));
|
|
127
154
|
return _getList.apply(this, arguments);
|
|
128
|
-
}
|
|
129
|
-
export function getTransDict(_x5) {
|
|
130
|
-
return _getTransDict.apply(this, arguments);
|
|
131
|
-
}
|
|
132
|
-
function _getTransDict() {
|
|
133
|
-
_getTransDict = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data) {
|
|
134
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
135
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
136
|
-
case 0:
|
|
137
|
-
_context3.next = 2;
|
|
138
|
-
return request('/wffzpt-service/dict/transDict', {
|
|
139
|
-
method: 'POST',
|
|
140
|
-
data: data
|
|
141
|
-
});
|
|
142
|
-
case 2:
|
|
143
|
-
return _context3.abrupt("return", _context3.sent);
|
|
144
|
-
case 3:
|
|
145
|
-
case "end":
|
|
146
|
-
return _context3.stop();
|
|
147
|
-
}
|
|
148
|
-
}, _callee3);
|
|
149
|
-
}));
|
|
150
|
-
return _getTransDict.apply(this, arguments);
|
|
151
155
|
}
|
|
@@ -105,6 +105,15 @@ export interface ThSelectProps {
|
|
|
105
105
|
* @default records
|
|
106
106
|
*/
|
|
107
107
|
responseField?: string;
|
|
108
|
+
/**
|
|
109
|
+
* 授权accessToken
|
|
110
|
+
*/
|
|
111
|
+
accessToken?: string;
|
|
112
|
+
/**
|
|
113
|
+
* 获取accessToken的cookie key值,如果accessToken存在,则不传
|
|
114
|
+
* @default "accessToken"
|
|
115
|
+
*/
|
|
116
|
+
accessTokenKey?: string;
|
|
108
117
|
}
|
|
109
118
|
export interface ThSelectRequestProps {
|
|
110
119
|
/**
|