pier-front-common-toolkits-vue-2 3.16.21 → 3.16.23
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/lib/pier.common.js +9 -2
- package/lib/pier.umd.js +9 -2
- package/lib/pier.umd.min.js +2 -2
- package/package.json +1 -1
package/lib/pier.common.js
CHANGED
|
@@ -95568,6 +95568,12 @@ let entry_lib_hooks = new entry_lib_PiHooks({
|
|
|
95568
95568
|
|
|
95569
95569
|
//无需登录token就能请求的接口,base/auth包含登录、刷新token等认证接口
|
|
95570
95570
|
const entry_lib_noTokenUrls = ["base/auth"];
|
|
95571
|
+
|
|
95572
|
+
//无token请求拦截总开关,默认关闭(全部放行);需要拦截时调用 setTokenCheckEnabled(true) 开启
|
|
95573
|
+
let entry_lib_isTokenCheckEnabled = false;
|
|
95574
|
+
function entry_lib_setTokenCheckEnabled(enabled) {
|
|
95575
|
+
entry_lib_isTokenCheckEnabled = !!enabled;
|
|
95576
|
+
}
|
|
95571
95577
|
function entry_lib_setRequestHooks(key, func) {
|
|
95572
95578
|
entry_lib_hooks.register(key, func);
|
|
95573
95579
|
}
|
|
@@ -95628,10 +95634,10 @@ const entry_lib_request = async (method, url, data = {}, options) => {
|
|
|
95628
95634
|
method = beforeRequestResult.method;
|
|
95629
95635
|
}
|
|
95630
95636
|
|
|
95631
|
-
|
|
95637
|
+
//开启拦截(setTokenCheckEnabled)后:没有token信息时不再请求接口,直接返回失败;认证接口、指定了其他系统token(options.token)的、或 options.isSkipTokenCheck 为 true(无需登录的接口)时不校验
|
|
95632
95638
|
let hasToken = (await entry_lib_authService.getToken()) || (await entry_lib_authService.getRefreshToken()) || options.token || options.headers && options.headers.Authorization;
|
|
95633
95639
|
let isNoTokenUrl = entry_lib_noTokenUrls.some(noTokenUrl => url.includes(noTokenUrl));
|
|
95634
|
-
if (!hasToken && !isNoTokenUrl) {
|
|
95640
|
+
if (entry_lib_isTokenCheckEnabled && !hasToken && !isNoTokenUrl && !options.isSkipTokenCheck) {
|
|
95635
95641
|
console.debug(`没有token信息,取消请求:${url}`);
|
|
95636
95642
|
let result = {
|
|
95637
95643
|
data: {},
|
|
@@ -102155,6 +102161,7 @@ function entry_lib_initExternalConfiguration(externalConfiguration) {
|
|
|
102155
102161
|
thirdLogin: entry_lib_thirdLogin,
|
|
102156
102162
|
request: entry_lib_request,
|
|
102157
102163
|
setRequestHooks: entry_lib_setRequestHooks,
|
|
102164
|
+
setTokenCheckEnabled: entry_lib_setTokenCheckEnabled,
|
|
102158
102165
|
clearRequestCache: entry_lib_clearRequestCache,
|
|
102159
102166
|
DATE_FORMAT_TYPE: entry_lib_DATE_FORMAT_TYPE,
|
|
102160
102167
|
ddMmmYyToYymmdd: entry_lib_ddMmmYyToYymmdd,
|
package/lib/pier.umd.js
CHANGED
|
@@ -95578,6 +95578,12 @@ let entry_lib_hooks = new entry_lib_PiHooks({
|
|
|
95578
95578
|
|
|
95579
95579
|
//无需登录token就能请求的接口,base/auth包含登录、刷新token等认证接口
|
|
95580
95580
|
const entry_lib_noTokenUrls = ["base/auth"];
|
|
95581
|
+
|
|
95582
|
+
//无token请求拦截总开关,默认关闭(全部放行);需要拦截时调用 setTokenCheckEnabled(true) 开启
|
|
95583
|
+
let entry_lib_isTokenCheckEnabled = false;
|
|
95584
|
+
function entry_lib_setTokenCheckEnabled(enabled) {
|
|
95585
|
+
entry_lib_isTokenCheckEnabled = !!enabled;
|
|
95586
|
+
}
|
|
95581
95587
|
function entry_lib_setRequestHooks(key, func) {
|
|
95582
95588
|
entry_lib_hooks.register(key, func);
|
|
95583
95589
|
}
|
|
@@ -95638,10 +95644,10 @@ const entry_lib_request = async (method, url, data = {}, options) => {
|
|
|
95638
95644
|
method = beforeRequestResult.method;
|
|
95639
95645
|
}
|
|
95640
95646
|
|
|
95641
|
-
|
|
95647
|
+
//开启拦截(setTokenCheckEnabled)后:没有token信息时不再请求接口,直接返回失败;认证接口、指定了其他系统token(options.token)的、或 options.isSkipTokenCheck 为 true(无需登录的接口)时不校验
|
|
95642
95648
|
let hasToken = (await entry_lib_authService.getToken()) || (await entry_lib_authService.getRefreshToken()) || options.token || options.headers && options.headers.Authorization;
|
|
95643
95649
|
let isNoTokenUrl = entry_lib_noTokenUrls.some(noTokenUrl => url.includes(noTokenUrl));
|
|
95644
|
-
if (!hasToken && !isNoTokenUrl) {
|
|
95650
|
+
if (entry_lib_isTokenCheckEnabled && !hasToken && !isNoTokenUrl && !options.isSkipTokenCheck) {
|
|
95645
95651
|
console.debug(`没有token信息,取消请求:${url}`);
|
|
95646
95652
|
let result = {
|
|
95647
95653
|
data: {},
|
|
@@ -102165,6 +102171,7 @@ function entry_lib_initExternalConfiguration(externalConfiguration) {
|
|
|
102165
102171
|
thirdLogin: entry_lib_thirdLogin,
|
|
102166
102172
|
request: entry_lib_request,
|
|
102167
102173
|
setRequestHooks: entry_lib_setRequestHooks,
|
|
102174
|
+
setTokenCheckEnabled: entry_lib_setTokenCheckEnabled,
|
|
102168
102175
|
clearRequestCache: entry_lib_clearRequestCache,
|
|
102169
102176
|
DATE_FORMAT_TYPE: entry_lib_DATE_FORMAT_TYPE,
|
|
102170
102177
|
ddMmmYyToYymmdd: entry_lib_ddMmmYyToYymmdd,
|