更新底层架构

This commit is contained in:
2026-03-18 21:51:17 +08:00
parent b69c6ccbca
commit 68bea98b81
71 changed files with 5220 additions and 7619 deletions

View File

@@ -9,8 +9,7 @@
<!-- 站点图标 -->
<link rel="icon" type="image/svg+xml" href="/assets/favicon.svg" />
<link rel="shortcut icon" href="/favicon.ico" />
<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
<link href="//unpkg.com/layui@2.12.1/dist/css/layui.css" rel="stylesheet">
<link href="/static/lib/layui/css/layui.css" rel="stylesheet">
<style>
body {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
@@ -206,8 +205,7 @@
</div>
</form>
<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script src="//unpkg.com/layui@2.12.1/dist/layui.js"></script>
<script src="/static/lib/layui/layui.js"></script>
<script>
layui.use(function () {
var form = layui.form;
@@ -215,8 +213,10 @@
// 登录提交回调:向 /admin/login 发送请求,并依据 code===0 判断成功与否
form.on('submit(demo-login)', function (data) {
var loadIndex = layer.load(1, {
shade: [0.1, '#fff']
var loadIndex = layer.msg('登录中...', {
icon: 16,
shade: 0.01,
time: 0
});
// 获取CSRF令牌
@@ -231,7 +231,15 @@
},
body: JSON.stringify(data.field)
})
.then(response => response.json())
.then(response => response.text())
.then(text => {
try {
return JSON.parse(text);
} catch (e) {
console.error('Non-JSON response:', text);
throw new Error('服务器响应格式错误');
}
})
.then(result => {
layer.close(loadIndex);
@@ -256,7 +264,8 @@
.catch(error => {
layer.close(loadIndex);
console.error('登录错误:', error);
layer.msg('网络错误,请稍后重试', { icon: 2 });
var msg = error.message || '网络错误,请稍后重试';
layer.msg(msg, { icon: 2 });
// 网络错误时也刷新验证码
document.getElementById('captcha-img').src = '/admin/captcha?t=' + new Date().getTime();