mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Merge branch 'sxyazi:main' into main
This commit is contained in:
commit
7118180050
3 changed files with 13 additions and 0 deletions
|
|
@ -23,3 +23,7 @@ tokio = { version = "^1", features = [ "parking_lot" ] }
|
||||||
tracing = "^0"
|
tracing = "^0"
|
||||||
tracing-appender = "^0"
|
tracing-appender = "^0"
|
||||||
tracing-subscriber = "^0"
|
tracing-subscriber = "^0"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "yazi"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ impl Preview {
|
||||||
|
|
||||||
self.handle = Some(tokio::spawn(async move {
|
self.handle = Some(tokio::spawn(async move {
|
||||||
let result = match kind {
|
let result = match kind {
|
||||||
|
MimeKind::Empty => Ok(PreviewData::None),
|
||||||
MimeKind::Archive => Self::archive(&path).await.map(PreviewData::Text),
|
MimeKind::Archive => Self::archive(&path).await.map(PreviewData::Text),
|
||||||
MimeKind::Dir => Self::folder(&path).await,
|
MimeKind::Dir => Self::folder(&path).await,
|
||||||
MimeKind::Image => Self::image(&path).await,
|
MimeKind::Image => Self::image(&path).await,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ pub const MIME_DIR: &str = "inode/directory";
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum MimeKind {
|
pub enum MimeKind {
|
||||||
|
Empty,
|
||||||
|
|
||||||
Archive,
|
Archive,
|
||||||
Dir,
|
Dir,
|
||||||
|
|
||||||
|
|
@ -17,6 +19,10 @@ pub enum MimeKind {
|
||||||
|
|
||||||
impl MimeKind {
|
impl MimeKind {
|
||||||
pub fn valid(s: &str) -> bool {
|
pub fn valid(s: &str) -> bool {
|
||||||
|
if s == "inode/x-empty" {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
let parts = s.split('/').collect::<Vec<_>>();
|
let parts = s.split('/').collect::<Vec<_>>();
|
||||||
if parts.len() != 2 {
|
if parts.len() != 2 {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -47,6 +53,8 @@ impl MimeKind {
|
||||||
Self::Image
|
Self::Image
|
||||||
} else if s.starts_with("video/") {
|
} else if s.starts_with("video/") {
|
||||||
Self::Video
|
Self::Video
|
||||||
|
} else if s == "inode/x-empty" {
|
||||||
|
Self::Empty
|
||||||
} else if s == "application/json" {
|
} else if s == "application/json" {
|
||||||
Self::JSON
|
Self::JSON
|
||||||
} else if s == "application/pdf" {
|
} else if s == "application/pdf" {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue