编辑器模块(笔记)初版

This commit is contained in:
zhongluofeng committed 2026-09-30 18:12:53 +08:00
1 parent 7e65825d3e
commit ad987111a3
66 files changed
+17470 -283

No files matched your search

+91 -1
View File
@@ -10,6 +10,7 @@ mod mihomo_manager;
mod monitor_kernel;
pub mod music;
mod network_monitor;
mod notes;
mod osd_window;
mod process_manager;
mod quickpanel;
@@ -37,6 +38,18 @@ use download_engine::{
use logger::{
log_clear, log_info_state, log_list, log_message,
};
use notes::{
notes_add_template, notes_authorize_file, notes_backlinks, notes_backup_now,
notes_create_folder, notes_create_note, notes_daily_note, notes_delete_entry,
notes_export_note, notes_export_snapshot_local, notes_export_zip, notes_get_settings,
notes_import, notes_index_stats, notes_library_info, notes_link_graph, notes_list_backups,
notes_list_notes, notes_list_templates, notes_open_file, notes_read_asset, notes_read_note,
notes_read_template, notes_rebuild_index, notes_rename_entry, notes_restore_backup,
notes_save_note, notes_save_settings, notes_scan_library, notes_search_notes,
notes_set_library_root, notes_set_webdav_password, notes_sync_index, notes_sync_now,
notes_tags, notes_take_pending_file, notes_test_webdav, notes_webdav_status,
notes_write_asset, notes_write_file,
};
use mihomo_manager::{
proxy_activate_profile, proxy_apply_kernel_update, proxy_cancel_kernel_install, proxy_check_kernel_update, proxy_clear_system_proxy,
proxy_close_connection, proxy_confirm_install, proxy_delete_profile, proxy_get_connections, proxy_get_proxies, proxy_get_settings, proxy_get_system_proxy,
@@ -324,6 +337,18 @@ fn export_bindings() {
dsh_unregister_shortcut, dsh_start, dsh_stop, dsh_restart,
dsh_ai_preview, dsh_ai_sync, dsh_log_tail, dsh_install_log, dsh_log_clear,
dsh_open_dir,
// notes(39)——与 `run()` 里那份保持一致,否则 bindings.ts 缺类型
notes_get_settings, notes_save_settings, notes_library_info, notes_set_library_root,
notes_scan_library, notes_read_note, notes_save_note, notes_create_note,
notes_create_folder, notes_rename_entry, notes_delete_entry,
notes_rebuild_index, notes_sync_index, notes_search_notes, notes_list_notes,
notes_tags, notes_index_stats, notes_open_file, notes_write_file,
notes_write_asset, notes_authorize_file,
notes_list_templates, notes_add_template, notes_read_template, notes_daily_note,
notes_import, notes_export_note, notes_export_zip, notes_export_snapshot_local,
notes_webdav_status, notes_set_webdav_password, notes_test_webdav,
notes_sync_now, notes_backup_now, notes_list_backups, notes_restore_backup,
notes_backlinks, notes_link_graph, notes_take_pending_file, notes_read_asset,
])
.export(Typescript::default(), "../src/lib/bindings.ts")
.expect("failed to export bindings");
@@ -343,6 +368,30 @@ pub fn run() {
win32_util::set_app_user_model_id("thing.lfeng.me");
tauri::Builder::default()
// 单实例必须是**第一个**注册的插件:它决定「第二个进程是退出还是把参数转交过来」,
// 排在别的插件后面会让后面的插件在第二个进程里先跑一遍初始化(起两个托盘图标之类)。
//
// # 为什么需要它
//
// 「用 Thing 打开」的文件关联会让 Windows 用 `thing.exe <文件路径>` 启动本应用;
// 应用已在运行时就会冒出第二个进程 —— 没有这个插件,用户双击一个 .md 只会得到
// 一个(或两个)空窗口,而且第二个实例会和第一个抢同一个 sqlite 索引文件。
// 有了它,第二个进程立即退出,命令行参数被转交给第一个实例的下面这个回调。
.plugin(tauri_plugin_single_instance::init(|app, argv, _cwd| {
// 主窗口可能藏在托盘里:先把已有窗口叫出来,再决定开哪个
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
let _ = window.unminimize();
let _ = window.set_focus();
}
match crate::notes::note_path_from_args(argv.clone()) {
Some(path) => crate::notes::emit_open_file(app, &path),
None => {
// 没有文件参数(用户又点了一次快捷方式):只把主窗口叫到前面,别开新窗口
crate::logger::log_info("notes", "第二个实例无文件参数,仅聚焦主窗口");
}
}
}))
.plugin(tauri_plugin_autostart::Builder::new().build())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_dialog::init())
@@ -762,7 +811,48 @@ pub fn run() {
dsh_log_tail,
dsh_install_log,
dsh_log_clear,
dsh_open_dir
dsh_open_dir,
// notes(39)
notes_get_settings,
notes_save_settings,
notes_library_info,
notes_set_library_root,
notes_scan_library,
notes_read_note,
notes_save_note,
notes_create_note,
notes_create_folder,
notes_rename_entry,
notes_delete_entry,
notes_rebuild_index,
notes_sync_index,
notes_search_notes,
notes_list_notes,
notes_tags,
notes_index_stats,
notes_open_file,
notes_write_file,
notes_write_asset,
notes_authorize_file,
notes_list_templates,
notes_add_template,
notes_read_template,
notes_daily_note,
notes_import,
notes_export_note,
notes_export_zip,
notes_export_snapshot_local,
notes_webdav_status,
notes_set_webdav_password,
notes_test_webdav,
notes_sync_now,
notes_backup_now,
notes_list_backups,
notes_restore_backup,
notes_backlinks,
notes_link_graph,
notes_take_pending_file,
notes_read_asset
])
.setup(setup::init)
.on_window_event(|window, event| {