fix: Microsoft Windows
This commit is contained in:
@ -2,6 +2,7 @@ use log;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
use tokio::fs;
|
||||||
|
|
||||||
use crate::pkg::{Package, PkgKey};
|
use crate::pkg::{Package, PkgKey};
|
||||||
use crate::pkg_store::InstallResult;
|
use crate::pkg_store::InstallResult;
|
||||||
@ -140,9 +141,25 @@ pub async fn init_profile(
|
|||||||
new_profile.save().await;
|
new_profile.save().await;
|
||||||
appd.profile = Some(new_profile.clone());
|
appd.profile = Some(new_profile.clone());
|
||||||
|
|
||||||
|
fs::create_dir(new_profile.dir()).await
|
||||||
|
.map_err(|e| format!("Unable to create profile directory: {}", e))?;
|
||||||
|
|
||||||
Ok(new_profile)
|
Ok(new_profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn profile_dir(
|
||||||
|
state: State<'_, Mutex<AppData>>
|
||||||
|
) -> Result<PathBuf, &str> {
|
||||||
|
let appd = state.lock().await;
|
||||||
|
|
||||||
|
if let Some(p) = &appd.profile {
|
||||||
|
Ok(p.dir())
|
||||||
|
} else {
|
||||||
|
Err("No profile loaded")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn set_cfg(
|
pub async fn set_cfg(
|
||||||
state: State<'_, Mutex<AppData>>,
|
state: State<'_, Mutex<AppData>>,
|
||||||
|
@ -106,6 +106,7 @@ pub async fn run(_args: Vec<String>) {
|
|||||||
cmd::get_current_profile,
|
cmd::get_current_profile,
|
||||||
cmd::init_profile,
|
cmd::init_profile,
|
||||||
cmd::save_profile,
|
cmd::save_profile,
|
||||||
|
cmd::profile_dir,
|
||||||
cmd::startline,
|
cmd::startline,
|
||||||
cmd::kill,
|
cmd::kill,
|
||||||
cmd::set_cfg,
|
cmd::set_cfg,
|
||||||
|
@ -7,7 +7,7 @@ use crate::profile::Profile;
|
|||||||
use crate::util;
|
use crate::util;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
static CREATE_NO_WINDOW: i32 = 0x08000000;
|
static CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||||
|
|
||||||
pub fn start(p: &Profile, app: AppHandle) -> Result<()> {
|
pub fn start(p: &Profile, app: AppHandle) -> Result<()> {
|
||||||
use tokio::task::JoinSet;
|
use tokio::task::JoinSet;
|
||||||
|
@ -5,8 +5,9 @@ import InputNumber from 'primevue/inputnumber';
|
|||||||
import InputText from 'primevue/inputtext';
|
import InputText from 'primevue/inputtext';
|
||||||
import RadioButton from 'primevue/radiobutton';
|
import RadioButton from 'primevue/radiobutton';
|
||||||
import Toggle from 'primevue/toggleswitch';
|
import Toggle from 'primevue/toggleswitch';
|
||||||
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
import * as path from '@tauri-apps/api/path';
|
import * as path from '@tauri-apps/api/path';
|
||||||
import { readTextFile, writeTextFile } from '@tauri-apps/plugin-fs';
|
import { mkdir, readTextFile, writeTextFile } from '@tauri-apps/plugin-fs';
|
||||||
import { usePkgStore } from '../stores';
|
import { usePkgStore } from '../stores';
|
||||||
|
|
||||||
const store = usePkgStore();
|
const store = usePkgStore();
|
||||||
@ -28,18 +29,19 @@ const cfgAime = _cfg('aime', false);
|
|||||||
|
|
||||||
const aimeCode = ref('');
|
const aimeCode = ref('');
|
||||||
// temp
|
// temp
|
||||||
|
let profilePath = '';
|
||||||
let aimePath = '';
|
let aimePath = '';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
aimePath = await path.join(
|
profilePath = await invoke('profile_dir');
|
||||||
await path.dataDir(),
|
try {
|
||||||
'startliner/profile-ongeki-default/aime.txt'
|
aimePath = await path.join(profilePath, 'aime.txt');
|
||||||
);
|
aimeCode.value = await readTextFile(aimePath);
|
||||||
aimeCode.value = await readTextFile(aimePath);
|
} catch (_) {
|
||||||
|
aimeCode.value = '';
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
path.homeDir().then(console.log);
|
|
||||||
|
|
||||||
const aimeCodeModel = computed({
|
const aimeCodeModel = computed({
|
||||||
get() {
|
get() {
|
||||||
return aimeCode.value;
|
return aimeCode.value;
|
||||||
@ -47,6 +49,7 @@ const aimeCodeModel = computed({
|
|||||||
async set(value: string) {
|
async set(value: string) {
|
||||||
aimeCode.value = value;
|
aimeCode.value = value;
|
||||||
if (value.match(/^[0-9]{20}$/)) {
|
if (value.match(/^[0-9]{20}$/)) {
|
||||||
|
await mkdir(profilePath);
|
||||||
await writeTextFile(aimePath, aimeCode.value);
|
await writeTextFile(aimePath, aimeCode.value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user