Compare commits

..

No commits in common. "a2d1b2cc4974395f62d523fb2d7b337774f6dc8d" and "6c8ac211ae163614d2412f13db520de0ee5f559c" have entirely different histories.

4 changed files with 246 additions and 152 deletions

View File

@ -60,7 +60,7 @@
</div> </div>
<ul class="search-ul"> <ul class="search-ul">
<li class="search-li" v-for="(item,index) in items" :key="index" v-show="!item.isHide"> <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> <span v-text="item.title"></span>
</a> </a>
<p class="search-time" v-if="item.date"> <p class="search-time" v-if="item.date">

View File

@ -14,7 +14,7 @@
"photoswipe": "^4.1.3", "photoswipe": "^4.1.3",
"qrious": "^4.0.2", "qrious": "^4.0.2",
"scrollreveal": "^4.0.9", "scrollreveal": "^4.0.9",
"vue": "^2.7.16" "vue": "^3.5.14"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.26.0", "@babel/core": "^7.26.0",
@ -1646,7 +1646,6 @@
"version": "1.5.5", "version": "1.5.5",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/@jridgewell/trace-mapping": { "node_modules/@jridgewell/trace-mapping": {
@ -1731,19 +1730,118 @@
"undici-types": "~7.18.0" "undici-types": "~7.18.0"
} }
}, },
"node_modules/@vue/compiler-sfc": { "node_modules/@vue/compiler-core": {
"version": "2.7.16", "version": "3.5.30",
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.16.tgz", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.30.tgz",
"integrity": "sha512-KWhJ9k5nXuNtygPU7+t1rX6baZeqOYLEforUPjgNDBnLicfHCoi48H87Q8XyLZOrNNsmhuwKqtpDQWjEFe6Ekg==", "integrity": "sha512-s3DfdZkcu/qExZ+td75015ljzHc6vE+30cFMGRPROYjqkroYI5NV2X1yAMX9UeyBNWB9MxCfPcsjpLS11nzkkw==",
"license": "MIT",
"dependencies": { "dependencies": {
"@babel/parser": "^7.23.5", "@babel/parser": "^7.29.0",
"postcss": "^8.4.14", "@vue/shared": "3.5.30",
"source-map": "^0.6.1" "entities": "^7.0.1",
}, "estree-walker": "^2.0.2",
"optionalDependencies": { "source-map-js": "^1.2.1"
"prettier": "^1.18.2 || ^2.0.0"
} }
}, },
"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": { "node_modules/@webassemblyjs/ast": {
"version": "1.14.1", "version": "1.14.1",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz",
@ -2830,6 +2928,12 @@
"node": ">=4.0" "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": { "node_modules/esutils": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
@ -3662,6 +3766,15 @@
"yallist": "^3.0.2" "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": { "node_modules/make-dir": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
@ -4254,22 +4367,6 @@
"dev": true, "dev": true,
"license": "MIT" "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": { "node_modules/pretty-error": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz", "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz",
@ -4575,6 +4672,7 @@
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
@ -4830,14 +4928,24 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/vue": { "node_modules/vue": {
"version": "2.7.16", "version": "3.5.30",
"resolved": "https://registry.npmjs.org/vue/-/vue-2.7.16.tgz", "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.30.tgz",
"integrity": "sha512-4gCtFXaAA3zYZdTp5s4Hl2sozuySsgz4jy1EnpBHNfpMa9dK1ZCG7viqBPCwXtmgc8nHqUsAu3G4gtmXkkY3Sw==", "integrity": "sha512-hTHLc6VNZyzzEH/l7PFGjpcTvUgiaPK5mdLkbjrTeWSRcEfxFrv56g/XckIYlE9ckuobsdwqd5mk2g1sBkMewg==",
"deprecated": "Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details.",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@vue/compiler-sfc": "2.7.16", "@vue/compiler-dom": "3.5.30",
"csstype": "^3.1.0" "@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": { "node_modules/watchpack": {

View File

@ -23,7 +23,7 @@
"photoswipe": "^4.1.3", "photoswipe": "^4.1.3",
"qrious": "^4.0.2", "qrious": "^4.0.2",
"scrollreveal": "^4.0.9", "scrollreveal": "^4.0.9",
"vue": "^2.7.16" "vue": "^3.5.14"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.26.0", "@babel/core": "^7.26.0",

View File

@ -1,49 +1,56 @@
import http from './request' import http from './request'
import Vue from 'vue/dist/vue.esm' import { createApp } from 'vue'
import waifuTips from '../config/waifu-tip.json' import waifuTips from '../config/waifu-tip.json'
function setScrollZero() { function setScrollZero() {
let $sct = document.querySelectorAll('.tools-section') document.querySelectorAll('.tools-section').forEach(em => {
Array.prototype.forEach.call($sct, (em) => {
em.scrollTop = 0 em.scrollTop = 0
}) })
} }
function urlformat(str) {
return (window.themeConfig && window.themeConfig.root) ? window.themeConfig.root + str : '/' + str
}
var waifuTipTimer = null, fullTextSearchTimer = null var waifuTipTimer = null, fullTextSearchTimer = null
const vm = new Vue({
el: '#container', const vm = createApp({
data: { data() {
isCtnShow: false, return {
isShow: undefined, isCtnShow: false,
items: [], isShow: undefined,
innerArchive: false, items: [],
friends: false, innerArchive: false,
aboutme: false, friends: false,
showTags: false, aboutme: false,
showCategories: false, showTags: false,
search: null, showCategories: false,
searchItems: [], search: null,
fullTextSearch: { searchItems: [],
pageNum: 1, fullTextSearch: {
limit: 10, pageNum: 1,
isLoading: false, limit: 10,
tip: undefined, isLoading: false,
hasMore: false tip: undefined,
}, hasMore: false
fullTextSearchWords: null, },
fullTextSearchItems: [], fullTextSearchWords: null,
waifu: { fullTextSearchItems: [],
tip: null, // 提示语文字 waifu: {
tipOpacity: 0, // 提示语框透明度 tip: null, // 提示语文字
showTools: false // 显示工具栏 tipOpacity: 0, // 提示语框透明度
}, showTools: false // 显示工具栏
themeConfig: window.themeConfig },
themeConfig: window.themeConfig
}
}, },
methods: { methods: {
stop (event) { urlformat,
stop(event) {
event.stopPropagation() event.stopPropagation()
}, },
openSlider (event, type, isMobile) { openSlider(event, type, isMobile) {
if(isMobile && this.isShow) { if (isMobile && this.isShow) {
this.hideSlider() this.hideSlider()
return return
} }
@ -56,53 +63,53 @@ const vm = new Vue({
this.isCtnShow = true this.isCtnShow = true
setScrollZero() setScrollZero()
}, },
hideSlider () { hideSlider() {
if (this.isShow) { if (this.isShow) {
this.isShow = false this.isShow = false
setTimeout(() => {this.isCtnShow = false}, 300) setTimeout(() => { this.isCtnShow = false }, 300)
} }
}, },
linkMouseover(name) { linkMouseover(name) {
if(name === 'waifu' && waifuTipTimer) return if (name === 'waifu' && waifuTipTimer) return
this.showMessage(waifuTips.mouseover[name], 3000) this.showMessage(waifuTips.mouseover[name], 3000)
}, },
toolsClick(name) { toolsClick(name) {
this.showMessage(waifuTips.click[name]) this.showMessage(waifuTips.click[name])
if(name in waifuTools) { if (name in waifuTools) {
waifuTools[name].call(this) waifuTools[name].call(this)
} }
}, },
addSearchItem(query, type='title') { addSearchItem(query, type = 'title') {
if(query) { if (query) {
query = query.trim() 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 return searchItem.query === query && searchItem.type === type
}) })
if(!isExist && query) { if (!isExist && query) {
this.searchItems.push({query, type}) this.searchItems.push({ query, type })
} }
this.search = null this.search = null
}, },
openFullTextSearch() { openFullTextSearch() {
this.hideSlider() this.hideSlider()
this.$refs.fullTextSearch.classList.add('in') document.getElementById('search-panel').classList.add('in')
this.$refs.mask.classList.add('in') document.querySelector('.js-mask').classList.add('in')
}, },
loadSearchResult() { loadSearchResult() {
this.fullTextSearch.pageNum ++ this.fullTextSearch.pageNum++
this.fullTextSearch.isLoading = true this.fullTextSearch.isLoading = true
this.fullTextSearch.tip = undefined this.fullTextSearch.tip = undefined
let params = { const params = {
pageNum: this.fullTextSearch.pageNum, pageNum: this.fullTextSearch.pageNum,
limit: this.fullTextSearch.limit, limit: this.fullTextSearch.limit,
words: this.fullTextSearchWords 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 this.fullTextSearch.isLoading = false
fullTextSearchTimer = null fullTextSearchTimer = null
if(!Array.isArray(res.list) || !res.list.length) { if (!Array.isArray(res.list) || !res.list.length) {
this.fullTextSearch.tip = '未搜索到匹配文章' this.fullTextSearch.tip = '未搜索到匹配文章'
} else { } else {
this.fullTextSearchItems.push(...res.list) this.fullTextSearchItems.push(...res.list)
@ -115,62 +122,53 @@ const vm = new Vue({
}) })
}, },
searchKeydown(event) { searchKeydown(event) {
if(event.keyCode == 13){ // 回车键 if (event.keyCode == 13) { // 回车键
this.addSearchItem(this.search) this.addSearchItem(this.search)
} else if(event.keyCode == 8 && !this.search) { // 退格键 } else if (event.keyCode == 8 && !this.search) { // 退格键
this.searchItems.pop() this.searchItems.pop()
} }
}, },
showMessage (text, time) { showMessage(text, time) {
if(!text) return if (!text) return
if(Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1)-1] if (Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1) - 1]
this.waifu.tip = text this.waifu.tip = text
this.waifu.tipOpacity = 1 this.waifu.tipOpacity = 1
if(waifuTipTimer) { if (waifuTipTimer) {
clearTimeout(waifuTipTimer) clearTimeout(waifuTipTimer)
waifuTipTimer = null waifuTipTimer = null
} }
waifuTipTimer = setTimeout(()=>{ waifuTipTimer = setTimeout(() => {
this.waifu.tipOpacity = 0 this.waifu.tipOpacity = 0
waifuTipTimer = null waifuTipTimer = null
}, time || 5000) }, time || 5000)
}
},
filters: {
urlformat (str) {
return (window.themeConfig && window.themeConfig.root) ? window.themeConfig.root + str : '/' + str
} }
}, },
watch: { watch: {
searchItems (newVal, oldVal) { searchItems(newVal) {
if(newVal && newVal.length) { if (newVal && newVal.length) {
handleSearch.call(this, newVal) handleSearch.call(this, newVal)
} else { } else {
this.items.forEach(function(item){ this.items.forEach(item => { item.isHide = false })
item.isHide = false
})
} }
}, },
fullTextSearchWords (newVal, oldVal) { fullTextSearchWords(newVal) {
this.fullTextSearch.hasMore = false this.fullTextSearch.hasMore = false
this.fullTextSearchItems.isLoading = false this.fullTextSearchItems.isLoading = false
this.fullTextSearch.tip = undefined this.fullTextSearch.tip = undefined
this.fullTextSearchItems.splice(0, this.fullTextSearchItems.length) this.fullTextSearchItems.splice(0, this.fullTextSearchItems.length)
if(fullTextSearchTimer) { if (fullTextSearchTimer) {
clearTimeout(fullTextSearchTimer) clearTimeout(fullTextSearchTimer)
fullTextSearchTimer = null fullTextSearchTimer = null
} }
if(!newVal) { if (!newVal) return
return
}
this.fullTextSearch.pageNum = 0 this.fullTextSearch.pageNum = 0
fullTextSearchTimer = setTimeout(this.loadSearchResult.bind(this), 500) fullTextSearchTimer = setTimeout(this.loadSearchResult.bind(this), 500)
} }
}, },
mounted () { mounted() {
fetch(window.themeConfig.root + 'content.json').then(res => res.json()).then(resJson=>{ fetch(window.themeConfig.root + 'content.json').then(res => res.json()).then(resJson => {
this.items = resJson this.items = resJson
}).catch(err => { }).catch(() => {
console.warn('加载文章列表失败') console.warn('加载文章列表失败')
}) })
welcomeMessage().then(msg => { welcomeMessage().then(msg => {
@ -179,44 +177,40 @@ const vm = new Vue({
document.addEventListener('copy', () => { document.addEventListener('copy', () => {
this.showMessage('你都复制了些什么呀,转载要记得加上出处哦') this.showMessage('你都复制了些什么呀,转载要记得加上出处哦')
}) })
// 隐藏模态框 const maskEl = document.querySelector('.js-mask')
let hideModal = (function() { const hideModal = () => {
let modals = document.querySelectorAll('.page-modal') document.querySelectorAll('.page-modal').forEach(modal => {
Array.prototype.forEach.call(modals, modal => {
modal.classList.remove('in') modal.classList.remove('in')
}) })
this.$refs.mask.classList.remove('in') maskEl.classList.remove('in')
}).bind(this) }
this.$refs.mask.addEventListener('click', hideModal) // 隐藏模态框
Array.prototype.forEach.call(document.querySelectorAll('.js-modal-close'), modalClose => { maskEl.addEventListener('click', hideModal)
document.querySelectorAll('.js-modal-close').forEach(modalClose => {
modalClose.addEventListener('click', hideModal) modalClose.addEventListener('click', hideModal)
}) })
}, },
created() { created() {
// 夜间模式 // 夜间模式
let night = localStorage.getItem('night') const night = localStorage.getItem('night')
try { if (night === 'true') {
if(night && eval(night)) document.querySelector('body').classList.add('night') document.querySelector('body').classList.add('night')
} catch (e){} }
} }
}) }).mount('#container')
function handleSearch(searchItems) { function handleSearch(searchItems) {
this.items.forEach(articleItem => { this.items.forEach(articleItem => {
articleItem.isHide = !Array.prototype.every.call(searchItems, searchItem => { articleItem.isHide = !searchItems.every(searchItem => {
switch(searchItem.type) { switch (searchItem.type) {
case 'title': case 'title':
return articleItem.title.toLowerCase().indexOf(searchItem.query.toLowerCase()) !== -1 return articleItem.title.toLowerCase().indexOf(searchItem.query.toLowerCase()) !== -1
case 'tag' : case 'tag':
return Array.prototype.some.call(articleItem.tags, tag => { return articleItem.tags.some(tag => tag.name === searchItem.query)
return tag.name === searchItem.query case 'category':
}) return articleItem.categories.some(category => category.name === searchItem.query)
case 'category' : case 'date':
return Array.prototype.some.call(articleItem.categories, category => { return articleItem.date && (articleItem.date.substr(0, 7) === searchItem.query)
return 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() let now = new Date().getHours()
return http.get('/api/v2/common/config/waifu_tip').then(textTimes => { return http.get('/api/v2/common/config/waifu_tip').then(textTimes => {
let text = null let text = null
Array.prototype.sort.call(textTimes, (item1, item2) => { textTimes.sort((a, b) => a.start - b.start)
if(item1.start>item2.start) { textTimes.forEach(textTime => {
return 1 if (now > textTime.start && now <= textTime.end) {
} else if(item1.start<item2.start) {
return -1
} else {
return 0
}
})
Array.prototype.forEach.call(textTimes, textTime => {
if(now > textTime.start && now <= textTime.end) {
text = textTime.text text = textTime.text
} }
}) })
if(!text) { if (!text) {
text = textTimes[textTimes.length-1].text text = textTimes[textTimes.length - 1].text
} }
return text return text
}) })
@ -271,12 +257,12 @@ const waifuTools = {
}, },
'tools.chart'() { 'tools.chart'() {
// 一言 // 一言
http.get('/api/v2/common/hitokoto', { params: {format: 'json'} }).then(res => { http.get('/api/v2/common/hitokoto', { params: { format: 'json' } }).then(res => {
this.showMessage(res.hitokoto + (res.from?`  ——${res.from}`:'')) this.showMessage(res.hitokoto + (res.from ? `  ——${res.from}` : ''))
}) })
}, },
'tools.search'() { 'tools.search'() {
// 打开全文检索Modal // 打开全文检索Modal
vm.openFullTextSearch() vm.openFullTextSearch()
} }
} }