<Link href="/wallets">wallets</Link>
在当地运行时的工作原理。
当应用程序构建和包装时,这些链接并不是包含App Directory的预期格式,最终将其保留为原始源代码。 如果在SSR生成的
.html
中添加的情况下,也将导致此问题。
原始来源:
layout.tsx
在构建和包装后指示:
/wallets
实性:
file:///Users/user/Desktop/project/dist/mac-arm64/MintBox.app/Contents/Resources/app.asar/out/wallets.html
在单击后转换为
<a href="/wallets"> ... </a>
项目结构:
file:///wallets
功能:
.
├── app
│ ├── layout.tsx
│ ├── page.tsx
│ ├── providers.tsx
│ └── wallets
│ └── page.tsx
├── components
│ ├── list-item.tsx
│ └── sidebar
│ └── app_sidebar.tsx
├── electron
│ ├── main.js
│ └── preload.js
├── next-env.d.ts
├── next.config.js
├── package-lock.json
├── package.json
├── postcss.config.js
├── styles
│ └── global.css
├── tailwind.config.js
├── tsconfig.json
└── yarn.lock
package.json具有以下包脚本:
electron/main.js
function createWindow() {
mainWindow = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: false,
contextIsolation: true,
},
icon: path.join(__dirname, 'assets', 'icon.png')
});
mainWindow.setBackgroundColor("black");
// this page will load correctly, but in case of the Link with href='/' it will result in the same error as described
const appUrl = isDev
? 'http://localhost:3000'
: `file://${path.join(app.getAppPath(), 'out', 'index.html')}`;
mainWindow.loadURL(appUrl);
mainWindow.on('closed', () => {
mainWindow = null;
});
}
:
"main": "electron/main.js",
"scripts": {
"dev": "concurrently \"next dev\" \"cross-env NODE_ENV=development electron .\"",
"build": "next build",
"pack-app": "npm run build && electron-builder --dir",
"start": "electron ."
},
我试图:
switch
next.config.js
在main.js中
const isProd = process.env.NODE_ENV === 'production';
module.exports = {
reactStrictMode: true,
assetPrefix: isProd ? './' : '',
output: "export",
};
在Next.Config.js中
将原始途径带到
webSecurity
,例如,例如,assetPrefix
/
/wallets/
我没有使用过电子,但是您的错误应该在设置时围绕
electron-builder
--dir
您是否可以尝试将其设置为thisGuide?希望它有帮助