mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 23:39:47 +00:00
Some checks are pending
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (linux-arm64) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
46 lines
1.3 KiB
Rust
46 lines
1.3 KiB
Rust
use std::sync::OnceLock;
|
|
use rocket::get;
|
|
use sys_locale::get_locale;
|
|
use crate::api_token::APIToken;
|
|
|
|
/// The data directory where the application stores its data.
|
|
pub static DATA_DIRECTORY: OnceLock<String> = OnceLock::new();
|
|
|
|
/// The config directory where the application stores its configuration.
|
|
pub static CONFIG_DIRECTORY: OnceLock<String> = OnceLock::new();
|
|
|
|
/// Returns the config directory.
|
|
#[get("/system/directories/config")]
|
|
pub fn get_config_directory(_token: APIToken) -> String {
|
|
match CONFIG_DIRECTORY.get() {
|
|
Some(config_directory) => config_directory.clone(),
|
|
None => String::from(""),
|
|
}
|
|
}
|
|
|
|
/// Returns the data directory.
|
|
#[get("/system/directories/data")]
|
|
pub fn get_data_directory(_token: APIToken) -> String {
|
|
match DATA_DIRECTORY.get() {
|
|
Some(data_directory) => data_directory.clone(),
|
|
None => String::from(""),
|
|
}
|
|
}
|
|
|
|
/// Returns true if the application is running in development mode.
|
|
pub fn is_dev() -> bool {
|
|
cfg!(debug_assertions)
|
|
}
|
|
|
|
/// Returns true if the application is running in production mode.
|
|
pub fn is_prod() -> bool {
|
|
!is_dev()
|
|
}
|
|
|
|
#[get("/system/language")]
|
|
pub fn read_user_language(_token: APIToken) -> String {
|
|
get_locale().unwrap_or_else(|| {
|
|
log::warn!("Could not determine the system language. Use default 'en-US'.");
|
|
String::from("en-US")
|
|
})
|
|
} |