1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-12 19:51:39 +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

@@ -8,8 +8,9 @@ var localStorageUtils = {
localStorage.removeItem('test');
return true;
} catch (e) {
alert("您的浏览器不支持localStorage请更换浏览器");
window.location.href = "/";
swal("您的浏览器不支持localStorage请更换浏览器").then(function () {
window.location.href = "/";
});
return false;
}
},

View File

@@ -55,15 +55,16 @@ function search({ tableElementId = "", searchText = "", categoryId = 0 }) {
renderTable({ data: renderData, tableId: tableElementId, renderTableHead: true });
}
// 渲染后重新获取一次字体
if (typeof (fontmin) === "function") {
fontmin(getPageText());
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
// 渲染后重新获取一次字体
if (typeof (fontmin) === "function") {
fontmin(getPageText());
}
});
}

File diff suppressed because one or more lines are too long

View File

@@ -275,7 +275,7 @@
出版社:${data.publishingHouse}<br>
</p>
<div class="group-button">
<img id="favorties-button" src="/assets/image/svg/favorites_empty.svg" style="visibility: hidden; opacity: 1; transition: all 0.3s;" title="点击收藏/取消收藏" onclick="alert('请先登录!')" />
<img id="favorties-button" src="/assets/image/svg/favorites_empty.svg" style="visibility: hidden; opacity: 1; transition: all 0.3s;" title="点击收藏/取消收藏" onclick="swal('请先登录!')" />
<!-- 预加载图片 --><img src="/assets/image/svg/favorites_fill.svg" style="display: none;" />
<a class="download-link" href="javaScript:scrollToTarget()"><img id="download-icon" src="/assets/image/svg/download.svg" /><span>下载这本书</span></a>
@@ -293,11 +293,11 @@
// 获取用户收藏信息
getUserFavouritesStatus();
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
doFontmin();
});
@@ -336,12 +336,12 @@
// 登录过期,小问题,这里不弹窗显示
localStorageUtils.userLogout();
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}
}).catch(function (error) {
console.log(error);
// alert("无法连接到服务器,请检查网络连接!");
// swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
$("#favorties-button").css("visibility", "visible");
});
@@ -374,11 +374,11 @@
console.log("操作失败");
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
// alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
setTimeout(toggleDisplayButton, 500);
});
@@ -542,11 +542,11 @@
}, 500);
});
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
doFontmin();
});
@@ -560,7 +560,7 @@
console.log("fileObject", fileObject);
if(!localStorageUtils.getLoginStatus()) {
alert("请先登录!");
swal("请先登录!");
return;
}
@@ -582,11 +582,11 @@
console.log(downloadLink);
downloadLink.click();
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
</script>
@@ -612,16 +612,16 @@
if (status === "success") {
// console.log(data);
if (data) {
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

@@ -10,6 +10,7 @@
<script src="/assets/lib/axios/0.26.1/axios.min.js"></script>
<script src="/assets/javascripts/httpRequestUtils.js"></script>
<script src="/assets/javascripts/localStorageUtils.js"></script>
<script src="/assets/lib/sweetalert/2.1.2/sweetalert.min.js"></script>
<script>
// API地址
const APIHOST = '<%= global.site.api.prefix %>';
@@ -36,8 +37,9 @@
// 绑定第三方账号
// 绑定第三方账号成功
alert("绑定成功");
location.href = "/dashboard/user/my-account";
swal("绑定成功").then(() => {
location.href = "/dashboard/user/my-account";
});
} else {
// 第三方登录成功
localStorageUtils.userLogin({
@@ -51,8 +53,9 @@
}
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
location.replace("/login");
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`).then(function () {
location.replace("/login");
});
}
}).catch(function (error) {
console.log(error);

View File

@@ -89,15 +89,17 @@
<p>${data.description}</p>
</div>
</div>`;
// 渲染后重新获取一次字体
fontmin(getPageText());
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
// 渲染后重新获取一次字体
if (typeof (fontmin) === "function") {
fontmin(getPageText());
}
});
</script>
</body>

View File

@@ -113,16 +113,18 @@
} else {
renderTable({ data: renderData, tableId: "result-table", renderTableHead: true });
}
// 渲染后重新获取一次字体
fontmin(getPageText());
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
});
swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
// 渲染后重新获取一次字体
if (typeof (fontmin) === "function") {
fontmin(getPageText());
}
});
</script>
</body>
</html>

View File

@@ -39,17 +39,11 @@
.then(function (response) {
// 当接口成功返回时动态设置css
loadFont(response.data.url);
$("html,body").css("transition", ".05s");
setTimeout(() => {
$("html,body").css("opacity", "1");
}, 100)
})
.catch(function (error) {
console.log("字体加载失败", error);
$("html,body").css("transition", ".05s");
setTimeout(() => {
$("html,body").css("opacity", "1");
}, 100)
}).finally(function () {
finishFontLoading();
});
}
@@ -67,6 +61,12 @@
console.log("字体加载成功");
}
function finishFontLoading() {
$("html,body").css("transition", ".05s");
setTimeout(() => {
$("html,body").css("opacity", "1");
}, 100);
}
$(document).ready(function () {
var allText = getPageText();
@@ -74,7 +74,7 @@
if ('<%= typeof(minfontOnLoad) === "undefined" ? "true" : minfontOnLoad %>' != "false") {
fontmin(allText);
} else {
// $("html,body").css("opacity", "1");
setTimeout(finishFontLoading, 1000);
}
});
</script>

View File

@@ -8,6 +8,9 @@
<script src="/assets/lib/jquery/3.6.0/jquery.min.js"></script>
<script src="/assets/lib/axios/0.26.1/axios.min.js"></script>
<!-- refer: https://www.sweetalert.cn/ -->
<script src="/assets/lib/sweetalert/2.1.2/sweetalert.min.js"></script>
<script src="/assets/javascripts/httpRequestUtils.js"></script>
<script src="/assets/javascripts/localStorageUtils.js"></script>
<script>
@@ -19,7 +22,6 @@
/* 字体加载前先隐藏,不然文字会闪一下 */
html, body { opacity: 0; }
</style>
<script>
/**
* 获取用户浏览器指纹

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>

View File

@@ -62,7 +62,7 @@
$("#btn-account-cancellation-confirm").click(function () {
var accountCancellationPassword = $("#account-cancellation-password").val();
if (accountCancellationPassword == "") {
alert("请输入您的密码");
swal("请输入您的密码");
return;
}
postRequest("/user/cancelAccount", { token: localStorageUtils.getToken(), password: accountCancellationPassword })
@@ -73,18 +73,19 @@
if (status === "success") {
console.log(data);
if (data == "success") {
alert("注销成功!");
location.reload();
swal("注销成功!").then(function () {
location.reload();
});
} else {
alert("出错啦,刷新页面重新试试吧");
swal("出错啦,刷新页面重新试试吧");
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
$("#account-cancellation-password").val("");
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
});
</script>

View File

@@ -8,6 +8,9 @@
<script src="/assets/lib/jquery/3.6.0/jquery.min.js"></script>
<script src="/assets/lib/axios/0.26.1/axios.min.js"></script>
<!-- refer: https://www.sweetalert.cn/ -->
<script src="/assets/lib/sweetalert/2.1.2/sweetalert.min.js"></script>
<script src="/assets/javascripts/httpRequestUtils.js"></script>
<script src="/assets/javascripts/localStorageUtils.js"></script>
<script>
@@ -52,15 +55,16 @@
window.location.href = "/login";
}
} else {
if(data.errCode == "20004") { // 登录过期
localStorageUtils.userLogout();
window.location.href = "/login?redirect=" + encodeURIComponent(location.pathname + location.search);
}
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`).then(function () {
if(data.errCode == "20004") { // 登录过期
localStorageUtils.userLogout();
window.location.href = "/login?redirect=" + encodeURIComponent(location.pathname + location.search);
}
});
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
getUserStatus();

View File

@@ -125,11 +125,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("无法连接到服务器,请检查网络连接!");
});
}

View File

@@ -21,7 +21,7 @@
<div class="navbar-grid">
<div class="grid-item"></div>
<div class="grid-item" style="grid-column-start: span 2;">
<h1 style="display: inline; vertical-align: middle; margin-right: 20px; cursor: pointer;" onclick="location.href='/';">
<h1 style="display: inline; vertical-align: middle; margin-right: 20px; cursor: pointer;" onclick="window.open('/');">
<img src="/assets/image/svg/home.svg" style="width: 1em; height: 1em; transform: translateY(2px);" title="返回首页">
</h1>
<% Object.keys(dashboardPage).forEach(item => { %>
@@ -47,10 +47,10 @@
localStorageUtils.userLogout();
location.href = "/login";
} else {
alert("退出登录失败");
swal("退出登录失败");
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);

View File

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

View File

@@ -16,18 +16,20 @@
if (status === "success") {
console.log(data);
if (data == "success") {
alert("取消绑定成功!");
location.reload();
swal("取消绑定成功!").then(function () {
location.reload();
});
} else {
alert("出错啦,刷新页面重新试试吧");
swal("出错啦,刷新页面重新试试吧");
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
location.reload();
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`).then(function () {
location.reload();
});
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
if (localStorageUtils.getLoginStatus() != null) {
@@ -55,11 +57,11 @@
}
} else {
$(".btn-third-party").hide();
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
}
</script>

View File

@@ -99,7 +99,7 @@
var control = document.getElementById(controlsProfileItem.attr.id);
// 判断 control 是否为空
if (!control) {
alert("控件不存在:" + controlsProfileItem.attr.id);
swal("控件不存在:" + controlsProfileItem.attr.id);
return;
}
var name = control.name;
@@ -109,8 +109,9 @@
if (validateResult.result) {
data[name] = value;
} else {
alert(validateResult.msg);
control.focus();
swal(validateResult.msg).then(function () {
control.focus();
});
return;
}
}
@@ -133,16 +134,17 @@
if (status === "success") {
success(data);
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
if (data.errCode == "20004") {
// 登录过期
localStorageUtils.userLogout();
location.href = "/login?redirect=" + encodeURIComponent(location.pathname + location.search);
}
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`).then(function () {
if (data.errCode == "20004") {
// 登录过期
localStorageUtils.userLogout();
location.href = "/login?redirect=" + encodeURIComponent(location.pathname + location.search);
}
});
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
$("#favorties-button").css("visibility", "visible");
});

View File

@@ -48,17 +48,17 @@
} else {
renderTable({ data: renderData, tableId: tableElementId, renderTableHead: true });
}
// 渲染后重新获取一次字体
if (typeof (fontmin) === "function") {
fontmin(getPageText());
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
// 渲染后重新获取一次字体
if (typeof (fontmin) === "function") {
fontmin(getPageText());
}
});
}
@@ -93,11 +93,11 @@
console.log("操作失败");
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
requestingFlag = false;
});

View File

@@ -107,7 +107,7 @@
});
$(".btn-submit").click(async function () {
if ($("#username").val() === "" || $("#password").val() === "") {
alert("用户名或密码不能为空!");
await swal("用户名或密码不能为空!");
if ($("#username").val() === "") {
$("#username").focus();
} else {
@@ -157,14 +157,14 @@
window.location.href = "/dashboard/user/index";
}
} else {
alert("用户名或密码错误");
swal("用户名或密码错误");
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
}).finally(function () {
isOnLogin = false;
});

View File

@@ -21,10 +21,13 @@
width: 250px;
margin: 0 auto;
row-gap: 20px;
margin-bottom: 30px;
place-items: center;
}
.btn-register {
margin-top: 30px;
}
.form-group > input {
height: 25px;
}
@@ -33,6 +36,17 @@
height: 30px;
width: 72px;
}
.password-tips {
position: relative;
border-radius: 5px;
border: solid black 2px;
width: 300px;
margin: 0 auto;
background-color: aliceblue;
user-select: none;
font-size: 13px;
}
</style>
</head>
<body>
@@ -49,6 +63,11 @@
<label for="password">密码</label>
<input type="password" id="password" placeholder="密码">
</div>
<div style="height: 0; margin-top: 6px;">
<div class="password-tips" style="display: none;">
密码 8 - 16 位均可,可以包含:大小写字母、数字、下划线(_)、英文感叹号(!)、艾特(@)、井号(#)
</div>
</div>
<button class="btn-register">注册</button>
<p>
<a href="/login">登录</a>
@@ -59,6 +78,16 @@
</main>
<%- include("./component/footer.html"); %>
<script>
$("#password").focus(function () {
$("#password").attr("type", "text");
$(".password-tips").fadeIn(150);
});
$("#password").blur(function () {
$("#password").attr("type", "password");
$(".password-tips").fadeOut(150);
});
</script>
<script>
localStorageUtils.checkLocalStorage();
@@ -82,21 +111,22 @@
token: data.token,
is_admin: data.group === "ADMIN",
});
alert("注册成功");
if (localStorageUtils.getIsAdmin()) {
window.location.href = "/dashboard/admin/index";
} else {
window.location.href = "/dashboard/user/index";
}
swal("注册成功").then(function () {
if (localStorageUtils.getIsAdmin()) {
window.location.href = "/dashboard/admin/index";
} else {
window.location.href = "/dashboard/user/index";
}
});
} else {
alert("出错啦!");
swal("出错啦!");
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
swal(`出错啦!${data.errMsg} (错误码: ${data.errCode})`);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
swal("无法连接到服务器,请检查网络连接!");
});
});
</script>