From aad05a8e6150ba2964a783483df1247ef75018f7 Mon Sep 17 00:00:00 2001
From: Noah Hsu
Date: Thu, 19 May 2022 21:54:16 +0800
Subject: [PATCH 1/6] feat: customize pdf viewer (Xhofe/alist#1109)
---
src/pages/list/preview/pdf.tsx | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/pages/list/preview/pdf.tsx b/src/pages/list/preview/pdf.tsx
index 7dc24bc..8b0e606 100644
--- a/src/pages/list/preview/pdf.tsx
+++ b/src/pages/list/preview/pdf.tsx
@@ -1,17 +1,20 @@
import { Center } from "@chakra-ui/react";
-import React from "react";
+import React, { useContext } from "react";
+import { IContext } from "../context";
export const type = -1;
export const exts = [];
const Pdf = ({ url, unfold }: { url: string; unfold: boolean }) => {
+ const { getSetting } = useContext(IContext)
+ const pdfPreviewUrl = getSetting("pdf viewer url") || "https://alist-org.github.io/pdf.js/web/viewer.html?file=$url";
return (
);
From a42c4f9fde3c67b5895fd3d35510e961be148afd Mon Sep 17 00:00:00 2001
From: Xhofe
Date: Fri, 27 May 2022 13:57:55 +0800
Subject: [PATCH 2/6] chore: delete old build.sh
---
build_old.sh | 59 ----------------------------------------------------
1 file changed, 59 deletions(-)
delete mode 100644 build_old.sh
diff --git a/build_old.sh b/build_old.sh
deleted file mode 100644
index c4ac1c2..0000000
--- a/build_old.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-
-BUILD_LOCAL() {
- cd alist-web
- yarn
- yarn build
- mv dist/index.html dist/local.html
- mv dist/* ../dist
- cd ..
-}
-
-BUILD_JSDELIVR() {
- cd alist-web
- yarn
- webCommit=$(git log --pretty=format:"%h" -1)
- gitTag=$(git describe --long --tags --always)
- yarn build --base="https://cdn.jsdelivr.net/gh/alist-org/assets@$gitTag"
- mv dist/index.html ../dist/jsdelivr.html
- cd ../assets
- rm -rf assets
- mv ../alist-web/dist/assets .
- git add .
- git config --local user.email "i@nn.ci"
- git config --local user.name "Xhofe"
- git commit --allow-empty -m "upload $gitTag assets files" -a
- git tag -a $gitTag -m "upload $gitTag assets files"
- cd ..
-}
-
-BUILD_UNPKG_ZHIMG() {
- cd alist-web
- version=$(git describe --abbrev=0 --tags)
- sed -i -e "s/0.0.0/$version/g" package.json
- yarn build --base="https://unpkg.zhimg.com/alist-web@$version/dist"
- cp dist/index.html ../dist/zhimg.html
- cd ..
-}
-
-BUILD_UNPKG() {
- cd alist-web
- version=$(git describe --abbrev=0 --tags)
- sed -i -e "s/0.0.0/$version/g" package.json
- yarn build --base="https://unpkg.com/alist-web@$version/dist"
- cp dist/index.html ../dist/unpkg.html
- cd ..
-}
-
-MAKE_RELEASE() {
- mkdir release
- tar -czvf release/dist.tar.gz dist/*
- zip -r release/dist.zip dist/*
-}
-
-mkdir dist
-BUILD_LOCAL
-BUILD_JSDELIVR
-# BUILD_UNPKG_ZHIMG
-BUILD_UNPKG
-MAKE_RELEASE
\ No newline at end of file
From c542ccc3e12116e92a380580d01cb5d42cc58326 Mon Sep 17 00:00:00 2001
From: Xhofe
Date: Fri, 27 May 2022 14:06:56 +0800
Subject: [PATCH 3/6] chore: upgrade artplayer (Xhofe/alist#1134)
---
.env.development | 3 ++-
package.json | 2 +-
yarn.lock | 14 ++++----------
3 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/.env.development b/.env.development
index 1b21bae..d262eef 100644
--- a/.env.development
+++ b/.env.development
@@ -1 +1,2 @@
-VITE_SERVER_URL = "http://localhost:5244/"
\ No newline at end of file
+# VITE_SERVER_URL = "http://localhost:5244/"
+VITE_SERVER_URL = "https://alist.nn.ci/"
\ No newline at end of file
diff --git a/package.json b/package.json
index 39cccc6..8e27a50 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,7 @@
"@emotion/styled": "^11.8.1",
"@monaco-editor/react": "^4.4.4",
"@xhofe/react-viewer": "^3.2.3",
- "artplayer": "^4.3.1",
+ "artplayer": "^4.4.3",
"axios": "^0.26.0",
"flv.js": "^1.6.2",
"framer-motion": "^5.5.6",
diff --git a/yarn.lock b/yarn.lock
index e4e114b..89b687f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1214,13 +1214,12 @@ aria-hidden@^1.1.1:
dependencies:
tslib "^1.0.0"
-artplayer@^4.3.1:
- version "4.3.1"
- resolved "https://registry.yarnpkg.com/artplayer/-/artplayer-4.3.1.tgz#8e1203129a17f19b6fe5de216d04f1bd139d6bb7"
- integrity sha512-X0yD+PR4n07W9KMZpqX3R9kWzDF6QNaBDoeXzZU8kcFEgAwiueC4nkLR4NIVEuX02GWEEWfQgZ7Q2rNn6tLIrA==
+artplayer@^4.4.3:
+ version "4.4.3"
+ resolved "https://registry.yarnpkg.com/artplayer/-/artplayer-4.4.3.tgz#9387d30ecac836f4918d6c083a6cb66d97932ed3"
+ integrity sha512-RdIWInmYJquUfSuM2h/dh4MjH9SR0fcQoFWL38GgT55RuvjbiVnH/lWZASeEBveCnA1jntVDpiCZYf54wGOENQ==
dependencies:
option-validator "^2.0.6"
- screenfull "^6.0.1"
axios@^0.26.0:
version "0.26.0"
@@ -3083,11 +3082,6 @@ scheduler@^0.20.2:
loose-envify "^1.1.0"
object-assign "^4.1.1"
-screenfull@^6.0.1:
- version "6.0.1"
- resolved "https://registry.yarnpkg.com/screenfull/-/screenfull-6.0.1.tgz#3b71e6f06b72d817a8d3be73c45ebe71fa8da1ce"
- integrity sha512-yzQW+j4zMUBQC51xxWaoDYjxOtl8Kn+xvue3p6v/fv2pIi1jH4AldgVLU8TBfFVgH2x3VXlf3+YiA/AYIPlaew==
-
semver@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
From 3a73254c2f89a124b0ed9b78c88b7ef388f80e88 Mon Sep 17 00:00:00 2001
From: Noah Hsu
Date: Sat, 28 May 2022 19:39:19 +0800
Subject: [PATCH 4/6] chore: dev server url
---
.env.development | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.env.development b/.env.development
index d262eef..1b21bae 100644
--- a/.env.development
+++ b/.env.development
@@ -1,2 +1 @@
-# VITE_SERVER_URL = "http://localhost:5244/"
-VITE_SERVER_URL = "https://alist.nn.ci/"
\ No newline at end of file
+VITE_SERVER_URL = "http://localhost:5244/"
\ No newline at end of file
From edc8e29797c722ca38963bbe35b7f06fd06b5848 Mon Sep 17 00:00:00 2001
From: Noah Hsu
Date: Sat, 28 May 2022 19:55:40 +0800
Subject: [PATCH 5/6] fix: code editor for json file (close Xhofe/alist#1165)
---
src/pages/list/preview/codeeditor.tsx | 57 +++++----------------------
src/pages/list/preview/markdown.tsx | 29 +++++++-------
2 files changed, 24 insertions(+), 62 deletions(-)
diff --git a/src/pages/list/preview/codeeditor.tsx b/src/pages/list/preview/codeeditor.tsx
index b8a0244..4ee9314 100644
--- a/src/pages/list/preview/codeeditor.tsx
+++ b/src/pages/list/preview/codeeditor.tsx
@@ -1,46 +1,14 @@
// Integrating the ESM version of the Monaco Editor
// https://github.com/microsoft/monaco-editor/blob/main/docs/integrate-esm.md#using-vite
-// import * as monaco from 'monaco-editor';
-// self.MonacoEnvironment = {
-// getWorker: function (workerId, label) {
-// const getWorkerModule = (moduleUrl, label) => {
-// return new Worker(self.MonacoEnvironment.getWorkerUrl(moduleUrl), {
-// name: label,
-// type: 'module'
-// });
-// };
-
-// switch (label) {
-// case 'json':
-// return getWorkerModule('/monaco-editor/esm/vs/language/json/json.worker?worker', label);
-// case 'css':
-// case 'scss':
-// case 'less':
-// return getWorkerModule('/monaco-editor/esm/vs/language/css/css.worker?worker', label);
-// case 'html':
-// case 'handlebars':
-// case 'razor':
-// return getWorkerModule('/monaco-editor/esm/vs/language/html/html.worker?worker', label);
-// case 'typescript':
-// case 'javascript':
-// return getWorkerModule('/monaco-editor/esm/vs/language/typescript/ts.worker?worker', label);
-// default:
-// return getWorkerModule('/monaco-editor/esm/vs/editor/editor.worker?worker', label);
-// }
-// }
-// };
-
import Editor from "@monaco-editor/react";
import {
Box,
- Select,
Button,
Flex,
Spacer,
useColorModeValue,
useToast,
- Heading,
} from "@chakra-ui/react";
import React from "react";
import axios from "axios";
@@ -49,29 +17,27 @@ import { useTranslation } from "react-i18next";
import useFileUrl from "../../../hooks/useFileUrl";
import { FileProps } from "../context";
import request from "../../../utils/public";
+import { File } from "../context";
export const type = -1;
export const exts = [];
-const CodeEditor = ({ file }: FileProps) => {
+export interface CodeEditorProps {
+ file: File;
+ content: string;
+ setContent: (content: string) => void;
+}
+
+const CodeEditor = ({ file, content, setContent }: CodeEditorProps) => {
const theme = useColorModeValue("light", "dark");
const { t } = useTranslation();
const toast = useToast();
const { pathname } = useLocation();
- const [content, setContent] = React.useState("");
-
- let link = useFileUrl(true)(file);
- const getContent = () => {
- axios.get(link).then(async (resp) => {
- setContent(resp.data);
- });
- };
-
const handleSaveButton: React.MouseEventHandler = async () => {
const folder = pathname.substring(0, pathname.lastIndexOf("/") || 1);
const form = new FormData();
- form.append("files", new Blob([content as string]), file.name);
+ form.append("files", new Blob([content]), file.name);
form.append("path", folder);
request
.post("upload", form, {
@@ -89,9 +55,6 @@ const CodeEditor = ({ file }: FileProps) => {
});
});
};
- React.useEffect(() => {
- getContent();
- }, []);
return (
@@ -100,7 +63,7 @@ const CodeEditor = ({ file }: FileProps) => {
value={content}
path={file.name}
theme={theme === "light" ? "light" : "vs-dark"}
- onChange={(value) => setContent(value)}
+ onChange={(value) => setContent(value ?? "")}
/>
diff --git a/src/pages/list/preview/markdown.tsx b/src/pages/list/preview/markdown.tsx
index f8bd6fa..cd0c757 100644
--- a/src/pages/list/preview/markdown.tsx
+++ b/src/pages/list/preview/markdown.tsx
@@ -14,8 +14,7 @@ export const exts = [];
const MarkdownPreview = ({ file, readme }: FileProps) => {
const [content, setContent] = React.useState("");
- const [srcDoc, setSrcDoc] = React.useState("");
- const { getSetting,loggedIn } = useContext(IContext);
+ const { getSetting, loggedIn } = useContext(IContext);
let link = useFileUrl(true)(file);
const html = file.name.endsWith(".html");
const [show, setShow] = React.useState("preview");
@@ -36,16 +35,7 @@ const MarkdownPreview = ({ file, readme }: FileProps) => {
const decoder = new TextDecoder("gbk");
res = decoder.decode(await blob.arrayBuffer());
}
- if (html) {
- setSrcDoc(res);
- }
- if (file.name.endsWith(".md")) {
- setContent(res);
- } else {
- setContent(
- "```" + file.name.split(".").pop() + "\n" + res + "\n" + "```"
- );
- }
+ setContent(res);
});
};
useEffect(() => {
@@ -89,7 +79,7 @@ const MarkdownPreview = ({ file, readme }: FileProps) => {
{show === "render" ? (
) : show === "edit" ? (
-
+
) : (
- {content}
+
+ {file.name.endsWith(".md")
+ ? content
+ : "```" +
+ file.name.split(".").pop() +
+ "\n" +
+ content +
+ "\n" +
+ "```"}
+
)}
From 8d62361fc9b341b4fef04a7b2ea74fdfda5a9495 Mon Sep 17 00:00:00 2001
From: Noah Hsu
Date: Sat, 28 May 2022 20:49:54 +0800
Subject: [PATCH 6/6] fix: refresh while pagination (close Xhofe/alist#1124)
---
src/pages/list/layout/files/menus/refresh.tsx | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/pages/list/layout/files/menus/refresh.tsx b/src/pages/list/layout/files/menus/refresh.tsx
index 69e4712..9fd4fb4 100644
--- a/src/pages/list/layout/files/menus/refresh.tsx
+++ b/src/pages/list/layout/files/menus/refresh.tsx
@@ -10,7 +10,7 @@ import bus from "../../../../../utils/event-bus";
import { IContext } from "../../../context";
const Refresh = () => {
- const { loggedIn } = useContext(IContext);
+ const { loggedIn, setPage, page } = useContext(IContext);
const { t } = useTranslation();
const { refresh } = useApi();
const toast = useToast();
@@ -28,6 +28,7 @@ const Refresh = () => {
isClosable: true,
});
if (res.code === 200) {
+ setPage({ ...page, page_num: 1 });
bus.emit("refresh");
}
});
@@ -42,4 +43,4 @@ const Refresh = () => {
);
};
-export default Refresh;
\ No newline at end of file
+export default Refresh;