fix: resolve GUI buttons by safe tauri invoke, add validation toasts, build and bundle ostp-tun-helper in CI/CD pipeline

This commit is contained in:
ospab 2026-05-17 18:32:55 +03:00
parent 6ccaf3a303
commit 0306cbaccd
5 changed files with 44 additions and 2 deletions

View File

@ -258,6 +258,10 @@ jobs:
- name: Install Tauri CLI - name: Install Tauri CLI
run: cargo install tauri-cli --version "^2" run: cargo install tauri-cli --version "^2"
- name: Build Tun Helper
run: |
cargo build --release --target ${{ matrix.target }} -p ostp-tun-helper
- name: Build Tauri application - name: Build Tauri application
shell: pwsh shell: pwsh
run: | run: |
@ -275,6 +279,9 @@ jobs:
$exePath = Get-ChildItem -Path "ostp-gui/src-tauri/target/${{ matrix.target }}/release" -Filter "ostp-gui.exe" | Select-Object -First 1 $exePath = Get-ChildItem -Path "ostp-gui/src-tauri/target/${{ matrix.target }}/release" -Filter "ostp-gui.exe" | Select-Object -First 1
Copy-Item $exePath.FullName -Destination "$dist/ostp-gui.exe" Copy-Item $exePath.FullName -Destination "$dist/ostp-gui.exe"
# 1.5 Copy the Tun Helper executable
Copy-Item "target/${{ matrix.target }}/release/ostp-tun-helper.exe" -Destination "$dist/ostp-tun-helper.exe"
# 2. Download tun2socks # 2. Download tun2socks
Invoke-WebRequest -Uri "https://github.com/xjasonlyu/tun2socks/releases/download/v2.6.0/tun2socks-${{ matrix.tun2socks_arch }}.zip" -OutFile "tun2socks.zip" Invoke-WebRequest -Uri "https://github.com/xjasonlyu/tun2socks/releases/download/v2.6.0/tun2socks-${{ matrix.tun2socks_arch }}.zip" -OutFile "tun2socks.zip"
Expand-Archive -Path "tun2socks.zip" -DestinationPath "tun_temp" -Force Expand-Archive -Path "tun2socks.zip" -DestinationPath "tun_temp" -Force

View File

@ -413,9 +413,35 @@ struct HelperPipeState {
fn find_helper_exe() -> Option<PathBuf> { fn find_helper_exe() -> Option<PathBuf> {
if let Ok(exe) = std::env::current_exe() { if let Ok(exe) = std::env::current_exe() {
if let Some(dir) = exe.parent() { if let Some(dir) = exe.parent() {
// 1. Release/Production adjacent
let candidate = dir.join("ostp-tun-helper.exe"); let candidate = dir.join("ostp-tun-helper.exe");
if candidate.exists() { return Some(candidate); } if candidate.exists() { return Some(candidate); }
// 2. Tauri target directory fallback
// e.g. from ostp-gui/src-tauri/target/debug/deps/
let mut parent = dir;
while let Some(p) = parent.parent() {
if p.file_name().map(|n| n == "target").unwrap_or(false) {
let deb = p.join("debug").join("ostp-tun-helper.exe");
if deb.exists() { return Some(deb); }
let rel = p.join("release").join("ostp-tun-helper.exe");
if rel.exists() { return Some(rel); }
} }
parent = p;
}
}
}
// 3. Current working directory target fallback
let cwd = std::env::current_dir().unwrap_or_default();
let candidates = [
cwd.join("ostp-tun-helper.exe"),
cwd.join("target").join("debug").join("ostp-tun-helper.exe"),
cwd.join("target").join("release").join("ostp-tun-helper.exe"),
cwd.join("..").join("target").join("debug").join("ostp-tun-helper.exe"),
cwd.join("..").join("target").join("release").join("ostp-tun-helper.exe"),
];
for path in &candidates {
if path.exists() { return Some(path.clone()); }
} }
None None
} }

View File

@ -5,7 +5,7 @@
<link rel="stylesheet" href="styles.css" /> <link rel="stylesheet" href="styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OSTP Client</title> <title>OSTP Client</title>
<script type="module" src="/main.js" defer></script> <script type="module" src="main.js" defer></script>
</head> </head>
<body> <body>
<div class="app-container"> <div class="app-container">

View File

@ -1,6 +1,12 @@
import { t, toggleLang, applyTranslations, getLang } from './i18n.js'; import { t, toggleLang, applyTranslations, getLang } from './i18n.js';
const { invoke } = window.__TAURI__.core; let invoke = () => {
console.warn('Tauri invoke is not available in this environment.');
return Promise.resolve(null);
};
if (window.__TAURI__ && window.__TAURI__.core) {
invoke = window.__TAURI__.core.invoke;
}
// State management // State management
let appState = 'disconnected'; let appState = 'disconnected';
@ -240,9 +246,11 @@ async function handleSaveConfig() {
// Validation // Validation
if (!rawConfigObj.server) { if (!rawConfigObj.server) {
showToast(t('err_server_req') || 'Server address is required');
return; return;
} }
if (!rawConfigObj.access_key) { if (!rawConfigObj.access_key) {
showToast(t('err_key_req') || 'Access key is required');
return; return;
} }

1
ostp-wiki Submodule

@ -0,0 +1 @@
Subproject commit b5ab15bb8f63467df3393861c69142435e3cec65