添加显示图片和视频功能
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||
use std::fs;
|
||||
use tauri::menu::{MenuBuilder, MenuItemBuilder, SubmenuBuilder};
|
||||
use tauri::Emitter;
|
||||
use tauri::{Emitter, Manager};
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
@@ -43,8 +43,12 @@ fn pick_folder(app: tauri::AppHandle) -> Option<String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn read_dir(path: String) -> Result<Vec<DirEntry>, String> {
|
||||
fn read_dir(app: tauri::AppHandle, path: String) -> Result<Vec<DirEntry>, String> {
|
||||
let entries = fs::read_dir(&path).map_err(|e| format!("无法读取目录: {}", e))?;
|
||||
app.asset_protocol_scope()
|
||||
.allow_directory(&path, true)
|
||||
.map_err(|e| format!("无法授权媒体预览目录: {}", e))?;
|
||||
|
||||
let allowed_extensions = [
|
||||
"md", "png", "jpg", "jpeg", "gif", "webp", "avif", "mp4", "webm", "mov", "m4v", "ogv",
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user