feat: use sets etc.
This commit is contained in:
@ -7,7 +7,7 @@ import RadioButton from 'primevue/radiobutton';
|
||||
import Toggle from 'primevue/toggleswitch';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import * as path from '@tauri-apps/api/path';
|
||||
import { mkdir, readTextFile, writeTextFile } from '@tauri-apps/plugin-fs';
|
||||
import { readTextFile, writeTextFile } from '@tauri-apps/plugin-fs';
|
||||
import { usePkgStore } from '../stores';
|
||||
|
||||
const store = usePkgStore();
|
||||
@ -28,16 +28,13 @@ const cfgDisplayMode = _cfg('display-mode', 'borderless');
|
||||
const cfgAime = _cfg('aime', false);
|
||||
|
||||
const aimeCode = ref('');
|
||||
// temp
|
||||
let profilePath = '';
|
||||
let aimePath = '';
|
||||
|
||||
(async () => {
|
||||
profilePath = await invoke('profile_dir');
|
||||
try {
|
||||
aimePath = await path.join(profilePath, 'aime.txt');
|
||||
aimeCode.value = await readTextFile(aimePath);
|
||||
} catch (_) {
|
||||
aimeCode.value = await invoke('read_profile_data', {
|
||||
path: 'aime.txt',
|
||||
});
|
||||
} catch (e) {
|
||||
aimeCode.value = '';
|
||||
}
|
||||
})();
|
||||
@ -49,8 +46,10 @@ const aimeCodeModel = computed({
|
||||
async set(value: string) {
|
||||
aimeCode.value = value;
|
||||
if (value.match(/^[0-9]{20}$/)) {
|
||||
await mkdir(profilePath);
|
||||
await writeTextFile(aimePath, aimeCode.value);
|
||||
await invoke('write_profile_data', {
|
||||
path: 'aime.txt',
|
||||
content: aimeCode.value,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user