提交 d59d918a 编写于 作者: N ninecents

跨域问题修改(尝试)

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