Compare commits

..

2 Commits

Author SHA1 Message Date
a2d1b2cc49
Revert "升级 Vue 2 到 Vue 3"
This reverts commit fb1cbbada498ec1493ee2502074785b6f8f58207.
2026-03-24 23:06:58 +08:00
173e870a73
Revert "修改ref使用"
This reverts commit 6c8ac211ae163614d2412f13db520de0ee5f559c.
2026-03-24 23:06:54 +08:00
4 changed files with 150 additions and 244 deletions

View File

@ -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="urlformat(item.path)" class="search-title"><i class="icon icon-quote-left"></i>
<a :href="item.path|urlformat" 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">

View File

@ -14,7 +14,7 @@
"photoswipe": "^4.1.3",
"qrious": "^4.0.2",
"scrollreveal": "^4.0.9",
"vue": "^3.5.14"
"vue": "^2.7.16"
},
"devDependencies": {
"@babel/core": "^7.26.0",
@ -1646,6 +1646,7 @@
"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": {
@ -1730,118 +1731,19 @@
"undici-types": "~7.18.0"
}
},
"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.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",
"version": "2.7.16",
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.16.tgz",
"integrity": "sha512-KWhJ9k5nXuNtygPU7+t1rX6baZeqOYLEforUPjgNDBnLicfHCoi48H87Q8XyLZOrNNsmhuwKqtpDQWjEFe6Ekg==",
"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"
"@babel/parser": "^7.23.5",
"postcss": "^8.4.14",
"source-map": "^0.6.1"
},
"peerDependencies": {
"vue": "3.5.30"
"optionalDependencies": {
"prettier": "^1.18.2 || ^2.0.0"
}
},
"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",
@ -2928,12 +2830,6 @@
"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",
@ -3766,15 +3662,6 @@
"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",
@ -4367,6 +4254,22 @@
"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",
@ -4672,7 +4575,6 @@
"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"
@ -4928,24 +4830,14 @@
"license": "MIT"
},
"node_modules/vue": {
"version": "3.5.30",
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.30.tgz",
"integrity": "sha512-hTHLc6VNZyzzEH/l7PFGjpcTvUgiaPK5mdLkbjrTeWSRcEfxFrv56g/XckIYlE9ckuobsdwqd5mk2g1sBkMewg==",
"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.",
"license": "MIT",
"dependencies": {
"@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
}
"@vue/compiler-sfc": "2.7.16",
"csstype": "^3.1.0"
}
},
"node_modules/watchpack": {

View File

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

View File

@ -1,56 +1,49 @@
import http from './request'
import { createApp } from 'vue'
import Vue from 'vue/dist/vue.esm'
import waifuTips from '../config/waifu-tip.json'
function setScrollZero() {
document.querySelectorAll('.tools-section').forEach(em => {
let $sct = document.querySelectorAll('.tools-section')
Array.prototype.forEach.call($sct, (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 = 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
}
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
},
methods: {
urlformat,
stop(event) {
stop (event) {
event.stopPropagation()
},
openSlider(event, type, isMobile) {
if (isMobile && this.isShow) {
openSlider (event, type, isMobile) {
if(isMobile && this.isShow) {
this.hideSlider()
return
}
@ -63,53 +56,53 @@ const vm = createApp({
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()
}
// 如果已存在相同的查询条件, 则不加入
const isExist = this.searchItems.some(searchItem => {
var isExist = Array.prototype.some.call(this.searchItems, 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()
document.getElementById('search-panel').classList.add('in')
document.querySelector('.js-mask').classList.add('in')
this.$refs.fullTextSearch.classList.add('in')
this.$refs.mask.classList.add('in')
},
loadSearchResult() {
this.fullTextSearch.pageNum++
this.fullTextSearch.pageNum ++
this.fullTextSearch.isLoading = true
this.fullTextSearch.tip = undefined
const params = {
let 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)
@ -122,53 +115,62 @@ const vm = createApp({
})
},
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) {
if (newVal && newVal.length) {
searchItems (newVal, oldVal) {
if(newVal && newVal.length) {
handleSearch.call(this, newVal)
} else {
this.items.forEach(item => { item.isHide = false })
this.items.forEach(function(item){
item.isHide = false
})
}
},
fullTextSearchWords(newVal) {
fullTextSearchWords (newVal, oldVal) {
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(() => {
}).catch(err => {
console.warn('加载文章列表失败')
})
welcomeMessage().then(msg => {
@ -177,40 +179,44 @@ const vm = createApp({
document.addEventListener('copy', () => {
this.showMessage('你都复制了些什么呀,转载要记得加上出处哦')
})
const maskEl = document.querySelector('.js-mask')
const hideModal = () => {
document.querySelectorAll('.page-modal').forEach(modal => {
// 隐藏模态框
let hideModal = (function() {
let modals = document.querySelectorAll('.page-modal')
Array.prototype.forEach.call(modals, modal => {
modal.classList.remove('in')
})
maskEl.classList.remove('in')
}
// 隐藏模态框
maskEl.addEventListener('click', hideModal)
document.querySelectorAll('.js-modal-close').forEach(modalClose => {
this.$refs.mask.classList.remove('in')
}).bind(this)
this.$refs.mask.addEventListener('click', hideModal)
Array.prototype.forEach.call(document.querySelectorAll('.js-modal-close'), modalClose => {
modalClose.addEventListener('click', hideModal)
})
},
created() {
// 夜间模式
const night = localStorage.getItem('night')
if (night === 'true') {
document.querySelector('body').classList.add('night')
}
let night = localStorage.getItem('night')
try {
if(night && eval(night)) document.querySelector('body').classList.add('night')
} catch (e){}
}
}).mount('#container')
})
function handleSearch(searchItems) {
this.items.forEach(articleItem => {
articleItem.isHide = !searchItems.every(searchItem => {
switch (searchItem.type) {
articleItem.isHide = !Array.prototype.every.call(searchItems, searchItem => {
switch(searchItem.type) {
case 'title':
return articleItem.title.toLowerCase().indexOf(searchItem.query.toLowerCase()) !== -1
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)
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 )
}
})
})
@ -220,14 +226,22 @@ async function welcomeMessage() {
let now = new Date().getHours()
return http.get('/api/v2/common/config/waifu_tip').then(textTimes => {
let text = null
textTimes.sort((a, b) => a.start - b.start)
textTimes.forEach(textTime => {
if (now > textTime.start && now <= textTime.end) {
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) {
text = textTime.text
}
})
if (!text) {
text = textTimes[textTimes.length - 1].text
if(!text) {
text = textTimes[textTimes.length-1].text
}
return text
})
@ -257,8 +271,8 @@ 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'() {