Skip to content

Commit

Permalink
Merge pull request #246 from alley-rs/0.1.X
Browse files Browse the repository at this point in the history
fix: #245
  • Loading branch information
thep0y authored Aug 9, 2024
2 parents b8d4706 + 6fbfb5d commit 3384be0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
"@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",
"@types/node": "^22.1.0",
"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"
}
}
4 changes: 2 additions & 2 deletions static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
9 changes: 6 additions & 3 deletions static/src/components/upload/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
overflow-y: auto;

.upload-file-list {
height: 80%;
// height: 100%;
border-radius: 5px;
flex-grow: 14;
overflow-y: auto;
Expand All @@ -34,8 +34,11 @@
}

.submit-button {
margin-top: 5px;
flex-grow: 1;
position: fixed;
left: 10px;
top: 10px;
border-radius: 50%;
padding: 8px;
}

.empty {
Expand Down
25 changes: 17 additions & 8 deletions static/src/components/upload/index.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -56,17 +57,26 @@ 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);
};

const onClick: JSX.EventHandlerUnion<HTMLDivElement, MouseEvent> = (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: <explanation>
fileInput!.value = ""; // 点击按钮后清空 input files
fileInput?.click();
target.blur();
}
Expand All @@ -81,7 +91,7 @@ const Upload = ({ action, headers, withCredentials, method }: UploadProps) => {
headers,
withCredentials,
onProgress,
onError: function (e): void {
onError: (e) => {
console.log(e);
// todo: 反馈上传错误
},
Expand Down Expand Up @@ -120,7 +130,7 @@ const Upload = ({ action, headers, withCredentials, method }: UploadProps) => {
<ErrorBlock
status="empty"
title="未选择文件"
description="点击最下面的按钮选择文件"
description="点击左上角的加号按钮选择文件"
/>
</div>
) : (
Expand Down Expand Up @@ -155,11 +165,10 @@ const Upload = ({ action, headers, withCredentials, method }: UploadProps) => {
/>

<Button
block
class="submit-button"
disabled={fileItems.findIndex((f) => f.speed !== undefined) >= 0}
>
选择文件
<AiOutlinePlus />
</Button>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion static/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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");

Expand Down

0 comments on commit 3384be0

Please sign in to comment.