Skip to content

Commit

Permalink
Merge pull request #1 from asforest/main
Browse files Browse the repository at this point in the history
修复文件上传的问题和增加一个public目录上传按钮
  • Loading branch information
Sengimu authored Dec 10, 2024
2 parents 08a8888 + ae010b9 commit 98865a9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/api/fs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import instance from "@/utils/request.js";
import axios from "axios";
import store from "@/store/index.js";

export const fsDiskInfoRequest = () => instance.post('/fs/disk-info', {})

Expand All @@ -14,6 +15,7 @@ export const fsSignFileRequest = (path = '') => instance.post('/fs/sign-file', {
export const fsUploadRequest = (path = '', file, onProgress) => {
return axios.post(`${import.meta.env.VITE_API_URL}/fs/upload`, file, {
headers: {
'Token': store.getState().user.token,
'Content-Type': 'application/octet-stream',
'Path': encodeURIComponent(path)
},
Expand Down
4 changes: 4 additions & 0 deletions src/api/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ export const taskCombineRequest = () => instance.post('/task/combine', {})
export const taskTestRequest = () => instance.post('/task/test', {})

export const taskRevertRequest = () => instance.post('/task/revert', {})

export const taskUploadRequest = () => instance.post('/task/upload', {})

export const taskStatusRequest = () => instance.post('/task/status', {})
32 changes: 27 additions & 5 deletions src/pages/Dashboard/Log/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useEffect, useRef, useState} from "react";
import {Button, Input, message, Modal} from "antd";
import {taskCombineRequest, taskPackRequest, taskRevertRequest, taskTestRequest} from "@/api/task.js";
import {taskCombineRequest, taskPackRequest, taskRevertRequest, taskTestRequest, taskUploadRequest, taskStatusRequest} from "@/api/task.js";
import {terminalFullRequest, terminalMoreRequest} from "@/api/terminal.js";
import {RotateCcw} from "lucide-react";
import {generateRandomStr} from "@/utils/tool.js";
Expand Down Expand Up @@ -85,6 +85,26 @@ const Index = () => {
}
}

const taskUpload = async () => {
const {code, msg, data} = await taskUploadRequest();
if (code === 1) {
messageApi.success('任务已提交.')
await terminalMore()
} else {
messageApi.error(msg)
}
}

const taskStatus = async () => {
const {code, msg, data} = await taskStatusRequest();
if (code === 1) {
messageApi.success('任务已提交.')
await terminalMore()
} else {
messageApi.error(msg)
}
}

const copy = async (item) => {
await navigator.clipboard.writeText(`${showTime(item.time)}-${item.level}-${item.content}`);
messageApi.success('复制成功!')
Expand Down Expand Up @@ -115,10 +135,12 @@ const Index = () => {
<div className="flex flex-col min-h-[calc(100vh-80px)]">
<div className="flex justify-start items-center h-8">
<Button type="primary" size="large" icon={<RotateCcw size={20} strokeWidth={1.5}/>} onClick={terminalMore}/>
<Button type="primary" size="large" className="ml-2" onClick={() => setPackShow(true)}>打包</Button>
<Button type="primary" size="large" className="ml-2" onClick={taskCombine}>合并</Button>
<Button type="primary" size="large" className="ml-2" onClick={taskTest}>测试</Button>
<Button type="primary" size="large" className="ml-2" onClick={taskRevert}>回退</Button>
<Button type="primary" size="large" className="ml-2" onClick={taskStatus}>检查文件修改</Button>
<Button type="primary" size="large" className="ml-2" onClick={taskTest}>测试更新包</Button>
<Button type="primary" size="large" className="ml-2" onClick={taskUpload}>上传public目录</Button>
<Button type="primary" size="large" className="ml-2" onClick={() => setPackShow(true)}>打包新版本</Button>
<Button type="primary" size="large" className="ml-2" onClick={taskRevert}>回退整个工作空间</Button>
<Button type="primary" size="large" className="ml-2" onClick={taskCombine}>合并更新包</Button>
</div>
<div
ref={logsRef}
Expand Down

0 comments on commit 98865a9

Please sign in to comment.