Код: Выделить всё
[*]wallets
< /code>
, который работает так же, как и ожидалось, когда работает локально. и .html в исходном источнике:
Код: Выделить всё
/walletsожидается после сборки и пакета:
Код: Выделить всё
file:///Users/user/Desktop/project/dist/mac-arm64/MintBox.app/Contents/Resources/app.asar/out/wallets.htmlActual:
Код: Выделить всё
[url=/wallets] ... [/url]Структура проекта:
Код: Выделить всё
.
├── 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
Код: Выделить всё
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;
});
}
< /code>
У Package.json есть следующий сценарий пакета: < /p>
"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 ."
},
< /code>
next.config.jsКод: Выделить всё
const isProd = process.env.NODE_ENV === 'production';
module.exports = {
reactStrictMode: true,
assetPrefix: isProd ? './' : '',
output: "export",
};
< /code>
[b]I've tried to:[/b]
[list]
switch webSecurity[*]
Код: Выделить всё
assetPrefix[*] Сделайте исходные пути, чтобы закончить с/, например,/кошельки/
< li> Использовать электрон-строитель с и без-dir
[*] Создать пользовательский протокол файлов
[/list]
В результате либо не разрешено загружать локальный ресурс , либо файл, показанный как не найденный в запросах приложения.
Подробнее здесь: https://stackoverflow.com/questions/793 ... r-building
Мобильная версия