diff --git a/src-tauri/src/core/config.rs b/src-tauri/src/core/config.rs index 406563a63..768be391e 100644 --- a/src-tauri/src/core/config.rs +++ b/src-tauri/src/core/config.rs @@ -206,90 +206,6 @@ pub fn get_user_config() -> UserConfig { } } -pub fn load_or_initial() -> Option { - let user_config_path = get_user_config_path(); - - if !user_config_path.exists() { - fs::File::create(&user_config_path).expect("create user config failed"); - } - - let content = match fs::read_to_string(&user_config_path) { - Ok(content) => content, - Err(_) => "".to_string(), - }; - - let mut data = match content.parse::() { - Ok(data) => data, - Err(err) => { - println!("error ==> {:?}", err); - toml::map::Map::new() - } - }; - - if !data.contains_key("customize_style") { - data.insert( - String::from("customize_style"), - toml::Value::try_from::(CustomizeStyle::default()).unwrap(), - ); - } - - if !data.contains_key("threads") { - data.insert( - String::from("threads"), - toml::Value::try_from::(5).unwrap(), - ); - } - - if !data.contains_key("theme") { - data.insert( - String::from("theme"), - toml::Value::try_from::(String::from("system")).unwrap(), - ); - } - - if !data.contains_key("color_scheme") { - data.insert( - String::from("color_scheme"), - toml::Value::try_from::(ColorScheme::System).unwrap(), - ); - } - - if !data.contains_key("update_interval") { - data.insert( - String::from("update_interval"), - toml::Value::try_from::(0).unwrap(), - ); - } - - if !data.contains_key("last_sync_time") { - data.insert( - String::from("last_sync_time"), - toml::Value::try_from::( - Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true), - ) - .unwrap(), - ); - } - - if !data.contains_key("purge_on_days") { - data.insert( - String::from("purge_on_days"), - toml::Value::try_from::(0).unwrap(), - ); - } - - if !data.contains_key("purge_unread_articles") { - data.insert( - String::from("purge_unread_articles"), - toml::Value::try_from::(true).unwrap(), - ); - } - - log::debug!("USER CONFIG: {:?}", data); - - Some(data.try_into::().expect("config data error")) -} - pub fn add_proxy(proxy_cfg: Proxy) -> Result>, String> { let mut data = get_user_config(); let user_config_path = get_user_config_path(); @@ -397,15 +313,3 @@ pub fn update_user_config(cfg: UserConfig) -> String { return content; } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_load_or_initial() { - let res = load_or_initial(); - - println!("test_load_or_initial res {:?}", res); - } -} diff --git a/src/components/ArticleItem/index.tsx b/src/components/ArticleItem/index.tsx index fa49675a2..853c08927 100644 --- a/src/components/ArticleItem/index.tsx +++ b/src/components/ArticleItem/index.tsx @@ -44,7 +44,7 @@ export const ArticleItem = React.forwardRef((props: { article: ArticleResItem }, return (
  • - + {article.author || article.feed_title} diff --git a/src/components/PodcastPlayer/Player.tsx b/src/components/PodcastPlayer/Player.tsx index 18511fc1a..181eddc44 100644 --- a/src/components/PodcastPlayer/Player.tsx +++ b/src/components/PodcastPlayer/Player.tsx @@ -4,6 +4,7 @@ import clsx from "clsx"; import { Pause, Play, SkipBack, SkipForward } from "lucide-react"; import { busChannel } from "@/helpers/busChannel"; import { useBearStore } from "@/stores"; +import { IconButton } from "@radix-ui/themes"; type TimeDisplayProps = { time: { minutes: number; seconds: number }; @@ -26,8 +27,7 @@ const formatTime = (currentTime: any) => { const minutes = Math.floor(currentTime / 60); let seconds = Math.floor(currentTime % 60); - const formatTime = - minutes + ":" + (seconds >= 10 ? String(seconds) : "0" + (seconds % 60)); + const formatTime = minutes + ":" + (seconds >= 10 ? String(seconds) : "0" + (seconds % 60)); return formatTime; }; @@ -116,16 +116,12 @@ export const Player = React.forwardRef((props: PlayerProps, ref) => { const playHeadRect: DOMRect = timeline.getBoundingClientRect(); const left = playHeadRect.left; const userClickWidth = e.clientX - left; - const userClickWidthInPercent = - (userClickWidth * 100) / playHeadRect.width; + const userClickWidthInPercent = (userClickWidth * 100) / playHeadRect.width; playHead.style.width = userClickWidthInPercent + "%"; player.currentTime = (duration * userClickWidthInPercent) / 100; - console.log( - "🚀 ~ changeCurrentTime ~ player.currentTime:", - player.currentTime, - ); + console.log("🚀 ~ changeCurrentTime ~ player.currentTime:", player.currentTime); } }; @@ -140,8 +136,7 @@ export const Player = React.forwardRef((props: PlayerProps, ref) => { const playHeadRect: DOMRect = timeline.getBoundingClientRect(); const left = playHeadRect.left; const userClickWidth = e.clientX - left; - const userClickWidthInPercent = - (userClickWidth * 100) / playHeadRect.width; + const userClickWidthInPercent = (userClickWidth * 100) / playHeadRect.width; if (userClickWidthInPercent <= 100) { hoverPlayHead.style.width = userClickWidthInPercent + "%"; @@ -176,14 +171,14 @@ export const Player = React.forwardRef((props: PlayerProps, ref) => { } } }, - [list], + [list] ); function renderPlayButton() { if (pause) { - return ; + return ; } else if (!pause) { - return ; + return ; } } @@ -206,21 +201,9 @@ export const Player = React.forwardRef((props: PlayerProps, ref) => { } if (timelineRef.current) { - timelineRef.current.removeEventListener( - "click", - changeCurrentTime, - false, - ); - timelineRef.current.removeEventListener( - "mousemove", - hoverTimeLine, - false, - ); - timelineRef.current.removeEventListener( - "mouseout", - resetTimeLine, - false, - ); + timelineRef.current.removeEventListener("click", changeCurrentTime, false); + timelineRef.current.removeEventListener("mousemove", hoverTimeLine, false); + timelineRef.current.removeEventListener("mouseout", resetTimeLine, false); } }; }, []); @@ -257,21 +240,15 @@ export const Player = React.forwardRef((props: PlayerProps, ref) => {
    {list[currentAudio]?.thumbnail && ( - uri + uri )}
    {list[currentAudio]?.title}
    -
    - {list[currentAudio]?.feed_title} -
    +
    {list[currentAudio]?.feed_title}
    -
    +
    -
    - -
    + + + + {renderPlayButton()} -
    - + + + +
    diff --git a/src/components/PodcastPlayer/index.tsx b/src/components/PodcastPlayer/index.tsx index 7f883fd47..ffaca3c57 100644 --- a/src/components/PodcastPlayer/index.tsx +++ b/src/components/PodcastPlayer/index.tsx @@ -54,7 +54,7 @@ export const PodcastPlayer = () => {