Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
csbr-daop
/
fe-data-trusted-space
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
3ac5eedc
authored
2025-06-14 11:29:06 +0800
by
lxs
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
通过config.json配置appKey
1 parent
69b41bfa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
20 deletions
public/config.json
src/main.ts
src/store/modules/sysConfig.ts
src/store/modules/user.ts
public/config.json
0 → 100644
View file @
3ac5eed
{
"appKey"
:
"672c2c38e4b0cac8732a6106"
}
src/main.ts
View file @
3ac5eed
...
...
@@ -6,11 +6,12 @@ import App from './App.vue'
// import pinia from './store'
import
router
from
'./router'
import
useSettingsStore
from
'./store/modules/settings'
;
import
sysConfigStore
from
'@/store/modules/sysConfig'
import
{
ElMessage
}
from
"element-plus"
import
{
openMessageBox
}
from
"@/utils/common"
// pinia设置
import
{
createPinia
}
from
'pinia'
import
{
createPinia
}
from
'pinia'
import
piniaPluginPersistedstate
from
'pinia-plugin-persistedstate'
// 自定义指令
...
...
@@ -25,18 +26,52 @@ import '@/assets/styles/globals.scss'
// 加载 iconify 图标(element plus)
import
{
downloadAndInstall
}
from
'@/iconify-ep'
const
pinia
=
createPinia
();
pinia
.
use
(
piniaPluginPersistedstate
);
const
app
=
createApp
(
App
)
app
.
use
(
ElementPlus
)
app
.
use
(
pinia
)
app
.
use
(
router
)
directive
(
app
)
if
(
useSettingsStore
().
settings
.
app
.
iconifyOfflineUse
)
{
downloadAndInstall
()
}
app
.
config
.
globalProperties
.
$passCode
=
"00000"
;
// 定义全局变量
app
.
config
.
globalProperties
.
$ElMessage
=
ElMessage
;
// 全局消息提示
app
.
config
.
globalProperties
.
$openMessageBox
=
openMessageBox
;
// 二次确认提示对话框。
app
.
mount
(
'#main-app'
)
// 封装请求配置文件的函数
const
loadConfig
=
async
()
=>
{
try
{
const
response
=
await
fetch
(
'/config.json'
);
if
(
!
response
.
ok
)
{
throw
new
Error
(
`请求配置失败,状态码:
${
response
.
status
}
`
);
}
const
config
=
await
response
.
json
();
return
config
;
}
catch
(
error
)
{
console
.
error
(
'加载配置时出错:'
,
error
);
throw
error
;
}
};
// 初始化应用的异步函数
const
initApp
=
async
()
=>
{
try
{
// 加载配置文件
const
config
=
await
loadConfig
();
const
pinia
=
createPinia
();
pinia
.
use
(
piniaPluginPersistedstate
);
// 将配置信息存储到 Pinia 中
const
configStore
=
sysConfigStore
();
configStore
.
setConfig
(
config
);
const
app
=
createApp
(
App
)
app
.
use
(
ElementPlus
)
app
.
use
(
pinia
)
app
.
use
(
router
)
directive
(
app
)
if
(
useSettingsStore
().
settings
.
app
.
iconifyOfflineUse
)
{
downloadAndInstall
()
}
app
.
config
.
globalProperties
.
$passCode
=
"00000"
;
// 定义全局变量
app
.
config
.
globalProperties
.
$ElMessage
=
ElMessage
;
// 全局消息提示
app
.
config
.
globalProperties
.
$openMessageBox
=
openMessageBox
;
// 二次确认提示对话框。
app
.
mount
(
'#main-app'
)
}
catch
(
error
)
{
console
.
error
(
'应用初始化失败:'
,
error
);
// 这里可以添加一些错误处理逻辑,比如显示错误提示给用户
}
};
// 启动应用
initApp
();
...
...
src/store/modules/sysConfig.ts
0 → 100644
View file @
3ac5eed
const
sysConfigStore
=
defineStore
(
// 唯一ID
'config'
,
()
=>
{
let
configMap
:
any
=
{};
const
setConfig
=
(
val
)
=>
{
configMap
=
val
}
const
getConfig
=
(
field
)
=>
{
return
field
?
configMap
[
field
]:
configMap
;
}
return
{
configMap
,
setConfig
,
getConfig
}
},
)
export
default
sysConfigStore
src/store/modules/user.ts
View file @
3ac5eed
import
useRouteStore
from
'./route'
import
useMenuStore
from
'./menu'
import
sysConfigStore
from
'./sysConfig'
import
router
from
'@/router'
import
{
ElMessage
}
from
'element-plus'
import
apiUser
from
'@/api/modules/user'
...
...
@@ -30,12 +31,10 @@ const useUserStore = defineStore(
const
idassLoginUrl
=
import
.
meta
.
env
.
VITE_IDASS_BASEURL
;
const
timer
:
any
=
ref
(
null
);
//获取token.
async
function
getToken
(
data
,
state
)
{
const
config
=
system
.
appConfig
;
function
getToken
(
data
,
state
)
{
data
.
platformGuid
=
"7f16f697aec111ef8656fa163e60becd"
;
data
.
userType
=
2
;
// data.appKey = '672c2c38e4b0cac8732a6106';
data
.
appKey
=
config
.
appKey
;
data
.
appKey
=
sysConfigStore
().
getConfig
(
'appKey'
);
data
.
validateUri
=
location
.
origin
==
'http://localhost:9000'
?
'http://localhost:9000/'
:
location
.
origin
+
'/'
;
return
getTokenPromise
.
value
=
getTokenByCode
(
data
).
then
((
res
:
any
)
=>
{
getTokenPromise
.
value
=
null
;
...
...
@@ -304,6 +303,7 @@ const useUserStore = defineStore(
}
return
m
.
children
.
some
(
c
=>
c
.
menuType
==
'F'
&&
c
.
menuName
==
btnCaption
);
}
return
{
account
,
userId
,
...
...
Write
Preview
Styling with
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