Compare commits
No commits in common. "a2d1b2cc4974395f62d523fb2d7b337774f6dc8d" and "6c8ac211ae163614d2412f13db520de0ee5f559c" have entirely different histories.
a2d1b2cc49
...
6c8ac211ae
@ -60,7 +60,7 @@
|
||||
</div>
|
||||
<ul class="search-ul">
|
||||
<li class="search-li" v-for="(item,index) in items" :key="index" v-show="!item.isHide">
|
||||
<a :href="item.path|urlformat" class="search-title"><i class="icon icon-quote-left"></i>
|
||||
<a :href="urlformat(item.path)" class="search-title"><i class="icon icon-quote-left"></i>
|
||||
<span v-text="item.title"></span>
|
||||
</a>
|
||||
<p class="search-time" v-if="item.date">
|
||||
|
||||
176
themes/yilia/package-lock.json
generated
176
themes/yilia/package-lock.json
generated
@ -14,7 +14,7 @@
|
||||
"photoswipe": "^4.1.3",
|
||||
"qrious": "^4.0.2",
|
||||
"scrollreveal": "^4.0.9",
|
||||
"vue": "^2.7.16"
|
||||
"vue": "^3.5.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.26.0",
|
||||
@ -1646,7 +1646,6 @@
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
|
||||
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@jridgewell/trace-mapping": {
|
||||
@ -1731,19 +1730,118 @@
|
||||
"undici-types": "~7.18.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-sfc": {
|
||||
"version": "2.7.16",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.16.tgz",
|
||||
"integrity": "sha512-KWhJ9k5nXuNtygPU7+t1rX6baZeqOYLEforUPjgNDBnLicfHCoi48H87Q8XyLZOrNNsmhuwKqtpDQWjEFe6Ekg==",
|
||||
"node_modules/@vue/compiler-core": {
|
||||
"version": "3.5.30",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.30.tgz",
|
||||
"integrity": "sha512-s3DfdZkcu/qExZ+td75015ljzHc6vE+30cFMGRPROYjqkroYI5NV2X1yAMX9UeyBNWB9MxCfPcsjpLS11nzkkw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.23.5",
|
||||
"postcss": "^8.4.14",
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"prettier": "^1.18.2 || ^2.0.0"
|
||||
"@babel/parser": "^7.29.0",
|
||||
"@vue/shared": "3.5.30",
|
||||
"entities": "^7.0.1",
|
||||
"estree-walker": "^2.0.2",
|
||||
"source-map-js": "^1.2.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-core/node_modules/entities": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz",
|
||||
"integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-dom": {
|
||||
"version": "3.5.30",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.30.tgz",
|
||||
"integrity": "sha512-eCFYESUEVYHhiMuK4SQTldO3RYxyMR/UQL4KdGD1Yrkfdx4m/HYuZ9jSfPdA+nWJY34VWndiYdW/wZXyiPEB9g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-core": "3.5.30",
|
||||
"@vue/shared": "3.5.30"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-sfc": {
|
||||
"version": "3.5.30",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.30.tgz",
|
||||
"integrity": "sha512-LqmFPDn89dtU9vI3wHJnwaV6GfTRD87AjWpTWpyrdVOObVtjIuSeZr181z5C4PmVx/V3j2p+0f7edFKGRMpQ5A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.29.0",
|
||||
"@vue/compiler-core": "3.5.30",
|
||||
"@vue/compiler-dom": "3.5.30",
|
||||
"@vue/compiler-ssr": "3.5.30",
|
||||
"@vue/shared": "3.5.30",
|
||||
"estree-walker": "^2.0.2",
|
||||
"magic-string": "^0.30.21",
|
||||
"postcss": "^8.5.8",
|
||||
"source-map-js": "^1.2.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-ssr": {
|
||||
"version": "3.5.30",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.30.tgz",
|
||||
"integrity": "sha512-NsYK6OMTnx109PSL2IAyf62JP6EUdk4Dmj6AkWcJGBvN0dQoMYtVekAmdqgTtWQgEJo+Okstbf/1p7qZr5H+bA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-dom": "3.5.30",
|
||||
"@vue/shared": "3.5.30"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/reactivity": {
|
||||
"version": "3.5.30",
|
||||
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.30.tgz",
|
||||
"integrity": "sha512-179YNgKATuwj9gB+66snskRDOitDiuOZqkYia7mHKJaidOMo/WJxHKF8DuGc4V4XbYTJANlfEKb0yxTQotnx4Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/shared": "3.5.30"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/runtime-core": {
|
||||
"version": "3.5.30",
|
||||
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.30.tgz",
|
||||
"integrity": "sha512-e0Z+8PQsUTdwV8TtEsLzUM7SzC7lQwYKePydb7K2ZnmS6jjND+WJXkmmfh/swYzRyfP1EY3fpdesyYoymCzYfg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/reactivity": "3.5.30",
|
||||
"@vue/shared": "3.5.30"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/runtime-dom": {
|
||||
"version": "3.5.30",
|
||||
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.30.tgz",
|
||||
"integrity": "sha512-2UIGakjU4WSQ0T4iwDEW0W7vQj6n7AFn7taqZ9Cvm0Q/RA2FFOziLESrDL4GmtI1wV3jXg5nMoJSYO66egDUBw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/reactivity": "3.5.30",
|
||||
"@vue/runtime-core": "3.5.30",
|
||||
"@vue/shared": "3.5.30",
|
||||
"csstype": "^3.2.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/server-renderer": {
|
||||
"version": "3.5.30",
|
||||
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.30.tgz",
|
||||
"integrity": "sha512-v+R34icapydRwbZRD0sXwtHqrQJv38JuMB4JxbOxd8NEpGLny7cncMp53W9UH/zo4j8eDHjQ1dEJXwzFQknjtQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-ssr": "3.5.30",
|
||||
"@vue/shared": "3.5.30"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "3.5.30"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/shared": {
|
||||
"version": "3.5.30",
|
||||
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.30.tgz",
|
||||
"integrity": "sha512-YXgQ7JjaO18NeK2K9VTbDHaFy62WrObMa6XERNfNOkAhD1F1oDSf3ZJ7K6GqabZ0BvSDHajp8qfS5Sa2I9n8uQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@webassemblyjs/ast": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz",
|
||||
@ -2830,6 +2928,12 @@
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/estree-walker": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/esutils": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
@ -3662,6 +3766,15 @@
|
||||
"yallist": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/magic-string": {
|
||||
"version": "0.30.21",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
|
||||
"integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.5.5"
|
||||
}
|
||||
},
|
||||
"node_modules/make-dir": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
|
||||
@ -4254,22 +4367,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.8.8",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/pretty-error": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz",
|
||||
@ -4575,6 +4672,7 @@
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
@ -4830,14 +4928,24 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vue": {
|
||||
"version": "2.7.16",
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-2.7.16.tgz",
|
||||
"integrity": "sha512-4gCtFXaAA3zYZdTp5s4Hl2sozuySsgz4jy1EnpBHNfpMa9dK1ZCG7viqBPCwXtmgc8nHqUsAu3G4gtmXkkY3Sw==",
|
||||
"deprecated": "Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details.",
|
||||
"version": "3.5.30",
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.30.tgz",
|
||||
"integrity": "sha512-hTHLc6VNZyzzEH/l7PFGjpcTvUgiaPK5mdLkbjrTeWSRcEfxFrv56g/XckIYlE9ckuobsdwqd5mk2g1sBkMewg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-sfc": "2.7.16",
|
||||
"csstype": "^3.1.0"
|
||||
"@vue/compiler-dom": "3.5.30",
|
||||
"@vue/compiler-sfc": "3.5.30",
|
||||
"@vue/runtime-dom": "3.5.30",
|
||||
"@vue/server-renderer": "3.5.30",
|
||||
"@vue/shared": "3.5.30"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/watchpack": {
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
"photoswipe": "^4.1.3",
|
||||
"qrious": "^4.0.2",
|
||||
"scrollreveal": "^4.0.9",
|
||||
"vue": "^2.7.16"
|
||||
"vue": "^3.5.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.26.0",
|
||||
|
||||
@ -1,49 +1,56 @@
|
||||
import http from './request'
|
||||
import Vue from 'vue/dist/vue.esm'
|
||||
import { createApp } from 'vue'
|
||||
import waifuTips from '../config/waifu-tip.json'
|
||||
|
||||
function setScrollZero() {
|
||||
let $sct = document.querySelectorAll('.tools-section')
|
||||
Array.prototype.forEach.call($sct, (em) => {
|
||||
document.querySelectorAll('.tools-section').forEach(em => {
|
||||
em.scrollTop = 0
|
||||
})
|
||||
}
|
||||
|
||||
function urlformat(str) {
|
||||
return (window.themeConfig && window.themeConfig.root) ? window.themeConfig.root + str : '/' + str
|
||||
}
|
||||
|
||||
var waifuTipTimer = null, fullTextSearchTimer = null
|
||||
const vm = new Vue({
|
||||
el: '#container',
|
||||
data: {
|
||||
isCtnShow: false,
|
||||
isShow: undefined,
|
||||
items: [],
|
||||
innerArchive: false,
|
||||
friends: false,
|
||||
aboutme: false,
|
||||
showTags: false,
|
||||
showCategories: false,
|
||||
search: null,
|
||||
searchItems: [],
|
||||
fullTextSearch: {
|
||||
pageNum: 1,
|
||||
limit: 10,
|
||||
isLoading: false,
|
||||
tip: undefined,
|
||||
hasMore: false
|
||||
},
|
||||
fullTextSearchWords: null,
|
||||
fullTextSearchItems: [],
|
||||
waifu: {
|
||||
tip: null, // 提示语文字
|
||||
tipOpacity: 0, // 提示语框透明度
|
||||
showTools: false // 显示工具栏
|
||||
},
|
||||
themeConfig: window.themeConfig
|
||||
|
||||
const vm = createApp({
|
||||
data() {
|
||||
return {
|
||||
isCtnShow: false,
|
||||
isShow: undefined,
|
||||
items: [],
|
||||
innerArchive: false,
|
||||
friends: false,
|
||||
aboutme: false,
|
||||
showTags: false,
|
||||
showCategories: false,
|
||||
search: null,
|
||||
searchItems: [],
|
||||
fullTextSearch: {
|
||||
pageNum: 1,
|
||||
limit: 10,
|
||||
isLoading: false,
|
||||
tip: undefined,
|
||||
hasMore: false
|
||||
},
|
||||
fullTextSearchWords: null,
|
||||
fullTextSearchItems: [],
|
||||
waifu: {
|
||||
tip: null, // 提示语文字
|
||||
tipOpacity: 0, // 提示语框透明度
|
||||
showTools: false // 显示工具栏
|
||||
},
|
||||
themeConfig: window.themeConfig
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
stop (event) {
|
||||
urlformat,
|
||||
stop(event) {
|
||||
event.stopPropagation()
|
||||
},
|
||||
openSlider (event, type, isMobile) {
|
||||
if(isMobile && this.isShow) {
|
||||
openSlider(event, type, isMobile) {
|
||||
if (isMobile && this.isShow) {
|
||||
this.hideSlider()
|
||||
return
|
||||
}
|
||||
@ -56,53 +63,53 @@ const vm = new Vue({
|
||||
this.isCtnShow = true
|
||||
setScrollZero()
|
||||
},
|
||||
hideSlider () {
|
||||
hideSlider() {
|
||||
if (this.isShow) {
|
||||
this.isShow = false
|
||||
setTimeout(() => {this.isCtnShow = false}, 300)
|
||||
setTimeout(() => { this.isCtnShow = false }, 300)
|
||||
}
|
||||
},
|
||||
linkMouseover(name) {
|
||||
if(name === 'waifu' && waifuTipTimer) return
|
||||
if (name === 'waifu' && waifuTipTimer) return
|
||||
this.showMessage(waifuTips.mouseover[name], 3000)
|
||||
},
|
||||
toolsClick(name) {
|
||||
this.showMessage(waifuTips.click[name])
|
||||
if(name in waifuTools) {
|
||||
if (name in waifuTools) {
|
||||
waifuTools[name].call(this)
|
||||
}
|
||||
},
|
||||
addSearchItem(query, type='title') {
|
||||
if(query) {
|
||||
addSearchItem(query, type = 'title') {
|
||||
if (query) {
|
||||
query = query.trim()
|
||||
}
|
||||
// 如果已存在相同的查询条件, 则不加入
|
||||
var isExist = Array.prototype.some.call(this.searchItems, searchItem => {
|
||||
const isExist = this.searchItems.some(searchItem => {
|
||||
return searchItem.query === query && searchItem.type === type
|
||||
})
|
||||
if(!isExist && query) {
|
||||
this.searchItems.push({query, type})
|
||||
if (!isExist && query) {
|
||||
this.searchItems.push({ query, type })
|
||||
}
|
||||
this.search = null
|
||||
},
|
||||
openFullTextSearch() {
|
||||
this.hideSlider()
|
||||
this.$refs.fullTextSearch.classList.add('in')
|
||||
this.$refs.mask.classList.add('in')
|
||||
document.getElementById('search-panel').classList.add('in')
|
||||
document.querySelector('.js-mask').classList.add('in')
|
||||
},
|
||||
loadSearchResult() {
|
||||
this.fullTextSearch.pageNum ++
|
||||
this.fullTextSearch.pageNum++
|
||||
this.fullTextSearch.isLoading = true
|
||||
this.fullTextSearch.tip = undefined
|
||||
let params = {
|
||||
const params = {
|
||||
pageNum: this.fullTextSearch.pageNum,
|
||||
limit: this.fullTextSearch.limit,
|
||||
words: this.fullTextSearchWords
|
||||
}
|
||||
http.get('/api/v2/common/search', {params}).then(res => {
|
||||
http.get('/api/v2/common/search', { params }).then(res => {
|
||||
this.fullTextSearch.isLoading = false
|
||||
fullTextSearchTimer = null
|
||||
if(!Array.isArray(res.list) || !res.list.length) {
|
||||
if (!Array.isArray(res.list) || !res.list.length) {
|
||||
this.fullTextSearch.tip = '未搜索到匹配文章'
|
||||
} else {
|
||||
this.fullTextSearchItems.push(...res.list)
|
||||
@ -115,62 +122,53 @@ const vm = new Vue({
|
||||
})
|
||||
},
|
||||
searchKeydown(event) {
|
||||
if(event.keyCode == 13){ // 回车键
|
||||
if (event.keyCode == 13) { // 回车键
|
||||
this.addSearchItem(this.search)
|
||||
} else if(event.keyCode == 8 && !this.search) { // 退格键
|
||||
} else if (event.keyCode == 8 && !this.search) { // 退格键
|
||||
this.searchItems.pop()
|
||||
}
|
||||
},
|
||||
showMessage (text, time) {
|
||||
if(!text) return
|
||||
if(Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1)-1]
|
||||
showMessage(text, time) {
|
||||
if (!text) return
|
||||
if (Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1) - 1]
|
||||
this.waifu.tip = text
|
||||
this.waifu.tipOpacity = 1
|
||||
if(waifuTipTimer) {
|
||||
if (waifuTipTimer) {
|
||||
clearTimeout(waifuTipTimer)
|
||||
waifuTipTimer = null
|
||||
}
|
||||
waifuTipTimer = setTimeout(()=>{
|
||||
waifuTipTimer = setTimeout(() => {
|
||||
this.waifu.tipOpacity = 0
|
||||
waifuTipTimer = null
|
||||
}, time || 5000)
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
urlformat (str) {
|
||||
return (window.themeConfig && window.themeConfig.root) ? window.themeConfig.root + str : '/' + str
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
searchItems (newVal, oldVal) {
|
||||
if(newVal && newVal.length) {
|
||||
searchItems(newVal) {
|
||||
if (newVal && newVal.length) {
|
||||
handleSearch.call(this, newVal)
|
||||
} else {
|
||||
this.items.forEach(function(item){
|
||||
item.isHide = false
|
||||
})
|
||||
this.items.forEach(item => { item.isHide = false })
|
||||
}
|
||||
},
|
||||
fullTextSearchWords (newVal, oldVal) {
|
||||
fullTextSearchWords(newVal) {
|
||||
this.fullTextSearch.hasMore = false
|
||||
this.fullTextSearchItems.isLoading = false
|
||||
this.fullTextSearch.tip = undefined
|
||||
this.fullTextSearchItems.splice(0, this.fullTextSearchItems.length)
|
||||
if(fullTextSearchTimer) {
|
||||
if (fullTextSearchTimer) {
|
||||
clearTimeout(fullTextSearchTimer)
|
||||
fullTextSearchTimer = null
|
||||
}
|
||||
if(!newVal) {
|
||||
return
|
||||
}
|
||||
if (!newVal) return
|
||||
this.fullTextSearch.pageNum = 0
|
||||
fullTextSearchTimer = setTimeout(this.loadSearchResult.bind(this), 500)
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
fetch(window.themeConfig.root + 'content.json').then(res => res.json()).then(resJson=>{
|
||||
mounted() {
|
||||
fetch(window.themeConfig.root + 'content.json').then(res => res.json()).then(resJson => {
|
||||
this.items = resJson
|
||||
}).catch(err => {
|
||||
}).catch(() => {
|
||||
console.warn('加载文章列表失败')
|
||||
})
|
||||
welcomeMessage().then(msg => {
|
||||
@ -179,44 +177,40 @@ const vm = new Vue({
|
||||
document.addEventListener('copy', () => {
|
||||
this.showMessage('你都复制了些什么呀,转载要记得加上出处哦')
|
||||
})
|
||||
// 隐藏模态框
|
||||
let hideModal = (function() {
|
||||
let modals = document.querySelectorAll('.page-modal')
|
||||
Array.prototype.forEach.call(modals, modal => {
|
||||
const maskEl = document.querySelector('.js-mask')
|
||||
const hideModal = () => {
|
||||
document.querySelectorAll('.page-modal').forEach(modal => {
|
||||
modal.classList.remove('in')
|
||||
})
|
||||
this.$refs.mask.classList.remove('in')
|
||||
}).bind(this)
|
||||
this.$refs.mask.addEventListener('click', hideModal)
|
||||
Array.prototype.forEach.call(document.querySelectorAll('.js-modal-close'), modalClose => {
|
||||
maskEl.classList.remove('in')
|
||||
}
|
||||
// 隐藏模态框
|
||||
maskEl.addEventListener('click', hideModal)
|
||||
document.querySelectorAll('.js-modal-close').forEach(modalClose => {
|
||||
modalClose.addEventListener('click', hideModal)
|
||||
})
|
||||
},
|
||||
created() {
|
||||
// 夜间模式
|
||||
let night = localStorage.getItem('night')
|
||||
try {
|
||||
if(night && eval(night)) document.querySelector('body').classList.add('night')
|
||||
} catch (e){}
|
||||
const night = localStorage.getItem('night')
|
||||
if (night === 'true') {
|
||||
document.querySelector('body').classList.add('night')
|
||||
}
|
||||
}
|
||||
})
|
||||
}).mount('#container')
|
||||
|
||||
function handleSearch(searchItems) {
|
||||
this.items.forEach(articleItem => {
|
||||
articleItem.isHide = !Array.prototype.every.call(searchItems, searchItem => {
|
||||
switch(searchItem.type) {
|
||||
case 'title':
|
||||
articleItem.isHide = !searchItems.every(searchItem => {
|
||||
switch (searchItem.type) {
|
||||
case 'title':
|
||||
return articleItem.title.toLowerCase().indexOf(searchItem.query.toLowerCase()) !== -1
|
||||
case 'tag' :
|
||||
return Array.prototype.some.call(articleItem.tags, tag => {
|
||||
return tag.name === searchItem.query
|
||||
})
|
||||
case 'category' :
|
||||
return Array.prototype.some.call(articleItem.categories, category => {
|
||||
return category.name === searchItem.query
|
||||
})
|
||||
case 'date' :
|
||||
return articleItem.date && ( articleItem.date.substr(0,7) === searchItem.query )
|
||||
case 'tag':
|
||||
return articleItem.tags.some(tag => tag.name === searchItem.query)
|
||||
case 'category':
|
||||
return articleItem.categories.some(category => category.name === searchItem.query)
|
||||
case 'date':
|
||||
return articleItem.date && (articleItem.date.substr(0, 7) === searchItem.query)
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -226,22 +220,14 @@ async function welcomeMessage() {
|
||||
let now = new Date().getHours()
|
||||
return http.get('/api/v2/common/config/waifu_tip').then(textTimes => {
|
||||
let text = null
|
||||
Array.prototype.sort.call(textTimes, (item1, item2) => {
|
||||
if(item1.start>item2.start) {
|
||||
return 1
|
||||
} else if(item1.start<item2.start) {
|
||||
return -1
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
})
|
||||
Array.prototype.forEach.call(textTimes, textTime => {
|
||||
if(now > textTime.start && now <= textTime.end) {
|
||||
textTimes.sort((a, b) => a.start - b.start)
|
||||
textTimes.forEach(textTime => {
|
||||
if (now > textTime.start && now <= textTime.end) {
|
||||
text = textTime.text
|
||||
}
|
||||
})
|
||||
if(!text) {
|
||||
text = textTimes[textTimes.length-1].text
|
||||
if (!text) {
|
||||
text = textTimes[textTimes.length - 1].text
|
||||
}
|
||||
return text
|
||||
})
|
||||
@ -271,12 +257,12 @@ const waifuTools = {
|
||||
},
|
||||
'tools.chart'() {
|
||||
// 一言
|
||||
http.get('/api/v2/common/hitokoto', { params: {format: 'json'} }).then(res => {
|
||||
this.showMessage(res.hitokoto + (res.from?` ——${res.from}`:''))
|
||||
http.get('/api/v2/common/hitokoto', { params: { format: 'json' } }).then(res => {
|
||||
this.showMessage(res.hitokoto + (res.from ? ` ——${res.from}` : ''))
|
||||
})
|
||||
},
|
||||
'tools.search'() {
|
||||
// 打开全文检索Modal
|
||||
vm.openFullTextSearch()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user