修复退出登录问题

detailed:
1.更新了readme文件和主题配置文件
2.修复了退出登录无法退出的问题
This commit is contained in:
UPToZ 2024-04-16 17:08:46 +08:00
parent 19df302749
commit d197c0e95c
6 changed files with 1430 additions and 1354 deletions

View File

@ -1,3 +1,54 @@
# halo-theme-hao
<div align="center">
<!-- 主题Logo -->
<img width="100px" src="https://api.minio.yyds.pink/moony/files/2024/04/halo-theme-hao-sbxqdmuv.png">
<!-- 主题名称 -->
<h1>Halo-Theme-Hao</h1>
基于halo-theme-hao的1.4.9-beta2版本进行修改。
## 🔥 预览
| 站点名称 | 站点地址 |
|:----------:|:----------------------:|
| 小小笔记大大用处 | https://blog.uptoz.cn |
## 👋 简介
[Halo-Theme-Hao](https://gitea.uptoz.cn/UPToZ/halo-theme-hao)
是一款适用于 [Halo2.x](https://github.com/halo-dev/halo) 的博客主题。
移植自 [Hexo](https://hexo.io/zh-cn/index.html) 社区中 [张洪 Heo](https://blog.zhheo.com/)
对 [Hexo-Theme-hao](https://github.com/chengzhongxue/halo-theme-hao)主题1.4.9-beta2的魔改版本。
## 🚨 注意事项(看我看我)
1. **建站时间必填**
2. 如果安装主题后报错,请仔细查阅[主题说明](https://gitea.uptoz.cn/UPToZ/halo-theme-hao)
与[更新说明](https://gitea.uptoz.cn/UPToZ/halo-theme-hao/releases)
3. 如果还未解决,可以加群求助!!!
4. 如果群友也解决不了再考虑提ISSUE
5. `1.3.1`及以上版本需要`Halo`版本>=`2.8.0`
6. **若安装主题后出现500错误请到主题设置页面将每个设置项都保存一下**
7. **`beta`版本主题必须使用`本地资源`,正式版本才会存在`在线资源`**
### 🔌 插件依赖
> 所有插件均为可选,不安装则不会出现对应功能。
> 部分插件可能已经预设在 Halo 内。
> 部分插件主题尚未适配。
- 评论功能 [plugin-comment-widget](https://github.com/halo-sigs/plugin-comment-widget/releases)
- 搜索功能 [plugin-search-widget](https://github.com/halo-sigs/plugin-search-widget/releases)
- 友链页面 [plugin-links](https://github.com/halo-sigs/plugin-links)
- 瞬间页面 [plugin-moments](https://github.com/halo-sigs/plugin-moments)
- 追番插件 [plugin-bilibili-bangumi](https://github.com/Roozenlz/plugin-bilibili-bangumi)
- 图库插件 [plugin-photos](https://github.com/halo-sigs/plugin-photos)
- katex插件 [plugin-katex](https://github.com/chengzhongxue/plugin-katex/releases/)
- 我的装备 [plugin-equipments](https://github.com/chengzhongxue/plugin-equipments)
- Markdown / HTML 内容块插件 [plugin-hybrid-edit-block](https://www.halo.run/store/apps/app-NgHnY)
> 更多插件请参见https://github.com/halo-sigs/awesome-halo
## 📝 使用
[点我查看](https://www.yuque.com/liuzhihangs/halo-theme-hao)

View File

@ -1,12 +1,14 @@
let heo_cookiesTime = null
// 第一次播放音乐
,heo_musicFirst = false
,
heo_musicFirst = false
// 音乐播放状态
,heo_musicPlaying = false
,heo_keyboard = false
,heo_intype = false
,lastSayHello = ""
,refreshNum = 1;
,
heo_musicPlaying = false,
heo_keyboard = false,
heo_intype = false,
lastSayHello = "",
refreshNum = 1;
// 私有函数
var heo = {
// 检测显示模式
@ -63,8 +65,8 @@ var heo = {
//监测是否在页面开头
addNavBackgroundInit: function() {
var e = 0
, t = 0;
var e = 0,
t = 0;
document.body && (e = document.body.scrollTop),
document.documentElement && (t = document.documentElement.scrollTop),
0 != (e - t > 0 ? e : t) && (document.getElementById("page-header").classList.add("nav-fixed"),
@ -89,7 +91,8 @@ var heo = {
document.querySelector("#category-bar") && $(".category-bar-item").removeClass("select");
var e = window.location.pathname;
if ("/" == (e = decodeURIComponent(e)))
document.querySelector("#category-bar") && document.getElementById("category-bar-home").classList.add("select");
document.querySelector("#category-bar") && document.getElementById("category-bar-home").classList
.add("select");
else {
if (/\/categories\/.*?/.test(e)) {
var t = e.split("/")[2];
@ -109,8 +112,10 @@ var heo = {
footerRandomFriendsBtn.style.opacity = "0.2";
footerRandomFriendsBtn.style.transitionDuration = "0.3s";
footerRandomFriendsBtn.style.transform = "rotate(" + 360 * refreshNum++ + "deg)";
function getLinks() {
const fetchUrl = "/apis/api.plugin.halo.run/v1alpha1/plugins/PluginLinks/links?keyword=&sort=priority,asc"
const fetchUrl =
"/apis/api.plugin.halo.run/v1alpha1/plugins/PluginLinks/links?keyword=&sort=priority,asc"
fetch(fetchUrl)
.then(res => res.json())
.then(json => {
@ -118,6 +123,7 @@ var heo = {
renderer(json.items);
})
}
function renderer(data) {
const linksUrl = GLOBAL_CONFIG.source.links.linksUrl
const num = GLOBAL_CONFIG.source.links.linksNum
@ -125,13 +131,15 @@ var heo = {
var htmlText = '';
for (let i = 0; i < randomFriendLinks.length; ++i) {
var item = randomFriendLinks[i]
htmlText += `<a class='footer-item' href='${item.spec.url}' target="_blank" rel="noopener nofollow">${item.spec.displayName}</a>`;
htmlText +=
`<a class='footer-item' href='${item.spec.url}' target="_blank" rel="noopener nofollow">${item.spec.displayName}</a>`;
}
htmlText += `<a class='footer-item' href='${linksUrl}'>更多</a>`
if (document.getElementById("friend-links-in-footer")) {
document.getElementById("friend-links-in-footer").innerHTML = htmlText;
}
}
function friendLinksInFooterInit() {
const data = saveToLocal.get('links-data')
if (data) {
@ -216,9 +224,9 @@ var heo = {
reflashEssayWaterFall: function() {
document.querySelector("#waterfall") && setTimeout((function() {
waterfall("#waterfall"),
document.getElementById("waterfall") && document.getElementById("waterfall").classList.add("show")
}
), 500)
document.getElementById("waterfall") && document.getElementById("waterfall")
.classList.add("show")
}), 500)
},
// 下载图片
@ -282,10 +290,8 @@ var heo = {
document.getElementById("cookies-window").classList.add("cw-hide"),
setTimeout((() => {
$("#cookies-window").hide()
}
), 1e3)
}
), 3e3)
}), 1e3)
}), 3e3)
},
//隐藏今日推荐
@ -310,7 +316,8 @@ var heo = {
let themeColor = getComputedStyle(document.documentElement).getPropertyValue('--heo-main');
heo.changeThemeColor(themeColor);
} else {
let themeColor = getComputedStyle(document.documentElement).getPropertyValue('--heo-background');
let themeColor = getComputedStyle(document.documentElement).getPropertyValue(
'--heo-background');
heo.changeThemeColor(themeColor);
}
} else {
@ -419,7 +426,6 @@ var heo = {
$('.console-card-group').attr('style', 'display: none');
document.querySelector("#console").classList.add("show");
heo.initConsoleState()
},
//显示中控台
@ -427,8 +433,6 @@ var heo = {
$('.console-card-group-reward').attr('style', 'display: none');
$('.console-card-group').attr('style', 'display: flex');
document.querySelector("#console").classList.add("show");
},
//隐藏中控台
@ -453,36 +457,36 @@ var heo = {
scrollTo: function(e) {
const t = document.getElementById(e);
if (t) {
const e = t.getBoundingClientRect().top + window.pageYOffset - 80
, o = window.pageYOffset
, n = e - o;
const e = t.getBoundingClientRect().top + window.pageYOffset - 80,
o = window.pageYOffset,
n = e - o;
let a = null;
window.requestAnimationFrame((function e(t) {
a || (a = t);
const l = t - a
, i = (c = Math.min(l / 0, 1)) < .5 ? 2 * c * c : (4 - 2 * c) * c - 1;
const l = t - a,
i = (c = Math.min(l / 0, 1)) < .5 ? 2 * c * c : (4 - 2 * c) * c - 1;
var c;
window.scrollTo(0, o + n * i),
l < 600 && window.requestAnimationFrame(e)
}
))
}))
}
},
//隐藏侧边栏
hideAsideBtn: () => { // Hide aside
const $htmlDom = document.documentElement.classList
$htmlDom.contains('hide-aside')
? saveToLocal.set('aside-status', 'show', 2)
: saveToLocal.set('aside-status', 'hide', 2)
$htmlDom.contains('hide-aside') ?
saveToLocal.set('aside-status', 'show', 2) :
saveToLocal.set('aside-status', 'hide', 2)
$htmlDom.toggle('hide-aside')
$htmlDom.contains("hide-aside") ? document.querySelector("#consoleHideAside").classList.add("on") : document.querySelector("#consoleHideAside").classList.remove("on")
$htmlDom.contains("hide-aside") ? document.querySelector("#consoleHideAside").classList.add("on") :
document.querySelector("#consoleHideAside").classList.remove("on")
},
toPage: function() {
var e = document.querySelectorAll(".page-number")
, t = parseInt(e[e.length - 1].innerHTML)
, o = document.getElementById("toPageText")
, n = parseInt(o.value);
var e = document.querySelectorAll(".page-number"),
t = parseInt(e[e.length - 1].innerHTML),
o = document.getElementById("toPageText"),
n = parseInt(o.value);
if (!isNaN(n) && n > 0 && "0" !== ("" + n)[0] && n <= t) {
var url = window.location.href;
@ -504,8 +508,10 @@ var heo = {
}
},
changeSayHelloText: function() {
const greetings = GLOBAL_CONFIG.helloText.length == 0 ? ["🤖️ 数码科技爱好者", "🔍 分享与热心帮助", "🏠 智能家居小能手", "🔨 设计开发一条龙", "🤝 专修交互与设计", "🏃 脚踏实地行动派", "🧱 团队小组发动机", "💢 壮汉人狠话不多"] : GLOBAL_CONFIG.helloText
, authorInfoSayHiElement = document.getElementById("author-info__sayhi");
const greetings = GLOBAL_CONFIG.helloText.length == 0 ? ["🤖️ 数码科技爱好者", "🔍 分享与热心帮助", "🏠 智能家居小能手",
"🔨 设计开发一条龙", "🤝 专修交互与设计", "🏃 脚踏实地行动派", "🧱 团队小组发动机", "💢 壮汉人狠话不多"
] : GLOBAL_CONFIG.helloText,
authorInfoSayHiElement = document.getElementById("author-info__sayhi");
// 如果只有一个问候语,设置为默认值
if (greetings.length === 1) {
authorInfoSayHiElement.textContent = greetings[0];
@ -589,15 +595,15 @@ var heo = {
//爱发电赞助
addPowerLinksInPostRightSide: async function() {
const image = document.getElementById("power-star-image")
, star = document.getElementById("power-star")
, title = document.getElementById("power-star-title")
, desc = document.getElementById("power-star-desc");
const image = document.getElementById("power-star-image"),
star = document.getElementById("power-star"),
title = document.getElementById("power-star-title"),
desc = document.getElementById("power-star-desc");
if (image && star && title && desc)
try {
const list = GLOBAL_CONFIG.source.power.list
, i = heo.getRandomInt(0, list.length)
, power = list[i].realNode;
const list = GLOBAL_CONFIG.source.power.list,
i = heo.getRandomInt(0, list.length),
power = list[i].realNode;
image.style.backgroundImage = `url(${power.avatar})`,
star.href = power.link,
title.innerText = power.name,
@ -610,7 +616,8 @@ var heo = {
//初始化console图标
initConsoleState: function() {
document.documentElement.classList.contains("hide-aside") ? document.querySelector("#consoleHideAside").classList.add("on") : document.querySelector("#consoleHideAside").classList.remove("on")
document.documentElement.classList.contains("hide-aside") ? document.querySelector("#consoleHideAside")
.classList.add("on") : document.querySelector("#consoleHideAside").classList.remove("on")
},
@ -669,17 +676,26 @@ var heo = {
},
};
const adjectives = ["美丽的", "英俊的", "聪明的", "勇敢的", "可爱的", "慷慨的", "善良的", "可靠的", "开朗的", "成熟的", "稳重的", "真诚的", "幽默的", "豁达的", "有趣的", "活泼的", "优雅的", "敏捷的", "温柔的", "温暖的", "敬业的", "细心的", "耐心的", "深沉的", "朴素的", "含蓄的", "率直的", "开放的", "务实的", "坚强的", "自信的", "谦虚的", "文静的", "深刻的", "纯真的", "朝气蓬勃的", "慎重的", "大方的", "顽强的", "迷人的", "机智的", "善解人意的", "富有想象力的", "有魅力的", "独立的", "好奇的", "干净的", "宽容的", "尊重他人的", "体贴的", "守信的", "有耐性的", "有责任心的", "有担当的", "有远见的", "有智慧的", "有眼光的", "有冒险精神的", "有爱心的", "有同情心的", "喜欢思考的", "喜欢学习的", "具有批判性思维的", "善于表达的", "善于沟通的", "善于合作的", "善于领导的", "有激情的", "有幽默感的", "有思想的", "有个性的", "有正义感的", "有责任感的", "有创造力的", "有想象力的", "有艺术细胞的", "有团队精神的", "有协调能力的", "有决策能力的", "有组织能力的", "有学习能力的", "有执行能力的", "有分析能力的", "有逻辑思维的", "有创新能力的", "有专业素养的", "有商业头脑的"]
, vegetablesAndFruits = ["萝卜", "白菜", "芹菜", "生菜", "青椒", "辣椒", "茄子", "豆角", "黄瓜", "西红柿", "洋葱", "大蒜", "土豆", "南瓜", "豆腐", "韭菜", "花菜", "西兰花", "蘑菇", "金针菇", "苹果", "香蕉", "橙子", "柠檬", "猕猴桃", "草莓", "葡萄", "桃子", "杏子", "李子", "石榴", "西瓜", "哈密瓜", "蜜瓜", "樱桃", "蓝莓", "柿子", "橄榄", "柚子", "火龙果"];
const adjectives = ["美丽的", "英俊的", "聪明的", "勇敢的", "可爱的", "慷慨的", "善良的", "可靠的", "开朗的", "成熟的", "稳重的", "真诚的", "幽默的", "豁达的",
"有趣的", "活泼的", "优雅的", "敏捷的", "温柔的", "温暖的", "敬业的", "细心的", "耐心的", "深沉的", "朴素的", "含蓄的", "率直的", "开放的", "务实的", "坚强的",
"自信的", "谦虚的", "文静的", "深刻的", "纯真的", "朝气蓬勃的", "慎重的", "大方的", "顽强的", "迷人的", "机智的", "善解人意的", "富有想象力的", "有魅力的", "独立的",
"好奇的", "干净的", "宽容的", "尊重他人的", "体贴的", "守信的", "有耐性的", "有责任心的", "有担当的", "有远见的", "有智慧的", "有眼光的", "有冒险精神的", "有爱心的",
"有同情心的", "喜欢思考的", "喜欢学习的", "具有批判性思维的", "善于表达的", "善于沟通的", "善于合作的", "善于领导的", "有激情的", "有幽默感的", "有思想的", "有个性的",
"有正义感的", "有责任感的", "有创造力的", "有想象力的", "有艺术细胞的", "有团队精神的", "有协调能力的", "有决策能力的", "有组织能力的", "有学习能力的", "有执行能力的",
"有分析能力的", "有逻辑思维的", "有创新能力的", "有专业素养的", "有商业头脑的"
],
vegetablesAndFruits = ["萝卜", "白菜", "芹菜", "生菜", "青椒", "辣椒", "茄子", "豆角", "黄瓜", "西红柿", "洋葱", "大蒜", "土豆", "南瓜", "豆腐",
"韭菜", "花菜", "西兰花", "蘑菇", "金针菇", "苹果", "香蕉", "橙子", "柠檬", "猕猴桃", "草莓", "葡萄", "桃子", "杏子", "李子", "石榴", "西瓜", "哈密瓜",
"蜜瓜", "樱桃", "蓝莓", "柿子", "橄榄", "柚子", "火龙果"
];
$(document).ready((function() {
initBlog()
}
)),
})),
document.addEventListener("pjax:complete", (function() {
initBlog();
// 解决 katex pjax问题
if((GLOBAL_CONFIG.htmlType == 'post' || GLOBAL_CONFIG.htmlType == 'page') && typeof window.renderKaTex != 'undefined'){
if ((GLOBAL_CONFIG.htmlType == 'post' || GLOBAL_CONFIG.htmlType == 'page') && typeof window
.renderKaTex != 'undefined') {
window.renderKaTex();
}
}
));
}));

View File

@ -39,9 +39,9 @@ var btf = {
loadLightbox: ele => {
const jqLoadAndRun = () => {
const $fancyboxEle = GLOBAL_CONFIG.lightbox === 'fancybox'
? ele
: []
const $fancyboxEle = GLOBAL_CONFIG.lightbox === 'fancybox' ?
ele :
[]
const fbLengthNoZero = $fancyboxEle.length > 0
if (fbLengthNoZero) {
@ -60,7 +60,9 @@ var btf = {
const $this = $(o)
const lazyloadSrc = $this.attr('data-lazy-src') || $this.attr('src')
const dataCaption = $this.attr('alt') || ''
$this.wrap(`<a href="${lazyloadSrc}" data-fancybox="images" data-caption="${dataCaption}" class="fancybox" data-srcset="${lazyloadSrc}"></a>`)
$this.wrap(
`<a href="${lazyloadSrc}" data-fancybox="images" data-caption="${dataCaption}" class="fancybox" data-srcset="${lazyloadSrc}"></a>`
)
})
$().fancybox({
@ -146,7 +148,11 @@ var btf = {
},
snackbarShow: (text, showActionFunction = false, duration = 2000, actionText = false) => {
const { position, bgLight, bgDark } = GLOBAL_CONFIG.Snackbar;
const {
position,
bgLight,
bgDark
} = GLOBAL_CONFIG.Snackbar;
const bg = document.documentElement.getAttribute("data-theme") === "light" ? bgLight : bgDark;
const root = document.querySelector(":root");
root.style.setProperty("--heo-snackbar-time", duration + "ms");
@ -173,8 +179,7 @@ var btf = {
this.$container.style.opacity = "1"
}
})
}
))
}))
document.querySelectorAll('#article-container .loadings')[0]?.classList.remove("loadings");
},
@ -225,7 +230,9 @@ var btf = {
callback()
observerItem.disconnect()
}
}, {threshold: [0]})
}, {
threshold: [0]
})
observerItem.observe(dom)
} else {
callback()
@ -256,8 +263,7 @@ var btf = {
window.scrollTo(0, n - (n - e) * r / t),
r < t ? window.requestAnimationFrame(i) : window.scrollTo(0, e)
}
}
))
}))
},
fadeIn: (ele, time) => {

View File

@ -200,7 +200,9 @@ function imageToBlob(imageURL) {
async function copyImage(imageURL) {
const blob = await imageToBlob(imageURL)
const item = new ClipboardItem({"image/png": blob});
const item = new ClipboardItem({
"image/png": blob
});
navigator.clipboard.write([item]);
}
@ -300,7 +302,8 @@ rm.insertAtCaret = function (elemt, value) {
} else {
if (startPos || startPos == '0') {
var scrollTop = elemt.scrollTop;
elemt.value = elemt.value.substring(0, startPos) + value + elemt.value.substring(endPos, elemt.value.length);
elemt.value = elemt.value.substring(0, startPos) + value + elemt.value.substring(endPos, elemt.value
.length);
elemt.focus();
elemt.selectionStart = startPos + value.length;
elemt.selectionEnd = startPos + value.length;

View File

@ -4,9 +4,9 @@
<!-- 功能都需要添加开关 -->
<!-- 随机前往一个开往项目网站 -->
<div class="nav-button only-home" id="travellings_button" title="随机前往一个开往项目网站" th:if="${theme.config.nav.right.travelling}">
<a class="site-page" href="https://www.travellings.cn/go.html" rel="external nofollow"
title="随机前往一个开往项目网站">
<div class="nav-button only-home" id="travellings_button" title="随机前往一个开往项目网站"
th:if="${theme.config.nav.right.travelling}">
<a class="site-page" href="https://www.travellings.cn/go.html" rel="external nofollow" title="随机前往一个开往项目网站">
<i class="haofont hao-icon-eicon_train-line"></i>
</a>
</div>
@ -19,8 +19,8 @@
<!-- 切换模式 -->
<div class="nav-button" id="darkmode_button" th:if="${theme.config.nav.right.darkMode}">
<a class="console_switchbutton" href="javascript:void(0);" onclick="navFn.switchDarkMode();" rel="external nofollow"
title="切换模式 - 日夜交替,黑白互换。">
<a class="console_switchbutton" href="javascript:void(0);" onclick="navFn.switchDarkMode();"
rel="external nofollow" title="切换模式 - 日夜交替,黑白互换。">
<i class="haofont hao-icon-moon-clear-fill" style="font-size: 1rem;"></i>
</a>
</div>
@ -37,8 +37,7 @@
th:with="currentUser = ${contributorFinder.getContributor(#authentication.name)}">
<span class="site-page nav-login">
<i sec:authorize="isAnonymous()" class="haofont hao-icon-zhanghao1 " style="font-size: 19.5px;"></i>
<img sec:authorize="isAuthenticated()" th:src="${currentUser.avatar}"
th:alt="${currentUser.displayName}"
<img sec:authorize="isAuthenticated()" th:src="${currentUser.avatar}" th:alt="${currentUser.displayName}"
style=" width: 24px; height: 24px; border-radius: 9999px" />
</span>
<div class="back-menu-list-groups">
@ -49,11 +48,12 @@
<span class="back-menu-item-text">控制台</span>
</a>
<a class="back-menu-item" rel="external nofollow"
href="javascript:$.ajax({type: 'post',url:'/logout'});window.location.reload()">
href="javascript:$.ajax({type: 'post',url:'/logout',headers:{'X-Xsrf-Token':document.cookie.split('; ').find((row) => row.startsWith('XSRF-TOKEN'))?.split('=')[1] || ''},success: function() {window.location.reload();},error: function(xhr, status, error) {console.error('退出登录时发生错误:', error);}});">
<span class="back-menu-item-text">退出登录</span>
</a>
</th:block>
<a sec:authorize="isAnonymous()" class="back-menu-item" rel="external nofollow" target="_blank" href="/console/login">
<a sec:authorize="isAnonymous()" class="back-menu-item" rel="external nofollow" target="_blank"
href="/console/login">
<span class="back-menu-item-text">登录</span>
</a>
</div>

View File

@ -48,8 +48,8 @@ spec:
description: Halo 2.x Theme base on Thymeleaf, Referring to Butterfly and Heo
logo: /themes/theme-hao/assets/images/hao-logo.jpg
website: https://blog.uptoz.cn
repo: https://githubfast.com/liuzhihang/halo-theme-hao
repo: https://gitea.uptoz.cn/UPToZ/halo-theme-hao
settingName: "theme-hao-setting"
configMapName: "theme-hao-configMap"
version: "1.4.9-CommemorativeEdition"
version: "1.0.1-ce"
require: ">=2.10.0"