chore: factory reset works
This commit is contained in:
parent
24b8a1b66a
commit
9079067332
2
.gitignore
vendored
2
.gitignore
vendored
@ -51,3 +51,5 @@ electron/shared/**
|
||||
# docs
|
||||
docs/yarn.lock
|
||||
electron/.version.bak
|
||||
src-tauri/binaries/engines/cortex.llamacpp
|
||||
src-tauri/resources/themes
|
||||
|
||||
@ -4,7 +4,7 @@ use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use tar::Archive;
|
||||
use tauri::AppHandle;
|
||||
use tauri::{process, AppHandle};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
@ -150,6 +150,11 @@ pub fn default_data_folder_path(app_handle: tauri::AppHandle) -> String {
|
||||
.to_string();
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn relaunch(app: AppHandle) {
|
||||
app.restart()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_active_extensions(app: AppHandle) -> Vec<serde_json::Value> {
|
||||
let mut path = get_jan_extensions_path(app);
|
||||
|
||||
@ -61,6 +61,7 @@ pub fn run() {
|
||||
handlers::cmd::update_app_configuration,
|
||||
handlers::cmd::get_jan_data_folder_path,
|
||||
handlers::cmd::get_jan_extensions_path,
|
||||
handlers::cmd::relaunch,
|
||||
app_token,
|
||||
])
|
||||
.manage(AppState {
|
||||
|
||||
@ -39,18 +39,16 @@ export default function useFactoryReset() {
|
||||
await stopModel()
|
||||
|
||||
await Promise.all(
|
||||
EngineManager.instance()
|
||||
.engines.values()
|
||||
.map(async (engine) => {
|
||||
await engine.onUnload()
|
||||
})
|
||||
Object.values(EngineManager.instance().engines).map(async (engine) => {
|
||||
await engine.onUnload()
|
||||
})
|
||||
)
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 4000))
|
||||
|
||||
// 2: Delete the old jan data folder
|
||||
setFactoryResetState(FactoryResetState.DeletingData)
|
||||
await fs.rm(janDataFolderPath)
|
||||
await fs.rm({ args: [janDataFolderPath] })
|
||||
|
||||
// 3: Set the default jan data folder
|
||||
if (!keepCurrentFolder) {
|
||||
@ -64,16 +62,15 @@ export default function useFactoryReset() {
|
||||
}
|
||||
|
||||
// Perform factory reset
|
||||
await window.core?.api?.factoryReset()
|
||||
// await window.core?.api?.factoryReset()
|
||||
|
||||
// 4: Clear app local storage
|
||||
setFactoryResetState(FactoryResetState.ClearLocalStorage)
|
||||
// reset the localStorage
|
||||
localStorage.clear()
|
||||
|
||||
window.core = undefined
|
||||
// 5: Relaunch the app
|
||||
window.location.reload()
|
||||
window.core.api.relaunch()
|
||||
},
|
||||
[defaultJanDataFolder, stopModel, setFactoryResetState]
|
||||
)
|
||||
|
||||
@ -51,8 +51,10 @@ export const useLoadTheme = () => {
|
||||
|
||||
const themesOptions: { name: string; value: string }[] =
|
||||
installedThemes.map((x: string) => ({
|
||||
name: x.replace(/-/g, ' ').replace(/\b\w/g, (char) => char.toUpperCase()),
|
||||
value: x,
|
||||
name: x
|
||||
.replace(/-/g, ' ')
|
||||
.replace(/\b\w/g, (char) => char.toUpperCase()),
|
||||
value: x,
|
||||
}))
|
||||
setThemeOptions(themesOptions)
|
||||
|
||||
|
||||
@ -56,11 +56,6 @@ export default function AppearanceOptions() {
|
||||
const theme: Theme = JSON.parse(await fs.readFileSync(filePath, 'utf-8'))
|
||||
setThemeData(theme)
|
||||
setTheme(String(theme?.nativeTheme))
|
||||
if (theme?.reduceTransparent) {
|
||||
setReduceTransparent(reduceTransparent)
|
||||
} else {
|
||||
setReduceTransparent(true)
|
||||
}
|
||||
},
|
||||
[
|
||||
janDataFolderPath,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user