Skip to content

Commit ffd668f

Browse files
committed
refine dashboard css
1 parent ed803c6 commit ffd668f

File tree

5 files changed

+63
-10
lines changed

5 files changed

+63
-10
lines changed

src/components/TodoList/index.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,15 @@
246246
list-style: none;
247247
position: absolute;
248248
right: 0;
249-
left: 0;
249+
left: -20px;
250250
}
251251
.filters li {
252252
display: inline;
253253
}
254254
.filters li a {
255255
color: inherit;
256256
margin: 3px;
257+
font-size: 12px;
257258
padding: 3px 7px;
258259
text-decoration: none;
259260
border: 1px solid transparent;

src/mock/login.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ const userMap = {
66
token: 'admin',
77
introduction: '我是超级管理员',
88
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
9-
name: '超级管理员小潘',
9+
name: 'Super Admin',
1010
uid: '001'
1111
},
1212
editor: {
1313
role: ['editor'],
1414
token: 'editor',
1515
introduction: '我是编辑',
1616
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
17-
name: '普通编辑小张',
17+
name: 'Normal Editor',
1818
uid: '002'
1919

2020
},

src/utils/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,38 @@
212212
}
213213
}
214214

215+
export function debounce(func, wait, immediate) {
216+
let timeout, args, context, timestamp, result;
217+
218+
const later = function() {
219+
// 据上一次触发时间间隔
220+
const last = +new Date() - timestamp;
221+
222+
// 上次被包装函数被调用时间间隔last小于设定时间间隔wait
223+
if (last < wait && last > 0) {
224+
timeout = setTimeout(later, wait - last);
225+
} else {
226+
timeout = null;
227+
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
228+
if (!immediate) {
229+
result = func.apply(context, args);
230+
if (!timeout) context = args = null;
231+
}
232+
}
233+
};
234+
235+
return function(...args) {
236+
context = this;
237+
timestamp = +new Date();
238+
const callNow = immediate && !timeout;
239+
// 如果延时不存在,重新设定延时
240+
if (!timeout) timeout = setTimeout(later, wait);
241+
if (callNow) {
242+
result = func.apply(context, args);
243+
context = args = null;
244+
}
245+
246+
return result;
247+
};
248+
}
249+

src/views/dashboard/editor/index.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@
6565
</el-row>
6666

6767
<el-row :gutter="20">
68-
<el-col :span="16">
68+
<el-col :span="15">
6969
<line-chart></line-chart>
7070
</el-col>
71-
<el-col :span="8">
71+
<el-col :span="9">
7272
<todo-list></todo-list>
7373
</el-col>
7474
</el-row>
@@ -129,10 +129,12 @@
129129
}
130130
.display_name{
131131
font-size: 30px;
132+
display: block;
132133
}
133134
.info-item{
134135
display: inline-block;
135136
margin-top: 10px;
137+
font-size: 14px;
136138
&:last-of-type{
137139
margin-left: 15px;
138140
}

src/views/dashboard/editor/lineChart.vue

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<script>
55
import echarts from 'echarts';
66
require('echarts/theme/macarons'); // echarts 主题
7+
import { debounce } from 'utils';
8+
79
810
export default {
911
props: {
@@ -18,6 +20,10 @@
1820
height: {
1921
type: String,
2022
default: '300px'
23+
},
24+
autoResize: {
25+
type: Boolean,
26+
default: true
2127
}
2228
},
2329
data() {
@@ -27,11 +33,20 @@
2733
},
2834
mounted() {
2935
this.initChart();
36+
if (this.autoResize) {
37+
this.__resizeHanlder = debounce(() => {
38+
this.chart.resize()
39+
}, 100)
40+
window.addEventListener('resize', this.__resizeHanlder)
41+
}
3042
},
3143
beforeDestroy() {
3244
if (!this.chart) {
3345
return
3446
}
47+
if (this.autoResize) {
48+
window.removeEventListener('resize', this.__resizeHanlder)
49+
}
3550
this.chart.dispose();
3651
this.chart = null;
3752
},
@@ -41,12 +56,12 @@
4156
4257
this.chart.setOption({
4358
xAxis: {
44-
data: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
59+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
4560
boundaryGap: false
4661
},
4762
grid: {
48-
left: 0,
49-
right: 0,
63+
left: 10,
64+
right: 10,
5065
bottom: 20,
5166
containLabel: true
5267
},
@@ -59,7 +74,7 @@
5974
},
6075
yAxis: {},
6176
series: [{
62-
name: 'vistor',
77+
name: 'visitors',
6378
itemStyle: {
6479
normal: {
6580
areaStyle: {}
@@ -70,7 +85,7 @@
7085
data: [100, 120, 161, 134, 105, 160, 165]
7186
},
7287
{
73-
name: 'buyer',
88+
name: 'buyers',
7489
smooth: true,
7590
type: 'line',
7691
itemStyle: {

0 commit comments

Comments
 (0)