Skip to content

Commit

Permalink
Merge pull request #8 from mjsoftking/feat-login-visible
Browse files Browse the repository at this point in the history
feat: Add groups, link login visible controls #7
  • Loading branch information
Anyexyz authored Jan 4, 2025
2 parents 4e656c9 + eb005bb commit 40ba96c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
24 changes: 23 additions & 1 deletion settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ spec:
language: html
help: 方案1:粘贴图标的SVG代码(推荐);方案2:使用图片地址,需要img标签,如<img src="/assets/img/logo.png" />
- $formkit: radio
id: show_on_hellopage
name: show_on_hellopage
label: 显示在HelloPage中
help: 控制此分组是否显示在HelloPage中
Expand All @@ -194,6 +195,17 @@ spec:
value: "true"
- label: 不显示
value: "false"
- $formkit: radio
name: login_visible_group
if: $get(show_on_hellopage).value == "true"
label: 是否登录可见
help: 控制此分组是否在用户登录后显示
value: "false"
options:
- label:
value: "true"
- label:
value: "false"
---

apiVersion: v1alpha1
Expand Down Expand Up @@ -239,4 +251,14 @@ spec:
value: ""
height: 100px
language: html
help: 方案1:粘贴图标的SVG代码(推荐);方案2:使用图片地址,需要img标签,如<img src="/assets/img/logo.png" />
help: 方案1:粘贴图标的SVG代码(推荐);方案2:使用图片地址,需要img标签,如<img src="/assets/img/logo.png" />
- $formkit: radio
name: login_visible_link
label: 是否登录可见
help: 控制此链接是否在用户登录后显示
value: "false"
options:
- label:
value: "true"
- label:
value: "false"
11 changes: 8 additions & 3 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
rel="stylesheet">
</head>

<body>
<body th:with="user_login = ${#authentication.name != 'anonymousUser'}">
<!-- 页面背景 -->
<div class="banner-video">
<th:block th:if="${theme.config.style.cover_type == 'false'}">
Expand Down Expand Up @@ -142,6 +142,7 @@ <h2 class="title" th:text="${theme.config.style.h2_title != '' ? theme.config.st
</span>
</label>
</li>
</th:block>
</ul>
</div>
</div>
Expand All @@ -168,14 +169,18 @@ <h2 class="title" th:text="${theme.config.style.h2_title != '' ? theme.config.st

<!-- 导航列表 -->
<th:block th:each="group : ${linkFinder.groupBy()}"
th:if="${#annotations.getOrDefault(group, 'show_on_hellopage', 'true') == 'true'}">
th:if="${#annotations.getOrDefault(group, 'show_on_hellopage', 'true') == 'true' &&
(#annotations.getOrDefault(group, 'login_visible_group', 'false') != 'true' ||
(#annotations.getOrDefault(group, 'login_visible_group', 'false') == 'true' && user_login))}">

<ul class="mylist row" th:if="${#lists.size(group.links) > 0}">
<li class="title" th:if="${group.spec.displayName != ''}">
<th:block th:utext="${#annotations.getOrDefault(group, 'icon', '')}"></th:block>
<span th:text="${group.spec.displayName}"></span>
</li>
<li class="col-3 col-sm-3 col-md-3 col-lg-1" th:each="link : ${group.links}" :key="i">
<li class="col-3 col-sm-3 col-md-3 col-lg-1" th:each="link : ${group.links}" :key="i"
th:if="${#annotations.getOrDefault(link, 'login_visible_link', 'false') != 'true' ||
(#annotations.getOrDefault(link, 'login_visible_link', 'false') == 'true' && user_login)}">
<a rel="nofollow" th:with="to_post_radio = ${#annotations.get(link, 'to_post_radio')},
to_post = ${#annotations.get(link, 'to_post')},
shouldLinkToPost = ${to_post_radio == 'true' and to_post != null and to_post != ''}"
Expand Down

0 comments on commit 40ba96c

Please sign in to comment.