|
@@ -304,26 +304,25 @@ router.route("/updateFolder").all(async (req, res, next) => {
|
|
|
//移除文件
|
|
|
router.route("/removeFile").all(async (req, res, next) => {
|
|
|
if (req.body[0]) {
|
|
|
- try {
|
|
|
- let documentids = decodeURIComponent(req.body[0].documentids).split(",")
|
|
|
- let folderid = req.body[0].folderid
|
|
|
- let ids = req.body[0].ids
|
|
|
- documentids.map(documentid =>
|
|
|
- client.collections.removeDocument({ id: folderid, documentId: documentid })
|
|
|
- )
|
|
|
- // await Promise.all(documentids.map(documentid =>
|
|
|
- // client.collections.removeDocument({ id: folderid, documentId: documentid })
|
|
|
- // ));
|
|
|
- p = [ids, folderid];
|
|
|
- p.unshift(_mysqlLabor[0], _mysqlLabor[1], "removeFile");
|
|
|
- mysql.usselect(p, async function(ret) {
|
|
|
- res.end(JSON.stringify(ret));
|
|
|
- });
|
|
|
-
|
|
|
- } catch (error) {
|
|
|
- res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
- }
|
|
|
+ let documentids = decodeURIComponent(req.body[0].documentids).split(",");
|
|
|
+ let folderid = req.body[0].folderid;
|
|
|
+ let ids = req.body[0].ids;
|
|
|
+
|
|
|
+ // 使用 Promise.all 确保所有删除操作都被执行
|
|
|
+ const removePromises = documentids.map(documentid =>
|
|
|
+ client.collections.removeDocument({ id: folderid, documentId: documentid })
|
|
|
+ );
|
|
|
+
|
|
|
+ // 不管client.documents报错没有也要执行removeFile
|
|
|
+ Promise.all(removePromises).catch(error => {
|
|
|
+ console.error("移除文件时发生错误:", error);
|
|
|
+ });
|
|
|
|
|
|
+ p = [ids, folderid];
|
|
|
+ p.unshift(_mysqlLabor[0], _mysqlLabor[1], "removeFile");
|
|
|
+ mysql.usselect(p, async function(ret) {
|
|
|
+ res.end(JSON.stringify(ret));
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -334,53 +333,49 @@ router.route("/moveFile").all(async (req, res, next) => {
|
|
|
let documentids = decodeURIComponent(req.body[0].documentids).split(",")
|
|
|
let folderid = req.body[0].folderid
|
|
|
let ids = decodeURIComponent(req.body[0].ids).split(",")
|
|
|
- documentids.map(documentid => client.collections.addDocument({
|
|
|
- id: folderid,
|
|
|
- documentId: documentid
|
|
|
- }))
|
|
|
- // const results = await Promise.all(documentids.map(documentid => client.collections.addDocument({
|
|
|
- // id: folderid,
|
|
|
- // documentId: documentid
|
|
|
- // })));
|
|
|
- // console.log("每一条接口返回的值:", results); // 查看每一条接口返回来的值
|
|
|
+
|
|
|
+ // 使用 Promise.all 确保所有添加操作都被执行
|
|
|
+ await Promise.all(documentids.map(documentid =>
|
|
|
+ client.collections.addDocument({
|
|
|
+ id: folderid,
|
|
|
+ documentId: documentid
|
|
|
+ }).catch(error => {
|
|
|
+ console.error("移动文件时发生错误:", error);
|
|
|
+ })
|
|
|
+ ));
|
|
|
|
|
|
for (const id of ids) {
|
|
|
p = [id, folderid];
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "moveFile");
|
|
|
- const ret = await mysql.usselect(p, async function(ret) {});
|
|
|
+ await mysql.usselect(p, async function(ret) {});
|
|
|
}
|
|
|
res.status(200).json({ messages: "移动成功" });
|
|
|
|
|
|
} catch (error) {
|
|
|
- res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
+ // 这里不返回错误,确保deleteFile执行完
|
|
|
+ console.error("处理过程中发生错误:", error);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//移入文件
|
|
|
router.route("/deleteFile").all(async (req, res, next) => {
|
|
|
if (req.body[0]) {
|
|
|
- try {
|
|
|
- let documentids = decodeURIComponent(req.body[0].documentids).split(",")
|
|
|
- let ids = req.body[0].ids
|
|
|
- documentids.map(documentid => client.documents.delete({
|
|
|
- id: documentid,
|
|
|
- }))
|
|
|
- // const results = await Promise.all(documentids.map(documentid => client.documents.delete({
|
|
|
- // id: documentid,
|
|
|
- // })));
|
|
|
- // console.log("每一条接口返回的值:", results); // 查看每一条接口返回来的值
|
|
|
-
|
|
|
- p = [ids];
|
|
|
- p.unshift(_mysqlLabor[0], _mysqlLabor[1], "deleteFile");
|
|
|
- mysql.usselect(p, async function(ret) {
|
|
|
- res.end(JSON.stringify(ret));
|
|
|
- });
|
|
|
-
|
|
|
- } catch (error) {
|
|
|
- res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
- }
|
|
|
+ let documentids = decodeURIComponent(req.body[0].documentids).split(",");
|
|
|
+ let ids = req.body[0].ids;
|
|
|
+
|
|
|
+ // 使用 Promise.all 确保所有删除操作都被执行
|
|
|
+ Promise.all(documentids.map(documentid =>
|
|
|
+ client.documents.delete({ id: documentid }).catch(error => {
|
|
|
+ console.error("删除文件时发生错误:", error);
|
|
|
+ })
|
|
|
+ ));
|
|
|
+
|
|
|
+ p = [ids];
|
|
|
+ p.unshift(_mysqlLabor[0], _mysqlLabor[1], "deleteFile");
|
|
|
+ mysql.usselect(p, async function(ret) {
|
|
|
+ res.end(JSON.stringify(ret));
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
});
|
|
@@ -389,6 +384,11 @@ router.route("/getFolder").all((req, res, next) => {
|
|
|
getmysql2(req, res, "getFolder", req.body.uid);
|
|
|
});
|
|
|
|
|
|
+router.route("/getFolderPage").all((req, res, next) => {
|
|
|
+ getmysql2(req, res, "getFolderPage2", req.body[0].uid, req.body[0].n, req.body[0].sub, req.body[0].class, req.body[0].page, req.body[0].num);
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
//search文件
|
|
|
router.route("/searchFile").all(async (req, res, next) => {
|
|
|
if (req.body) {
|