提交 14e35fcd 编写于 作者: yma16's avatar yma16

perf:滚动条出现的逻辑修复和天气标题由后端控制

上级 351da7ac
...@@ -108,9 +108,8 @@ ...@@ -108,9 +108,8 @@
<div class="footer_font"> <div class="footer_font">
<div style="float: left"></div> <div style="float: left"></div>
<span> <span>
Copyright &copy;2021-2022 yongma16.xyz Copyright &copy;{{startTime}} yongma16.xyz
个人空间&nbsp;&nbsp;&nbsp;</span 个人空间&nbsp;&nbsp;&nbsp;</span>
>
<span> 足迹:{{ readCount }}&nbsp;&nbsp;&nbsp;</span> <span> 足迹:{{ readCount }}&nbsp;&nbsp;&nbsp;</span>
<span <span
><img ><img
...@@ -122,9 +121,7 @@ ...@@ -122,9 +121,7 @@
padding-bottom: 0; padding-bottom: 0;
" "
/>&nbsp;&nbsp;<span style="cursor: pointer" @click="jumpIpDns" />&nbsp;&nbsp;<span style="cursor: pointer" @click="jumpIpDns"
>黔ICP备20001426号-1</span >黔ICP备20001426号-1</span></span>
></span
>
</div> </div>
<!-- <div></div>--> <!-- <div></div>-->
</div> </div>
...@@ -140,6 +137,8 @@ export default { ...@@ -140,6 +137,8 @@ export default {
name: 'App', name: 'App',
data () { data () {
return { return {
// 开始时间
startTime: '',
authSlogan: 'yma16', authSlogan: 'yma16',
chat_flag: false, chat_flag: false,
msg: 'yma16', msg: 'yma16',
...@@ -164,10 +163,16 @@ export default { ...@@ -164,10 +163,16 @@ export default {
} }
}, },
mounted () { mounted () {
this.initStartTime()
this.addReadCountFun() this.addReadCountFun()
this.readCountFun() this.readCountFun()
}, },
methods: { methods: {
initStartTime () {
const now = new Date()
const year = now.getFullYear()
this.startTime = `2021-${year}`
},
jumpIpDns: function () { jumpIpDns: function () {
try { try {
window.open('https://beian.miit.gov.cn') window.open('https://beian.miit.gov.cn')
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<ul v-for="(item, index) in md_title" :key="item" class="ul_style"> <ul v-for="(item, index) in md_title" :key="item" class="ul_style">
<div <div
v-bind:class="[ v-bind:class="[
{ li_active: index == article_loc }, { li_active: index === article_loc },
li_errorClass, li_errorClass,
]" ]"
> >
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
:current-page="currentPage" :current-page="currentPage"
:page-sizes="pageArray" :page-sizes="pageArray"
background background
:pager-count="3" :page-count="pageCount"
:page-size="pageSize" :page-size="pageSize"
@size-change="handleSizeChange" @size-change="handleSizeChange"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
</div> </div>
<!-- 中间 markdown--> <!-- 中间 markdown-->
<div class="midclass" ref="mark-down-ref"> <div class="midclass" ref="mark-down-ref">
<a name="home" id="hometitle" style="transition: 1s"></a> <a name="home" id="homeTitleId" style="transition: 1s"></a>
<el-card shadow="hover" style="line-height: 10px"> <el-card shadow="hover" style="line-height: 10px">
<div class="block" style="line-height: 20px"> <div class="block" style="line-height: 20px">
<h1>{{ the_title }}</h1> <h1>{{ the_title }}</h1>
...@@ -229,6 +229,7 @@ export default { ...@@ -229,6 +229,7 @@ export default {
name: 'Article', name: 'Article',
data () { data () {
return { return {
pageCount: 3,
msgDrawTitle: '~邮件沟通~', msgDrawTitle: '~邮件沟通~',
direction: 'rtl', direction: 'rtl',
drawObj: { drawObj: {
...@@ -261,7 +262,7 @@ export default { ...@@ -261,7 +262,7 @@ export default {
toTopIsShow: false, toTopIsShow: false,
article_loc: 0, article_loc: 0,
challenge_loc: -1, challenge_loc: -1,
topshow: false, topShow: false,
userImg: '', userImg: '',
username: '匿名', username: '匿名',
articleCommit: '评论区', articleCommit: '评论区',
...@@ -280,7 +281,7 @@ export default { ...@@ -280,7 +281,7 @@ export default {
} }
}, },
watch: { watch: {
topshow: function (newvalue, oldvalue) { topShow: function (newvalue, oldvalue) {
if (newvalue === true) { if (newvalue === true) {
document.getElementById('topiconid').style.display = 'none' document.getElementById('topiconid').style.display = 'none'
} else { } else {
...@@ -289,13 +290,30 @@ export default { ...@@ -289,13 +290,30 @@ export default {
} }
}, },
beforeDestroy () { beforeDestroy () {
window.removeEventListener('onload', this.topvisible()) window.removeEventListener('onload', this.topVisible())
this.articleScrollListen('remove')
}, },
mounted () { mounted () {
this.articleScrollListen('add')
this.initPageSpliteFun() this.initPageSpliteFun()
window.addEventListener('onload', this.topvisible()) window.addEventListener('onload', this.topVisible())
}, },
methods: { methods: {
/**
* dom的滚动事件监听
*/
articleScrollListen (key) {
const dom = this.$refs['mark-down-ref']
if (dom && key === 'add') {
dom.addEventListener('scroll', function (e) {
this.topShow = e.scrollTop > 0
})
} else if (dom && key === 'remove') {
dom.removeEventListener('scroll', function (e) {
this.topShow = e.scrollTop > 0
})
}
},
initPageSpliteFun () { initPageSpliteFun () {
this.splitLength = this.pageArray[0] this.splitLength = this.pageArray[0]
}, },
...@@ -314,9 +332,7 @@ export default { ...@@ -314,9 +332,7 @@ export default {
let that = this let that = this
that.total = allTitleArray.length // 总数 that.total = allTitleArray.length // 总数
let splitLength = that.splitLength let splitLength = that.splitLength
if (!selectListLength) { if (selectListLength) {
that.splitLength = that.splitLength
} else {
this.currentPage = 1 this.currentPage = 1
that.splitLength = selectListLength // 划分长度 that.splitLength = selectListLength // 划分长度
} }
...@@ -324,7 +340,7 @@ export default { ...@@ -324,7 +340,7 @@ export default {
let splitNum = Math.ceil(that.total / splitLength) // 向上取整 let splitNum = Math.ceil(that.total / splitLength) // 向上取整
that.pageAnalys.childNum = splitNum // 子数组个数 that.pageAnalys.childNum = splitNum // 子数组个数
that.pageAnalys.allTitle = allTitleArray // 所有标题 that.pageAnalys.allTitle = allTitleArray // 所有标题
that.pageAnalys.titleArray = new Array() // 子数组个数 that.pageAnalys.titleArray = [] // 子数组个数
let locSplit = 0 let locSplit = 0
let locLength = splitLength // 每一页的条数 let locLength = splitLength // 每一页的条数
while (splitNum--) { while (splitNum--) {
...@@ -359,10 +375,10 @@ export default { ...@@ -359,10 +375,10 @@ export default {
increment: function () { increment: function () {
this.$store.commit('increment') this.$store.commit('increment')
}, },
topvisible: function () { topVisible: function () {
let dom = document.getElementById('hometitle') let dom = document.getElementById('homeTitleId')
this.topshow = this.elementIsVisibleInViewport(dom) this.topShow = this.elementIsVisibleInViewport(dom)
setTimeout(this.topvisible) setTimeout(this.topVisible)
}, },
elementIsVisibleInViewport: function (el, partiallyVisible = false) { elementIsVisibleInViewport: function (el, partiallyVisible = false) {
try { try {
......
...@@ -44,9 +44,7 @@ export default { ...@@ -44,9 +44,7 @@ export default {
await that.getWeatherData() await that.getWeatherData()
await that.weatherInint() await that.weatherInint()
} }
waitGetWeatherData().then((o) => { waitGetWeatherData()
console.log(o)
}) // 同步
}, },
getWeatherData () { getWeatherData () {
let that = this let that = this
...@@ -55,9 +53,9 @@ export default { ...@@ -55,9 +53,9 @@ export default {
that.$axios that.$axios
.get(that.baseurl + 'article/weather/') .get(that.baseurl + 'article/weather/')
.then((res) => { .then((res) => {
console.log('天气接口返回', res) let resData = res.data
let resdata = res.data let weather = resData.weather
let weather = resdata.weather that.msg = weather.location
let title = weather.title let title = weather.title
let high = weather.high let high = weather.high
let low = weather.low let low = weather.low
...@@ -96,10 +94,9 @@ export default { ...@@ -96,10 +94,9 @@ export default {
discribeText.windwl = that.weather_windwl[loc] discribeText.windwl = that.weather_windwl[loc]
that.tableData.push(discribeText) that.tableData.push(discribeText)
} }
console.log(that.tableData, 'that.tableData')
}) })
.catch((r) => { .catch((r) => {
console.log('r', r) throw Error(r)
}) })
}, 1000) }, 1000)
resolve('获取后端天气成功的promise') resolve('获取后端天气成功的promise')
...@@ -114,9 +111,7 @@ export default { ...@@ -114,9 +111,7 @@ export default {
let highData = Array.from(...[that.weather_high]) let highData = Array.from(...[that.weather_high])
let lowData = Array.from(...[that.weather_low]) let lowData = Array.from(...[that.weather_low])
let titleData = Array.from(...[that.weather_title]) let titleData = Array.from(...[that.weather_title])
console.log('绘制折线图数据', titleData, highData, lowData)
let dom = document.getElementById('echart_weather') let dom = document.getElementById('echart_weather')
// console.log('dom', dom)
let myChart = echarts.init(dom) let myChart = echarts.init(dom)
// 绘制图表 // 绘制图表
let option = { let option = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册