mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
feat: switch origin
This commit is contained in:
@@ -33,3 +33,30 @@ pub fn open_link(app: AppHandle, url: String) {
|
||||
pub fn get_chat_conf() -> ChatConfJson {
|
||||
ChatConfJson::get_chat_conf()
|
||||
}
|
||||
|
||||
#[command]
|
||||
pub fn form_confirm(app: AppHandle, data: serde_json::Value) {
|
||||
ChatConfJson::amend(&serde_json::json!(data)).unwrap();
|
||||
tauri::api::process::restart(&app.env());
|
||||
}
|
||||
|
||||
#[command]
|
||||
pub fn form_cancel(app: AppHandle, label: &str, title: &str, msg: &str) {
|
||||
let win = app.app_handle().get_window(label).unwrap();
|
||||
tauri::api::dialog::ask(
|
||||
app.app_handle().get_window(label).as_ref(),
|
||||
title,
|
||||
msg,
|
||||
move |is_cancel| {
|
||||
if is_cancel {
|
||||
win.close().unwrap();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
#[command]
|
||||
pub fn form_msg(app: AppHandle, label: &str, title: &str, msg: &str) {
|
||||
let win = app.app_handle().get_window(label);
|
||||
tauri::api::dialog::message(win.as_ref(), title, msg);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ use tauri::{
|
||||
use tauri_plugin_positioner::{on_tray_event, Position, WindowExt};
|
||||
|
||||
// --- Menu
|
||||
pub fn init(chat_conf: &conf::ChatConfJson, context: &Context<EmbeddedAssets>) -> Menu {
|
||||
pub fn init(context: &Context<EmbeddedAssets>) -> Menu {
|
||||
let chat_conf = ChatConfJson::get_chat_conf();
|
||||
let name = &context.package_info().name;
|
||||
let app_menu = Submenu::new(
|
||||
name,
|
||||
|
||||
@@ -5,10 +5,8 @@ use crate::{
|
||||
};
|
||||
use tauri::{utils::config::WindowUrl, window::WindowBuilder, App, Manager};
|
||||
|
||||
pub fn init(
|
||||
app: &mut App,
|
||||
chat_conf: ChatConfJson,
|
||||
) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||
pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||
let chat_conf = ChatConfJson::get_chat_conf();
|
||||
let url = chat_conf.origin.to_string();
|
||||
let theme = ChatConfJson::theme();
|
||||
window::mini_window(&app.app_handle());
|
||||
|
||||
@@ -25,14 +25,17 @@ pub fn mini_window(handle: &tauri::AppHandle) {
|
||||
}
|
||||
|
||||
pub fn origin_window(handle: &tauri::AppHandle) {
|
||||
let theme = conf::ChatConfJson::theme();
|
||||
|
||||
WindowBuilder::new(handle, "main", WindowUrl::External("/".parse().unwrap()))
|
||||
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
||||
// tauri://localhost/origin
|
||||
// let url = chat_conf.origin;
|
||||
WindowBuilder::new(handle, "origin", WindowUrl::App(chat_conf.origin.into()))
|
||||
.resizable(false)
|
||||
.fullscreen(false)
|
||||
.inner_size(400.0, 300.0)
|
||||
.always_on_top(true)
|
||||
.theme(theme)
|
||||
.decorations(false)
|
||||
.initialization_script(include_str!("../assets/core.js"))
|
||||
.initialization_script(include_str!("../assets/origin.js"))
|
||||
.build()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user