mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-06 08:32:51 +08:00
🔧 参考最新项目修改配置
This commit is contained in:
@@ -9,6 +9,13 @@ edition = "2021"
|
|||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
# The `_lib` suffix may seem redundant but it is necessary
|
||||||
|
# to make the lib name unique and wouldn't conflict with the bin name.
|
||||||
|
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
||||||
|
name = "teyvat_guide_lib"
|
||||||
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.0.6", features = [] }
|
tauri-build = { version = "2.0.6", features = [] }
|
||||||
|
|
||||||
@@ -73,8 +80,3 @@ branch = "v2"
|
|||||||
git = "ssh://git@github.com/tauri-apps/plugins-workspace.git"
|
git = "ssh://git@github.com/tauri-apps/plugins-workspace.git"
|
||||||
branch = "v2"
|
branch = "v2"
|
||||||
features = ["sqlite"]
|
features = ["sqlite"]
|
||||||
|
|
||||||
[features]
|
|
||||||
# this feature is used for production builds or when `devPath` points to the filesystem
|
|
||||||
# DO NOT REMOVE!!
|
|
||||||
custom-protocol = ["tauri/custom-protocol"]
|
|
||||||
|
|||||||
67
src-tauri/src/lib.rs
Normal file
67
src-tauri/src/lib.rs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
//! @file src/lib.rs
|
||||||
|
//! @desc 主模块,用于启动应用
|
||||||
|
//! @since Beta v0.7.2
|
||||||
|
|
||||||
|
mod client;
|
||||||
|
mod commands;
|
||||||
|
mod plugins;
|
||||||
|
mod utils;
|
||||||
|
|
||||||
|
use crate::client::create_mhy_client;
|
||||||
|
use crate::commands::{create_window, execute_js, get_dir_size, init_app};
|
||||||
|
use crate::plugins::{build_log_plugin, build_si_plugin};
|
||||||
|
use tauri::{generate_context, generate_handler, Builder, Manager, Window, WindowEvent};
|
||||||
|
|
||||||
|
// 窗口事件处理
|
||||||
|
fn window_event_handler(app: &Window, event: &WindowEvent) {
|
||||||
|
match event {
|
||||||
|
WindowEvent::CloseRequested { api, .. } => {
|
||||||
|
api.prevent_close();
|
||||||
|
if app.label() == "TeyvatGuide" {
|
||||||
|
// 子窗口 label 的数组
|
||||||
|
const SUB_WINDOW_LABELS: [&str; 3] = ["Sub_window", "Dev_JSON", "mhy_client"];
|
||||||
|
for label in SUB_WINDOW_LABELS.iter() {
|
||||||
|
let sub = app.get_webview_window(label);
|
||||||
|
if sub.is_some() {
|
||||||
|
sub.unwrap().destroy().unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
app.destroy().unwrap();
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
|
pub fn run() {
|
||||||
|
Builder::default()
|
||||||
|
.on_window_event(move |app, event| window_event_handler(app, event))
|
||||||
|
.plugin(build_si_plugin())
|
||||||
|
.plugin(tauri_plugin_deep_link::init())
|
||||||
|
.plugin(tauri_plugin_dialog::init())
|
||||||
|
.plugin(tauri_plugin_fs::init())
|
||||||
|
.plugin(tauri_plugin_http::init())
|
||||||
|
.plugin(tauri_plugin_os::init())
|
||||||
|
.plugin(tauri_plugin_process::init())
|
||||||
|
.plugin(tauri_plugin_shell::init())
|
||||||
|
.plugin(tauri_plugin_sql::Builder::default().build())
|
||||||
|
.plugin(build_log_plugin())
|
||||||
|
.setup(|_app| {
|
||||||
|
let _window = _app.get_webview_window("TeyvatGuide");
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
if _window.is_some() {
|
||||||
|
_window.unwrap().open_devtools();
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.invoke_handler(generate_handler![
|
||||||
|
init_app,
|
||||||
|
create_window,
|
||||||
|
execute_js,
|
||||||
|
get_dir_size,
|
||||||
|
create_mhy_client
|
||||||
|
])
|
||||||
|
.run(generate_context!())
|
||||||
|
.expect("error while running tauri application");
|
||||||
|
}
|
||||||
@@ -1,69 +1,10 @@
|
|||||||
//! @file src/main.rs
|
//! @file src/main.rs
|
||||||
//! @desc 主模块,用于启动应用
|
//! @desc 主模块,用于启动应用
|
||||||
//! @since Beta v0.6.2
|
//! @since Beta v0.7.2
|
||||||
|
|
||||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
mod client;
|
|
||||||
mod commands;
|
|
||||||
mod plugins;
|
|
||||||
mod utils;
|
|
||||||
|
|
||||||
use crate::client::create_mhy_client;
|
|
||||||
use crate::commands::{create_window, execute_js, get_dir_size, init_app};
|
|
||||||
use crate::plugins::{build_log_plugin, build_si_plugin};
|
|
||||||
use tauri::{generate_context, generate_handler, Builder, Manager, Window, WindowEvent};
|
|
||||||
|
|
||||||
// 窗口事件处理
|
|
||||||
fn window_event_handler(app: &Window, event: &WindowEvent) {
|
|
||||||
match event {
|
|
||||||
WindowEvent::CloseRequested { api, .. } => {
|
|
||||||
api.prevent_close();
|
|
||||||
if app.label() == "TeyvatGuide" {
|
|
||||||
// 子窗口 label 的数组
|
|
||||||
const SUB_WINDOW_LABELS: [&str; 3] = ["Sub_window", "Dev_JSON", "mhy_client"];
|
|
||||||
for label in SUB_WINDOW_LABELS.iter() {
|
|
||||||
let sub = app.get_webview_window(label);
|
|
||||||
if sub.is_some() {
|
|
||||||
sub.unwrap().destroy().unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
app.destroy().unwrap();
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
Builder::default()
|
teyvat_guide_lib::run()
|
||||||
.on_window_event(move |app, event| window_event_handler(app, event))
|
|
||||||
.plugin(build_si_plugin())
|
|
||||||
.plugin(tauri_plugin_deep_link::init())
|
|
||||||
.plugin(tauri_plugin_dialog::init())
|
|
||||||
.plugin(tauri_plugin_fs::init())
|
|
||||||
.plugin(tauri_plugin_http::init())
|
|
||||||
.plugin(tauri_plugin_os::init())
|
|
||||||
.plugin(tauri_plugin_process::init())
|
|
||||||
.plugin(tauri_plugin_shell::init())
|
|
||||||
.plugin(tauri_plugin_sql::Builder::default().build())
|
|
||||||
.plugin(build_log_plugin())
|
|
||||||
.setup(|_app| {
|
|
||||||
let _window = _app.get_webview_window("TeyvatGuide");
|
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
if _window.is_some() {
|
|
||||||
_window.unwrap().open_devtools();
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
.invoke_handler(generate_handler![
|
|
||||||
init_app,
|
|
||||||
create_window,
|
|
||||||
execute_js,
|
|
||||||
get_dir_size,
|
|
||||||
create_mhy_client
|
|
||||||
])
|
|
||||||
.run(generate_context!())
|
|
||||||
.expect("error while running tauri application");
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "TeyvatGuide",
|
"productName": "TeyvatGuide",
|
||||||
"identifier": "TeyvatGuide",
|
"identifier": "TeyvatGuide",
|
||||||
"version": "0.7.1",
|
"version": "0.7.1",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file vite.config.ts
|
* @file vite.config.ts
|
||||||
* @description vite 配置文件
|
* @description vite 配置文件
|
||||||
* @since Beta v0.6.5
|
* @since Beta v0.7.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
@@ -11,7 +11,7 @@ import vuetify from "vite-plugin-vuetify";
|
|||||||
|
|
||||||
import buildTimePlugin from "./src/utils/TGBuild.js";
|
import buildTimePlugin from "./src/utils/TGBuild.js";
|
||||||
|
|
||||||
const env: TauriProcessEnv = process.env;
|
const host = process.env.TAURI_DEV_HOST;
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@@ -26,31 +26,13 @@ export default defineConfig({
|
|||||||
"@Bili/": "/src/plugins/Bili/",
|
"@Bili/": "/src/plugins/Bili/",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
clearScreen: false,
|
server: {
|
||||||
server: { port: 4000, strictPort: true },
|
port: 4000,
|
||||||
envPrefix: ["VITE_", "TAURI_"],
|
strictPort: true,
|
||||||
esbuild: { supported: { "top-level-await": true } },
|
host: host || false,
|
||||||
build: {
|
hmr: host ? { protocol: "ws", host, port: 4001 } : undefined,
|
||||||
// Tauri supports es2021
|
watch: { ignored: ["**/src-tauri/**"] },
|
||||||
target: env.TAURI_PLATFORM === "windows" ? "chrome105" : "safari13",
|
|
||||||
// don't minify for debug builds
|
|
||||||
minify: !env.TAURI_DEBUG ? "esbuild" : false,
|
|
||||||
// produce sourcemaps for debug builds
|
|
||||||
sourcemap: !!env.TAURI_DEBUG,
|
|
||||||
// chunk size warning limit, default is 500kB,here set 4096KB which is 4MB
|
|
||||||
chunkSizeWarningLimit: 4096, // KB
|
|
||||||
// rollup options
|
|
||||||
rollupOptions: {
|
|
||||||
// chunking
|
|
||||||
output: {
|
|
||||||
manualChunks(id: string) {
|
|
||||||
// pnpm 依赖包路径格式为 本地路径/node_modules/.pnpm/包名@版本号/node_modules/依赖包名/文件路径
|
|
||||||
if (id.includes("node_modules")) {
|
|
||||||
const arr = id.split("node_modules/");
|
|
||||||
return arr[2].split("/")[0];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
esbuild: { supported: { "top-level-await": true } },
|
||||||
|
build: { chunkSizeWarningLimit: 4096 },
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user