Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
BeardedManZhao committed Apr 25, 2024
1 parent 40ffe5f commit 0ba8c43
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ const indexConfig = {

## 更新记录

### 1.0.5 版本开始开发

- 修复了文件编辑器上传文件的问题
- 支持新增文件的操作
- 优化版本号显示方法

### 1.0.4 版本 发布

- 文件管理器列表允许粘贴
Expand Down
3 changes: 2 additions & 1 deletion web/FileExplorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div>
<img alt="logo" class="icon-navigation" src="image/logo.png">
</div>
<div id="show_area" style="text-align: center">diskMirror-front 1.0.4</div>
<div id="show_area" title="diskMirror-front 版本:点击查看前端界面历史包" onclick="window.open('https://github.com/BeardedManZhao/diskMirror-front/releases')" style="text-align: center"> 1.0.5</div>
<div class="button_list1">
<button class="item_Button" onclick="window.open('index.html')">新界面</button>
<button class="item_Button" id="showTransferDeposit_fileList_table_button"
Expand All @@ -41,6 +41,7 @@
</button>
<button class="item_Button" onclick="reloadFsPath()"> 刷新</button>
<button class="item_Button" onclick="mkdir()"> 创目录</button>
<button class="item_Button" onclick="mkFile()"> 创文件</button>
<button class="item_Button" onclick="window.open('https://github.com/BeardedManZhao/DiskMirror.git')">
盘镜
</button>
Expand Down
46 changes: 36 additions & 10 deletions web/FileWriter.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
const searchParams0 = DiskMirrorFront.search_Params("fileName");
const searchParams1 = DiskMirrorFront.search_Params("fileUrl");
const isUpdate = searchParams0.length > 0 && searchParams1.length > 0;
let fileName_str;
if (isUpdate) {
fileName_str = searchParams0[searchParams0.length - 1];
} else {
const s1 = prompt("请您为文件起个名字吧!", "/xxx/xxx/Untitled_" + DiskMirrorFront.getDate(new Date()));
fileName_str = s1 ? s1 : '未命名文件_' + DiskMirrorFront.getDate(new Date()) + '.md';
}
const jokerBoxPopUp = new JokerBox_popUp(document.getElementById("joker"));
const diskMirror = new DiskMirror(indexConfig.server);
diskMirror.setSk(parseInt(DiskMirrorFront.getLatestCookieValue("diskMirror_server_pass")), indexConfig.domain)
Expand Down Expand Up @@ -79,26 +86,41 @@
$("#save_button").click(function () {
if (isUpdate) {
const type1 = type;
const name = searchParams0[searchParams0.length - 1];
diskMirror.remove(userId, type1, searchParams0[searchParams0.length - 1],
(res) => {
diskMirror.upload({
userId: userId,
type: type1,
fileName: name
fileName: fileName_str
}, editor.getMarkdown(), (r) => jokerBoxPopUp.show(r.fileName + " 保存成功!"), (error) => jokerBoxPopUp.show("保存操作出现了问题!请稍后再试吧!" + error));
},
(error) => jokerBoxPopUp.show("覆写操作出现了问题!请稍后再试吧!" + error)
)
} else {
diskMirror.upload({
userId: userId,
type: type,
fileName: fileName_str
}, editor.getMarkdown(), (r) => {
jokerBoxPopUp.show(r.fileName + " 保存成功!稍后自动跳转到文件管理器!");
setTimeout(() => {
window.location.href = `FileExplorer.html?server_id=${userId}&path=/`
}, 5000);
}, (error) => jokerBoxPopUp.show("保存操作出现了问题!请稍后再试吧!" + error)
);
}
});

$("#remove_button").click(function () {
jokerBoxPopUp.show("还未接入")
if (isUpdate) {
if (confirm("您确定要删除此文件吗?")) {
diskMirror.remove(userId, type, searchParams0[searchParams0.length - 1],
(res) => jokerBoxPopUp.show(res.fileName + " 删除完毕!"),
diskMirror.remove(userId, type, fileName_str,
(res) => {
jokerBoxPopUp.show(res.fileName + " 删除完毕!稍后自动跳转到文件管理器");
setTimeout(() => {
window.location.href = `FileExplorer.html?server_id=${userId}&path=/`
}, 5000);
},
(error) => jokerBoxPopUp.show("删除操作出现了问题!请稍后再试吧!" + error)
)
}
Expand All @@ -108,7 +130,11 @@
});

$("#download_button").click(function () {
window.open(searchParams1[searchParams1.length - 1])
if (isUpdate) {
window.open(searchParams1[searchParams1.length - 1])
} else {
jokerBoxPopUp.show("请您重新打开此文件,便于获取到文件下载链接!")
}
});

// 设置粘贴事件
Expand All @@ -117,15 +143,15 @@
// 图片数据
(file) => {
const randomInt = file.size + new Date().getTime();
const fileName_old = searchParams0 + "_resource/" + randomInt + ".jpg";
const fileName_old = fileName_str + "_resource/" + randomInt + ".jpg";
// 获取到当前层级
diskMirror.upload({
fileName: fileName_old,
userId: userId,
type: type
}, file, (res) => {
diskMirror.downLoad(userId, indexConfig.spaceType, fileName_old, (url) => {
editor.insertValue(`\n[${res.fileName}](${url})\n`);
editor.insertValue(`\n![${res.fileName}](${url})\n`);
})
jokerBoxPopUp.show(res.fileName + " 上传成功!!! ");
}, undefined, undefined);
Expand All @@ -140,7 +166,7 @@
return
}
// 获取到当前层级
const s = searchParams0 + "_resource/" + fileName;
const s = fileName_str + "_resource/" + fileName;
diskMirror.upload({
fileName: s,
userId: userId,
Expand All @@ -160,7 +186,7 @@
return;
}
// 获取到当前层级
const s = searchParams0 + "_resource/" + fileName;
const s = fileName_str + "_resource/" + fileName;
diskMirror.upload({
fileName: s,
userId: userId,
Expand Down
4 changes: 4 additions & 0 deletions web/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ function mkdir() {
}
}

function mkFile() {
window.open('FileWriter.html?server_id=' + userId)
}

function extractedFsList(res) {
if (res.length === 0) {
jokerBoxPopUp.show("空空如也,快去创建一个吧!");
Expand Down

0 comments on commit 0ba8c43

Please sign in to comment.