mirror of https://github.com/ospab/ostp.git
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:
parent
6ccaf3a303
commit
0306cbaccd
|
|
@ -258,6 +258,10 @@ jobs:
|
|||
- name: Install Tauri CLI
|
||||
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
|
||||
shell: pwsh
|
||||
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
|
||||
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
|
||||
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
|
||||
|
|
|
|||
|
|
@ -413,9 +413,35 @@ struct HelperPipeState {
|
|||
fn find_helper_exe() -> Option<PathBuf> {
|
||||
if let Ok(exe) = std::env::current_exe() {
|
||||
if let Some(dir) = exe.parent() {
|
||||
// 1. Release/Production adjacent
|
||||
let candidate = dir.join("ostp-tun-helper.exe");
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<link rel="stylesheet" href="styles.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>OSTP Client</title>
|
||||
<script type="module" src="/main.js" defer></script>
|
||||
<script type="module" src="main.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="app-container">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
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
|
||||
let appState = 'disconnected';
|
||||
|
|
@ -240,9 +246,11 @@ async function handleSaveConfig() {
|
|||
|
||||
// Validation
|
||||
if (!rawConfigObj.server) {
|
||||
showToast(t('err_server_req') || 'Server address is required');
|
||||
return;
|
||||
}
|
||||
if (!rawConfigObj.access_key) {
|
||||
showToast(t('err_key_req') || 'Access key is required');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit b5ab15bb8f63467df3393861c69142435e3cec65
|
||||
Loading…
Reference in New Issue