v1
This commit is contained in:
38
internal/erpserver/templ/home/dashboard.templ
Normal file
38
internal/erpserver/templ/home/dashboard.templ
Normal file
@@ -0,0 +1,38 @@
|
||||
package home
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"management/internal/pkg/mid"
|
||||
)
|
||||
|
||||
templ Dashboard(ctx context.Context, loginCount int, thisLoginTime, lastLoginTime time.Time) {
|
||||
{{ user := mid.GetUser(ctx) }}
|
||||
<div class="layui-row h-all">
|
||||
<div class="layui-col-md12" style="padding: 10px;">
|
||||
<div class="layui-panel userinfo">
|
||||
<div class="logo">
|
||||
@avatar(user.Avatar)
|
||||
</div>
|
||||
<div class="info">
|
||||
@info(user.Username, user.RoleName, loginCount, thisLoginTime, lastLoginTime)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ avatar(avatar string) {
|
||||
<img src={ avatar } alt="logo">
|
||||
}
|
||||
|
||||
templ info(username, roleName string, loginCount int, thisLoginTime, lastLoginTime time.Time) {
|
||||
<p class="name">欢迎您,{ username } ({ roleName })</p>
|
||||
if loginCount == 1 {
|
||||
<p>这是您第 1 次登录,本次登录日期:{ thisLoginTime.Format(time.DateTime) },如果不是您本人登录,请及时修改密码 。</p>
|
||||
} else {
|
||||
<p>这是您第 { loginCount } 次登录,本次登录日期:{ thisLoginTime.Format(time.DateTime) },
|
||||
上次登录日期:{ lastLoginTime.Format(time.DateTime) },如果不是您本人登录,请及时修改密码 。</p>
|
||||
}
|
||||
}
|
||||
224
internal/erpserver/templ/home/dashboard_templ.go
Normal file
224
internal/erpserver/templ/home/dashboard_templ.go
Normal file
@@ -0,0 +1,224 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package home
|
||||
|
||||
//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"
|
||||
"time"
|
||||
|
||||
"management/internal/pkg/mid"
|
||||
)
|
||||
|
||||
func Dashboard(ctx context.Context, loginCount int, thisLoginTime, lastLoginTime time.Time) 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)
|
||||
user := mid.GetUser(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"layui-row h-all\"><div class=\"layui-col-md12\" style=\"padding: 10px;\"><div class=\"layui-panel userinfo\"><div class=\"logo\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = avatar(user.Avatar).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</div><div class=\"info\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = info(user.Username, user.RoleName, loginCount, thisLoginTime, lastLoginTime).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</div></div></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func avatar(avatar string) 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_Var2 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var2 == nil {
|
||||
templ_7745c5c3_Var2 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<img src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(avatar)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/home/dashboard.templ`, Line: 27, Col: 21}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\" alt=\"logo\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func info(username, roleName string, loginCount int, thisLoginTime, lastLoginTime time.Time) 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_Var4 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var4 == nil {
|
||||
templ_7745c5c3_Var4 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<p class=\"name\">欢迎您,")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(username)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/home/dashboard.templ`, Line: 31, Col: 42}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " (")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(roleName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/home/dashboard.templ`, Line: 31, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, ")</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if loginCount == 1 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<p>这是您第 1 次登录,本次登录日期:")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(thisLoginTime.Format(time.DateTime))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/home/dashboard.templ`, Line: 33, Col: 96}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, ",如果不是您本人登录,请及时修改密码 。</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "<p>这是您第 ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(loginCount)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/home/dashboard.templ`, Line: 35, Col: 36}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, " 次登录,本次登录日期:")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(thisLoginTime.Format(time.DateTime))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/home/dashboard.templ`, Line: 35, Col: 109}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, ", 上次登录日期:")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(lastLoginTime.Format(time.DateTime))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/home/dashboard.templ`, Line: 36, Col: 70}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, ",如果不是您本人登录,请及时修改密码 。</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
174
internal/erpserver/templ/home/home.templ
Normal file
174
internal/erpserver/templ/home/home.templ
Normal file
@@ -0,0 +1,174 @@
|
||||
package home
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"management/internal/pkg/mid"
|
||||
)
|
||||
|
||||
templ Home(ctx context.Context) {
|
||||
<!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/admin.css" />
|
||||
<link rel="stylesheet" href="/statics/admin/css/admin.dark.css" />
|
||||
<link rel="stylesheet" href="/statics/admin/css/variables.css" />
|
||||
<link rel="stylesheet" href="/statics/admin/css/reset.css" />
|
||||
<link rel="stylesheet" href="/statics/admin/css/style.css" />
|
||||
</head>
|
||||
|
||||
<body class="layui-layout-body pear-admin">
|
||||
<!-- 布 局 框 架 -->
|
||||
<div class="layui-layout layui-layout-admin">
|
||||
<!-- 顶 部 样 式 -->
|
||||
<div class="layui-header">
|
||||
<!-- 菜 单 顶 部 -->
|
||||
<div class="layui-logo">
|
||||
<!-- 图 标 -->
|
||||
<img class="logo" alt="" src="">
|
||||
<!-- 标 题 -->
|
||||
<span class="title"></span>
|
||||
</div>
|
||||
<!-- 顶 部 左 侧 功 能 -->
|
||||
<ul class="layui-nav layui-layout-left">
|
||||
<li class="collapse layui-nav-item">
|
||||
<a href="#" class="layui-icon layui-icon-shrink-right"> </a>
|
||||
</li>
|
||||
<li class="refresh layui-nav-item">
|
||||
<a href="#" class="layui-icon layui-icon-refresh-1"> </a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- 多 系 统 菜 单 -->
|
||||
<div id="control" class="layui-layout-control"></div>
|
||||
<!-- 顶 部 右 侧 菜 单 -->
|
||||
<ul class="layui-nav layui-layout-right">
|
||||
<!-- <li class="layui-nav-item layui-hide-xs"><a href="#"
|
||||
class="menuSearch layui-icon layui-icon-search"></a></li>
|
||||
<li class="layui-nav-item layui-hide-xs message"></li> -->
|
||||
<li class="layui-nav-item layui-hide-xs"><a href="#"
|
||||
class="fullScreen layui-icon layui-icon-screen-full"></a></li>
|
||||
<li class="layui-nav-item user">
|
||||
<!-- 头 像 -->
|
||||
<a class="layui-icon layui-icon-username" href="javascript:;"></a>
|
||||
<!-- 功 能 菜 单 -->
|
||||
<dl class="layui-nav-child">
|
||||
{{ user := mid.GetUser(ctx) }}
|
||||
if user.ID > 0 {
|
||||
<dd>
|
||||
<a user-menu-url="/system/user/profile" user-menu-id="profile"
|
||||
user-menu-title="基本资料">基本资料</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="javascript:void(0);" title={ user.Username } class="logout">注销登录</a>
|
||||
</dd>
|
||||
}
|
||||
</dl>
|
||||
</li>
|
||||
<!-- 主 题 配 置 -->
|
||||
<li class="layui-nav-item setting"><a href="#" class="layui-icon layui-icon-more-vertical"></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- 侧 边 区 域 -->
|
||||
<div class="layui-side layui-bg-black">
|
||||
<!-- 菜 单 顶 部 -->
|
||||
<div class="layui-logo">
|
||||
<!-- 图 标 -->
|
||||
<img class="logo">
|
||||
<!-- 标 题 -->
|
||||
<span class="title"></span>
|
||||
</div>
|
||||
<!-- 菜 单 内 容 -->
|
||||
<div class="layui-side-scroll">
|
||||
<div id="side"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 视 图 页 面 -->
|
||||
<div class="layui-body" style="padding: 0">
|
||||
<!-- 内 容 页 面 -->
|
||||
<div id="content"></div>
|
||||
</div>
|
||||
<!-- 页脚 -->
|
||||
<div class="layui-footer layui-text"></div>
|
||||
<!-- 遮 盖 层 -->
|
||||
<div class="pear-cover"></div>
|
||||
<!-- 加 载 动 画 -->
|
||||
<div class="loader-wrapper">
|
||||
<!-- 动 画 对 象 -->
|
||||
<div class="loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 移 动 端 便 捷 操 作 -->
|
||||
<div class="pear-collapsed-pe collapse">
|
||||
<a href="#" class="layui-icon layui-icon-shrink-right"></a>
|
||||
</div>
|
||||
|
||||
<script src="/statics/component/layui/layui.js"></script>
|
||||
<script src="/statics/component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use(['admin', 'jquery', 'popup', 'drawer'], function () {
|
||||
const $ = layui.jquery;
|
||||
const admin = layui.admin;
|
||||
const popup = layui.popup;
|
||||
|
||||
// yml | json | api
|
||||
admin.setConfigurationPath("/pear.json");
|
||||
|
||||
admin.render();
|
||||
|
||||
// 登出逻辑
|
||||
admin.logout(function () {
|
||||
window.location.href = '/logout';
|
||||
// 清空 tabs 缓存
|
||||
return new Promise((resolve) => {
|
||||
resolve(true)
|
||||
});
|
||||
})
|
||||
|
||||
// 读取 localStorage 主题颜色值,初始化 iframe 主题
|
||||
//darkTheme();
|
||||
//themeColor();
|
||||
|
||||
// iframe 页监听 localStorage [pear 框架主题颜色] 变化。发生变化,同步更新 iframe 显示效果
|
||||
// window.addEventListener('storage', function (event) {
|
||||
// if (event.key === 'dark') {
|
||||
// darkTheme();
|
||||
// }
|
||||
// if (event.key === 'theme-color') {
|
||||
// themeColor();
|
||||
// }
|
||||
// });
|
||||
|
||||
// 夜间模式切换
|
||||
// function darkTheme() {
|
||||
// var $pearAdmin = $(".pear-admin"); // 主体
|
||||
// var $layuiCard = $('.layui-card'); // 编辑页
|
||||
|
||||
// if (localStorage.getItem('dark') === 'true') {
|
||||
// $pearAdmin.addClass("pear-admin-dark");
|
||||
// $layuiCard.addClass('layui-card-dark');
|
||||
// } else {
|
||||
// $pearAdmin.removeClass("pear-admin-dark");
|
||||
// $layuiCard.removeClass('layui-card-dark');
|
||||
// }
|
||||
// }
|
||||
|
||||
// 主题颜色切换
|
||||
// function themeColor() {
|
||||
// const variableKey = "--global-primary-color";
|
||||
// const variableVal = localStorage.getItem("theme-color-color");
|
||||
// document.documentElement.style.setProperty(variableKey, variableVal);
|
||||
// }
|
||||
|
||||
// 消息点击回调
|
||||
// admin.message(function (id, title, context, form) { });
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
70
internal/erpserver/templ/home/home_templ.go
Normal file
70
internal/erpserver/templ/home/home_templ.go
Normal file
@@ -0,0 +1,70 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package home
|
||||
|
||||
//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 Home(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)
|
||||
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/admin.css\"><link rel=\"stylesheet\" href=\"/statics/admin/css/admin.dark.css\"><link rel=\"stylesheet\" href=\"/statics/admin/css/variables.css\"><link rel=\"stylesheet\" href=\"/statics/admin/css/reset.css\"><link rel=\"stylesheet\" href=\"/statics/admin/css/style.css\"></head><body class=\"layui-layout-body pear-admin\"><!-- 布 局 框 架 --><div class=\"layui-layout layui-layout-admin\"><!-- 顶 部 样 式 --><div class=\"layui-header\"><!-- 菜 单 顶 部 --><div class=\"layui-logo\"><!-- 图 标 --><img class=\"logo\" alt=\"\" src=\"\"><!-- 标 题 --><span class=\"title\"></span></div><!-- 顶 部 左 侧 功 能 --><ul class=\"layui-nav layui-layout-left\"><li class=\"collapse layui-nav-item\"><a href=\"#\" class=\"layui-icon layui-icon-shrink-right\"></a></li><li class=\"refresh layui-nav-item\"><a href=\"#\" class=\"layui-icon layui-icon-refresh-1\"></a></li></ul><!-- 多 系 统 菜 单 --><div id=\"control\" class=\"layui-layout-control\"></div><!-- 顶 部 右 侧 菜 单 --><ul class=\"layui-nav layui-layout-right\"><!-- <li class=\"layui-nav-item layui-hide-xs\"><a href=\"#\"\n class=\"menuSearch layui-icon layui-icon-search\"></a></li>\n <li class=\"layui-nav-item layui-hide-xs message\"></li> --><li class=\"layui-nav-item layui-hide-xs\"><a href=\"#\" class=\"fullScreen layui-icon layui-icon-screen-full\"></a></li><li class=\"layui-nav-item user\"><!-- 头 像 --><a class=\"layui-icon layui-icon-username\" href=\"javascript:;\"></a><!-- 功 能 菜 单 --><dl class=\"layui-nav-child\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
user := mid.GetUser(ctx)
|
||||
if user.ID > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<dd><a user-menu-url=\"/system/user/profile\" user-menu-id=\"profile\" user-menu-title=\"基本资料\">基本资料</a></dd><dd><a href=\"javascript:void(0);\" title=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(user.Username)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/home/home.templ`, Line: 68, Col: 91}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\" class=\"logout\">注销登录</a></dd>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</dl></li><!-- 主 题 配 置 --><li class=\"layui-nav-item setting\"><a href=\"#\" class=\"layui-icon layui-icon-more-vertical\"></a></li></ul></div><!-- 侧 边 区 域 --><div class=\"layui-side layui-bg-black\"><!-- 菜 单 顶 部 --><div class=\"layui-logo\"><!-- 图 标 --><img class=\"logo\"><!-- 标 题 --><span class=\"title\"></span></div><!-- 菜 单 内 容 --><div class=\"layui-side-scroll\"><div id=\"side\"></div></div></div><!-- 视 图 页 面 --><div class=\"layui-body\" style=\"padding: 0\"><!-- 内 容 页 面 --><div id=\"content\"></div></div><!-- 页脚 --><div class=\"layui-footer layui-text\"></div><!-- 遮 盖 层 --><div class=\"pear-cover\"></div><!-- 加 载 动 画 --><div class=\"loader-wrapper\"><!-- 动 画 对 象 --><div class=\"loader\"></div></div></div><!-- 移 动 端 便 捷 操 作 --><div class=\"pear-collapsed-pe collapse\"><a href=\"#\" class=\"layui-icon layui-icon-shrink-right\"></a></div><script src=\"/statics/component/layui/layui.js\"></script><script src=\"/statics/component/pear/pear.js\"></script><script>\n layui.use(['admin', 'jquery', 'popup', 'drawer'], function () {\n const $ = layui.jquery;\n const admin = layui.admin;\n const popup = layui.popup;\n\n // yml | json | api\n admin.setConfigurationPath(\"/pear.json\");\n\n admin.render();\n\n // 登出逻辑\n admin.logout(function () {\n window.location.href = '/logout';\n // 清空 tabs 缓存\n return new Promise((resolve) => {\n resolve(true)\n });\n })\n\n // 读取 localStorage 主题颜色值,初始化 iframe 主题\n //darkTheme();\n //themeColor();\n\n // iframe 页监听 localStorage [pear 框架主题颜色] 变化。发生变化,同步更新 iframe 显示效果\n // window.addEventListener('storage', function (event) {\n // if (event.key === 'dark') {\n // darkTheme();\n // }\n // if (event.key === 'theme-color') {\n // themeColor();\n // }\n // });\n\n // 夜间模式切换\n // function darkTheme() {\n // var $pearAdmin = $(\".pear-admin\"); // 主体\n // var $layuiCard = $('.layui-card'); // 编辑页\n\n // if (localStorage.getItem('dark') === 'true') {\n // $pearAdmin.addClass(\"pear-admin-dark\");\n // $layuiCard.addClass('layui-card-dark');\n // } else {\n // $pearAdmin.removeClass(\"pear-admin-dark\");\n // $layuiCard.removeClass('layui-card-dark');\n // }\n // }\n\n // 主题颜色切换\n // function themeColor() {\n // const variableKey = \"--global-primary-color\";\n // const variableVal = localStorage.getItem(\"theme-color-color\");\n // document.documentElement.style.setProperty(variableKey, variableVal);\n // }\n\n // 消息点击回调\n // admin.message(function (id, title, context, form) { });\n })\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