Merge branch 'zyl' of http://xny.yj-3d.com:3000/zhouyulong/electron-4 into zyl
This commit is contained in:
@ -436,6 +436,18 @@ function createWindow(): void {
|
|||||||
// 1. 创建独立临时会话
|
// 1. 创建独立临时会话
|
||||||
const tempSession = createTempSession();
|
const tempSession = createTempSession();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (option && option.Authorization) {
|
||||||
|
tempSession.webRequest.onBeforeSendHeaders((details, callback) => {
|
||||||
|
const headers = Object.assign({}, details.requestHeaders);
|
||||||
|
headers['Authorization'] = option.Authorization;
|
||||||
|
callback({ requestHeaders: headers });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('注入认证头失败:', e);
|
||||||
|
}
|
||||||
|
|
||||||
// 2. 合并窗口配置:注入独立会话
|
// 2. 合并窗口配置:注入独立会话
|
||||||
const windowConfig = {
|
const windowConfig = {
|
||||||
...params,
|
...params,
|
||||||
|
|||||||
@ -677,6 +677,12 @@ const intoBack = async () => {
|
|||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const { ipcRenderer } = require('electron')
|
const { ipcRenderer } = require('electron')
|
||||||
|
|
||||||
|
const token = localStorage.getItem('Authorization')
|
||||||
|
if (!token) {
|
||||||
|
ElMessage({ message: '请先登录后再进入后台管理', type: 'error' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let availablePort = await ipcRenderer.invoke('get-available-port')
|
let availablePort = await ipcRenderer.invoke('get-available-port')
|
||||||
|
|
||||||
let baseURL = localStorage.getItem('ip')
|
let baseURL = localStorage.getItem('ip')
|
||||||
@ -710,7 +716,7 @@ const intoBack = async () => {
|
|||||||
},
|
},
|
||||||
// `http://localhost:${availablePort}/backManage/index.html#/login?timestamp=${Date.now()}`,
|
// `http://localhost:${availablePort}/backManage/index.html#/login?timestamp=${Date.now()}`,
|
||||||
`${baseURL}/index.html#/login?timestamp=${Date.now()}`,
|
`${baseURL}/index.html#/login?timestamp=${Date.now()}`,
|
||||||
{},
|
{ Authorization: token },
|
||||||
id
|
id
|
||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -81,7 +81,7 @@ export const useLogin = () => {
|
|||||||
})
|
})
|
||||||
localStorage.setItem('frontFunctionArr', JSON.stringify(obj))
|
localStorage.setItem('frontFunctionArr', JSON.stringify(obj))
|
||||||
//数据权限
|
//数据权限
|
||||||
let dataArr:any = []
|
let dataArr: any[] = []
|
||||||
res.data.roleOperates.forEach(item => {
|
res.data.roleOperates.forEach(item => {
|
||||||
dataArr.push(item.operate)
|
dataArr.push(item.operate)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user