2024-12-19 14:01:14 +08:00

54 lines
1.5 KiB
Plaintext

package base
import (
"github.com/zhang2092/go-url-shortener/internal/templ/util"
"net/http"
)
templ Base(r *http.Request, css templ.Component, js templ.Component) {
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<link rel="shortcut icon" href="/assets/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="/assets/css/bootstrap.min.css"/>
<link rel="stylesheet" href="/assets/css/index.css"/>
@css
<title>URL短地址服务</title>
</head>
<body>
<div class="wrapper">
<nav class="navbar navbar-light bg-light navbar-wh">
<a class="navbar-brand navbar-brand-fs" href="/">
URL短地址服务
</a>
<ul class="flex oauth">
{{ auth := util.GetAuthorize(ctx) }}
if auth != nil {
<li style="font-size: 12px;">
欢迎您: { auth.Name }
</li>
<li style="font-size: 12px;">
<a href="/logout" class="btn btn-primary btn-sm">退出</a>
</li>
} else {
<li>
<a href="/login" class="btn btn-outline-primary btn-sm">登录</a>
</li>
<li>
<a href="/register" class="btn btn-primary btn-sm">注册</a>
</li>
}
</ul>
</nav>
</div>
{ children... }
<input type="hidden" id="csrf_token" value={ util.CsrfToken(r) }/>
<script src="/assets/js/jquery.min.js"></script>
<script src="/assets/js/bootstrap.bundle.min.js"></script>
@js
</body>
</html>
}