Skip to content

Commit e8e7b00

Browse files
author
李杰
committed
fix: opencode start cleanup and add codeql
1 parent 637629b commit e8e7b00

4 files changed

Lines changed: 58 additions & 11 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: "31 2 * * 1"
10+
11+
permissions:
12+
actions: read
13+
contents: read
14+
security-events: write
15+
16+
jobs:
17+
analyze:
18+
name: Analyze
19+
runs-on: ubuntu-latest
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
language: [ "javascript-typescript", "rust" ]
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Initialize CodeQL
31+
uses: github/codeql-action/init@v3
32+
with:
33+
languages: ${{ matrix.language }}
34+
35+
- name: Autobuild
36+
uses: github/codeql-action/autobuild@v3
37+
38+
- name: Perform CodeQL Analysis
39+
uses: github/codeql-action/analyze@v3

scripts/update_locales.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const translations = {
2121
settings_general_closeBehavior: "سلوك الإغلاق",
2222
settings_general_closeBehaviorDesc: "اختر الإجراء عند إغلاق النافذة",
2323
settings_general_closeBehaviorAsk: "اسأل في كل مرة",
24+
2425
settings_general_closeBehaviorMinimize: "تصغير إلى الدرج",
2526
settings_general_closeBehaviorQuit: "إنهاء التطبيق",
2627
settings_general_opencodeAppPathDesc: "اتركه فارغًا لاستخدام المسار الافتراضي",

src-tauri/src/lib.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ mod utils;
44
mod commands;
55
pub mod error;
66

7-
use tauri::{Emitter, Manager, RunEvent};
7+
use tauri::{Emitter, Manager};
8+
#[cfg(target_os = "macos")]
9+
use tauri::RunEvent;
810
use tauri::WindowEvent;
911
use modules::logger;
1012
use modules::config::CloseWindowBehavior;
@@ -209,12 +211,18 @@ pub fn run() {
209211

210212
app.run(|app_handle, event| {
211213
#[cfg(target_os = "macos")]
212-
if let RunEvent::Reopen { .. } = event {
213-
if let Some(window) = app_handle.get_webview_window("main") {
214-
let _ = window.show();
215-
let _ = window.unminimize();
216-
let _ = window.set_focus();
214+
{
215+
if let RunEvent::Reopen { .. } = event {
216+
if let Some(window) = app_handle.get_webview_window("main") {
217+
let _ = window.show();
218+
let _ = window.unminimize();
219+
let _ = window.set_focus();
220+
}
217221
}
218222
}
223+
#[cfg(not(target_os = "macos"))]
224+
{
225+
let _ = (app_handle, event);
226+
}
219227
});
220228
}

src-tauri/src/modules/process.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ pub fn is_opencode_running() -> bool {
323323

324324
let current_pid = std::process::id();
325325
let app_lower = OPENCODE_APP_NAME.to_lowercase();
326-
let bundle_lower = format!("{}.app", app_lower);
327326

328327
for (pid, process) in system.processes() {
329328
let pid_u32 = pid.as_u32();
@@ -358,6 +357,7 @@ pub fn is_opencode_running() -> bool {
358357

359358
#[cfg(target_os = "macos")]
360359
{
360+
let bundle_lower = format!("{}.app", app_lower);
361361
if exe_path.contains(&bundle_lower) && !is_helper {
362362
return true;
363363
}
@@ -393,7 +393,6 @@ fn get_opencode_pids() -> Vec<u32> {
393393
let mut pids = Vec::new();
394394
let current_pid = std::process::id();
395395
let app_lower = OPENCODE_APP_NAME.to_lowercase();
396-
let bundle_lower = format!("{}.app", app_lower);
397396

398397
for (pid, process) in system.processes() {
399398
let pid_u32 = pid.as_u32();
@@ -428,6 +427,7 @@ fn get_opencode_pids() -> Vec<u32> {
428427

429428
#[cfg(target_os = "macos")]
430429
{
430+
let bundle_lower = format!("{}.app", app_lower);
431431
if exe_path.contains(&bundle_lower) && !is_helper {
432432
pids.push(pid_u32);
433433
}
@@ -560,9 +560,8 @@ pub fn start_opencode_with_path(custom_path: Option<&str>) -> Result<(), String>
560560
candidates.push(custom);
561561
}
562562

563-
let default_path = get_default_opencode_app_path();
564-
if !default_path.is_empty() {
565-
candidates.push(default_path);
563+
if let Ok(local_appdata) = std::env::var("LOCALAPPDATA") {
564+
candidates.push(format!("{}/Programs/OpenCode/OpenCode.exe", local_appdata));
566565
}
567566

568567
if let Ok(program_files) = std::env::var("PROGRAMFILES") {

0 commit comments

Comments
 (0)