From 7391d4d3520d98471ceaebb3a2324a8dcdb1d316 Mon Sep 17 00:00:00 2001 From: yma16 <17685043634@163.com> Date: Fri, 19 Aug 2022 00:49:26 +0800 Subject: [PATCH] =?UTF-8?q?perf:=E6=BB=9A=E5=8A=A8=E6=9D=A1=E7=BC=93?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 22 +++++++++++++++++++++- src/components/Article.vue | 31 ++++++++++++++++++++++++++----- src/main.js | 4 ++-- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/App.vue b/src/App.vue index fa7c893..8031780 100644 --- a/src/App.vue +++ b/src/App.vue @@ -459,7 +459,27 @@ body > .el-container { transform: rotate(45deg) scale(0.25); } } - +::-webkit-scrollbar { + width: 10px; + /* height:5px; */ + /* display: none; */ +} +::-webkit-scrollbar-track { + background: rgba(226, 247, 255, 0.5); + border-radius: 2px; + /* display: none; */ +} +::-webkit-scrollbar-track-piece { + background: rgba(255, 255, 255, 0.1); + border-radius: 2px; + /* display: none; */ +} +::-webkit-scrollbar-thumb { + background: #ff995e; + height: 2px; + border-radius: 2px; + /* display: none; */ +} @keyframes backdiv { 50% { background: #ffe6f2; diff --git a/src/components/Article.vue b/src/components/Article.vue index 5d52ca6..28676d9 100644 --- a/src/components/Article.vue +++ b/src/components/Article.vue @@ -22,7 +22,7 @@ -
+
-
+
@@ -431,8 +431,27 @@ export default { }, toTop: function () { - location.href = '#home' // 定位 - document.getElementById('mainappid').scrollTop = 0 + const dom = this.$refs['mark-down-ref'] + if (!dom) { + return 0 + } + const speedValue = Math.floor(dom.scrollTop / 20) + const second = 20 + const diffTop = function (speed, time) { + let top = Math.ceil(dom.scrollTop) + if (top > 0) { + dom.scrollTop = top - speed > 0 ? top - speed : 0 + } + if (dom.scrollTop > 0) { + setTimeout(() => { + return diffTop(speed, time) + }, 10) + } + } + diffTop(speedValue, second) + if (document.getElementById('mainappid') && document.getElementById('mainappid').scrollTop > 0) { + document.getElementById('mainappid').scrollTop = 0 + } }, // 返回天气相当于返回顶部 getCommentsFromArticle (id) { this.$refs.commentRef.getComments(id) // 触发子组件的方法 @@ -591,7 +610,9 @@ el-col::-webkit-scrollbar { /* scrollbar-track-color: darkslategrey; */ } - +.pagenation-block{ + overflow: auto; +} .midclass::-webkit-scrollbar { width: 10px; /* height:5px; */ diff --git a/src/main.js b/src/main.js index 971194c..45b9641 100644 --- a/src/main.js +++ b/src/main.js @@ -5,6 +5,7 @@ import Vue from 'vue' import VueRouter from 'vue-router' import axios from 'axios' import hljs from 'highlight.js' +import * as echarts from 'echarts' import importElementComponents from './importElement' import importEchartsComponents from './importEchartsComponents' // 样式cnd @@ -15,8 +16,6 @@ import useRouter from './router' import cookies from 'vue-cookies' import App from './App' import 'highlight.js/styles/github.css' -import * as echarts from 'echarts/core' - const env = process.env.NODE_ENV // 生产环境 @@ -41,6 +40,7 @@ if (env === 'production') { Vue.prototype.$axios = axios window.$axios_w = axios Vue.prototype.$echarts = echarts + window.$echarts_w = echarts Vue.prototype.$cookies.set('user_session', 'null') -- GitLab