From a83fe43cbbbd0642b35f7edf2e431550f15596b1 Mon Sep 17 00:00:00 2001 From: lutinglt Date: Fri, 21 Nov 2025 14:28:40 +0800 Subject: [PATCH] Navigation bar Issue & PR moved to the right side. --- .env.example | 4 +- .github/CHANGELOG.md | 8 +- CHANGELOG.md | 13 +- gitea/README.md | 1 + gitea/templates/base/head_navbar.tmpl | 173 ++++++++++++++++++++ gitea/templates/base/head_navbar_icons.tmpl | 25 +++ src/core/vite.ts | 23 ++- styles/components/notification.ts | 2 +- styles/public/input.ts | 2 +- templates/base/head_navbar.tmpl | 167 +++++++++++++++++++ templates/base/head_navbar_icons.tmpl | 35 ++++ 11 files changed, 440 insertions(+), 13 deletions(-) create mode 100644 gitea/README.md create mode 100644 gitea/templates/base/head_navbar.tmpl create mode 100644 gitea/templates/base/head_navbar_icons.tmpl create mode 100644 templates/base/head_navbar.tmpl create mode 100644 templates/base/head_navbar_icons.tmpl diff --git a/.env.example b/.env.example index 77f64d6..d8bbf22 100644 --- a/.env.example +++ b/.env.example @@ -5,4 +5,6 @@ SSH_SERVER=localhost # 上传到服务器的用户名称, 不支持密码, 请确保有 SSH 免密登录权限 SSH_USER=root # 上传到服务器的主题路径, 请使用绝对路径 -GITEA_THEME_PATH=/data/gitea/public/assets/css/ \ No newline at end of file +GITEA_THEME_PATH=/data/gitea/public/assets/css/ +# Gitea 数据路径, 用于上传到服务器的模板路径, 请使用绝对路径 +GITEA_PATH=/data/gitea/ \ No newline at end of file diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index a611f54..a87bff8 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -6,7 +6,9 @@ ### 🌈 Style -##### 更符合 GitHub 风格 +#### 更符合 GitHub 风格 + +##### 模板文件 ### 🐞 Fix @@ -14,7 +16,9 @@ #### CSS Variable -##### More GitHub-like style +#### More GitHub-like style + +##### Template File ```text 在 English 下方补充上面 Feature 以下部分的内容的中译英​ diff --git a/CHANGELOG.md b/CHANGELOG.md index 93eacda..85afc88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ +### ✨ Feature + +- Added template files to make Gitea's layout more similar to GitHub. (This is optional, you can choose whether to use + template files based on your needs) + ### 🌈 Style -##### More aligned with GitHub style +#### More aligned with GitHub style - Optimize global line height. - Optimize the workflow log page style. @@ -8,10 +13,14 @@ - Optimize organization detail page style. - Optimize top navbar style on mobile. +##### Template File + +- Navigation bar Issue & PR moved to the right side. + ### 🐞 Fix - Fix the problem of missing background color and width when there is a unicode character in the diff. - Fix the disabled operation button interval in the code preview interface. - Fix fixed height when scrolling through step titles on workflow detail pages. - Fix packages details page style. -- Fix the color of missing icons and text on the homepage when not logged in. \ No newline at end of file +- Fix the color of missing icons and text on the homepage when not logged in. diff --git a/gitea/README.md b/gitea/README.md new file mode 100644 index 0000000..d94abc6 --- /dev/null +++ b/gitea/README.md @@ -0,0 +1 @@ +模板的原始文件 diff --git a/gitea/templates/base/head_navbar.tmpl b/gitea/templates/base/head_navbar.tmpl new file mode 100644 index 0000000..b721779 --- /dev/null +++ b/gitea/templates/base/head_navbar.tmpl @@ -0,0 +1,173 @@ + diff --git a/gitea/templates/base/head_navbar_icons.tmpl b/gitea/templates/base/head_navbar_icons.tmpl new file mode 100644 index 0000000..e3bdd27 --- /dev/null +++ b/gitea/templates/base/head_navbar_icons.tmpl @@ -0,0 +1,25 @@ +{{- $itemExtraClass := .ItemExtraClass -}} +{{- $data := .PageGlobalData -}} +{{if and $data $data.IsSigned}}{{/* data may not exist, for example: rendering 503 page before the PageGlobalData middleware */}} + {{- $activeStopwatch := call $data.GetActiveStopwatch -}} + {{- $notificationUnreadCount := call $data.GetNotificationUnreadCount -}} + {{if $activeStopwatch}} + +
+ {{svg "octicon-stopwatch"}} + +
+
+ {{end}} + +
+ {{svg "octicon-bell"}} + {{$notificationUnreadCount}} +
+
+ {{if $data.IsSiteAdmin}} + + {{svg "octicon-server"}} + + {{end}} +{{end}} diff --git a/src/core/vite.ts b/src/core/vite.ts index 55337ca..251ed37 100644 --- a/src/core/vite.ts +++ b/src/core/vite.ts @@ -121,17 +121,28 @@ export function themePlugin(): Plugin { const server = process.env.SSH_SERVER; const user = process.env.SSH_USER || "root"; const theme_path = process.env.GITEA_THEME_PATH; - if (server && theme_path) { - const cmd = `scp dist/${prefix}*.css ${user}@${server}:${theme_path}`; - console.log("[themePlugin] exec:", cmd); + const gitea_path = process.env.GITEA_PATH; + if (server) { try { - execSync(cmd, { stdio: "inherit" }); - // eslint-disable-next-line @typescript-eslint/no-unused-vars + if (theme_path) { + const cmd = `scp dist/${prefix}*.css ${user}@${server}:${theme_path}`; + console.log("[themePlugin] exec:", cmd); + execSync(cmd, { stdio: "inherit" }); + } else { + console.log("[themePlugin] no GITEA_THEME_PATH, skip upload"); + } + if (gitea_path) { + const cmd = `scp -r templates ${user}@${server}:${gitea_path}`; + console.log("[themePlugin] exec:", cmd); + execSync(cmd, { stdio: "inherit" }); + } else { + console.log("[themePlugin] no GITEA_TMPL_PATH, skip upload"); + } } catch (_) { // continue regardless of error } } else { - console.log("[themePlugin] no SSH_SERVER or GITEA_THEME_PATH, skip upload"); + console.log("[themePlugin] no SSH_SERVER, skip upload"); } console.log("[themePlugin] exec end."); }, diff --git a/styles/components/notification.ts b/styles/components/notification.ts index 6a2b132..2f20aa3 100644 --- a/styles/components/notification.ts +++ b/styles/components/notification.ts @@ -153,7 +153,7 @@ export const notification = css` box-shadow: 2px 0 0 ${themeVars.github.borderColor.accent.emphasis} inset; color: ${themeVars.color.text.self}; } - > .notifications-link > div{ + > .notifications-link > div { &:first-child { font-size: 12px !important; } diff --git a/styles/public/input.ts b/styles/public/input.ts index fe2a3bf..2a79dfe 100644 --- a/styles/public/input.ts +++ b/styles/public/input.ts @@ -40,7 +40,7 @@ export const input = css` align-items: center; } // 下拉菜单的输入框 - .ui.dropdown.dropdown .menu>.input { + .ui.dropdown.dropdown .menu > .input { margin: 12px 10px; } `; diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl new file mode 100644 index 0000000..8bdd240 --- /dev/null +++ b/templates/base/head_navbar.tmpl @@ -0,0 +1,167 @@ + diff --git a/templates/base/head_navbar_icons.tmpl b/templates/base/head_navbar_icons.tmpl new file mode 100644 index 0000000..29bba0a --- /dev/null +++ b/templates/base/head_navbar_icons.tmpl @@ -0,0 +1,35 @@ +{{- $itemExtraClass := .ItemExtraClass -}} +{{- $data := .PageGlobalData -}} +{{if and $data $data.IsSigned}}{{/* data may not exist, for example: rendering 503 page before the PageGlobalData middleware */}} + {{- $activeStopwatch := call $data.GetActiveStopwatch -}} + {{- $notificationUnreadCount := call $data.GetNotificationUnreadCount -}} + {{if $activeStopwatch}} + +
+ {{svg "octicon-stopwatch"}} + +
+
+ {{end}} + {{if not ctx.Consts.RepoUnitTypeIssues.UnitGlobalDisabled}} + + {{svg "octicon-issue-opened"}} + + {{end}} + {{if not ctx.Consts.RepoUnitTypePullRequests.UnitGlobalDisabled}} + + {{svg "octicon-git-pull-request"}} + + {{end}} + +
+ {{svg "octicon-inbox"}} + {{$notificationUnreadCount}} +
+
+ {{if $data.IsSiteAdmin}} + + {{svg "octicon-server"}} + + {{end}} +{{end}}