mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
@@ -20,3 +20,6 @@ pub fn reopen_as_admin() {
|
|||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn reopen_as_admin() {}
|
pub fn reopen_as_admin() {}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
pub fn reopen_as_admin() {}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub struct Configuration {
|
|||||||
pub last_ip: Option<String>,
|
pub last_ip: Option<String>,
|
||||||
pub last_port: Option<String>,
|
pub last_port: Option<String>,
|
||||||
pub language: Option<String>,
|
pub language: Option<String>,
|
||||||
pub customBackground: Option<String>,
|
pub custom_background: Option<String>,
|
||||||
pub cert_generated: Option<bool>,
|
pub cert_generated: Option<bool>,
|
||||||
pub theme: Option<String>,
|
pub theme: Option<String>,
|
||||||
pub https_enabled: Option<bool>,
|
pub https_enabled: Option<bool>,
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ fn restart_grasscutter(window: tauri::Window) -> bool {
|
|||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn restart_grasscutter(window: tauri::Window) {
|
fn restart_grasscutter(_window: tauri::Window) {
|
||||||
// Placeholder text for imports
|
// Placeholder text for imports
|
||||||
let s = System::new();
|
let s = System::new();
|
||||||
if let Some(process) = s.process(Pid::from(1337)) {
|
if let Some(process) = s.process(Pid::from(1337)) {
|
||||||
@@ -412,8 +412,9 @@ fn enable_grasscutter_watcher(window: tauri::Window, process: String) {
|
|||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn enable_grasscutter_watcher(window: tauri::Window, process: String) {
|
fn enable_grasscutter_watcher(_window: tauri::Window, _process: String) {
|
||||||
let gc_pid = Pid::from(696969);
|
let gc_pid = Pid::from(696969);
|
||||||
|
*GC_PID.lock().unwrap() = gc_pid.into();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ pub fn service_status(service: String) -> bool {
|
|||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn service_status(service: String) {}
|
pub fn service_status(_service: String) {}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -270,8 +270,8 @@ pub fn start_service(service: String) -> bool {
|
|||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn start_service(service: String) {
|
pub fn start_service(_service: String) {
|
||||||
let started = OsStr::new("Started service!");
|
let _started = OsStr::new("Started service!");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@@ -295,7 +295,7 @@ pub fn stop_service(service: String) -> bool {
|
|||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn stop_service(service: String) {}
|
pub fn stop_service(_service: String) {}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class App extends React.Component<Readonly<unknown>, IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get custom bg AFTER theme is loaded !! important !!
|
// Get custom bg AFTER theme is loaded !! important !!
|
||||||
const custom_bg = await getConfigOption('customBackground')
|
const custom_bg = await getConfigOption('custom_background')
|
||||||
|
|
||||||
if (custom_bg) {
|
if (custom_bg) {
|
||||||
const isUrl = /^http(s)?:\/\//gm.test(custom_bg)
|
const isUrl = /^http(s)?:\/\//gm.test(custom_bg)
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
grasscutter_with_game: config.grasscutter_with_game || false,
|
grasscutter_with_game: config.grasscutter_with_game || false,
|
||||||
language_options: languages,
|
language_options: languages,
|
||||||
current_language: config.language || 'en',
|
current_language: config.language || 'en',
|
||||||
bg_url_or_path: config.customBackground || '',
|
bg_url_or_path: config.custom_background || '',
|
||||||
themes: (await getThemeList()).map((t) => t.name),
|
themes: (await getThemeList()).map((t) => t.name),
|
||||||
theme: config.theme || 'default',
|
theme: config.theme || 'default',
|
||||||
encryption: encEnabled || false,
|
encryption: encEnabled || false,
|
||||||
@@ -231,13 +231,13 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
async setCustomBackground(value: string) {
|
async setCustomBackground(value: string) {
|
||||||
const isUrl = /^(?:http(s)?:\/\/)/gm.test(value)
|
const isUrl = /^(?:http(s)?:\/\/)/gm.test(value)
|
||||||
|
|
||||||
if (!value) return await setConfigOption('customBackground', '')
|
if (!value) return await setConfigOption('custom_background', '')
|
||||||
|
|
||||||
if (!isUrl) {
|
if (!isUrl) {
|
||||||
const filename = value.replace(/\\/g, '/').split('/').pop()
|
const filename = value.replace(/\\/g, '/').split('/').pop()
|
||||||
const localBgPath = ((await dataDir()) as string).replace(/\\/g, '/')
|
const localBgPath = ((await dataDir()) as string).replace(/\\/g, '/')
|
||||||
|
|
||||||
await setConfigOption('customBackground', `${localBgPath}/cultivation/bg/${filename}`)
|
await setConfigOption('custom_background', `${localBgPath}/cultivation/bg/${filename}`)
|
||||||
|
|
||||||
// Copy the file over to the local directory
|
// Copy the file over to the local directory
|
||||||
await invoke('copy_file', {
|
await invoke('copy_file', {
|
||||||
@@ -247,7 +247,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
|
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
} else {
|
} else {
|
||||||
await setConfigOption('customBackground', value)
|
await setConfigOption('custom_background', value)
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -541,7 +541,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
readonly={false}
|
readonly={false}
|
||||||
clearable={true}
|
clearable={true}
|
||||||
customClearBehaviour={async () => {
|
customClearBehaviour={async () => {
|
||||||
await setConfigOption('customBackground', '')
|
await setConfigOption('custom_background', '')
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ let defaultConfig: Configuration
|
|||||||
last_ip: 'localhost',
|
last_ip: 'localhost',
|
||||||
last_port: '443',
|
last_port: '443',
|
||||||
language: 'en',
|
language: 'en',
|
||||||
customBackground: '',
|
custom_background: '',
|
||||||
cert_generated: false,
|
cert_generated: false,
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
https_enabled: false,
|
https_enabled: false,
|
||||||
@@ -43,7 +43,7 @@ export interface Configuration {
|
|||||||
last_ip: string
|
last_ip: string
|
||||||
last_port: string
|
last_port: string
|
||||||
language: string
|
language: string
|
||||||
customBackground: string
|
custom_background: string
|
||||||
cert_generated: boolean
|
cert_generated: boolean
|
||||||
theme: string
|
theme: string
|
||||||
https_enabled: boolean
|
https_enabled: boolean
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ export async function loadTheme(theme: ThemeList, document: Document) {
|
|||||||
// Set custom background
|
// Set custom background
|
||||||
if (theme.customBackgroundURL) {
|
if (theme.customBackgroundURL) {
|
||||||
// If the custom bg is already set don't overwrite
|
// If the custom bg is already set don't overwrite
|
||||||
if (config.customBackground === '') {
|
if (config.custom_background === '') {
|
||||||
config.customBackground = theme.customBackgroundURL
|
config.custom_background = theme.customBackgroundURL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,13 +130,13 @@ export async function loadTheme(theme: ThemeList, document: Document) {
|
|||||||
|
|
||||||
// Set the background
|
// Set the background
|
||||||
// If the custom bg is already set don't overwrite
|
// If the custom bg is already set don't overwrite
|
||||||
if (config.customBackground === '') {
|
if (config.custom_background === '') {
|
||||||
config.customBackground = bgPath + imageName
|
config.custom_background = bgPath + imageName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write config
|
// Write config
|
||||||
await setConfigOption('customBackground', config.customBackground)
|
await setConfigOption('custom_background', config.custom_background)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user