Skip to content

Commit

Permalink
feat: 可见度监听可选和相对路径图片
Browse files Browse the repository at this point in the history
  • Loading branch information
zkz098 committed Feb 2, 2023
1 parent 95adaf0 commit 7840e43
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ experiments:
gradientCover: "" # 当gradient为true时使用的主页面cover(为空则使用bing随机图片)
debug: false # 使用debug模式启动
disableThemeComment: false # 禁用主题评论系统(一般用于关闭评论或让插件接管评论系统)
usingRelative: false # _image.yml 使用相对路径

playerAPI: "https://api.injahow.cn" # 结尾不带/,只填写域名
# 如果条件允许,请参考 https://github.com/injahow/meting-api 自建API
# 建议使用vercel自行部署,请参考: https://github.com/xizeyoupan/Meting-API

disableVL: false # 禁用可见度监听

icon:
favicon: "/favicon.ico"
apple_touch_icon: "/apple-touch-icon.png"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-shokax",
"version": "0.1.3",
"version": "0.1.4",
"description": "a hexo theme based on shoka",
"main": "index.js",
"repository": "https://github.com/zkz098/hexo-theme-shokaX",
Expand Down
3 changes: 2 additions & 1 deletion scripts/generaters/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ hexo.extend.generator.register('script', function (locals) {
timeout: theme.quicklink.timeout,
priority: theme.quicklink.priority
},
playerAPI: theme.playerAPI
playerAPI: theme.playerAPI,
disableVL: theme.disableVL
}

if (config?.algolia) {
Expand Down
2 changes: 2 additions & 0 deletions scripts/helpers/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const randomBG = function (count = 1, image_server = null, image_list = []) {
const parseImage = function (img, size) {
if (img.startsWith('//') || img.startsWith('http')) {
return img
} else if (hexo.theme.config.experiments?.usingRelative) { // support relative url
return img
} else {
console.warn("sinaimg blocked all request from outside website,so don't use this format")
return `https://tva${randomServer}.sinaimg.cn/` + size + '/' + img
Expand Down
3 changes: 2 additions & 1 deletion source/js/_app/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ declare const CONFIG: {
search: any,
valine: string
quicklink: {
ignores: any;
ignores: any
timeout: number
priority: string
}
playerAPI: string
disableVL: boolean
}

const getDocHeight = () => $dom('main > .inner').offsetHeight
Expand Down
4 changes: 3 additions & 1 deletion source/js/_app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,9 @@ const siteInit = function () {
CONFIG.quicklink.ignores = LOCAL.ignores;
quicklink.listen(CONFIG.quicklink);
autoDarkmode();
visibilityListener();
if (!CONFIG.disableVL) {
visibilityListener();
}
themeColorListener();
algoliaSearch(pjax);
window.addEventListener('scroll', scrollHandle);
Expand Down
4 changes: 3 additions & 1 deletion source/js/_app/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,9 @@ const siteInit = function () {
quicklink.listen(CONFIG.quicklink)
autoDarkmode()

visibilityListener()
if (!CONFIG.disableVL) {
visibilityListener()
}
themeColorListener()

algoliaSearch(pjax)
Expand Down

0 comments on commit 7840e43

Please sign in to comment.