diff --git a/package.json b/package.json index efe70e2..51f034e 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@tauri-apps/api": "^1.6.0", "alley-components": "^0.2.10", "solid-icons": "^1.1.0", - "solid-js": "^1.8.19" + "solid-js": "^1.8.20" }, "devDependencies": { "@tauri-apps/cli": "^1.6.0", @@ -28,7 +28,7 @@ "cross-env": "^7.0.3", "sass": "^1.77.8", "typescript": "^5.5.4", - "vite": "^5.3.5", + "vite": "^5.4.0", "vite-plugin-solid": "^2.10.2" } } diff --git a/static/package.json b/static/package.json index b76539e..f2f0459 100644 --- a/static/package.json +++ b/static/package.json @@ -12,12 +12,12 @@ "dependencies": { "@tauri-apps/api": "^1.6.0", "solid-icons": "^1.1.0", - "solid-js": "^1.8.19" + "solid-js": "^1.8.20" }, "devDependencies": { "sass": "^1.77.8", "typescript": "^5.5.4", - "vite": "^5.3.5", + "vite": "^5.4.0", "vite-plugin-solid": "^2.10.2" } } diff --git a/static/src/components/upload/index.scss b/static/src/components/upload/index.scss index 168c239..1c4427c 100644 --- a/static/src/components/upload/index.scss +++ b/static/src/components/upload/index.scss @@ -7,7 +7,7 @@ overflow-y: auto; .upload-file-list { - height: 80%; + // height: 100%; border-radius: 5px; flex-grow: 14; overflow-y: auto; @@ -34,8 +34,11 @@ } .submit-button { - margin-top: 5px; - flex-grow: 1; + position: fixed; + left: 10px; + top: 10px; + border-radius: 50%; + padding: 8px; } .empty { diff --git a/static/src/components/upload/index.tsx b/static/src/components/upload/index.tsx index 1b0ce5e..09272a1 100644 --- a/static/src/components/upload/index.tsx +++ b/static/src/components/upload/index.tsx @@ -1,13 +1,14 @@ -import { JSX, createEffect, createSignal, createUniqueId } from "solid-js"; +import { type JSX, createEffect, createSignal, createUniqueId } from "solid-js"; import { createStore } from "solid-js/store"; import { getFileItemIndex } from "./util"; import request from "./request"; import asyncPool from "~/components/upload/asyncPool"; -import Button from "../button"; import ErrorBlock from "../error-block"; import List from "../list"; import FileItem from "./fileItem"; import "./index.scss"; +import Button from "../button"; +import { AiOutlinePlus } from "solid-icons/ai"; interface UploadProps { action: string; @@ -56,7 +57,9 @@ const Upload = ({ action, headers, withCredentials, method }: UploadProps) => { fileItems.push({ file, id: createUniqueId() }); } - fileItems.forEach((f) => send(f)); + for (const f of fileItems) { + send(f); + } setFileItems(fileItems); }; @@ -64,9 +67,16 @@ const Upload = ({ action, headers, withCredentials, method }: UploadProps) => { const onClick: JSX.EventHandlerUnion = (e) => { const target = e.target as HTMLElement; - if (target && target.tagName === "BUTTON") { + if ( + target && + (target.tagName === "BUTTON" || + target.parentElement?.tagName === "BUTTON" || + target.parentElement?.parentElement?.tagName === "BUTTON") + ) { setFileItems([]); setRequestTasks([]); + // biome-ignore lint/style/noNonNullAssertion: + fileInput!.value = ""; // 点击按钮后清空 input files fileInput?.click(); target.blur(); } @@ -81,7 +91,7 @@ const Upload = ({ action, headers, withCredentials, method }: UploadProps) => { headers, withCredentials, onProgress, - onError: function (e): void { + onError: (e) => { console.log(e); // todo: 反馈上传错误 }, @@ -120,7 +130,7 @@ const Upload = ({ action, headers, withCredentials, method }: UploadProps) => { ) : ( @@ -155,11 +165,10 @@ const Upload = ({ action, headers, withCredentials, method }: UploadProps) => { /> ); diff --git a/static/vite.config.ts b/static/vite.config.ts index 5a1e263..bdcfc15 100644 --- a/static/vite.config.ts +++ b/static/vite.config.ts @@ -1,6 +1,6 @@ import { defineConfig } from "vite"; import solid from "vite-plugin-solid"; -import path from "path"; +import path from "node:path"; const pathSrc = path.resolve(__dirname, "src");