Skip to content

Commit

Permalink
feat: video preview
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Aug 20, 2022
1 parent 663398e commit 032bb93
Show file tree
Hide file tree
Showing 27 changed files with 338 additions and 44 deletions.
Binary file added images/iina.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/mxplayer-pro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/mxplayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/nplayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/potplayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/vlc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
"@solid-primitives/i18n": "^1.1.0",
"@solid-primitives/storage": "^1.3.1",
"@stitches/core": "^1.2.8",
"artplayer": "^4.5.4",
"axios": "^0.27.2",
"copy-to-clipboard": "^3.3.2",
"flv.js": "^1.6.2",
"hls.js": "^1.2.1",
"lightgallery": "^2.5.0",
"mitt": "^3.0.0",
"motion": "^10.13.3",
Expand Down
48 changes: 48 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/images/iina.webp
Binary file not shown.
Binary file added public/images/mxplayer-pro.webp
Binary file not shown.
Binary file added public/images/mxplayer.webp
Binary file not shown.
Binary file added public/images/nplayer.webp
Binary file not shown.
Binary file added public/images/potplayer.webp
Binary file not shown.
Binary file added public/images/vlc.webp
Binary file not shown.
3 changes: 2 additions & 1 deletion src/components/SwitchColorMode.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Icon, useColorMode, useColorModeValue } from "@hope-ui/solid";
import { IoMoonOutline as Moon } from "solid-icons/io";
// import { IoMoonOutline as Moon } from "solid-icons/io";
import { FiSun as Sun } from "solid-icons/fi";
import { FiMoon as Moon } from "solid-icons/fi";

const SwitchColorMode = () => {
const { toggleColorMode } = useColorMode();
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/usePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const usePath = () => {
handleFolder(path, 1);
} else {
ObjStore.setReadme(data.readme);
ObjStore.setRelated(data.related);
ObjStore.setRelated(data.related ?? []);
ObjStore.setRawUrl(data.raw_url);
ObjStore.setState(State.File);
}
Expand Down
12 changes: 11 additions & 1 deletion src/hooks/useRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import {
useSearchParams,
} from "@solidjs/router";
import { createMemo } from "solid-js";
import { encodePath, joinBase, log, pathJoin, trimBase } from "~/utils";
import {
encodePath,
joinBase,
log,
pathDir,
pathJoin,
trimBase,
} from "~/utils";

const useRouter = () => {
const navigate = useNavigate();
Expand All @@ -25,6 +32,9 @@ const useRouter = () => {
log("to:", path);
navigate(path, options);
},
replace: (to: string) => {
navigate(encodePath(pathJoin(pathDir(location.pathname), to), true));
},
pushHref: (to: string): string => {
return encodePath(pathJoin(location.pathname, to));
},
Expand Down
1 change: 1 addition & 0 deletions src/lang/en/home.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"input_filename": "Input filename"
},
"footer": {
"powered_by": "Powered by AList",
"manage": "Manage"
}
}
2 changes: 1 addition & 1 deletion src/pages/home/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const Footer = () => {
<VStack class="footer" w="$full" py="$4">
<HStack spacing="$1">
<Anchor href="https://github.com/Xhofe/alist" external>
Powered by AList
{t("home.footer.powered_by")}
</Anchor>
<span>|</span>
<AnchorWithBase as={Link} href="/@manage">
Expand Down
6 changes: 5 additions & 1 deletion src/pages/home/Password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ const Password = () => {
columnGap="$1"
>
<Text>{t("global.have_account")}</Text>
<Text color="$info9" as={LinkWithBase} href="/@login">
<Text
color="$info9"
as={LinkWithBase}
href={`/@login?redirect=${encodeURIComponent(location.pathname)}`}
>
{t("global.go_login")}
</Text>
</Flex>
Expand Down
45 changes: 26 additions & 19 deletions src/pages/home/Readme.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, useColorModeValue } from "@hope-ui/solid";
import { createMemo, Show, createResource } from "solid-js";
import { createMemo, Show, createResource, on } from "solid-js";
import { Markdown, MaybeLoading } from "~/components";
import { useUrl } from "~/hooks";
import { objStore, State } from "~/store";
Expand All @@ -8,25 +8,32 @@ import { fetchText } from "~/utils";
export const Readme = () => {
const cardBg = useColorModeValue("white", "$neutral3");
const { proxyUrl } = useUrl();
const readme = createMemo(() => {
if (
![State.FetchingMore, State.Folder, State.File].includes(objStore.state)
) {
return "";
}
if (objStore.readme) {
return objStore.readme;
}
if ([State.FetchingMore, State.Folder].includes(objStore.state)) {
const obj = objStore.objs.find(
(item) => item.name.toLowerCase() === "readme.md"
);
if (obj) {
return proxyUrl(obj, true);
const readme = createMemo(
on(
() => objStore.state,
() => {
if (
![State.FetchingMore, State.Folder, State.File].includes(
objStore.state
)
) {
return "";
}
if (objStore.readme) {
return objStore.readme;
}
if ([State.FetchingMore, State.Folder].includes(objStore.state)) {
const obj = objStore.objs.find(
(item) => item.name.toLowerCase() === "readme.md"
);
if (obj) {
return proxyUrl(obj, true);
}
}
return "";
}
}
return "";
});
)
);
const fetchContent = async (readme: string) => {
if (/https?:\/\//g.test(readme)) {
return await fetchText(readme);
Expand Down
18 changes: 3 additions & 15 deletions src/pages/home/file/ExternalPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,7 @@ import { createMemo, For, Show } from "solid-js";
import { useT } from "~/hooks";
import { getPreviewsByName, objStore } from "~/store";
import { FaSolidAngleDown } from "solid-icons/fa";

export const getPreviewURL = (
placehoder: string,
url: string,
name: string
) => {
let ans = placehoder;
ans = ans.replace("$name", name);
ans = ans.replace("$url", url);
ans = ans.replace("$e_url", encodeURIComponent(url));
ans = ans.replace("$b_url", window.btoa(url));
ans = ans.replace("$eb_url", encodeURIComponent(window.btoa(url)));
return ans;
};
import { convertURL } from "~/utils";

export const ExternalPreview = () => {
const t = useT();
Expand All @@ -45,7 +32,8 @@ export const ExternalPreview = () => {
{(preview) => (
<MenuItem
as="a"
href={getPreviewURL(
target="_blank"
href={convertURL(
preview.value,
objStore.raw_url,
objStore.obj.name
Expand Down
Loading

0 comments on commit 032bb93

Please sign in to comment.