@tsingroc/tsingroc-components 5.0.0-alpha.17 → 5.0.0-alpha.19
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.
|
@@ -175,9 +175,13 @@ interface CommonAuth {
|
|
|
175
175
|
logout(redirect?: string): void;
|
|
176
176
|
/**
|
|
177
177
|
* 以当前用户的 access token 作为 bearer token 发起请求。
|
|
178
|
-
* 用法与正常的 {@linkcode fetch} 完全一致。未登录时,返回的 Promise
|
|
178
|
+
* 用法与正常的 {@linkcode fetch} 完全一致。未登录时,返回的 Promise 会立即抛出异常。
|
|
179
|
+
* 如果请求返回的状态码是 401,则会自动跳转到登录页。可以使用 `options.redirectOn401`
|
|
180
|
+
* 选项关闭这个行为。
|
|
179
181
|
*/
|
|
180
|
-
fetchWithAuth(resource: RequestInfo | URL, options?: RequestInit
|
|
182
|
+
fetchWithAuth(resource: RequestInfo | URL, options?: RequestInit & {
|
|
183
|
+
redirectOn401?: boolean;
|
|
184
|
+
}): Promise<Response>;
|
|
181
185
|
/** 用户的个人信息,未经过 {@linkcode AuthCheck} 验证时为空。*/
|
|
182
186
|
userInfo?: UserInfo;
|
|
183
187
|
/** Access Token,未登录时为空。*/
|
package/dist/components/Auth.js
CHANGED
|
@@ -19,10 +19,16 @@ const commonAuth = (user, setUser) => ({
|
|
|
19
19
|
if (!headers.has("Authorization")) {
|
|
20
20
|
headers.set("Authorization", `Bearer ${token}`);
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
const resp = await fetch(resource, {
|
|
23
23
|
...options,
|
|
24
24
|
headers
|
|
25
25
|
});
|
|
26
|
+
if ((options?.redirectOn401 ?? true) && resp.status === 401) {
|
|
27
|
+
localStorage.removeItem("access_token");
|
|
28
|
+
setUser({});
|
|
29
|
+
throw new Error("登陆状态无效!");
|
|
30
|
+
}
|
|
31
|
+
return resp;
|
|
26
32
|
}
|
|
27
33
|
});
|
|
28
34
|
function casdoorAuth(user, setUser, sdkConfig, signinOrigin, signinPath) {
|
|
@@ -226,7 +226,7 @@ export const withSelectable = ECharts => function SelectableECharts(props) {
|
|
|
226
226
|
if (inputSeries) {
|
|
227
227
|
const series = {
|
|
228
228
|
...inputSeries,
|
|
229
|
-
showSymbol:
|
|
229
|
+
showSymbol: false,
|
|
230
230
|
markArea: {
|
|
231
231
|
itemStyle: {
|
|
232
232
|
...DEFAULT_MARK_AREA_STYLE,
|
|
@@ -240,7 +240,7 @@ export const withSelectable = ECharts => function SelectableECharts(props) {
|
|
|
240
240
|
};
|
|
241
241
|
if (inputSeries.data && (selectedIndices.size > 0 || mode === "add" && mouseState?.end)) {
|
|
242
242
|
const allSelectedIndices = new Set();
|
|
243
|
-
|
|
243
|
+
const data = inputSeries.data.map((point_1, i_2) => {
|
|
244
244
|
const destructured_1 = destructureLineDataItem(point_1, i_2);
|
|
245
245
|
if (destructured_1 == null) {
|
|
246
246
|
return point_1;
|
|
@@ -273,26 +273,30 @@ export const withSelectable = ECharts => function SelectableECharts(props) {
|
|
|
273
273
|
};
|
|
274
274
|
}
|
|
275
275
|
});
|
|
276
|
-
if (
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
276
|
+
if (allSelectedIndices.size > 0) {
|
|
277
|
+
series.data = data;
|
|
278
|
+
series.showSymbol = true;
|
|
279
|
+
if (markArea) {
|
|
280
|
+
debugAssert(markAreaWidth !== undefined, "when markArea === true, markAreaWidth is guaranteed to be defined at the beginning of this function");
|
|
281
|
+
const markAreas = [];
|
|
282
|
+
for (const i_3 of allSelectedIndices) {
|
|
283
|
+
const destructured_2 = destructureLineDataItem(inputSeries.data[i_3], i_3);
|
|
284
|
+
if (destructured_2 == null) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const [t6] = destructured_2;
|
|
288
|
+
const [xValue] = t6;
|
|
289
|
+
if (typeof xValue !== "number") {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
markAreas.push([{
|
|
293
|
+
coord: [xValue - markAreaWidth / 2]
|
|
294
|
+
}, {
|
|
295
|
+
coord: [xValue + markAreaWidth / 2]
|
|
296
|
+
}]);
|
|
288
297
|
}
|
|
289
|
-
markAreas
|
|
290
|
-
coord: [xValue - markAreaWidth / 2]
|
|
291
|
-
}, {
|
|
292
|
-
coord: [xValue + markAreaWidth / 2]
|
|
293
|
-
}]);
|
|
298
|
+
series.markArea.data = markAreas;
|
|
294
299
|
}
|
|
295
|
-
series.markArea.data = markAreas;
|
|
296
300
|
}
|
|
297
301
|
}
|
|
298
302
|
const seriesArray = [...inputSeriesArray];
|