注册全局组件SVG,集成pinia,封装axios
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
/**
|
||||
* 主进程与渲染进程通信频道定义
|
||||
* Definition of communication channels between main process and rendering process
|
||||
@@ -7,7 +6,4 @@ const ipcApiRoute = {
|
||||
test: 'controller.example.test',
|
||||
}
|
||||
|
||||
export {
|
||||
ipcApiRoute
|
||||
}
|
||||
|
||||
export { ipcApiRoute }
|
||||
|
||||
57
frontend/src/api/user/index.ts
Normal file
57
frontend/src/api/user/index.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import request from '@/utils/http'
|
||||
import { useUserInfoStore } from '@/stores/user'
|
||||
import { sm3Digest } from '@/assets/commjs/sm3.js'
|
||||
import { sm2, encrypt } from '@/assets/commjs/sm2.js'
|
||||
|
||||
// 获取公钥
|
||||
export const publicKey = (params?: any) => {
|
||||
if (!params) {
|
||||
const userInfo = useUserInfoStore()
|
||||
params = {
|
||||
loginName: encrypt(userInfo.loginName),
|
||||
}
|
||||
}
|
||||
return request({
|
||||
url: '/user/generateSm2Key',
|
||||
method: 'get',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
export const pwdSm3 = async (pwd: any, loginName?: string) => {
|
||||
let publicKeyStr = await publicKey(
|
||||
loginName ? { loginName: encrypt(loginName) } : false,
|
||||
)
|
||||
let sm3Pwd = sm3Digest(pwd) //SM3加密
|
||||
return sm2(sm3Pwd + '|' + pwd, publicKeyStr.data, 0)
|
||||
}
|
||||
|
||||
//登录获取token
|
||||
export const login = async (params: any) => {
|
||||
params.password = await pwdSm3(params.password, params.username)
|
||||
params.username = encrypt(params.username)
|
||||
return request({
|
||||
url: '/pqs-auth/oauth/token',
|
||||
method: 'post',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
//获取用户信息
|
||||
export const getUserById = () => {
|
||||
const userInfo = useUserInfoStore()
|
||||
return request({
|
||||
url: '/user-boot/user/getUserById?id=' + userInfo.userIndex,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
// 刷新token
|
||||
export function refreshToken(): Promise<any> {
|
||||
const userInfo = useUserInfoStore()
|
||||
return login({
|
||||
grant_type: 'refresh_token',
|
||||
refresh_token: userInfo.refresh_token,
|
||||
username: userInfo.loginName,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user