前端优化

This commit is contained in:
John Smith 2020-05-09 23:17:49 +08:00
parent 32ba4187aa
commit 7f25c219d8
3 changed files with 8 additions and 7 deletions

View File

@ -66,6 +66,7 @@ export default {
return { return {
MESSAGE_TYPE_MEMBER: constants.MESSAGE_TYPE_MEMBER, MESSAGE_TYPE_MEMBER: constants.MESSAGE_TYPE_MEMBER,
curTime: new Date(),
updateTimerId: window.setInterval(this.updateProgress.bind(this), 1000), updateTimerId: window.setInterval(this.updateProgress.bind(this), 1000),
pinnedMessage: null pinnedMessage: null
} }
@ -108,7 +109,7 @@ export default {
color2 = config.colors.headerBg color2 = config.colors.headerBg
pinTime = config.pinTime pinTime = config.pinTime
} }
let progress = (1 - (new Date() - message.addTime) / (60 * 1000) / pinTime) * 100 let progress = (1 - (this.curTime - message.addTime) / (60 * 1000) / pinTime) * 100
if (progress < 0) { if (progress < 0) {
progress = 0 progress = 0
} else if (progress > 100) { } else if (progress > 100) {
@ -129,7 +130,7 @@ export default {
return 'CN¥' + formatCurrency(message.price) return 'CN¥' + formatCurrency(message.price)
}, },
updateProgress() { updateProgress() {
let curTime = new Date() this.curTime = new Date()
for (let i = 0; i < this.messages.length;) { for (let i = 0; i < this.messages.length;) {
let pinTime let pinTime
if (this.messages[i].type === constants.MESSAGE_TYPE_MEMBER) { if (this.messages[i].type === constants.MESSAGE_TYPE_MEMBER) {
@ -138,7 +139,7 @@ export default {
let config = constants.getPriceConfig(this.messages[i].price) let config = constants.getPriceConfig(this.messages[i].price)
pinTime = config.pinTime pinTime = config.pinTime
} }
if ((curTime - this.messages[i].addTime) / (60 * 1000) >= pinTime) { if ((this.curTime - this.messages[i].addTime) / (60 * 1000) >= pinTime) {
if (this.pinnedMessage == this.messages[i]) { if (this.pinnedMessage == this.messages[i]) {
this.pinnedMessage = null this.pinnedMessage = null
} }
@ -147,8 +148,6 @@ export default {
i++ i++
} }
} }
this.$forceUpdate()
}, },
onItemClick(message) { onItemClick(message) {
if (this.pinnedMessage == message) { if (this.pinnedMessage == message) {

View File

@ -514,7 +514,7 @@ export default {
return true return true
} }
// OBS // OBS
return new Date() - this.cantScrollStartTime >= 10 * 1000 return new Date() - this.cantScrollStartTime >= 5 * 1000
}, },
refreshCantScrollStartTime() { refreshCantScrollStartTime() {
// //

View File

@ -15,7 +15,9 @@
</el-aside> </el-aside>
<el-main> <el-main>
<el-button v-show="isMobile" class="menu-button" icon="el-icon-s-unfold" @click="hideSidebar = false"></el-button> <el-button v-show="isMobile" class="menu-button" icon="el-icon-s-unfold" @click="hideSidebar = false"></el-button>
<router-view></router-view> <keep-alive>
<router-view></router-view>
</keep-alive>
</el-main> </el-main>
</el-container> </el-container>
</template> </template>