提交 988f1928 编写于 作者: N ninecents

跨域问题修改(尝试)

上级 3102079a
...@@ -2,6 +2,8 @@ import { app, shell, BrowserWindow } from 'electron' ...@@ -2,6 +2,8 @@ import { app, shell, BrowserWindow } from 'electron'
import * as path from 'path' import * as path from 'path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils' import { electronApp, optimizer, is } from '@electron-toolkit/utils'
app.commandLine.appendSwitch("disable-features", "OutOfBlinkCors"); app.commandLine.appendSwitch("disable-features", "OutOfBlinkCors");
app.commandLine.appendSwitch("disable-web-security");
app.commandLine.appendSwitch('disable-site-isolation-trials')
function createWindow(): void { function createWindow(): void {
// Create the browser window. // Create the browser window.
...@@ -19,7 +21,8 @@ function createWindow(): void { ...@@ -19,7 +21,8 @@ function createWindow(): void {
preload: path.join(__dirname, '../preload/index.js'), preload: path.join(__dirname, '../preload/index.js'),
sandbox: false, sandbox: false,
nodeIntegration: true, nodeIntegration: true,
webSecurity:false webSecurity: false,
allowRunningInsecureContent: true
} }
}) })
...@@ -41,8 +44,9 @@ function createWindow(): void { ...@@ -41,8 +44,9 @@ function createWindow(): void {
mainWindow.webContents.session.webRequest.onHeadersReceived((details, callback) => { mainWindow.webContents.session.webRequest.onHeadersReceived((details, callback) => {
callback({ callback({
responseHeaders: { responseHeaders: {
'Access-Control-Allow-Origin': ['*'],
...details.responseHeaders, ...details.responseHeaders,
'Access-Control-Allow-Origin': ['*'],
'Content-Security-Policy': ['*']
}, },
}); });
}); });
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>Electron</title> <title>Electron</title>
<!-- https://www.electronjs.org/zh/docs/latest/tutorial/security -->
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta <!-- <meta
http-equiv="Content-Security-Policy" http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'"
/> /> -->
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script type="module" src="/src/main.ts"></script> <script type="module" src="/src/main.ts"></script>
</body> </body>
</html>
</html>
\ No newline at end of file
...@@ -8,10 +8,14 @@ const router = createRouter({ ...@@ -8,10 +8,14 @@ const router = createRouter({
history: createWebHistory(), history: createWebHistory(),
routes: [ routes: [
{ {
path: '/', path: '/welcome',
name: 'welcome', name: 'welcome',
component: welcome component: welcome
}, },
{
path: '/',
redirect: '/lilili'
},
{ {
path: '/lilili', path: '/lilili',
name: 'lilili', name: 'lilili',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册