1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-16 23:22:20 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

引入sweetalert代替alert;用户注册密码长度及字符校验;注册页前端显示密码策略及样式优化;字体渲染显示网页逻辑调整;后端添加40004错误码

This commit is contained in:
2022-04-28 19:34:00 +08:00
parent 3028d0d008
commit 1378ef1bdf
32 changed files with 291 additions and 184 deletions

View File

@@ -85,11 +85,11 @@
renderTable({ data: renderData, tableId: tableElementId, renderTableHead: true });
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
@@ -110,14 +110,14 @@
categoryId: null
});
} else {
alert("删除失败!");
swal("删除失败!");
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
</script>

View File

@@ -25,13 +25,14 @@
data: { id: bookId },
success: function (data) {
console.log(data);
alert(isModify ? "修改成功!" : "添加成功!");
if (!isModify && document.getElementById("isContinuous").checked) {
location.reload();
} else {
// 回到书籍管理页
location.href = "<%= pageUrl %>../";
}
swal(isModify ? "修改成功!" : "添加成功!").then(function () {
if (!isModify && document.getElementById("isContinuous").checked) {
location.reload();
} else {
// 回到书籍管理页
location.href = "<%= pageUrl %>../";
}
});
}
});
}
@@ -46,7 +47,7 @@
console.log(data)
return data;
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
// 回到书籍管理页
location.href = "<%= pageUrl %>../";
}
@@ -77,7 +78,7 @@
render({ children: hierarchyData });
categoryOptions.shift(); // 删除数组中的第一个元素
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
console.log(categoryOptions);

View File

@@ -14,10 +14,10 @@
if (status === "success") {
console.log(data);
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
</script>

View File

@@ -89,11 +89,11 @@
renderTable({ data: renderData, tableId: tableElementId, renderTableHead: true });
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
@@ -114,14 +114,14 @@
// categoryId: null
// });
// } else {
// alert("删除失败!");
// swal("删除失败!");
// }
// } else {
// alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
// swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
// }
// }).catch(function (error) {
// console.log(error);
// alert("无法连接到服务器,请检查网络连接!");
// swal("无法连接到服务器,请检查网络连接!");
// });
// }
</script>

View File

@@ -58,11 +58,11 @@
</table>`;
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
getFileInfo();
@@ -111,11 +111,11 @@
${items.join("")}
</table>`;
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
getFileObjectInfo();
@@ -140,17 +140,17 @@
if (status === "success") {
console.log(data);
if(data == "success") {
// alert("绑定成功!");
// swal("绑定成功!");
} else {
alert("绑定失败!");
swal("绑定失败!");
}
getFileInfo();
} else {
alert(`出错啦!${data.errMsg}(错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
toggleSelectBook();
});

View File

@@ -67,11 +67,11 @@
renderTable({ data: renderData, tableId: tableElementId, renderTableHead: true });
}
} else {
alert(`出错啦!${data.errMsg}(错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
@@ -83,14 +83,14 @@
var data = axiosData.data;
if (status === "success") {
console.log(data);
alert("刷新成功!");
swal("刷新成功!");
list({ tableElementId: "book-table" });
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
@@ -107,16 +107,16 @@
console.log(data)
if (data == "success") {
list({ tableElementId: "book-table" });
alert("删除成功!");
swal("删除成功!");
} else {
alert("删除失败!");
swal("删除失败!");
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
</script>

View File

@@ -7,8 +7,9 @@
var fileObjectId = params.id;
var fileId = params.fileId;
if (!fileId) {
alert("未传入 fileId ");
history.go(-1);
swal("未传入 fileId ").then(function () {
history.go(-1);
});
}
var isModify = fileObjectId ? true : false;
@@ -28,11 +29,12 @@
data: { id: fileObjectId },
success: function (data) {
console.log(data);
alert(isModify ? "修改成功!" : "添加成功!");
if (params.referrer)
location.replace(params.referrer);
else
history.go(-1);
swal(isModify ? "修改成功!" : "添加成功!").then(function () {
if (params.referrer)
location.replace(params.referrer);
else
history.go(-1);
});
}
});
}
@@ -47,9 +49,10 @@
console.log(data)
return data;
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
// 回到上一页
history.go(-1);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`).then(function () {
// 回到上一页
history.go(-1);
});
}
}

View File

@@ -63,7 +63,7 @@
// 点击粘贴按钮
function pasteText() {
if (!navigator.clipboard) {
alert("浏览器不支持读取剪切板,请手动粘贴!");
swal("浏览器不支持读取剪切板,请手动粘贴!");
return;
}
navigator.clipboard.readText().then(text => {
@@ -72,7 +72,7 @@
onPaste();
}).catch(err => {
console.error('Failed to read clipboard contents: ', err);
alert("读取剪切板失败,请手动粘贴!");
swal("读取剪切板失败,请手动粘贴!");
});
}
</script>

View File

@@ -161,7 +161,7 @@
return;
}
if (fileList.length > 1) {
alert("一次只能选择1个文件");
swal("一次只能选择1个文件");
return;
}
@@ -171,7 +171,7 @@
// // 判断用户选择的文件是否为文件夹
// if (await isFolder(file)) {
// alert("不支持文件夹,请选择文件!");
// swal("不支持文件夹,请选择文件!");
// return;
// }
@@ -277,11 +277,11 @@
updateUI({ isFileEmpty: true });
if (dt.items.length > 1) {
alert("一次只能选择1个文件");
swal("一次只能选择1个文件");
return;
}
if (dt.items[0].webkitGetAsEntry().isDirectory) {
alert("不支持文件夹,请选择文件!");
swal("不支持文件夹,请选择文件!");
return;
}
handleFiles(files);
@@ -350,7 +350,7 @@
//##############################################
function upload() {
if (!file) {
alert("您还未选择文件!");
swal("您还未选择文件!");
return;
}
var postParams = {
@@ -378,7 +378,7 @@
} else {
if (data.errCode == "60001") {
// 文件已存在
console.log(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
console.log(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
// 再次发送请求,查询这个已存在文件的 fileId
postRequest("/file/getFileByHash", { token: localStorageUtils.getToken(), fileSha1: fileInfo.fileSha1 })
@@ -394,19 +394,19 @@
if (isRedirect)
location.href = `<%= pageUrl %>../detail?fileId=${data.id}`;
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
@@ -436,13 +436,14 @@
setTimeout(function () {
// 上传成功触发一次 “刷新文件对象上传状态”,避免因为云函数回调不成功导致文件对象上传状态没有及时更新
refreshFileObjectStatus(fileObjectId, function () {
alert("上传成功!");
if ($("#checkbox-auto-upload").is(":checked")) {
window.location.reload();
} else {
// location.href = "<%= pageUrl %>../";
location.href = "<%= pageUrl %>../detail?id=" + fileId;
}
swal("上传成功!").then(function () {
if ($("#checkbox-auto-upload").is(":checked")) {
window.location.reload();
} else {
// location.href = "<%= pageUrl %>../";
location.href = "<%= pageUrl %>../detail?id=" + fileId;
}
});
});
}, 300);
};
@@ -474,11 +475,11 @@
// fileAssociator.innerHTML += optionHTML;
fileAssociator.innerHTML = `<option value="0">新建文件</option>` + optionHTML;
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
</script>
@@ -495,11 +496,11 @@
if (callback)
callback();
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
</script>