From 64de5f0a33d73879a7273810f00b1156aa9b93f1 Mon Sep 17 00:00:00 2001 From: Marqle Date: Thu, 7 May 2026 16:50:08 +0800 Subject: [PATCH] zsh adapt && remote unused permissions --- .../main/ets/entryability/EntryAbility.ets | 2 +- src/apps/vcoder/entry/src/main/module.json5 | 30 -------------- .../main/resources/base/element/string.json | 27 ++++++------ .../service/terminal/src/shell/detection.rs | 41 ++++++++++++++++++- .../src/shell/scripts/shellIntegration-rc.zsh | 28 ++++++++++++- .../config/components/BasicsConfig.tsx | 2 +- 6 files changed, 81 insertions(+), 49 deletions(-) diff --git a/src/apps/vcoder/entry/src/main/ets/entryability/EntryAbility.ets b/src/apps/vcoder/entry/src/main/ets/entryability/EntryAbility.ets index 55d7e7191..b479a2e4f 100644 --- a/src/apps/vcoder/entry/src/main/ets/entryability/EntryAbility.ets +++ b/src/apps/vcoder/entry/src/main/ets/entryability/EntryAbility.ets @@ -126,7 +126,7 @@ export default class EntryAbility extends RustAbility { }); setTimeout(() => { windowStage.getMainWindow((err, data) => { - data.setWindowDecorHeight(32) + data.setWindowDecorHeight(44) data.setWindowDecorVisible(false); }) }, 40) diff --git a/src/apps/vcoder/entry/src/main/module.json5 b/src/apps/vcoder/entry/src/main/module.json5 index 614326843..d0827d935 100644 --- a/src/apps/vcoder/entry/src/main/module.json5 +++ b/src/apps/vcoder/entry/src/main/module.json5 @@ -34,45 +34,15 @@ } ], "requestPermissions": [ - { - "name": "ohos.permission.PREPARE_APP_TERMINATE" - }, { "name": "ohos.permission.INTERNET" }, -// { -// "name": "ohos.permission.GET_ALL_PROCESSES" -// }, { "name": "ohos.permission.READ_WRITE_USER_FILE" }, -// { -// "name": "ohos.permission.SECURE_PASTE" -// }, { "name": "ohos.permission.CUSTOM_SANDBOX" }, -// { -// "name": "ohos.permission.MANAGE_USER_IDM" -// }, -// { -// "name": "ohos.permission.ACCESS_PIN_AUTH" -// }, -// { -// "name": "ohos.permission.ACCESS_USER_AUTH_INTERNAL" -// }, -// { -// "name": "ohos.permission.DUMP" -// }, -// { -// "name": "ohos.permission.READ_DIAGNOSTIC_LOGS" -// }, -// { -// "name": "ohos.permission.READ_DFX_SYSEVENT" -// }, -// { -// "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" -// }, { "name": "ohos.permission.READ_CALENDAR", "reason": "$string:module_desc", diff --git a/src/apps/vcoder/entry/src/main/resources/base/element/string.json b/src/apps/vcoder/entry/src/main/resources/base/element/string.json index f94595515..fafc54ff3 100644 --- a/src/apps/vcoder/entry/src/main/resources/base/element/string.json +++ b/src/apps/vcoder/entry/src/main/resources/base/element/string.json @@ -1,16 +1,15 @@ { - "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "label" - } - ] + "string": [{ + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Bitfun" + } + ] } \ No newline at end of file diff --git a/src/crates/core/src/service/terminal/src/shell/detection.rs b/src/crates/core/src/service/terminal/src/shell/detection.rs index ac550bf79..e1dbd09ae 100644 --- a/src/crates/core/src/service/terminal/src/shell/detection.rs +++ b/src/crates/core/src/service/terminal/src/shell/detection.rs @@ -82,14 +82,22 @@ impl ShellDetector { #[cfg(not(windows))] { - if let Some(bash_path) = Self::find_bash_with_which() { + if let Some(zsh_path) = Self::find_zsh_with_which() { + return DetectedShell { + shell_type: ShellType::Zsh, + path: zsh_path.clone(), + version: Self::get_shell_version(zsh_path.to_str().unwrap_or_default()), + display_name: "zsh".to_string(), + }; + } else if let Some(bash_path) = Self::find_bash_with_which() { return DetectedShell { shell_type: ShellType::Bash, path: bash_path.clone(), version: Self::get_shell_version(bash_path.to_str().unwrap_or_default()), display_name: "bash".to_string(), }; - } else { + } + { log::error!("bash not found"); } // Try to use $SHELL environment variable @@ -313,6 +321,35 @@ impl ShellDetector { None } + #[cfg(not(windows))] + fn find_zsh_with_which() -> Option { + let output = std::process::Command::new("which").arg("zsh").output(); + match output { + Ok(output) => { + if output.status.success() { + let path_str = String::from_utf8_lossy(&output.stdout).trim().to_string(); + if !path_str.is_empty() { + let path = PathBuf::from(path_str); + if path.exists() { + return Some(path); + } else { + log::warn!("zsh path not exist"); + } + } else { + log::warn!("zsh not exist"); + } + } else { + let stderr = String::from_utf8_lossy(&output.stderr); + log::error!("which zsh error: {}", stderr.trim()); + } + } + Err(e) => { + log::error!("which zsh error: {}", e); + } + }; + None + } + #[cfg(not(windows))] fn find_bash_with_which() -> Option { let output = std::process::Command::new("which").arg("bash").output(); diff --git a/src/crates/core/src/service/terminal/src/shell/scripts/shellIntegration-rc.zsh b/src/crates/core/src/service/terminal/src/shell/scripts/shellIntegration-rc.zsh index 871a0dbd7..99b13327d 100644 --- a/src/crates/core/src/service/terminal/src/shell/scripts/shellIntegration-rc.zsh +++ b/src/crates/core/src/service/terminal/src/shell/scripts/shellIntegration-rc.zsh @@ -1,7 +1,33 @@ # --------------------------------------------------------------------------------------------- # Shell Integration for Zsh # --------------------------------------------------------------------------------------------- -builtin autoload -Uz add-zsh-hook is-at-least + +add-zsh-hook() { + local hook_name= "$1" + local func_name= "$2" + local -a hook_array + + case "${hook_name}" in + precmd) + hook_array=("${(@)precmd_functions[@]}") + precmd_functions+=("${func_name}") + ;; + preexec) + preexec_functions+=("${func_name}") + ;; + *) + return 1 + ;; + esac +} + +if ! builtin type is-at-least >/dev/null 2>&1; then + is-at-least() { + local required="$1" + local current="${ZSH_VERSION}" + [[ "${current}" == $(echo -e "${required}\n${current}" sort -V | head -n1) ]] + } +fi # Prevent the script recursing when setting up if [ -n "$TERMINAL_SHELL_INTEGRATION" ]; then diff --git a/src/web-ui/src/infrastructure/config/components/BasicsConfig.tsx b/src/web-ui/src/infrastructure/config/components/BasicsConfig.tsx index d0d72156d..e6e30c4e7 100644 --- a/src/web-ui/src/infrastructure/config/components/BasicsConfig.tsx +++ b/src/web-ui/src/infrastructure/config/components/BasicsConfig.tsx @@ -267,7 +267,7 @@ function BasicsLoggingSection() { if (!runtimeInfo?.sessionLogDir) return ''; return runtimeInfo.sessionLogDir.replace( '/data/storage/el2/base/files/bitfun', - '/storage/Users/currentUser/appdata/el2/base/com.huawei.bitfunide/files/bitfun' + '/storage/Users/currentUser/appdata/el2/base/com.huawei.BitFun/files/bitfun' ); }, [runtimeInfo?.sessionLogDir]);