chore: menu sync

This commit is contained in:
lencx
2022-12-23 18:52:56 +08:00
parent e4be2bc2f3
commit 2a9fba7d27
3 changed files with 21 additions and 5 deletions

View File

@@ -17,6 +17,8 @@ use tauri_plugin_log::{
fn main() {
ChatConfJson::init();
// If the file does not exist, creating the file will block menu synchronization
utils::create_chatgpt_prompts();
let chat_conf = ChatConfJson::get_chat_conf();
let context = tauri::generate_context!();
let colors = ColoredLevelConfig {

View File

@@ -30,6 +30,14 @@ pub fn create_file(path: &Path) -> Result<File> {
File::create(path).map_err(Into::into)
}
pub fn create_chatgpt_prompts() {
let sync_file = chat_root().join("cache_model").join("chatgpt_prompts.json");
if !exists(&sync_file) {
create_file(&sync_file).unwrap();
fs::write(&sync_file, "[]").unwrap();
}
}
pub fn script_path() -> PathBuf {
let script_file = chat_root().join("main.js");
if !exists(&script_file) {