v1
This commit is contained in:
79
internal/erpserver/templ/base/base.templ
Normal file
79
internal/erpserver/templ/base/base.templ
Normal file
@@ -0,0 +1,79 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
tpl "github.com/a-h/templ"
|
||||
)
|
||||
|
||||
templ Base(ctx context.Context, style, script tpl.Component) {
|
||||
<!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>component</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" />
|
||||
@style
|
||||
</head>
|
||||
|
||||
<body class="pear-container">
|
||||
{ children... }
|
||||
<script src="/statics/component/layui/layui.js"></script>
|
||||
<script src="/statics/component/pear/pear.js"></script>
|
||||
<script src="/statics/component/pear/help.js"></script>
|
||||
<script src="/statics/js/function/public.js"></script>
|
||||
<script src="/statics/js/upload.js"></script>
|
||||
<script>
|
||||
layui.use(['admin', 'jquery', 'popup', 'drawer'], function () {
|
||||
var $ = layui.jquery;
|
||||
var admin = layui.admin;
|
||||
var popup = layui.popup;
|
||||
|
||||
// 读取 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);
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@script
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
70
internal/erpserver/templ/base/base_templ.go
Normal file
70
internal/erpserver/templ/base/base_templ.go
Normal file
@@ -0,0 +1,70 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package base
|
||||
|
||||
//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"
|
||||
|
||||
tpl "github.com/a-h/templ"
|
||||
)
|
||||
|
||||
func Base(ctx context.Context, style, script tpl.Component) 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>component</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\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = style.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</head><body class=\"pear-container\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<script src=\"/statics/component/layui/layui.js\"></script><script src=\"/statics/component/pear/pear.js\"></script><script src=\"/statics/component/pear/help.js\"></script><script src=\"/statics/js/function/public.js\"></script><script src=\"/statics/js/upload.js\"></script><script>\n layui.use(['admin', 'jquery', 'popup', 'drawer'], function () {\n var $ = layui.jquery;\n var admin = layui.admin;\n var popup = layui.popup;\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 </script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = script.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</body></html>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
Reference in New Issue
Block a user