From 74b5b07498941611a59597d3aae2c456440777c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=93=E5=8F=91=E5=8F=97=E9=95=BF=E7=94=9F?= Date: Sat, 7 Sep 2019 20:39:35 +0800 Subject: [PATCH] =?UTF-8?q?api=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/yilia/source-src/css/archive.scss | 2 +- themes/yilia/source-src/css/night.scss | 2 +- themes/yilia/source-src/js/comment.js | 2 +- themes/yilia/source-src/js/main.js | 10 ++--- themes/yilia/source-src/js/slider.js | 56 +++++++++++++----------- 5 files changed, 37 insertions(+), 35 deletions(-) diff --git a/themes/yilia/source-src/css/archive.scss b/themes/yilia/source-src/css/archive.scss index 24618e4..559cf19 100644 --- a/themes/yilia/source-src/css/archive.scss +++ b/themes/yilia/source-src/css/archive.scss @@ -3,7 +3,7 @@ margin: 0 30px; padding-right: 60px; border-bottom: 1px solid #eee; - background: $colorBg; + background: adjust-color($colorBg, $alpha: -0.2); @extend %trans; &:first-child{ margin-top: 30px; diff --git a/themes/yilia/source-src/css/night.scss b/themes/yilia/source-src/css/night.scss index 43f6458..a5915a0 100644 --- a/themes/yilia/source-src/css/night.scss +++ b/themes/yilia/source-src/css/night.scss @@ -76,7 +76,7 @@ body.night { } // 归档列表 .archives-wrap { - background: $articleBg_night; + background: adjust-color($articleBg_night, $alpha: -0.2); border-bottom-color: $borderColor_night; .archive-article { border-color: $borderColor_night; diff --git a/themes/yilia/source-src/js/comment.js b/themes/yilia/source-src/js/comment.js index 96d6b59..4154256 100644 --- a/themes/yilia/source-src/js/comment.js +++ b/themes/yilia/source-src/js/comment.js @@ -10,7 +10,7 @@ window.AV = require('leancloud-storage') import(/* webpackChunkName: "valine" */ '../lib/Valine.min').then(({default: Valine }) => { // 从接口获取评论配置 - axios.get(`${window.themeConfig.root}api/common/valineConfig`).then(res => { + axios.get(`${window.themeConfig.root}api/common/config/valine_config`).then(res => { let config = res.data config.path = window.location.pathname // config.av = AV diff --git a/themes/yilia/source-src/js/main.js b/themes/yilia/source-src/js/main.js index e356637..bca99bd 100644 --- a/themes/yilia/source-src/js/main.js +++ b/themes/yilia/source-src/js/main.js @@ -48,12 +48,10 @@ if(window.themeConfig.isPost && window.themeConfig.comment) { import(/* webpackChunkName: "comment" */ './comment') } -var hideWaifu = localStorage.getItem('hideWaifu') -if(!hideWaifu || !eval(hideWaifu)) { - import(/* webpackChunkName: "waifu" */ './waifu').then(waifuInit => { - waifuInit.default.init() - }) -} +// 初始化看板娘 +import(/* webpackChunkName: "waifu" */ './waifu').then(waifuInit => { + waifuInit.default.init() +}) // 控制台 console.log( diff --git a/themes/yilia/source-src/js/slider.js b/themes/yilia/source-src/js/slider.js index 0a24ca1..7e3f2f7 100644 --- a/themes/yilia/source-src/js/slider.js +++ b/themes/yilia/source-src/js/slider.js @@ -174,7 +174,9 @@ const vm = new Vue({ }).catch(err => { console.warn('加载文章列表失败') }) - this.showMessage(welcomeMessage(), 6000) + welcomeMessage().then(msg => { + this.showMessage(msg, 6000) + }) document.addEventListener('copy', () => { this.showMessage('你都复制了些什么呀,转载要记得加上出处哦') }) @@ -221,29 +223,31 @@ function handleSearch(searchItems) { }) } -function welcomeMessage() { +async function welcomeMessage() { let now = new Date().getHours() - let text - if (now > 23 || now <= 5) { - text = '你是夜猫子呀?这么晚还不睡觉,明天起的来嘛' - } else if (now > 5 && now <= 7) { - text = '早上好!一日之计在于晨,美好的一天就要开始了' - } else if (now > 7 && now <= 11) { - text = '上午好!工作顺利嘛,不要久坐,多起来走动走动哦!' - } else if (now > 11 && now <= 14) { - text = '中午了,工作了一个上午,现在是午餐时间!' - } else if (now > 14 && now <= 17) { - text = '午后很容易犯困呢,今天的运动目标完成了吗?' - } else if (now > 17 && now <= 19) { - text = '傍晚了!窗外夕阳的景色很美丽呢,最美不过夕阳红~' - } else if (now > 19 && now <= 21) { - text = '晚上好,今天过得怎么样?' - } else if (now > 21 && now <= 23) { - text = '已经这么晚了呀,早点休息吧,晚安~' - } else { - text = '嗨~ 快来逗我玩吧!' - } - return text + return axios.get(`${window.themeConfig.root}api/common/config/waifu_tip`).then(res => { + let textTimes = res.data + let text = null + Array.prototype.sort.call(textTimes, (item1, item2) => { + if(item1.start>item2.start) { + return 1 + } else if(item1.start { + if(now > textTime.start && now <= textTime.end) { + text = textTime.text + } + }) + if(!text) { + text = textTimes[textTimes.length-1].text + } + this.showMessage(res.data.hitokoto + (res.data.from?`  ——${res.data.from}`:'')) + return text + }) } const waifuTools = { @@ -253,10 +257,10 @@ const waifuTools = { window.Live2D.captureFrame = true }, 'tools.close'() { - // 隐藏看板娘 + // 移除看板娘 setTimeout(function() { - document.querySelector('.waifu').style.display = 'none' - localStorage.setItem('hideWaifu', true) + let waifuDiv = document.querySelector('.waifu') + waifuDiv.parentNode.removeChild(waifuDiv) }, 1300) }, 'tools.eye'() {