Dev
This commit is contained in:
宏尘 2024-12-22 10:45:04 +08:00 committed by GitHub
commit c787c621bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 229 additions and 42 deletions

6
package-lock.json generated
View File

@ -2818,9 +2818,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001597",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001597.tgz",
"integrity": "sha512-7LjJvmQU6Sj7bL0j5b5WY/3n7utXUJvAe1lxhsHDbLmwX9mdL86Yjtr+5SRCyf8qME4M7pU2hswj0FpyBVCv9w==",
"version": "1.0.30001690",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz",
"integrity": "sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w==",
"dev": true,
"funding": [
{

View File

@ -116,11 +116,21 @@ spec:
if: $get(show_console).value != 'false'
label: 登录组件样式
value:
console_post_class: 'ri-book-read-line'
console_moment_class: 'ri-camera-lens-line'
console_login_class: 'ri-login-circle-line'
console_person_class: 'ri-account-circle-line'
console_manage_class: 'ri-settings-3-line'
console_logout_class: 'ri-logout-circle-line'
children:
- $formkit: text
name: console_post_class
label: 新建文章图标
help: '输入新建文章图标class清空不显示图标。'
- $formkit: text
name: console_moment_class
label: 发布瞬间图标
help: '输入发布瞬间图标class清空不显示图标。'
- $formkit: text
name: console_login_class
label: 登录按钮图标
@ -186,6 +196,18 @@ spec:
label: 新标签页
- value: '_self'
label: 当前窗口
- $formkit: radio
name: expand_login_skill
label: 扩展登录后能力
help: 开启后,在文章详情界面,根据作者身份显示编辑按钮。控制台按钮 - 登录组件样式 添加 新建文章 和 发布瞬间 菜单项。登录用户需要具有进入相应功能的权限。
value: 'console'
options:
- label: 跳转到控制台
value: 'console'
- label: 跳转到个人中心
value: 'uc'
- label: 关闭
value: 'none'
- $formkit: radio
name: load_progress
label: 加载进度条
@ -1124,6 +1146,15 @@ spec:
label: 开启
- value: false
label: 关闭
- $formkit: radio
name: enable_journals_tags
label: 瞬间页面-开启标签栏
value: true
options:
- value: true
label: 开启
- value: false
label: 关闭
- $formkit: number
name: journals_fold_height
label: 瞬间页面-动态内容折叠
@ -1613,3 +1644,10 @@ spec:
label: "内嵌JSbody"
placeholder: 请输入 JS 代码内容
help: '填入JS代码无需script标签将插入body标签尾部。'
- $formkit: code
language: html
height: 45px
name: inline_body_html
label: "内嵌Html内容body"
placeholder: 请输入 Html 代码内容
help: '填入Html代码将插入body标签尾部用于自定义显示一段Html内容注意Html内容默认会在页脚下方请注意设置样式避免页脚出现样式问题。'

View File

@ -30,3 +30,7 @@ p, input[type=text], blockquote, th, td, code, h1, h2, h3, h4, h5, h6, hr, li, t
.wechat .flip-wrapper.pointer {
cursor: @pointer;
}
label {
cursor: @default;
}

View File

@ -264,6 +264,82 @@ li, ol, ul {
list-style: none
}
ul[data-type=taskList] {
li {
display: flex;
& > div {
flex: 1 1 auto;
}
& > label {
flex: 0 0 auto;
margin-right: 0.4rem;
user-select: none;
& > input[type="checkbox"],
& > input[type="radio"] {
pointer-events: none;
display: none;
visibility: hidden;
opacity: 0;
& + span {
width: 1rem;
height: 1rem;
line-height: 1rem;
display: inline-block;
position: relative;
}
& + span::before {
content: '✖';
cursor: inherit;
width: 0.8rem;
height: 0.8rem;
padding: 0.1rem;
text-align: center;
line-height: 1rem;
background: var(--dark-d);
color: var(--light-a);
display: flex;
align-items: center;
justify-content: center;
transition: all .5s;
transform: rotateZ(0deg);
}
&:checked + span::before {
content: '✔';
background: var(--theme);
color: var(--light-a);
}
}
& > input[type="checkbox"] {
& + span::before {
border-radius: var(--radius-inner);
}
}
& > input[type="radio"] {
& + span::before {
border-radius: 100%;
}
}
}
&:last-child p {
margin-bottom: 0;
}
&:hover label span::before {
transform: rotate(360deg) !important;
background: #e67700 !important;
}
}
}
img {
border: 0;
vertical-align: middle;
@ -547,6 +623,14 @@ table td, table th {
color: var(--light-d);
padding: 0 5px;
}
a {
color: inherit;
&:hover {
color: var(--theme);
}
}
}
}
@ -3603,7 +3687,7 @@ button.swiper-pagination-bullet {
}
}
ul:not([class]):not([style]) > li:not([class]):not([style]) {
ul:not([class]):not([style]):not([data-type=taskList]) > li:not([class]):not([style]) {
list-style: none;
position: relative;
padding-left: 1.2em;
@ -4104,6 +4188,10 @@ button.swiper-pagination-bullet {
}
}
.is-hidden-laptop {
display: none !important;
}
.swiper-slide-details {
&-title {

View File

@ -143,6 +143,12 @@ const commonContext = {
}
})
},
/*初始化任务列表,禁止点击*/
iniTaskItemDisabled() {
$('li[data-type="taskItem"]').each(function () {
$(this).find('label > input[type="checkbox"]').prop('disabled', true)
})
},
/* 激活登录窗口下拉框功能 */
initLogonMenu() {
$('.navbar-logon').each(function (index, item) {
@ -365,7 +371,7 @@ const commonContext = {
}
const grt = new Date(loveTime)
setInterval(function () {
let now= Date.now()
let now = Date.now()
let difference = parseInt((now - grt) / 1000)
let seconds = difference % 60
difference = parseInt(difference / 60)
@ -612,7 +618,7 @@ let timeLifeHour = -1
!(function () {
const loads = ['initCarousel', 'sparkInput', 'websiteTime']
const omits = ['initEffects', 'showThemeVersion']
const omits = ['initEffects', 'showThemeVersion', 'iniTaskItemDisabled']
Object.keys(commonContext).forEach(
(c) => !loads.includes(c) && !omits.includes(c) && commonContext[c]()

View File

@ -31,7 +31,7 @@ document.addEventListener('DOMContentLoaded', () => {
let isToc = $this.find('h1,h2,h3,h4,h5').length !== 0
this.setAttribute('hide', window.encrypt(this.innerHTML))
this.innerHTML = ''
if(isToc) {
if (isToc) {
this.setAttribute('toc', true)
commonContext.initTocAndNotice()
}
@ -65,13 +65,21 @@ document.addEventListener('DOMContentLoaded', () => {
constructor() {
super()
this.innerHTML = '音乐播放器加载中...'
this.innerHTML = this.getAttribute('prompt') || '音乐播放器加载中...'
this.options = {
container: this,
fixed: this.hasAttribute('fixed') || false,
mutex: this.hasAttribute('mutex') || true,
theme: this.getAttribute('theme') || 'var(--theme)',
loop: this.getAttribute('loop') || 'all',
autoplay: this.hasAttribute('autoplay') && this.getAttribute('autoplay') !== 'false',
lrcType: 3,
lrcType: this.getAttribute('lrcType') || 3,
listFolded: this.getAttribute('listFolded') || false,
volume: this.getAttribute('volume') || 0.7,
listMaxHeight: this.getAttribute('listMaxHeight') || '450px',
mini: this.getAttribute('mini') || false,
order: this.getAttribute('order') || 'list',
storageName: this.getAttribute('storageName') || 'aplayer-setting',
}
if (!('APlayer' in window)) {
if (!MewMusic.prototype.load) {
@ -102,14 +110,15 @@ document.addEventListener('DOMContentLoaded', () => {
}
// eslint-disable-next-line no-async-promise-executor
new Promise(async (resolve) => {
if (this.hasAttribute('song')) {
if (this.hasAttribute('meetingUrl')) {
this.options.audio = await fetch(this.getAttribute('meetingUrl'))
.then((response) => response.json())
} else if (this.hasAttribute('song')) {
this.options.audio = await fetch(
'https://api.i-meto.com/meting/api?server=netease&type=song&id=' +
this.getAttribute('song')
).then((response) => response.json())
} else if (this.hasAttribute('playlist')) {
this.options.listFolded = this.getAttribute('fold')
this.options.order = this.getAttribute('order')
this.options.audio = await fetch(
'https://api.i-meto.com/meting/api?server=netease&type=playlist&id=' +
this.getAttribute('playlist')
@ -122,6 +131,15 @@ document.addEventListener('DOMContentLoaded', () => {
cover: this.getAttribute('cover'),
lrc: this.getAttribute('lrc') || (this.options.lrcType = undefined),
}]
} else if (this.hasAttribute('music-list')) {
var musicList = JSON.parse(this.getAttribute('music-list'))
musicList.forEach((item) => {
item.lrc = item.lrc || ''
item.name = item.name || '音乐'
item.artist = item.artist || '未知歌手'
item.cover = item.cover || '/themes/theme-dream2-plus/assets/img/music.webp'
})
this.options.audio = musicList
} else {
this.innerHTML = '未指定播放的音乐!'
return resolve()
@ -129,7 +147,12 @@ document.addEventListener('DOMContentLoaded', () => {
this.aplayer = new APlayer(this.options)
resolve()
})
.catch((e) => {})
.catch((e) => {
})
}
getAPlayer() {
return this.aplayer
}
disconnectedCallback() {
@ -367,10 +390,10 @@ document.addEventListener('DOMContentLoaded', () => {
}
if (this.options.id || this.options.slug) {
await Utils.request({
url: this.options.id? `/api/content/${this.options.type}s/${this.options.id}` : `/api/content/${this.options.type}s/slug?slug=${this.options.slug}`,
url: this.options.id ? `/api/content/${this.options.type}s/${this.options.id}` : `/api/content/${this.options.type}s/slug?slug=${this.options.slug}`,
method: 'GET',
})
.then(res=>{
.then(res => {
this.options.img = this.options.img || res.thumbnail
this.options.href = this.options.title || res.fullPath
this.options.title = this.options.title || res.title
@ -432,6 +455,7 @@ document.addEventListener('DOMContentLoaded', () => {
this.render()
}
}
render() {
this.options = {
captions: this.hasAttribute('captions') && this.getAttribute('captions') !== 'false',
@ -451,7 +475,7 @@ document.addEventListener('DOMContentLoaded', () => {
init() {
let html = this.innerHTML
this.innerHTML = ''
const shadowRoot = this.attachShadow({ mode: 'closed' })
const shadowRoot = this.attachShadow({mode: 'closed'})
shadowRoot.innerHTML = html
this.drawComplete()
}

View File

@ -175,6 +175,8 @@ $(document).on('pjax:success', async function (event, data, status, xhr, options
window.postPjax && window.postPjax(serialNumber)
/* 刷新人生倒计时 */
commonContext.initTimeCount()
/* 初始化任务列表,禁止点击 */
commonContext.iniTaskItemDisabled()
/* 初始化轮播 */
commonContext.initCarousel()
window.DProgress && DProgress.done()
@ -209,6 +211,8 @@ $(document).on('pjax:end', function (event, xhr, options) {
commonContext.initCarousel()
/* 刷新人生倒计时 */
commonContext.initTimeCount()
/* 初始化任务列表,禁止点击 */
commonContext.iniTaskItemDisabled()
window.DProgress && DProgress.done()
// 应该是由于浏览器缓存失效有时候浏览器前后退还是会执行pjax:beforeSend
$('html').removeClass('pjax-loading')

View File

@ -41,6 +41,7 @@
// 后端 api 不进行缓存
const notHandleList = [
location.origin + '/api',
location.origin + '/apis',
]
// 需要走cdn和缓存的请求cdn优先于缓存
@ -167,6 +168,10 @@
|| isExitInUrlList(notHandleList, event.request.url)) {
return false
}
// 检查请求协议是否为 http 或 https
if (!event.request.url.startsWith('http://') && !event.request.url.startsWith('https://')) {
return false
}
const isCdnAndCache = isExitInUrlList(cdnAndCacheList, event.request.url)
const isOnlyCacheList = isExitInUrlList(onlyCacheList, event.request.url)
// cdn并发请求未开启 或 请求没有被任何路由命中

View File

@ -1 +1 @@
body{cursor:var(--cursor-default)}.actions>div,.expand-done,.main-content figure>figcaption div,.navbar-above .navbar-nav .item,.navbar-searchicon,.navbar-slideicon,.photos .picture-details,.wechat .flip-wrapper.pointer,.widget .ad-tag .click-close,a,button{cursor:var(--cursor-pointer)}.aplayer .aplayer-bar-wrap,.aplayer .aplayer-icon,.aplayer .aplayer-music,.aplayer .aplayer-pic{cursor:var(--cursor-pointer)!important}.main-content :not(.jg-entry)>img:not([class]){cursor:var(--cursor-zoom-in)}blockquote,code,h1,h2,h3,h4,h5,h6,hr,input[type=text],li,p,td,textarea,th{cursor:var(--cursor-text)}.wechat .flip-wrapper{cursor:var(--cursor-default)}
body{cursor:var(--cursor-default)}.actions>div,.expand-done,.main-content figure>figcaption div,.navbar-above .navbar-nav .item,.navbar-searchicon,.navbar-slideicon,.photos .picture-details,.wechat .flip-wrapper.pointer,.widget .ad-tag .click-close,a,button{cursor:var(--cursor-pointer)}.aplayer .aplayer-bar-wrap,.aplayer .aplayer-icon,.aplayer .aplayer-music,.aplayer .aplayer-pic{cursor:var(--cursor-pointer)!important}.main-content :not(.jg-entry)>img:not([class]){cursor:var(--cursor-zoom-in)}blockquote,code,h1,h2,h3,h4,h5,h6,hr,input[type=text],li,p,td,textarea,th{cursor:var(--cursor-text)}.wechat .flip-wrapper,label{cursor:var(--cursor-default)}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(()=>{const i=new Set($('link[href*=".css"]').map((o,e)=>$(e).attr("href")).get()),l=new Set($('script[src*=".js"]').map((o,e)=>$(e).attr("src")).get()),e=()=>{var o=(new Date).getTime();return window.pjaxSerialNumber=o,console.log("sn = "+o),o},n=o=>"/"!==o.pathname&&0!==$(".banner").length?(window.initTop=99999999,window.innerHeight/4):0,c=(e,n,t)=>{if(n>=e.length)t&&t();else{let o=$(e[n]).attr("src");l.has(o)?c(e,n+1,t):(console.log((t?"同步":"异步")+"顺序加载js "+o),Utils.cachedScript(o).done(function(){console.log((t?"同步":"异步")+"顺序加载js完成 "+o),l.add(o),window.DProgress&&DProgress.inc(),c(e,n+1,t)}).fail(function(){console.log((t?"同步":"异步")+"顺序加载js失败 "+o),c(e,n+1,t)}))}};$(document).on("click","a[target!=_blank][href]:not([data-not-pjax])",o=>{$.pjax.click(o,".column-main",{scrollTo:n(o.currentTarget),fragment:".column-main",serialNumber:e(),timeout:8e3})}),$(document).on("submit","form[data-pjax]",function(o){$.pjax.submit(o,".column-main",{scrollTo:n(o.currentTarget),fragment:".column-main",serialNumber:e(),timeout:8e3})}),$(document).on("pjax:click",function(o,e){console.log("------------------------"),console.log("pjax:click sn = "+e.serialNumber)}),$(document).on("pjax:beforeSend",function(o,e,n){console.log("pjax:beforeSend sn = "+n.serialNumber),$("html").addClass("pjax-loading")}),$(document).on("pjax:start",function(o,e,n){console.log("pjax:start sn = "+n.serialNumber),window.DProgress&&DProgress.start(),$(".pjax-close").remove()}),$(document).on("pjax:send",function(o,e,n){console.log("pjax:send sn = "+n.serialNumber)}),$(document).on("pjax:clicked",function(o,e){console.log("pjax:clicked sn = "+e.serialNumber)}),$(document).on("pjax:beforeReplace",function(o,e,n){console.log("pjax:beforeReplace sn = "+n.serialNumber),$(".navbar-nav .current,.panel-side-menu .current").removeClass("current"),commonContext.initNavbar(),0<$("html.disable-scroll").length&&$(".navbar-mask").trigger("click")}),$(document).on("pjax:success",async function(o,e,n,t,a){a=a.serialNumber;if(console.log("pjax:success sn = "+a),window.pjaxSerialNumber===a){commonContext.initGallery(),commonContext.initTocAndNotice(),$("html").removeClass("pjax-loading");const r=$($.parseHTML(e,document,!0)),s=$("head");s.find("meta").remove(),s.find('link[rel="canonical"]').remove(),s.append(r.filter("meta")),s.append(r.filter('link[rel="canonical"]')),r.filter("link[data-pjax]").each(function(){let o=$(this).attr("href");i.has(o)||(s.append($(this)),console.log("加载css "+$(this).attr("href")),this.onload=function(){i.add(o),window.DProgress&&DProgress.inc(),console.log("加载css完成 "+$(this).attr("href"))})});let o=r.filter("script[data-pjax]");if(0<o.length){o.filter("[async]").each(function(){let o=$(this).attr("src");l.has(o)||(console.log("异步无序加载js "+o),Utils.cachedScript(o).done(function(){console.log("异步无序js完成 "+o),window.DProgress&&DProgress.inc(),l.add(o)}).fail(function(){console.log("异步无序js失败 "+o)}))}),new Promise(()=>{c(o.filter("[defer]"),0)});let e=o.filter(":not([async]):not([defer])");0<e.length&&await new Promise(o=>{c(e,0,o)})}console.log("全部处理完成"),window.pjaxSerialNumber===a&&(window.journalPjax&&window.journalPjax(a),window.postPjax&&window.postPjax(a),commonContext.initTimeCount(),commonContext.initCarousel(),window.DProgress)&&DProgress.done()}}),$(document).on("pjax:timeout",function(o,e,n){console.log("pjax:timeout sn = "+n.serialNumber)}),$(document).on("pjax:error",function(o,e,n,t,a){console.log(`pjax:error sn = ${a.serialNumber} error `+t)}),$(document).on("pjax:complete",function(o,e,n,t){console.log("pjax:complete sn = "+t.serialNumber)}),$(document).on("pjax:end",function(o,e,n){console.log("pjax:end sn = "+n.serialNumber),null==e&&(commonContext.initTocAndNotice(),commonContext.initCarousel(),commonContext.initTimeCount(),window.DProgress&&DProgress.done(),$("html").removeClass("pjax-loading"))}),$(document).on("pjax:popstate",function(o){console.log("pjax:popstate")})})();
(()=>{const i=new Set($('link[href*=".css"]').map((o,e)=>$(e).attr("href")).get()),l=new Set($('script[src*=".js"]').map((o,e)=>$(e).attr("src")).get()),e=()=>{var o=(new Date).getTime();return window.pjaxSerialNumber=o,console.log("sn = "+o),o},n=o=>"/"!==o.pathname&&0!==$(".banner").length?(window.initTop=99999999,window.innerHeight/4):0,c=(e,n,t)=>{if(n>=e.length)t&&t();else{let o=$(e[n]).attr("src");l.has(o)?c(e,n+1,t):(console.log((t?"同步":"异步")+"顺序加载js "+o),Utils.cachedScript(o).done(function(){console.log((t?"同步":"异步")+"顺序加载js完成 "+o),l.add(o),window.DProgress&&DProgress.inc(),c(e,n+1,t)}).fail(function(){console.log((t?"同步":"异步")+"顺序加载js失败 "+o),c(e,n+1,t)}))}};$(document).on("click","a[target!=_blank][href]:not([data-not-pjax])",o=>{$.pjax.click(o,".column-main",{scrollTo:n(o.currentTarget),fragment:".column-main",serialNumber:e(),timeout:8e3})}),$(document).on("submit","form[data-pjax]",function(o){$.pjax.submit(o,".column-main",{scrollTo:n(o.currentTarget),fragment:".column-main",serialNumber:e(),timeout:8e3})}),$(document).on("pjax:click",function(o,e){console.log("------------------------"),console.log("pjax:click sn = "+e.serialNumber)}),$(document).on("pjax:beforeSend",function(o,e,n){console.log("pjax:beforeSend sn = "+n.serialNumber),$("html").addClass("pjax-loading")}),$(document).on("pjax:start",function(o,e,n){console.log("pjax:start sn = "+n.serialNumber),window.DProgress&&DProgress.start(),$(".pjax-close").remove()}),$(document).on("pjax:send",function(o,e,n){console.log("pjax:send sn = "+n.serialNumber)}),$(document).on("pjax:clicked",function(o,e){console.log("pjax:clicked sn = "+e.serialNumber)}),$(document).on("pjax:beforeReplace",function(o,e,n){console.log("pjax:beforeReplace sn = "+n.serialNumber),$(".navbar-nav .current,.panel-side-menu .current").removeClass("current"),commonContext.initNavbar(),0<$("html.disable-scroll").length&&$(".navbar-mask").trigger("click")}),$(document).on("pjax:success",async function(o,e,n,t,a){a=a.serialNumber;if(console.log("pjax:success sn = "+a),window.pjaxSerialNumber===a){commonContext.initGallery(),commonContext.initTocAndNotice(),$("html").removeClass("pjax-loading");const s=$($.parseHTML(e,document,!0)),r=$("head");r.find("meta").remove(),r.find('link[rel="canonical"]').remove(),r.append(s.filter("meta")),r.append(s.filter('link[rel="canonical"]')),s.filter("link[data-pjax]").each(function(){let o=$(this).attr("href");i.has(o)||(r.append($(this)),console.log("加载css "+$(this).attr("href")),this.onload=function(){i.add(o),window.DProgress&&DProgress.inc(),console.log("加载css完成 "+$(this).attr("href"))})});let o=s.filter("script[data-pjax]");if(0<o.length){o.filter("[async]").each(function(){let o=$(this).attr("src");l.has(o)||(console.log("异步无序加载js "+o),Utils.cachedScript(o).done(function(){console.log("异步无序js完成 "+o),window.DProgress&&DProgress.inc(),l.add(o)}).fail(function(){console.log("异步无序js失败 "+o)}))}),new Promise(()=>{c(o.filter("[defer]"),0)});let e=o.filter(":not([async]):not([defer])");0<e.length&&await new Promise(o=>{c(e,0,o)})}console.log("全部处理完成"),window.pjaxSerialNumber===a&&(window.journalPjax&&window.journalPjax(a),window.postPjax&&window.postPjax(a),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),commonContext.initCarousel(),window.DProgress)&&DProgress.done()}}),$(document).on("pjax:timeout",function(o,e,n){console.log("pjax:timeout sn = "+n.serialNumber)}),$(document).on("pjax:error",function(o,e,n,t,a){console.log(`pjax:error sn = ${a.serialNumber} error `+t)}),$(document).on("pjax:complete",function(o,e,n,t){console.log("pjax:complete sn = "+t.serialNumber)}),$(document).on("pjax:end",function(o,e,n){console.log("pjax:end sn = "+n.serialNumber),null==e&&(commonContext.initTocAndNotice(),commonContext.initCarousel(),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),window.DProgress&&DProgress.done(),$("html").removeClass("pjax-loading"))}),$(document).on("pjax:popstate",function(o){console.log("pjax:popstate")})})();

View File

@ -1 +1 @@
!function(){if(self.document){var e=document.currentScript.src;new URLSearchParams(e.split("?")[1]).get("uninstall")?(console.log("uninstall service worker."),navigator.serviceWorker.getRegistrations().then(function(e){for(var t of e)t.active&&t.active.scriptURL&&-1!==t.active.scriptURL.indexOf("/sw.min.js")&&t.unregister()}),window.caches&&caches.keys&&caches.keys().then(function(e){e.forEach(function(e){console.log("delete cache",e),caches.delete(e)})})):navigator.serviceWorker.register(document.currentScript.src).catch(function(e){console.log("cache failed with "+e)})}else{const i="Dream2-plus-1.0.0",t=new URLSearchParams(location.href.split("?")[1]),o=t.get("concurrent"),c=t.get("cache"),n=location.origin+"/themes/theme-dream2-plus",a=t.get("cdn").split(",").filter(e=>0<e.length&&0===e.indexOf("http")),u=[location.origin+"/api"],l=[n,...a],h=[location.origin+"/upload","https://cdn.jsdelivr.net/"],f={theme:{handleRequest:e=>{if(0===e.indexOf(n)){const t=e.substring(n.length),r=new URLSearchParams(e.split("?")[1]).get("mew")||"latest";return[e,...a.map(e=>e+"/halo-theme-dream2-plus@"+r+t)]}}},npm:{handleRequest:e=>{for(var t in a)if(0===e.indexOf(a[t])){const r=e.substring(a[t].length);return a.map(e=>e+r)}}}};function r(e,t){return e.some(function(e){return 0===t.indexOf(e)})}function s(e,t){var r=new Set(["mew","v","version","t","time","ts","timestamp"]),e=e.split("?"),t=t.split("?");if(e[0]===t[0]){var n=new URLSearchParams("?"+e[1]),s=new URLSearchParams("?"+t[1]);for(const e of n.keys())if(!r.has(e)&&n.get(e)!==s.get(e))return;return 1}}self.addEventListener("install",function(e){console.log("install service worker."),e.waitUntil(self.skipWaiting())}),self.addEventListener("activate",function(e){console.log("service worker activate.");const t=[i];return e.waitUntil(caches.keys().then(function(e){return Promise.all(e.map(function(e){if(-1===t.indexOf(e))return console.info("version changed, clean the cache, SW: deleting "+e),caches.delete(e)}))})),self.clients.claim()}),self.addEventListener("fetch",function(n){if("GET"!==n.request.method||r(u,n.request.url))return!1;const t=r(l,n.request.url),e=r(h,n.request.url);if(!o||!t&&!e)return!!c&&(n.respondWith(caches.open(i).then(t=>fetch(n.request).then(e=>(200===e.status&&t.put(n.request,e.clone()),e)).catch(()=>t.match(n.request)))),!0);n.respondWith(caches.open(i).then(function(r){return r.match(n.request).then(function(e){return e||function(e,t){if(t&&o)for(const t in f){var r=f[t].handleRequest(e.url);if(r){var n=e.url;const s=new AbortController,i=s.signal,c=r.map(e=>new Promise(async(t,r)=>{fetch(e,{signal:i}).then(async e=>{var t=new Headers(e.headers);return t.set("service-worker-origin",n),new Response(await e.arrayBuffer(),{status:e.status,headers:t})}).then(e=>{(200===e.status?(s.abort(),t):r)(e)}).catch(()=>r(null))}));return Promise.any||(Promise.any=function(e){return new Promise((t,r)=>{let n=(e=Array.isArray(e)?e:[]).length,s=[];if(0===n)return r(new AggregateError("All promises were rejected"));e.forEach(e=>{if(!(e instanceof Promise))return r(e);e.then(e=>t(e),e=>{n--,s.push(e),0===n&&r(new AggregateError(s))})})})}),Promise.any(c);return}}return fetch(e)}(n.request,t).then(e=>{const t=e.clone();return r.matchAll(n.request,{ignoreSearch:!0}).then(function(e){if(e)for(const t of e){const e=t.url||t.headers.get("service-worker-origin");s(e,n.request.url)&&r.delete(e)}r.put(n.request,t)}),e}).catch(e=>(console.error(e),r.matchAll(n.request,{ignoreSearch:!0}).then(function(e){if(e)for(const t of e)if(s(t.url||t.headers.get("service-worker-origin"),n.request.url))return t})))})}))})}}();
!function(){if(self.document){var e=document.currentScript.src;new URLSearchParams(e.split("?")[1]).get("uninstall")?(console.log("uninstall service worker."),navigator.serviceWorker.getRegistrations().then(function(e){for(var t of e)t.active&&t.active.scriptURL&&-1!==t.active.scriptURL.indexOf("/sw.min.js")&&t.unregister()}),window.caches&&caches.keys&&caches.keys().then(function(e){e.forEach(function(e){console.log("delete cache",e),caches.delete(e)})})):navigator.serviceWorker.register(document.currentScript.src).catch(function(e){console.log("cache failed with "+e)})}else{const i="Dream2-plus-1.0.0",t=new URLSearchParams(location.href.split("?")[1]),o=t.get("concurrent"),c=t.get("cache"),n=location.origin+"/themes/theme-dream2-plus",a=t.get("cdn").split(",").filter(e=>0<e.length&&0===e.indexOf("http")),u=[location.origin+"/api",location.origin+"/apis"],l=[n,...a],h=[location.origin+"/upload","https://cdn.jsdelivr.net/"],f={theme:{handleRequest:e=>{if(0===e.indexOf(n)){const t=e.substring(n.length),r=new URLSearchParams(e.split("?")[1]).get("mew")||"latest";return[e,...a.map(e=>e+"/halo-theme-dream2-plus@"+r+t)]}}},npm:{handleRequest:e=>{for(var t in a)if(0===e.indexOf(a[t])){const r=e.substring(a[t].length);return a.map(e=>e+r)}}}};function r(e,t){return e.some(function(e){return 0===t.indexOf(e)})}function s(e,t){var r=new Set(["mew","v","version","t","time","ts","timestamp"]),e=e.split("?"),t=t.split("?");if(e[0]===t[0]){var n=new URLSearchParams("?"+e[1]),s=new URLSearchParams("?"+t[1]);for(const e of n.keys())if(!r.has(e)&&n.get(e)!==s.get(e))return;return 1}}self.addEventListener("install",function(e){console.log("install service worker."),e.waitUntil(self.skipWaiting())}),self.addEventListener("activate",function(e){console.log("service worker activate.");const t=[i];return e.waitUntil(caches.keys().then(function(e){return Promise.all(e.map(function(e){if(-1===t.indexOf(e))return console.info("version changed, clean the cache, SW: deleting "+e),caches.delete(e)}))})),self.clients.claim()}),self.addEventListener("fetch",function(n){if("GET"!==n.request.method||r(u,n.request.url))return!1;if(!n.request.url.startsWith("http://")&&!n.request.url.startsWith("https://"))return!1;const t=r(l,n.request.url),e=r(h,n.request.url);if(!o||!t&&!e)return!!c&&(n.respondWith(caches.open(i).then(t=>fetch(n.request).then(e=>(200===e.status&&t.put(n.request,e.clone()),e)).catch(()=>t.match(n.request)))),!0);n.respondWith(caches.open(i).then(function(r){return r.match(n.request).then(function(e){return e||function(e,t){if(t&&o)for(const t in f){var r=f[t].handleRequest(e.url);if(r){var n=e.url;const s=new AbortController,i=s.signal,c=r.map(e=>new Promise(async(t,r)=>{fetch(e,{signal:i}).then(async e=>{var t=new Headers(e.headers);return t.set("service-worker-origin",n),new Response(await e.arrayBuffer(),{status:e.status,headers:t})}).then(e=>{(200===e.status?(s.abort(),t):r)(e)}).catch(()=>r(null))}));return Promise.any||(Promise.any=function(e){return new Promise((t,r)=>{let n=(e=Array.isArray(e)?e:[]).length,s=[];if(0===n)return r(new AggregateError("All promises were rejected"));e.forEach(e=>{if(!(e instanceof Promise))return r(e);e.then(e=>t(e),e=>{n--,s.push(e),0===n&&r(new AggregateError(s))})})})}),Promise.any(c);return}}return fetch(e)}(n.request,t).then(e=>{const t=e.clone();return r.matchAll(n.request,{ignoreSearch:!0}).then(function(e){if(e)for(const t of e){const e=t.url||t.headers.get("service-worker-origin");s(e,n.request.url)&&r.delete(e)}r.put(n.request,t)}),e}).catch(e=>(console.error(e),r.matchAll(n.request,{ignoreSearch:!0}).then(function(e){if(e)for(const t of e)if(s(t.url||t.headers.get("service-worker-origin"),n.request.url))return t})))})}))})}}();

View File

@ -78,12 +78,15 @@
DreamConfig["pjax_state"] = [[${theme.config.enhance.enable_pjax}]];
/** 配置分享方式 */
let post_share = []
for (let share of [[${theme.config.post.custom_post_share}]]) {
let custom_post_share = [[${theme.config.post.custom_post_share}]];
if(custom_post_share) {
for (let share of custom_post_share) {
let type = share.realNode.type;
if (post_share.indexOf(type) === -1) {
post_share.push(type);
}
}
}
if (post_share.length === 0) {
post_share.push('link');
}

View File

@ -2,7 +2,7 @@
th:with="description=${isPost ? post != null ? post.status.excerpt : singlePage != null ? singlePage.status.excerpt : site.seo.description : site.seo.description}">
<meta charset="utf-8"/>
<title th:text="${title + (#strings.isEmpty(site.subtitle) ? '' : '|' + site.subtitle)}"></title>
<script th:if="${theme.config.enhance.enable_sw}" th:src="${(theme.config.enhance.enable_sw == 'uninstall')? #theme.assets('/assets/js/sw.min.js?uninstall=true') + '&mew=1.2.1' : '/sw.min.js?mew=1.2.1' + theme.config.enhance.enable_sw + '&cdn=' + theme.config.enhance.sw_cdn_source.replaceAll('\n', ',')}"></script>
<script th:if="${theme.config.enhance.enable_sw}" th:src="${(theme.config.enhance.enable_sw == 'uninstall')? #theme.assets('/assets/js/sw.min.js?uninstall=true') + '&mew=1.2.2' : '/sw.min.js?mew=1.2.2' + theme.config.enhance.enable_sw + '&cdn=' + theme.config.enhance.sw_cdn_source.replaceAll('\n', ',')}"></script>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="applicable-device" content="pc,mobile">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

View File

@ -32,6 +32,7 @@
<th:block th:replace="~{common/actions}"/>
<th:block th:replace="~{common/footer}"/>
<th:block th:replace="~{common/scripts}"/>
<th:block th:utext="${theme.config.custom.inline_body_html}"></th:block>
</body>
</th:block>
</th:block>

View File

@ -75,23 +75,31 @@
th:title="${theme.config.basic_style.console.console_title}">
<i th:class="${#strings.defaultString(theme.config.basic_style.console.console_icon, 'ri-equalizer-line')}"></i>
</a>
<div th:if="${theme.config.basic_style.show_console == 'logon'}" class="navbar-logon" trigger="hover" th:with="currentUser = ${contributorFinder.getContributor(#authentication.name)}">
<div th:if="${theme.config.basic_style.show_console == 'logon'}" class="navbar-logon" trigger="hover"
th:with="currentUser = ${contributorFinder.getContributor(#authentication.name)},
skillUrl = ${theme.config.basic_style.expand_login_skill}">
<div class="navbar-logon-head">
<img th:src="${currentUser.avatar ?: #theme.assets('/img/avatar.svg')}"
th:alt="${currentUser.displayName}"
/>
</div>
<ul class="navbar-logon-group">
<li sec:authorize="isAuthenticated()" class="navbar-logon-group-menu">
<li th:if="${skillUrl != 'none' && !#strings.isEmpty(logonUserName)}" class="navbar-logon-group-menu">
<a th:href="@{|/${skillUrl}/posts/editor|}" target="_blank"><i th:if="${!#strings.isEmpty(theme.config.basic_style.logon.console_person_class)}" th:class="${theme.config.basic_style.logon.console_post_class}"></i> 新建文章</a>
</li>
<li th:if="${skillUrl != 'none' && !#strings.isEmpty(logonUserName)}" class="navbar-logon-group-menu">
<a th:href="@{|/${skillUrl}/moments|}" target="_blank"><i th:if="${!#strings.isEmpty(theme.config.basic_style.logon.console_person_class)}" th:class="${theme.config.basic_style.logon.console_moment_class}"></i> 发布瞬间</a>
</li>
<li th:if="${!#strings.isEmpty(logonUserName)}" class="navbar-logon-group-menu">
<a href="/uc" target="_blank"><i th:if="${!#strings.isEmpty(theme.config.basic_style.logon.console_person_class)}" th:class="${theme.config.basic_style.logon.console_person_class}"></i> 个人中心</a>
</li>
<li sec:authorize="isAuthenticated()" class="navbar-logon-group-menu">
<li th:if="${!#strings.isEmpty(logonUserName)}" class="navbar-logon-group-menu">
<a href="/console" target="_blank"><i th:if="${!#strings.isEmpty(theme.config.basic_style.logon.console_manage_class)}" th:class="${theme.config.basic_style.logon.console_manage_class}"></i> 后台管理</a>
</li>
<li sec:authorize="isAuthenticated()" class="navbar-logon-group-menu">
<li th:if="${!#strings.isEmpty(logonUserName)}" class="navbar-logon-group-menu">
<a href="/logout"><i th:if="${!#strings.isEmpty(theme.config.basic_style.logon.console_logout_class)}" th:class="${theme.config.basic_style.logon.console_logout_class}"></i> 退出登录</a>
</li>
<li sec:authorize="isAnonymous()" class="navbar-logon-group-menu">
<li th:if="${#strings.isEmpty(logonUserName)}" class="navbar-logon-group-menu">
<a href="/login" onclick="this.href = '/login?redirect_uri=' + encodeURIComponent(window.location.href)"><i th:if="${!#strings.isEmpty(theme.config.basic_style.logon.console_login_class)}" th:class="${theme.config.basic_style.logon.console_login_class}"></i> 登录</a>
</li>
</ul>

View File

@ -1,11 +1,13 @@
<th:block xmlns:th="https://www.thymeleaf.org"
th:fragment="article (post, type)"
th:with="updateInterval = ${T(java.lang.Math).floor((#dates.createNow().getTime()/1000.0 - post.status.lastModifyTime.getEpochSecond())/86400.0).intValue()},
isPost = ${type == 'Post'},
skillUrl = ${theme.config.basic_style.expand_login_skill},
thumbnail = ${#strings.isEmpty(post.spec.cover) ? #strings.isEmpty(theme.config.post.default_thumbnail) ? '' : theme.config.post.default_thumbnail + (#strings.contains(theme.config.post.default_thumbnail, '?') ? '&' : '?') + 'id=' + post.metadata.name : thumbnail.gen(post.spec.cover, 'xl')}">
<div th:if="${!#strings.isEmpty(thumbnail)}" class="card widget">
<div class="cover-image" th:style="'background-image: url(' + ${thumbnail} + ')'">
<div th:if="${type == 'Post' && !#lists.isEmpty(post.categories)}" class="category">
<div th:if="${isPost && !#lists.isEmpty(post.categories)}" class="category">
<a th:each="cy : ${post.categories}" th:href="${cy.status.permalink}"
th:text="${cy.spec.displayName}"></a>&nbsp;
</div>
@ -18,6 +20,8 @@
</li>
<li><i class="ri-thumb-up-line"></i>[[${post.stats.upvote}]]</li>
<li><i class="ri-quill-pen-line"></i>[[${#strings.length(#strings.trim(post.content.content))}]]</li>
<li th:if="${logonUserName == post.spec.owner && (skillUrl == 'console' || (skillUrl == 'uc' && isPost))}" class="is-hidden-laptop">
<a target="_blank" title="编辑文章" th:href="@{|/${skillUrl}/${isPost ? 'posts' : 'single-pages'}/editor?name=${post.metadata.name}|}"><i class="ri-edit-2-line"></i>编辑</a></li>
</ul>
</div>
</div>
@ -45,8 +49,10 @@
</li>
<li><i class="ri-thumb-up-line"></i>[[${post.stats.upvote}]]</li>
<li><i class="ri-quill-pen-line"></i>[[${#strings.length(#strings.trim(post.content.content))}]]</li>
<li th:if="${logonUserName == post.spec.owner && (skillUrl == 'console' || (skillUrl == 'uc' && isPost))}" class="is-hidden-laptop">
<a target="_blank" title="编辑文章" th:href="@{|/${skillUrl}/${isPost ? 'posts' : 'single-pages'}/editor?name=${post.metadata.name}|}"><i class="ri-edit-2-line"></i>编辑</a></li>
</ul>
<div th:if="${type == 'Post' && !#lists.isEmpty(post.categories)}" class="level-item">
<div th:if="${isPost && !#lists.isEmpty(post.categories)}" class="level-item">
<a th:each="cy : ${post.categories}" th:href="${cy.status.permalink}"
th:text="${cy.spec.displayName}"></a>&nbsp;
</div>
@ -60,7 +66,7 @@
<th:block th:replace="~{main/admire}"/>
<div th:if="${type == 'Post' && !#lists.isEmpty(post.tags)}" class="article-operation">
<div th:if="${isPost && !#lists.isEmpty(post.tags)}" class="article-operation">
<div class="level-item">
<a th:each=" tag : ${post.tags}" th:href="${tag.status.permalink}"
th:text="${tag.spec.displayName}"></a>&nbsp;
@ -76,7 +82,7 @@
</div>
</div>
<th:block th:if="${type == 'Post'}" th:with="postCursor = ${postFinder.cursor(post.metadata.name)}">
<th:block th:if="${isPost}" th:with="postCursor = ${postFinder.cursor(post.metadata.name)}">
<div th:if="${postCursor.hasPrevious() || postCursor.hasNext()}" class="card">
<div class="level post-navigation card-content">
<a th:if="${postCursor.hasPrevious()}" class="level-item"

View File

@ -4,7 +4,7 @@
th:with="isJournals = true, enableShare = ${theme.config.page_config.enable_journals_share}, baseEnableComment = ${theme.config.page_config.enable_journals_comment}"
xmlns:th="https://www.thymeleaf.org">
<th:block th:fragment="content">
<div class="card card-content journal" th:if="${!#lists.isEmpty(tags)}">
<div class="card card-content journal" th:if="${!#lists.isEmpty(tags) && theme.config.page_config.enable_journals_tags}">
<div class="card-tab">
<div>
[[${#strings.replace(title, ' - ' + site.title, '')}]]

View File

@ -30,7 +30,7 @@ spec:
settingName: theme-dream2-plus-setting
configMapName: theme-dream2-plus-configMap
# 版本号
version: 1.3.2
version: 1.3.3.beta12
# 最低支持的 Halo 版本
require: ">=2.20.0"
# 许可