Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
npm
/
glsx-common
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a4f80c4a
authored
Sep 11, 2025
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
05479e50
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
6 deletions
dist/glsk-common.js
package.json
src/whiteUrlManager.js
dist/glsk-common.js
View file @
a4f80c4
...
...
@@ -602,7 +602,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
/***/
((
__unused_webpack_module
,
__webpack_exports__
,
__webpack_require__
)
=>
{
"use strict"
;
eval
(
"__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/*\n * @Descripttion:\n * @version: 1.0.0\n * @Author: limin\n * @Date: 2025-09-09 09:49:02\n * @LastEditors: limin\n * @LastEditTime: 2025-09-09 09:49:33\n * @FilePath: \\glsx-common\\src\\whiteUrlManager.js\n */\n// 使用IIFE和闭包来管理白名单状态\nconst WhiteUrlManager = (() => {\n let cachedWhiteUrl = null\n let fetchPromise = null\n // 返回获取白名单的函数\n return {\n getWhiteUrls: () => {\n // 如果已有缓存,直接返回Promise\n if (cachedWhiteUrl) {\n return Promise.resolve(cachedWhiteUrl)\n }\n // 如果已经有一个请求在进行中,返回该Promise\n if (fetchPromise) {\n return fetchPromise\n }\n // 创建新的Promise并保存引用\n fetchPromise = fetch('https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=glsx-common')\n .then(response => response.json())\n .then(result => {\n cachedWhiteUrl = result.whiteUrl || []\n if (Array.isArray(cachedWhiteUrl)) {\n
cachedWhiteUrl.forEach((url, index) => {\n cachedWhiteUrl[index] = url.startsWith('http:') ? url.substring(5) : url\n })\n }\n console.log('获取配置成功:', cachedWhiteUrl)
\n return cachedWhiteUrl\n })\n .catch(error => {\n console.error('获取配置失败:', error)\n cachedWhiteUrl = []\n return []\n })\n .finally(() => {\n fetchPromise = null\n })\n return fetchPromise\n }\n }\n // 添加清除缓存的方法\n clearCache: () => {\n cachedWhiteUrl = null\n fetchPromise = null\n return true\n }\n})()\n\n// 模块加载时立即开始预加载白名单,但不阻塞后续代码执行\nWhiteUrlManager.getWhiteUrls()\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (WhiteUrlManager);\n\n\n//# sourceURL=webpack://glsk-common/./src/whiteUrlManager.js?"
);
eval
(
"__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/*\n * @Descripttion:\n * @version: 1.0.0\n * @Author: limin\n * @Date: 2025-09-09 09:49:02\n * @LastEditors: limin\n * @LastEditTime: 2025-09-09 09:49:33\n * @FilePath: \\glsx-common\\src\\whiteUrlManager.js\n */\n// 使用IIFE和闭包来管理白名单状态\nconst WhiteUrlManager = (() => {\n let cachedWhiteUrl = null\n let fetchPromise = null\n // 返回获取白名单的函数\n return {\n getWhiteUrls: () => {\n // 如果已有缓存,直接返回Promise\n if (cachedWhiteUrl) {\n return Promise.resolve(cachedWhiteUrl)\n }\n // 如果已经有一个请求在进行中,返回该Promise\n if (fetchPromise) {\n return fetchPromise\n }\n // 创建新的Promise并保存引用\n fetchPromise = fetch('https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=glsx-common')\n .then(response => response.json())\n .then(result => {\n cachedWhiteUrl = result.whiteUrl || []\n if (Array.isArray(cachedWhiteUrl)) {\n
// 过滤掉http和https开头的url\n cachedWhiteUrl = cachedWhiteUrl.map(url => url.replace(/^https?:/, ''))\n }
\n return cachedWhiteUrl\n })\n .catch(error => {\n console.error('获取配置失败:', error)\n cachedWhiteUrl = []\n return []\n })\n .finally(() => {\n fetchPromise = null\n })\n return fetchPromise\n }\n }\n // 添加清除缓存的方法\n clearCache: () => {\n cachedWhiteUrl = null\n fetchPromise = null\n return true\n }\n})()\n\n// 模块加载时立即开始预加载白名单,但不阻塞后续代码执行\nWhiteUrlManager.getWhiteUrls()\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (WhiteUrlManager);\n\n\n//# sourceURL=webpack://glsk-common/./src/whiteUrlManager.js?"
);
/***/
}),
...
...
package.json
View file @
a4f80c4
{
"name"
:
"glsk-common"
,
"version"
:
"2.10.
4
"
,
"version"
:
"2.10.
7
"
,
"description"
:
"glsk common"
,
"main"
:
"./dist/glsk-common.js"
,
"private"
:
false
,
...
...
src/whiteUrlManager.js
View file @
a4f80c4
...
...
@@ -28,11 +28,9 @@ const WhiteUrlManager = (() => {
.
then
(
result
=>
{
cachedWhiteUrl
=
result
.
whiteUrl
||
[]
if
(
Array
.
isArray
(
cachedWhiteUrl
))
{
cachedWhiteUrl
.
forEach
((
url
,
index
)
=>
{
cachedWhiteUrl
[
index
]
=
url
.
startsWith
(
'http:'
)
?
url
.
substring
(
5
)
:
url
})
// 过滤掉http和https开头的url
cachedWhiteUrl
=
cachedWhiteUrl
.
map
(
url
=>
url
.
replace
(
/^https
?
:/
,
''
))
}
// console.log('获取配置成功:', cachedWhiteUrl)
return
cachedWhiteUrl
})
.
catch
(
error
=>
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment