FIX 3 van de Windows:
1. LOAD CHAM: PyInstaller onefile 723MB giai nen toan bo vao %TEMP% moi lan chay -> chuyen ONEDIR (engine.spec COLLECT) + bundle qua Tauri resources (resource_dir/daw_engine/daw_engine.exe) thay externalBin — khoi dong tuc thi khong giai nen
2. WINDOW PICKER: Tauri v2 khong co window.__TAURI__.dialog — goi invoke('plugin:dialog|open', {options:{directory:true}}) qua __TAURI__.core.invoke
3. ICON exe: bundle.icon chuyen icon.ico -> favicon.ico + thay 3 PNG bang favicon render
- build_windows.ps1 buoc 4: copy onedir dist/daw_engine -> src-tauri/resources/daw_engine
This commit is contained in:
@@ -5299,11 +5299,15 @@ const PluginManagerModal = ({ isOpen, onClose, pluginsData }) => {
|
|||||||
setTimeout(() => { try { window.lucide.createIcons(); } catch(e) {} }, 50);
|
setTimeout(() => { try { window.lucide.createIcons(); } catch(e) {} }, 50);
|
||||||
}
|
}
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
// Folder picker: Tauri dialog (desktop) nếu có; fallback: paste path.
|
// Folder picker: Tauri v2 dialog qua invoke (window.__TAURI__.dialog KHONG
|
||||||
|
// ton tai trong v2 — plugin dialog chi co JS binding qua npm; goi truc tiep
|
||||||
|
// command 'plugin:dialog|open'). Fallback: prompt nhap path (browser).
|
||||||
const pickPluginFolder = async () => {
|
const pickPluginFolder = async () => {
|
||||||
try {
|
try {
|
||||||
if (window.__TAURI__ && window.__TAURI__.dialog) {
|
if (window.__TAURI__ && window.__TAURI__.core && window.__TAURI__.core.invoke) {
|
||||||
const sel = await window.__TAURI__.dialog.open({ directory: true, multiple: false });
|
const sel = await window.__TAURI__.core.invoke('plugin:dialog|open', {
|
||||||
|
options: { directory: true, multiple: false }
|
||||||
|
});
|
||||||
if (typeof sel === 'string' && sel) {
|
if (typeof sel === 'string' && sel) {
|
||||||
if (!pmDirs.includes(sel)) setPmDirs(prev => [...prev, sel]);
|
if (!pmDirs.includes(sel)) setPmDirs(prev => [...prev, sel]);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+13
-3
@@ -50,9 +50,19 @@ if ($LASTEXITCODE -ne 0) {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "== [4/6] Sidecar binary -> src-tauri/binaries (tauri triple naming) =="
|
Write-Host "== [4/6] ONEDIR engine -> src-tauri/resources/daw_engine (Tauri resources) =="
|
||||||
New-Item -ItemType Directory -Force src-tauri\binaries | Out-Null
|
# ONEDIR: copy ca thu muc dist\daw_engine\ (exe + _internal) vao resources.
|
||||||
Copy-Item dist\daw_engine.exe src-tauri\binaries\daw_engine-x86_64-pc-windows-msvc.exe -Force
|
# Tauri bundle resources -> resource_dir()/daw_engine/daw_engine.exe luc runtime.
|
||||||
|
if (-not (Test-Path "dist\daw_engine\daw_engine.exe")) {
|
||||||
|
Write-Host "ERROR: dist\daw_engine\daw_engine.exe khong ton tai (onedir build loi?)" -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
if (Test-Path "src-tauri\resources\daw_engine") {
|
||||||
|
Remove-Item -Recurse -Force "src-tauri\resources\daw_engine"
|
||||||
|
}
|
||||||
|
New-Item -ItemType Directory -Force "src-tauri\resources\daw_engine" | Out-Null
|
||||||
|
Copy-Item "dist\daw_engine\*" "src-tauri\resources\daw_engine\" -Recurse -Force
|
||||||
|
Write-Host "Copied onedir engine -> src-tauri\resources\daw_engine"
|
||||||
|
|
||||||
Write-Host "== [5/6] VC++ Redistributable cho hooks.nsh =="
|
Write-Host "== [5/6] VC++ Redistributable cho hooks.nsh =="
|
||||||
if (-not (Test-Path src-tauri\vc_redist.x64.exe)) {
|
if (-not (Test-Path src-tauri\vc_redist.x64.exe)) {
|
||||||
|
|||||||
+12
-3
@@ -112,10 +112,8 @@ pyz = PYZ(a.pure, a.zipped_data, cipher=None)
|
|||||||
exe = EXE(
|
exe = EXE(
|
||||||
pyz,
|
pyz,
|
||||||
a.scripts,
|
a.scripts,
|
||||||
a.binaries,
|
|
||||||
a.zipfiles,
|
|
||||||
a.datas,
|
|
||||||
[],
|
[],
|
||||||
|
exclude_binaries=True,
|
||||||
name='daw_engine',
|
name='daw_engine',
|
||||||
debug=False,
|
debug=False,
|
||||||
bootloader_ignore_signals=False,
|
bootloader_ignore_signals=False,
|
||||||
@@ -128,3 +126,14 @@ exe = EXE(
|
|||||||
# sinh boi tools/gen_favicon_ico.py). Cung nguon voi icon hien thi trong app.
|
# sinh boi tools/gen_favicon_ico.py). Cung nguon voi icon hien thi trong app.
|
||||||
icon='src-tauri/icons/favicon.ico',
|
icon='src-tauri/icons/favicon.ico',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# ONEDIR (khong phai onefile): exe 700MB+ onefile phai giai nen toan bo vao
|
||||||
|
# %TEMP% moi lan chay -> load RAT CHAM tren Windows. Onedir chay truc tiep tu
|
||||||
|
# thu muc (bundle qua Tauri resources), khoi dong gan nhu tuc thi.
|
||||||
|
coll = COLLECT(
|
||||||
|
exe,
|
||||||
|
a.binaries,
|
||||||
|
a.zipfiles,
|
||||||
|
a.datas,
|
||||||
|
name='daw_engine',
|
||||||
|
)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1009 B After Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 49 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 459 B After Width: | Height: | Size: 2.2 KiB |
+15
-7
@@ -12,15 +12,23 @@ pub fn run() {
|
|||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
.plugin(tauri_plugin_dialog::init())
|
.plugin(tauri_plugin_dialog::init())
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
// 1. Spawn sidecar daw_engine.exe (PyInstaller bundle)
|
// 1. Spawn daw_engine (PyInstaller ONEDIR bundle — khong giai nen
|
||||||
let sidecar_command = app
|
// moi lan chay nhu onefile, khoi dong nhanh). Bundle qua Tauri
|
||||||
.shell()
|
// resources: resource_dir()/daw_engine/daw_engine(.exe)
|
||||||
.sidecar("daw_engine")
|
let res_dir = app
|
||||||
.expect("sidecar daw_engine not found — run build_windows.ps1 first");
|
.path()
|
||||||
let (_rx, child) = sidecar_command
|
.resource_dir()
|
||||||
|
.expect("resource dir not found");
|
||||||
|
let engine_dir = res_dir.join("daw_engine");
|
||||||
|
let engine_exe = if cfg!(windows) {
|
||||||
|
engine_dir.join("daw_engine.exe")
|
||||||
|
} else {
|
||||||
|
engine_dir.join("daw_engine")
|
||||||
|
};
|
||||||
|
let (_rx, child) = tauri_plugin_shell::process::Command::new(engine_exe)
|
||||||
.env("SF_PARENT_PID", std::process::id().to_string())
|
.env("SF_PARENT_PID", std::process::id().to_string())
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("Failed to spawn daw_engine sidecar");
|
.expect("Failed to spawn daw_engine (onedir resource) — run build_windows.ps1 first");
|
||||||
|
|
||||||
app.manage(EngineProcess(Mutex::new(Some(child))));
|
app.manage(EngineProcess(Mutex::new(Some(child))));
|
||||||
println!("Python Background Engine started (localhost:8000, auto-fallback 8000-8010)");
|
println!("Python Background Engine started (localhost:8000, auto-fallback 8000-8010)");
|
||||||
|
|||||||
@@ -30,11 +30,12 @@
|
|||||||
"icons/32x32.png",
|
"icons/32x32.png",
|
||||||
"icons/128x128.png",
|
"icons/128x128.png",
|
||||||
"icons/128x128@2x.png",
|
"icons/128x128@2x.png",
|
||||||
"icons/icon.ico"
|
"icons/favicon.ico"
|
||||||
],
|
],
|
||||||
"externalBin": [
|
"resources": [
|
||||||
"binaries/daw_engine"
|
"resources/daw_engine/**"
|
||||||
],
|
],
|
||||||
|
"externalBin": [],
|
||||||
"windows": {
|
"windows": {
|
||||||
"nsis": {
|
"nsis": {
|
||||||
"installerHooks": "hooks.nsh"
|
"installerHooks": "hooks.nsh"
|
||||||
|
|||||||
Reference in New Issue
Block a user