后台管理
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,
|
||||||
|
|||||||
@ -654,10 +654,10 @@ const toggleGroup = (type: string) => {
|
|||||||
|
|
||||||
var backButShow: any = ref(false)
|
var backButShow: any = ref(false)
|
||||||
//根据角色权限控制后台管理按钮显隐
|
//根据角色权限控制后台管理按钮显隐
|
||||||
let option = JSON.parse(localStorage.getItem('frontFunctionArr'))
|
let option = JSON.parse(localStorage.getItem('frontFunctionArr') || '{}')
|
||||||
option = Object.keys(option)
|
option = Object.keys(option)
|
||||||
//数据权限
|
//数据权限
|
||||||
let data = JSON.parse(localStorage.getItem('frontDataArr'))
|
let data = JSON.parse(localStorage.getItem('frontDataArr') || '[]')
|
||||||
if (option.length == 0 && data.length == 0) {
|
if (option.length == 0 && data.length == 0) {
|
||||||
//管理员
|
//管理员
|
||||||
backButShow.value = true
|
backButShow.value = true
|
||||||
@ -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 = []
|
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