mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 15:46:39 +08:00
删除多余
This commit is contained in:
parent
b9e6dce193
commit
97099849b7
1
.gitignore
vendored
1
.gitignore
vendored
@ -46,3 +46,4 @@ dev
|
||||
*.key.pub
|
||||
|
||||
masks.json
|
||||
package-lock.json
|
11838
package-lock.json
generated
11838
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,35 +1,12 @@
|
||||
use tauri_specta::Event;
|
||||
|
||||
// demo command
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
fn greet(app: tauri::AppHandle, name: &str) -> String {
|
||||
DemoEvent("Demo event fired from Rust 🦀".to_string())
|
||||
.emit(&app)
|
||||
.ok();
|
||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||
}
|
||||
|
||||
// demo event
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, specta::Type, Event)]
|
||||
pub struct DemoEvent(String);
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
log::info!("App started!");
|
||||
log::warn!("Example Rust Log: warning!");
|
||||
log::error!("Example Rust Log: error!");
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
let devtools = tauri_plugin_devtools::init();
|
||||
let mut builder = tauri::Builder::default();
|
||||
|
||||
let specta_builder = tauri_specta::Builder::<tauri::Wry>::new()
|
||||
.commands(tauri_specta::collect_commands![greet])
|
||||
.events(tauri_specta::collect_events![crate::DemoEvent]);
|
||||
let specta_builder = tauri_specta::Builder::<tauri::Wry>::new();
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
@ -47,21 +24,10 @@ pub fn run() {
|
||||
|
||||
builder
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
// .plugin(tauri_plugin_updater::Builder::new().build())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.invoke_handler(specta_builder.invoke_handler())
|
||||
.setup(move |app| {
|
||||
specta_builder.mount_events(app);
|
||||
|
||||
// listen to demo event
|
||||
DemoEvent::listen(app, |event| {
|
||||
log::info!("DemoEvent received in Rust:: {:?}", event.payload);
|
||||
});
|
||||
|
||||
// dispatch demo event
|
||||
DemoEvent("Hello from Rust 🦀".to_string()).emit(app).ok();
|
||||
// /dispatch demo event
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
|
@ -1,16 +1,4 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
// #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
// fn main() {
|
||||
// tauri::Builder::default()
|
||||
// .plugin(tauri_plugin_window_state::Builder::default().build())
|
||||
// .run(tauri::generate_context!())
|
||||
// .expect("error while running tauri application");
|
||||
// }
|
||||
|
||||
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
nextchat::run()
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
|
||||
"productName": "NextChat",
|
||||
"identifier": "NextChat.template.dev",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.yida.chatgpt.next.web",
|
||||
"version": "2.15.4",
|
||||
"build": {
|
||||
"beforeBuildCommand": "yarn export",
|
||||
"beforeDevCommand": "yarn export:dev",
|
||||
@ -13,7 +13,7 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "quantum",
|
||||
"title": "NextChat",
|
||||
"width": 800,
|
||||
"height": 600
|
||||
}
|
||||
@ -21,7 +21,7 @@
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
"withGlobalTauri": false
|
||||
"withGlobalTauri": true
|
||||
},
|
||||
"bundle": {
|
||||
"macOS": {
|
||||
|
71
src/bindings.ts
Normal file
71
src/bindings.ts
Normal file
@ -0,0 +1,71 @@
|
||||
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
|
||||
|
||||
/** user-defined commands **/
|
||||
|
||||
export const commands = {};
|
||||
|
||||
/** user-defined events **/
|
||||
|
||||
/** user-defined constants **/
|
||||
|
||||
/** user-defined types **/
|
||||
|
||||
/** tauri-specta globals **/
|
||||
|
||||
import {
|
||||
invoke as TAURI_INVOKE,
|
||||
Channel as TAURI_CHANNEL,
|
||||
} from "@tauri-apps/api/core";
|
||||
import * as TAURI_API_EVENT from "@tauri-apps/api/event";
|
||||
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";
|
||||
|
||||
type __EventObj__<T> = {
|
||||
listen: (
|
||||
cb: TAURI_API_EVENT.EventCallback<T>,
|
||||
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
|
||||
once: (
|
||||
cb: TAURI_API_EVENT.EventCallback<T>,
|
||||
) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
|
||||
emit: T extends null
|
||||
? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
|
||||
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
|
||||
};
|
||||
|
||||
export type Result<T, E> =
|
||||
| { status: "ok"; data: T }
|
||||
| { status: "error"; error: E };
|
||||
|
||||
function __makeEvents__<T extends Record<string, any>>(
|
||||
mappings: Record<keyof T, string>,
|
||||
) {
|
||||
return new Proxy(
|
||||
{} as unknown as {
|
||||
[K in keyof T]: __EventObj__<T[K]> & {
|
||||
(handle: __WebviewWindow__): __EventObj__<T[K]>;
|
||||
};
|
||||
},
|
||||
{
|
||||
get: (_, event) => {
|
||||
const name = mappings[event as keyof T];
|
||||
|
||||
return new Proxy((() => {}) as any, {
|
||||
apply: (_, __, [window]: [__WebviewWindow__]) => ({
|
||||
listen: (arg: any) => window.listen(name, arg),
|
||||
once: (arg: any) => window.once(name, arg),
|
||||
emit: (arg: any) => window.emit(name, arg),
|
||||
}),
|
||||
get: (_, command: keyof __EventObj__<any>) => {
|
||||
switch (command) {
|
||||
case "listen":
|
||||
return (arg: any) => TAURI_API_EVENT.listen(name, arg);
|
||||
case "once":
|
||||
return (arg: any) => TAURI_API_EVENT.once(name, arg);
|
||||
case "emit":
|
||||
return (arg: any) => TAURI_API_EVENT.emit(name, arg);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user