diff --git a/src/App.scss b/src/App.scss index e69de29..11327c7 100644 --- a/src/App.scss +++ b/src/App.scss @@ -0,0 +1,5 @@ +#right { + flex: 2; + justify-content: center; + align-items: center; +} diff --git a/src/App.tsx b/src/App.tsx index f532483..c4831ea 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,11 +1,12 @@ -import { createResource, createSignal } from "solid-js"; -import "./App.scss"; +import { createResource, createSignal, Show } from "solid-js"; +import { LazyFlex, LazyToast } from "./lazy"; +import { AppContext } from "./context"; import { getAllHistory, readConfigFile } from "./command"; import History from "./components/history"; import Search from "./components/search"; -import { AppContext } from "./context"; import Settings from "./components/settings"; -import { LazyToast } from "./lazy"; +import Result from "./components/result"; +import "./App.scss"; const App = () => { const [items, { refetch: refetchHistoryItems }] = @@ -29,7 +30,15 @@ const App = () => { > - + + + + + + + + + diff --git a/src/components/result/index.scss b/src/components/result/index.scss new file mode 100644 index 0000000..3f31508 --- /dev/null +++ b/src/components/result/index.scss @@ -0,0 +1,58 @@ +.parsed-result { + background-color: rgba($color: #000000, $alpha: 0.2); + backdrop-filter: blur(5px); + border-radius: 16px; + padding: 5px 10px; + width: 440px; + min-height: 440px; + color: #fff; + box-shadow: var(--alley-box-shadow-secondary); + margin-top: 20px; + + .alley-button { + --alley-color-button-text: #fff; + + &-plain:hover:not(:disabled) { + color: #fff; + background: var(--alley-color-primary); + } + } + + .parsed-result-header { + flex: 1; + } + + .parsed-links-wrapper { + flex: 8; + } + + .parsed-links { + flex: 8; + + .link { + color: var(--alley-color-primary); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + cursor: pointer; + + &:hover { + cursor: pointer; + } + } + } + + .parsed-links-note { + flex: 1; + } +} + +.parsed-result-dialog { + .alley-dialog-close-button { + position: absolute; + right: 20px; + top: 20px; + color: #fff; + z-index: 99; + } +} diff --git a/src/components/result/index.tsx b/src/components/result/index.tsx new file mode 100644 index 0000000..6ad7d1c --- /dev/null +++ b/src/components/result/index.tsx @@ -0,0 +1,141 @@ +import { AiFillChrome, AiFillCopy, AiFillPlayCircle } from "solid-icons/ai"; +import { createEffect, For, useContext } from "solid-js"; +import { createStore } from "solid-js/store"; +import { insertHistory, open, play } from "~/command"; +import { AppContext } from "~/context"; +import { writeText } from "@tauri-apps/plugin-clipboard-manager"; +import { platforms } from "~/parser"; +import { + LazyAlert, + LazyButton, + LazyCol, + LazyDivider, + LazyFlex, + LazyLabel, + LazyRow, + LazySpace, + LazyTooltip, +} from "~/lazy"; +import "./index.scss"; + +const Result = (props: ParsedResult) => { + const [{ refetchHistoryItems }, { setToast }] = useContext(AppContext)!; + + const [links, setLinks] = createStore([]); + + createEffect(() => setLinks(props.links ?? [])); + + const onPlay = async (index: number) => { + await play(props!.links[index]); + + // 解析出来的链接只能访问一次,访问后即删除 + setLinks((prev) => prev.filter((_, idx) => index !== idx)); + + await insertHistory({ + id: 0, + platform: props.platform, + anchor: props.anchor, + room_id: props.roomID, + category: props.category, + last_title: props.title, + last_play_time: new Date(), + }); + refetchHistoryItems(); + }; + + const onCopy = async (link: string) => { + await writeText(link); + setToast({ + type: "success", + message: "已复制链接到系统剪贴板,可粘贴到其他播放器播放", + }); + }; + + return ( + <> + + +

{props.title}

+ + + } + shape="circle" + size="small" + type="plain" + onClick={() => + open(platforms[props.platform].roomBaseURL + props.roomID) + } + /> + +
+ + + + 分类 + {props.category ?? "无"} + + + + 主播 + {props.anchor} + + + + +
+ + + + + + + + ); +}; + +export default Result; diff --git a/src/components/search/index.scss b/src/components/search/index.scss index 453917f..4f5c06b 100644 --- a/src/components/search/index.scss +++ b/src/components/search/index.scss @@ -1,5 +1,4 @@ #search { - flex: 2; justify-content: center; align-items: center; @@ -8,65 +7,6 @@ } } -.parsed-result { - background-color: rgba($color: #000000, $alpha: 0.2); - backdrop-filter: blur(5px); - border-radius: 16px; - padding: 5px 10px; - width: 440px; - min-height: 440px; - color: #fff; - box-shadow: var(--alley-box-shadow-secondary); - margin-top: 20px; - - .alley-button { - --alley-color-button-text: #fff; - - &-plain:hover:not(:disabled) { - color: #fff; - background: var(--alley-color-primary); - } - } - - .parsed-result-header { - flex: 1; - } - - .parsed-links-wrapper { - flex: 8; - } - - .parsed-links { - flex: 8; - - .link { - color: var(--alley-color-primary); - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - cursor: pointer; - - &:hover { - cursor: pointer; - } - } - } - - .parsed-links-note { - flex: 1; - } -} - -.parsed-result-dialog { - .alley-dialog-close-button { - position: absolute; - right: 20px; - top: 20px; - color: #fff; - z-index: 99; - } -} - .bili-cookie-dialog { textarea { width: 480px; diff --git a/src/components/search/index.tsx b/src/components/search/index.tsx index e478f02..077d81c 100644 --- a/src/components/search/index.tsx +++ b/src/components/search/index.tsx @@ -1,7 +1,6 @@ import "./index.scss"; import { children, createSignal, For, useContext } from "solid-js"; import { platforms } from "~/parser"; -import Result from "./result"; import { AiOutlineCheck } from "solid-icons/ai"; import { AppContext } from "~/context"; import BiliCookieEditor from "./bili-cookie"; @@ -16,7 +15,7 @@ import { } from "~/lazy"; const Search = () => { - const [_, { setToast }, { config }, { parsedResult, setParsedResult }] = + const [_, { setToast }, { config }, { setParsedResult }] = useContext(AppContext)!; const [input, setInput] = createSignal(""); @@ -112,8 +111,6 @@ const Search = () => { {buttons()} - - { - const [{ refetchHistoryItems }, { setToast }] = useContext(AppContext)!; - - const [links, setLinks] = createStore([]); - - createEffect(() => setLinks(props.links ?? [])); - - const onPlay = async (index: number) => { - await play(props.links[index]); - - // 解析出来的链接只能访问一次,访问后即删除 - setLinks((prev) => prev.filter((_, idx) => index !== idx)); - - await insertHistory({ - id: 0, - platform: props.platform, - anchor: props.anchor, - room_id: props.roomID, - category: props.category, - last_title: props.title, - last_play_time: new Date(), - }); - refetchHistoryItems(); - }; - - const onCopy = async (link: string) => { - await writeText(link); - setToast({ - type: "success", - message: "已复制链接到系统剪贴板,可粘贴到其他播放器播放", - }); - }; - - return ( - - - - -

{props.title}

- - - } - shape="circle" - size="small" - type="plain" - onClick={() => - open(platforms[props.platform].roomBaseURL + props.roomID) - } - /> - -
- - - - 分类 - {props.category ?? "无"} - - - - 主播 - {props.anchor} - - - - -
- - - - - - -
-
- ); -}; - -export default Result;