Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 多次调用函数导致效果失效的问题 #108

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^6.4.2",
"@popperjs/core": "^2.11.8",
"bootstrap": "^5.2.3",
"bootstrap": "^5.3.2",
"glob": "^10.3.3",
"jquery": "^3.7.0",
"jquery": "^3.7.1",
"magnific-popup": "^1.1.0",
"tocbot": "^4.21.1"
"tocbot": "^4.21.2"
}
}
26 changes: 13 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/js/categories.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/js/commons.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/js/home.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/js/misc.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/js/page.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/js/post.js

This file was deleted.

23 changes: 17 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@ import 'magnific-popup';
import 'tocbot';

import './css/style.scss';
import './js/categories';
import './js/commons';
import './js/home';
import './js/misc';
import './js/page';
import './js/post';

import {basic} from "./js/modules/layouts/basic";
import {initSidebar} from "./js/modules/layouts/sidebar";
import {initTopbar} from "./js/modules/layouts/topbar";
import {categoryCollapse} from "./js/modules/components/category-collapse";
import {imgLazy} from "./js/modules/components/img-lazyload";
import {toc} from "./js/modules/components/toc";
import {initClipboard} from "./js/modules/plugins";

basic();
initSidebar();
initTopbar();
categoryCollapse();
imgLazy();
// imgPopup();
initClipboard();
toc();
2 changes: 1 addition & 1 deletion templates/archives.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html
th:replace="~{modules/layout :: html (title = '归档', content = ~{::content},
layout = 'archives', breadcrumb = ~{::breadcrumb})}"
layout = 'Archives', breadcrumb = ~{::breadcrumb})}"
xmlns:th="https://www.thymeleaf.org"
>
<th:block th:fragment="breadcrumb">
Expand Down
2 changes: 1 addition & 1 deletion templates/categories.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html
th:replace="~{modules/layout :: html (title = '分类',content = ~{::content},
layout = 'categories', breadcrumb = ~{::breadcrumb})}"
layout = 'Categories', breadcrumb = ~{::breadcrumb})}"
xmlns:th="https://www.thymeleaf.org"
>
<th:block th:fragment="breadcrumb">
Expand Down
2 changes: 1 addition & 1 deletion templates/category.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html
th:replace="~{modules/layout :: html (title = '分类:'+ ${category.spec.displayName},
content = ~{::content}, layout = 'category' ,breadcrumb = ~{::breadcrumb})}"
content = ~{::content}, layout = 'Category' ,breadcrumb = ~{::breadcrumb})}"
xmlns:th="https://www.thymeleaf.org"
>
<th:block th:fragment="breadcrumb">
Expand Down
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html
th:replace="~{modules/layout :: html (title = '', content = ~{::content},
layout = 'default', breadcrumb = ~{::breadcrumb})}"
layout = 'Default', breadcrumb = ~{::breadcrumb})}"
xmlns:th="https://www.thymeleaf.org"
>
<th:block th:fragment="breadcrumb">
Expand Down
140 changes: 92 additions & 48 deletions templates/modules/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,100 @@
lang="en"
th:fragment="html (title,content,layout,breadcrumb)"
>
<th:block th:replace="~{modules/head :: head(${title})}" />
<th:block th:replace="~{modules/head :: head(${title})}"/>

<body>
<th:block th:replace="~{modules/sidebar :: sidebar()}" />
<div id="main-wrapper" class="d-flex justify-content-center">
<div class="container px-xxl-5">
<th:block th:replace="~{modules/topbar :: topbar(${breadcrumb})}" />
<div class="row">
<main
aria-label="Main Content"
class="col-12 col-lg-11 col-xl-9 px-md-4 pb-5"
th:switch="${layout}"
>
<th:block th:case="default">
<th:block th:replace="${content}" />
</th:block>
<th:block th:case="*">
<article class="px-1">
<th:block th:replace="${content}" />
</article>
</th:block>
</main>
<body>
<th:block th:replace="~{modules/sidebar :: sidebar()}"/>
<div id="main-wrapper" class="d-flex justify-content-center">
<div class="container d-flex flex-column px-xxl-5">
<th:block th:switch="${layout}">
<th:block th:case="Default">
<th:block
th:replace="~{modules/topbar :: topbar(${breadcrumb}, ${site.title})}"
/>
</th:block>
<th:block th:case="Tag">
<th:block
th:replace="~{modules/topbar :: topbar(${breadcrumb}, 标签)}"
/>
</th:block>
<th:block th:case="Tags">
<th:block
th:replace="~{modules/topbar :: topbar(${breadcrumb}, 标签)}"
/>
</th:block>
<th:block th:case="Category">
<th:block
th:replace="~{modules/topbar :: topbar(${breadcrumb}, 分类)}"
/>
</th:block>
<th:block th:case="Categories">
<th:block
th:replace="~{modules/topbar :: topbar(${breadcrumb}, 分类)}"
/>
</th:block>
<th:block th:case="Archives">
<th:block
th:replace="~{modules/topbar :: topbar(${breadcrumb}, 归档)}"
/>
</th:block>
<th:block th:case="Post">
<th:block
th:replace="~{modules/topbar :: topbar(${breadcrumb}, 文章)}"
/>
</th:block>
<th:block th:case="*">
<th:block
th:replace="~{modules/topbar :: topbar(${breadcrumb}, ' ')}"
/>
</th:block>
</th:block>
<div class="row flex-grow-1">
<main
aria-label="Main Content"
class="col-12 col-lg-11 col-xl-9 px-md-4 pb-5"
th:switch="${layout}"
>
<th:block th:case="Default">
<th:block th:replace="${content}"/>
</th:block>
<th:block th:case="Page">
<th:block th:replace="${content}"/>
</th:block>
<th:block th:case="*">
<article class="px-1">
<th:block th:replace="${content}"/>
</article>
</th:block>
</main>

<!-- panel -->
<aside
aria-label="Panel"
id="panel-wrapper"
class="col-xl-3 ps-2 text-muted"
>
<th:block th:replace="~{modules/panel :: panel(${layout})}" />
</aside>
</div>
<div class="row">
<!-- tail -->
<div id="tail-wrapper" class="col-12 col-lg-11 col-xl-9 px-md-4">
<th:block th:replace="~{modules/footer :: footer()}" />
</div>
</div>
</div>

<aside aria-label="Scroll to Top">
<button
id="back-to-top"
type="button"
class="btn btn-lg btn-box-shadow"
>
<i class="fas fa-angle-up"></i>
</button>
<!-- panel -->
<aside
aria-label="Panel"
id="panel-wrapper"
class="col-xl-3 ps-2 text-muted"
>
<th:block th:replace="~{modules/panel :: panel(${layout})}"/>
</aside>
</div>
<div id="mask"></div>
</body>
<div class="row">
<!-- tail -->
<div id="tail-wrapper" class="col-12 col-lg-11 col-xl-9 px-md-4">
<th:block th:replace="~{modules/footer :: footer()}"/>
</div>
</div>
</div>

<aside aria-label="Scroll to Top">
<button
id="back-to-top"
type="button"
class="btn btn-lg btn-box-shadow"
>
<i class="fas fa-angle-up"></i>
</button>
</aside>
</div>
<div id="mask"></div>
</body>
</html>
4 changes: 2 additions & 2 deletions templates/modules/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html xmlns:th="https://www.thymeleaf.org" lang="en">
<!-- The Side Bar -->

<div
<aside
th:fragment="sidebar()"
aria-label="Sidebar"
id="sidebar"
Expand Down Expand Up @@ -73,6 +73,6 @@ <h1 class="site-title">
</th:block>
</div>
<!-- .sidebar-bottom -->
</div>
</aside>
<!-- #sidebar -->
</html>
19 changes: 8 additions & 11 deletions templates/modules/topbar.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org" lang="en">
<!-- The Top Bar -->
<header id="topbar-wrapper" th:fragment="topbar(content)">
<header id="topbar-wrapper" th:fragment="topbar(content, title)">
<div
id="topbar"
class="d-flex align-items-center justify-content-between px-lg-3 h-100"
Expand All @@ -14,18 +14,15 @@
<i class="fas fa-bars fa-fw"></i>
</button>

<div id="topbar-title">
<!-- {% if page.layout == 'home' %}-->
<!-- {{- site.data.locales[include.lang].title | default: site.title -}}-->
<!-- {% elsif page.collection == 'tabs' or page.layout == 'page' %}-->
<!-- {%- capture tab_key -%}{{ page.url | split: '/' }}{%- endcapture -%}-->
<!-- {{- site.data.locales[include.lang].tabs[tab_key] | default: page.title -}}-->
<!-- {% else %}-->
<!-- {{- site.data.locales[include.lang].layout[page.layout] | default: page.layout | capitalize -}}-->
<!-- {% endif %}-->
</div>
<div id="topbar-title">[[${title}]]</div>
<!-- .display none-->

<th:block th:if="${!pluginFinder.available('PluginSearchWidget')}">
<button type="button" onclick="alert('请安装搜索插件')" class="btn btn-link">
<i class="fas fa-search fa-fw"></i>
</button>
</th:block>

<th:block th:if="${pluginFinder.available('PluginSearchWidget')}">
<button type="button" id="search-trigger" class="btn btn-link">
<i class="fas fa-search fa-fw"></i>
Expand Down
2 changes: 1 addition & 1 deletion templates/page.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html
th:replace="~{modules/layout :: html (title = ${singlePage.spec.title},
content = ~{::content}, layout = 'default' ,breadcrumb = ~{::breadcrumb})}"
content = ~{::content}, layout = 'Page' ,breadcrumb = ~{::breadcrumb})}"
xmlns:th="https://www.thymeleaf.org"
>
<th:block th:fragment="breadcrumb">
Expand Down
Loading