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