mirror of
https://ghfast.top/https://github.com/zsjy/halo-theme-dream2.0-plus.git
synced 2025-03-15 20:09:41 +08:00
优化:SEO
This commit is contained in:
parent
68df3d7a2e
commit
e289a11139
@ -25,7 +25,7 @@
|
||||
//可以进行版本修改,删除缓存
|
||||
const version = '1.0.0'
|
||||
// 取得缓存名称
|
||||
const cacheName = `Dream-${version}`
|
||||
const cacheName = `Dream2-plus-${version}`
|
||||
// 取得请求参数
|
||||
const envParams = new URLSearchParams(location.href.split('?')[1])
|
||||
// 是否开启多cdn源并发请求
|
||||
@ -33,7 +33,7 @@
|
||||
// 是否开启全站缓存
|
||||
const isGlobalCache = envParams.get('cache')
|
||||
// 主题路径
|
||||
const themePath = location.origin + '/themes/dream'
|
||||
const themePath = location.origin + '/themes/theme-dream2-plus'
|
||||
// cdn源站点,一行一个
|
||||
const cdnSource = envParams.get('cdn').split(',').filter(item => item.length > 0 && item.indexOf('http') === 0)
|
||||
|
||||
@ -64,7 +64,7 @@
|
||||
const version = new URLSearchParams(url.split('?')[1]).get('mew') || 'latest'
|
||||
return [
|
||||
url,
|
||||
...cdnSource.map(value => `${value}/halo-theme-dream@${version}${path}`)
|
||||
...cdnSource.map(value => `${value}/halo-theme-dream2-plus@${version}${path}`)
|
||||
]
|
||||
},
|
||||
},
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 3.8 KiB |
BIN
templates/assets/img/ga.webp
Normal file
BIN
templates/assets/img/ga.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
2
templates/assets/js/sw.min.js
vendored
2
templates/assets/js/sw.min.js
vendored
@ -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="Dream-1.0.0",t=new URLSearchParams(location.href.split("?")[1]),o=t.get("concurrent"),c=t.get("cache"),n=location.origin+"/themes/dream",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-dream@"+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"],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})))})}))})}}();
|
@ -28,9 +28,9 @@
|
||||
</span>
|
||||
</p>
|
||||
<p th:if="${!#strings.isEmpty(theme.config.basic_info.record_number_ps)}"><a th:href="'https://beian.mps.gov.cn/#/query/webSearch?code=' + ${theme.config.basic_info.record_number_ps.replaceAll('[^\d]', '')}" target="_blank" rel="noopener noreferrer nofollow"><img
|
||||
th:src="${#theme.assets('/img/ga.png')}" alt="公网安备" style="vertical-align: text-top; width: 1.2em; margin-right: 4px;"/>[[${theme.config.basic_info.record_number_ps}]]</a></p>
|
||||
th:src="${#theme.assets('/img/ga.webp')}" height="auto" width="auto" alt="公网安备" style="vertical-align: text-top; width: 1.2em; margin-right: 4px;"/>[[${theme.config.basic_info.record_number_ps}]]</a></p>
|
||||
<p th:if="${!#strings.isEmpty(theme.config.basic_info.cloud_by_logo)}">本站由<a
|
||||
class="cloud-driven" target="_blank" rel="noopener noreferrer nofollow" th:href="${theme.config.basic_info.cloud_by_url}"><img
|
||||
class="cloud-driven" target="_blank" rel="noopener noreferrer nofollow" th:href="${theme.config.basic_info.cloud_by_url}"><img height="auto" width="auto"
|
||||
alt="云服务商" th:src="${theme.config.basic_info.cloud_by_logo}"/></a>提供云服务</p>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<head xmlns:th="https://www.thymeleaf.org" th:fragment="head"
|
||||
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>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
|
||||
<meta http-equiv="x-dns-prefetch-control" content="on">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="on">
|
||||
<meta name="keywords" th:content="${site.seo.keywords}"/>
|
||||
<meta name="description" th:content="${description}">
|
||||
<meta name="author" th:content="${site.title}">
|
||||
|
@ -4,7 +4,7 @@
|
||||
class="card card-transparent"
|
||||
th:with="urlParamStr = ${#strings.substringAfter(data.prevUrl,'?')},
|
||||
urlParams = ${urlParamStr == null ? '' : ('?' + urlParamStr)}">
|
||||
<nav class="pagination" role="navigation" aria-label="pagination">
|
||||
<nav class="pagination" aria-label="pagination">
|
||||
<a th:href="${data.prevUrl}"
|
||||
th:class="'pagination-previous' + ${data.hasPrevious()?'':' is-invisible is-hidden-mobile'}">上一页</a>
|
||||
<a th:href="${data.nextUrl}"
|
||||
|
@ -5,7 +5,7 @@
|
||||
<nav class="level">
|
||||
<div class="level-item" style="flex-direction: column;">
|
||||
<figure class="image">
|
||||
<img class="avatar" th:src="${contributor.avatar}" th:alt="${contributor.displayName}">
|
||||
<img class="avatar" height="auto" width="auto" th:src="${contributor.avatar}" th:alt="${contributor.displayName}">
|
||||
</figure>
|
||||
<p class="nickname" th:text="${contributor.displayName}"></p>
|
||||
<p class="motto spark-input" th:text="${contributor.bio}"></p>
|
||||
|
@ -9,10 +9,10 @@
|
||||
th:onclick="${#strings.isEmpty(wechatUrl)} ? 'event.preventDefault();'" target="_blank">
|
||||
<div th:class="${!#strings.isEmpty(faceImg) && !#strings.isEmpty(backImg) ? 'flip-content animation' : 'flip-content'}">
|
||||
<div class="wechatFace">
|
||||
<img th:if="${!#strings.isEmpty(faceImg)}" th:src="${faceImg}" alt="微信公众号"/>
|
||||
<img th:if="${!#strings.isEmpty(faceImg)}" height="auto" width="auto" th:src="${faceImg}" alt="微信公众号"/>
|
||||
</div>
|
||||
<div th:class="${!#strings.isEmpty(faceImg) && !#strings.isEmpty(backImg) ? 'wechatBack animation' : 'wechatBack'}" th:classappend="${#strings.isEmpty(faceImg)}? 'show'">
|
||||
<img th:if="${!#strings.isEmpty(backImg)}" th:src="${backImg}" alt="微信公众号"/>
|
||||
<img th:if="${!#strings.isEmpty(backImg)}" height="auto" width="auto" th:src="${backImg}" alt="微信公众号"/>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
@ -22,6 +22,6 @@ spec:
|
||||
settingName: theme-dream-setting
|
||||
configMapName: theme-dream-configMap
|
||||
# 版本号
|
||||
version: 1.0.2.8
|
||||
version: 1.0.2.13
|
||||
# 最低支持的 Halo 版本
|
||||
require: ">=2.6.0"
|
Loading…
x
Reference in New Issue
Block a user