Skip to content

Commit 9b74e32

Browse files
author
潘朝思
committed
feat: add pomodoro
1 parent 1b23e14 commit 9b74e32

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

web/src/layout/header/index.vue

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@
44
<showAside :toggle-click="toggleClick"/>
55
<breadcrumb />
66
</div>
7-
7+
8+
<div class="header-center" v-show="tomato_time_str!==''">
9+
<span style="font-size: 13px; letter-spacing: 1px; color: #3a8ee6">番茄开启 请专注 :</span>
10+
<span>{{ tomato_time_str }}</span>
11+
</div>
12+
813
<div class="header-right">
914
<div class="header-user-con">
15+
<!-- 全屏显示 -->
16+
<div class="btn-bell" @click="startTomato">
17+
<el-tooltip effect="dark" content="开启番茄钟 🍅" placement="bottom">
18+
<i class="el-icon-video-play" v-if="!tomato_run"></i>
19+
<i class="el-icon-video-pause" v-else></i>
20+
</el-tooltip>
21+
</div>
1022
<!-- 全屏显示 -->
1123
<div class="btn-fullscreen" @click="handleFullScreen">
1224
<el-tooltip effect="dark" :content="fullscreen?$t('header.cancelFullScreen'):$t('header.fullScreen')" placement="bottom">
@@ -61,6 +73,9 @@ export default {
6173
},
6274
data() {
6375
return {
76+
tomato_time_str: "",
77+
tomato_run: false,
78+
tomato_time_init: 300, // 60s
6479
fullscreen: this.$store.state.isFullScreen,
6580
message: 2,
6681
username: this.$store.state.user.name
@@ -123,14 +138,33 @@ export default {
123138
handleFullScreen() {
124139
let isFullScreen = this.$store.state.isFullScreen
125140
this.$store.commit('SET_FULLSCREEN', !isFullScreen)
141+
},
142+
startTomato() {
143+
if (this.tomato_time_str === "") {
144+
let ts = this.tomato_time_init
145+
this.tomato_run = true
146+
let timer = setInterval(() => {
147+
if (this.tomato_run) {
148+
ts--;
149+
this.tomato_time_str = ('0' + Math.floor(ts / 60)).slice(-2) + ':' + ('0' + ts % 60).slice(-2)
150+
if (ts <= 0) {
151+
this.tomato_time_str = ""
152+
this.tomato_run = false
153+
clearInterval(timer);
154+
}
155+
}
156+
}, 1000)
157+
}else{
158+
this.tomato_run = !this.tomato_run
159+
}
126160
}
127161
}
128-
};
162+
};
129163
</script>
130164

131165
<style lang="scss" scoped>
132166
.head-container {
133-
height: 50px;
167+
height: 52px;
134168
line-height: 50px;
135169
-webkit-box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12),
136170
0 0 3px 0 rgba(0, 0, 0, 0.04);
@@ -140,6 +174,15 @@ export default {
140174
.header-left {
141175
float: left;
142176
}
177+
.header-center {
178+
float: left;
179+
padding-left: 30%;
180+
position: relative;
181+
letter-spacing: 5px;
182+
font-weight: bolder;
183+
font-size: 21px;
184+
color: red;
185+
}
143186
.header-right {
144187
float: right;
145188
padding-right: 50px;

0 commit comments

Comments
 (0)