v1
This commit is contained in:
150
internal/erpserver/templ/auth/login.templ
Normal file
150
internal/erpserver/templ/auth/login.templ
Normal file
@@ -0,0 +1,150 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"management/internal/pkg/mid"
|
||||
)
|
||||
|
||||
templ Login(ctx context.Context) {
|
||||
{{ token := mid.GetCsrfToken(ctx) }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>登录</title>
|
||||
<link rel="icon" type="image/x-icon" href="/statics/favicon.ico">
|
||||
<link rel="stylesheet" href="/statics/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/statics/admin/css/other/login.css" />
|
||||
<link rel="stylesheet" href="/statics/admin/css/variables.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-page" style="background-image: url('/statics/admin/images/background.svg')">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-sm6 login-bg layui-hide-xs">
|
||||
<img class="login-bg-img" src="/statics/admin/images/banner.png" alt="" />
|
||||
</div>
|
||||
<div class="layui-col-sm6 layui-col-xs12 login-form">
|
||||
<div class="layui-form">
|
||||
<div class="form-center">
|
||||
<div class="form-center-box">
|
||||
<div class="top-log-title">
|
||||
<img class="top-log" src="/statics/favicon.ico" alt="" />
|
||||
<span>Pear Admin 4.0</span>
|
||||
</div>
|
||||
<div class="top-desc">
|
||||
以 超 乎 想 象 的 速 度 构 建 内 部 工 具
|
||||
</div>
|
||||
<div style="margin-top: 30px;">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-wrap">
|
||||
<div class="layui-input-prefix">
|
||||
<i class="layui-icon layui-icon-username"></i>
|
||||
</div>
|
||||
<input placeholder="邮 箱 " name="email" type="email" value="1185230223@qq.com"
|
||||
lay-verify="required" hover class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-wrap">
|
||||
<div class="layui-input-prefix">
|
||||
<i class="layui-icon layui-icon-password"></i>
|
||||
</div>
|
||||
<input placeholder="密 码 " name="password" type="password" value="secret"
|
||||
lay-verify="required" hover class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-log-verification">
|
||||
<div class="verification-text">
|
||||
<div class="layui-input-wrap">
|
||||
<div class="layui-input-prefix">
|
||||
<i class="layui-icon layui-icon-auz"></i>
|
||||
</div>
|
||||
<input name="captcha" type="text" lay-verify="required" value=""
|
||||
placeholder="验证码" autocomplete="off" class="layui-input">
|
||||
<input type="hidden" id="captcha_id" name="captcha_id" />
|
||||
</div>
|
||||
</div>
|
||||
<img id="captcha" src="/captcha" class="verification-img"
|
||||
style="cursor: pointer;" />
|
||||
</div>
|
||||
<div class="login-btn" style="margin-top: 15px;">
|
||||
<button type="button" lay-submit lay-filter="login"
|
||||
class="layui-btn pear-btn-success login">
|
||||
登录</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 资 源 引 入 -->
|
||||
<script src="/statics/component/layui/layui.js"></script>
|
||||
<script src="/statics/component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use(['jquery', 'form', 'button', 'popup'], function () {
|
||||
var $ = layui.jquery;
|
||||
var form = layui.form;
|
||||
var button = layui.button;
|
||||
var popup = layui.popup;
|
||||
|
||||
$(function () {
|
||||
$('#captcha').click();
|
||||
})
|
||||
|
||||
$('#captcha').click(function () {
|
||||
$.ajax({
|
||||
url: '/captcha',
|
||||
method: 'get',
|
||||
success: function (j) {
|
||||
if (j.success) {
|
||||
$('#captcha').attr('src', j.data.pic_path);
|
||||
$('#captcha_id').val(j.data.captcha_id);
|
||||
} else {
|
||||
console.log(j)
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 登 录 提 交
|
||||
form.on('submit(login)', function (data) {
|
||||
let loading = button.load({
|
||||
elem: '.login',
|
||||
});
|
||||
|
||||
data.field.csrf_token = '{{ token }}';
|
||||
$.ajax({
|
||||
url: '/login',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: data.field,
|
||||
success: function (obj) {
|
||||
if (obj.success) {
|
||||
loading.stop(function () {
|
||||
popup.success("登录成功", function () {
|
||||
location.href = "/home.html"
|
||||
});
|
||||
});
|
||||
} else {
|
||||
loading.stop(function () {
|
||||
popup.failure(obj.msg);
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (ex) {
|
||||
loading.stop(function () {
|
||||
popup.failure('网络异常,请刷新重试');
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
59
internal/erpserver/templ/auth/login_templ.go
Normal file
59
internal/erpserver/templ/auth/login_templ.go
Normal file
@@ -0,0 +1,59 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package auth
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"management/internal/pkg/mid"
|
||||
)
|
||||
|
||||
func Login(ctx context.Context) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
token := mid.GetCsrfToken(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<!doctype html><html lang=\"zh-CN\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1\"><title>登录</title><link rel=\"icon\" type=\"image/x-icon\" href=\"/statics/favicon.ico\"><link rel=\"stylesheet\" href=\"/statics/component/pear/css/pear.css\"><link rel=\"stylesheet\" href=\"/statics/admin/css/other/login.css\"><link rel=\"stylesheet\" href=\"/statics/admin/css/variables.css\"></head><body><div class=\"login-page\" style=\"background-image: url('/statics/admin/images/background.svg')\"><div class=\"layui-row\"><div class=\"layui-col-sm6 login-bg layui-hide-xs\"><img class=\"login-bg-img\" src=\"/statics/admin/images/banner.png\" alt=\"\"></div><div class=\"layui-col-sm6 layui-col-xs12 login-form\"><div class=\"layui-form\"><div class=\"form-center\"><div class=\"form-center-box\"><div class=\"top-log-title\"><img class=\"top-log\" src=\"/statics/favicon.ico\" alt=\"\"> <span>Pear Admin 4.0</span></div><div class=\"top-desc\">以 超 乎 想 象 的 速 度 构 建 内 部 工 具</div><div style=\"margin-top: 30px;\"><div class=\"layui-form-item\"><div class=\"layui-input-wrap\"><div class=\"layui-input-prefix\"><i class=\"layui-icon layui-icon-username\"></i></div><input placeholder=\"邮 箱 \" name=\"email\" type=\"email\" value=\"1185230223@qq.com\" lay-verify=\"required\" hover class=\"layui-input\"></div></div><div class=\"layui-form-item\"><div class=\"layui-input-wrap\"><div class=\"layui-input-prefix\"><i class=\"layui-icon layui-icon-password\"></i></div><input placeholder=\"密 码 \" name=\"password\" type=\"password\" value=\"secret\" lay-verify=\"required\" hover class=\"layui-input\"></div></div><div class=\"tab-log-verification\"><div class=\"verification-text\"><div class=\"layui-input-wrap\"><div class=\"layui-input-prefix\"><i class=\"layui-icon layui-icon-auz\"></i></div><input name=\"captcha\" type=\"text\" lay-verify=\"required\" value=\"\" placeholder=\"验证码\" autocomplete=\"off\" class=\"layui-input\"> <input type=\"hidden\" id=\"captcha_id\" name=\"captcha_id\"></div></div><img id=\"captcha\" src=\"/captcha\" class=\"verification-img\" style=\"cursor: pointer;\"></div><div class=\"login-btn\" style=\"margin-top: 15px;\"><button type=\"button\" lay-submit lay-filter=\"login\" class=\"layui-btn pear-btn-success login\">登录</button></div></div></div></div></div></div></div></div><!-- 资 源 引 入 --><script src=\"/statics/component/layui/layui.js\"></script><script src=\"/statics/component/pear/pear.js\"></script><script>\n \t layui.use(['jquery', 'form', 'button', 'popup'], function () {\n \t\t\tvar $ = layui.jquery;\n \t\t\tvar form = layui.form;\n \t\t\tvar button = layui.button;\n \t\t\tvar popup = layui.popup;\n\n \t\t\t$(function () {\n \t\t\t\t$('#captcha').click();\n \t\t\t})\n\n \t\t\t$('#captcha').click(function () {\n \t\t\t\t$.ajax({\n \t\t\t\t\turl: '/captcha',\n \t\t\t\t\tmethod: 'get',\n \t\t\t\t\tsuccess: function (j) {\n \t\t\t\t\t\tif (j.success) {\n \t\t\t\t\t\t\t$('#captcha').attr('src', j.data.pic_path);\n \t\t\t\t\t\t\t$('#captcha_id').val(j.data.captcha_id);\n \t\t\t\t\t\t} else {\n \t\t\t\t\t\t\tconsole.log(j)\n \t\t\t\t\t\t}\n \t\t\t\t\t}\n \t\t\t\t});\n \t\t\t});\n\n \t\t\t// 登 录 提 交\n \t\t\tform.on('submit(login)', function (data) {\n \t\t\t\tlet loading = button.load({\n \t\t\t\t\telem: '.login',\n \t\t\t\t});\n\n \t\t\t\tdata.field.csrf_token = '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/auth/login.templ`, Line: 119, Col: 41}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "';\n \t\t\t\t$.ajax({\n \t\t\t\t\turl: '/login',\n \t\t\t\t\ttype: 'post',\n \t\t\t\t\tdataType: 'json',\n \t\t\t\t\tdata: data.field,\n \t\t\t\t\tsuccess: function (obj) {\n \t\t\t\t\t\tif (obj.success) {\n \t\t\t\t\t\t\tloading.stop(function () {\n \t\t\t\t\t\t\t\tpopup.success(\"登录成功\", function () {\n \t\t\t\t\t\t\t\t\tlocation.href = \"/home.html\"\n \t\t\t\t\t\t\t\t});\n \t\t\t\t\t\t\t});\n \t\t\t\t\t\t} else {\n \t\t\t\t\t\t\tloading.stop(function () {\n \t\t\t\t\t\t\t\tpopup.failure(obj.msg);\n \t\t\t\t\t\t\t});\n \t\t\t\t\t\t}\n \t\t\t\t\t},\n \t\t\t\t\terror: function (ex) {\n \t\t\t\t\t\tloading.stop(function () {\n \t\t\t\t\t\t\tpopup.failure('网络异常,请刷新重试');\n \t\t\t\t\t\t});\n \t\t\t\t\t}\n \t\t\t\t});\n \t\t\t\treturn false;\n \t\t\t});\n \t\t})\n </script></body></html>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
Reference in New Issue
Block a user