Skip to content

Commit d0651ad

Browse files
tuandmPanJiaChen
authored andcommitted
perf: add jsdoc for utils and format some code (PanJiaChen#1883)
1 parent 43ae852 commit d0651ad

File tree

11 files changed

+241
-147
lines changed

11 files changed

+241
-147
lines changed

src/components/Charts/keyboard.vue

Lines changed: 87 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -53,103 +53,102 @@ export default {
5353
data.push((Math.sin(i / 5) * (i / 5 - 10) + i / 6) * 5)
5454
data2.push((Math.sin(i / 5) * (i / 5 + 10) + i / 6) * 3)
5555
}
56-
this.chart.setOption(
57-
{
58-
backgroundColor: '#08263a',
59-
grid: {
60-
left: '5%',
61-
right: '5%'
56+
this.chart.setOption({
57+
backgroundColor: '#08263a',
58+
grid: {
59+
left: '5%',
60+
right: '5%'
61+
},
62+
xAxis: [{
63+
show: false,
64+
data: xAxisData
65+
}, {
66+
show: false,
67+
data: xAxisData
68+
}],
69+
visualMap: {
70+
show: false,
71+
min: 0,
72+
max: 50,
73+
dimension: 0,
74+
inRange: {
75+
color: ['#4a657a', '#308e92', '#b1cfa5', '#f5d69f', '#f5898b', '#ef5055']
76+
}
77+
},
78+
yAxis: {
79+
axisLine: {
80+
show: false
6281
},
63-
xAxis: [{
64-
show: false,
65-
data: xAxisData
66-
}, {
67-
show: false,
68-
data: xAxisData
69-
}],
70-
visualMap: {
71-
show: false,
72-
min: 0,
73-
max: 50,
74-
dimension: 0,
75-
inRange: {
76-
color: ['#4a657a', '#308e92', '#b1cfa5', '#f5d69f', '#f5898b', '#ef5055']
82+
axisLabel: {
83+
textStyle: {
84+
color: '#4a657a'
7785
}
7886
},
79-
yAxis: {
80-
axisLine: {
81-
show: false
82-
},
83-
axisLabel: {
84-
textStyle: {
85-
color: '#4a657a'
86-
}
87-
},
88-
splitLine: {
89-
show: true,
90-
lineStyle: {
91-
color: '#08263f'
92-
}
93-
},
94-
axisTick: {
95-
show: false
87+
splitLine: {
88+
show: true,
89+
lineStyle: {
90+
color: '#08263f'
9691
}
9792
},
98-
series: [{
99-
name: 'back',
100-
type: 'bar',
101-
data: data2,
102-
z: 1,
103-
itemStyle: {
104-
normal: {
105-
opacity: 0.4,
106-
barBorderRadius: 5,
107-
shadowBlur: 3,
108-
shadowColor: '#111'
109-
}
110-
}
111-
}, {
112-
name: 'Simulate Shadow',
113-
type: 'line',
114-
data,
115-
z: 2,
116-
showSymbol: false,
117-
animationDelay: 0,
118-
animationEasing: 'linear',
119-
animationDuration: 1200,
120-
lineStyle: {
121-
normal: {
122-
color: 'transparent'
123-
}
124-
},
125-
areaStyle: {
126-
normal: {
127-
color: '#08263a',
128-
shadowBlur: 50,
129-
shadowColor: '#000'
130-
}
93+
axisTick: {
94+
show: false
95+
}
96+
},
97+
series: [{
98+
name: 'back',
99+
type: 'bar',
100+
data: data2,
101+
z: 1,
102+
itemStyle: {
103+
normal: {
104+
opacity: 0.4,
105+
barBorderRadius: 5,
106+
shadowBlur: 3,
107+
shadowColor: '#111'
131108
}
132-
}, {
133-
name: 'front',
134-
type: 'bar',
135-
data,
136-
xAxisIndex: 1,
137-
z: 3,
138-
itemStyle: {
139-
normal: {
140-
barBorderRadius: 5
141-
}
109+
}
110+
}, {
111+
name: 'Simulate Shadow',
112+
type: 'line',
113+
data,
114+
z: 2,
115+
showSymbol: false,
116+
animationDelay: 0,
117+
animationEasing: 'linear',
118+
animationDuration: 1200,
119+
lineStyle: {
120+
normal: {
121+
color: 'transparent'
142122
}
143-
}],
144-
animationEasing: 'elasticOut',
145-
animationEasingUpdate: 'elasticOut',
146-
animationDelay(idx) {
147-
return idx * 20
148123
},
149-
animationDelayUpdate(idx) {
150-
return idx * 20
124+
areaStyle: {
125+
normal: {
126+
color: '#08263a',
127+
shadowBlur: 50,
128+
shadowColor: '#000'
129+
}
130+
}
131+
}, {
132+
name: 'front',
133+
type: 'bar',
134+
data,
135+
xAxisIndex: 1,
136+
z: 3,
137+
itemStyle: {
138+
normal: {
139+
barBorderRadius: 5
140+
}
151141
}
152-
})
142+
}],
143+
animationEasing: 'elasticOut',
144+
animationEasingUpdate: 'elasticOut',
145+
animationDelay(idx) {
146+
return idx * 20
147+
},
148+
animationDelayUpdate(idx) {
149+
return idx * 20
150+
}
151+
})
153152
}
154153
}
155154
}

src/components/DragSelect/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ export default {
4949
</script>
5050

5151
<style scoped>
52-
.drag-select >>> .sortable-ghost{
52+
.drag-select >>> .sortable-ghost {
5353
opacity: .8;
5454
color: #fff!important;
5555
background: #42b983!important;
5656
}
5757
58-
.drag-select >>> .el-tag{
58+
.drag-select >>> .el-tag {
5959
cursor: pointer;
6060
}
6161
</style>

src/filters/index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
// set function parseTime,formatTime to filter
22
export { parseTime, formatTime } from '@/utils'
33

4+
/**
5+
* Show plural label if time is plural number
6+
* @param {number} time
7+
* @param {string} label
8+
* @return {string}
9+
*/
410
function pluralize(time, label) {
511
if (time === 1) {
612
return time + label
713
}
814
return time + label + 's'
915
}
1016

17+
/**
18+
* @param {number} time
19+
*/
1120
export function timeAgo(time) {
1221
const between = Date.now() / 1000 - Number(time)
1322
if (between < 3600) {
@@ -19,7 +28,12 @@ export function timeAgo(time) {
1928
}
2029
}
2130

22-
/* 数字 格式化*/
31+
/**
32+
* Number formatting
33+
* like 10000 => 10k
34+
* @param {number} num
35+
* @param {number} digits
36+
*/
2337
export function numberFormatter(num, digits) {
2438
const si = [
2539
{ value: 1E18, symbol: 'E' },
@@ -37,6 +51,10 @@ export function numberFormatter(num, digits) {
3751
return num.toString()
3852
}
3953

54+
/**
55+
* 10000 => "10,000"
56+
* @param {number} num
57+
*/
4058
export function toThousandFilter(num) {
4159
return (+num || 0).toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
4260
}

src/layout/components/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
export { default as AppMain } from './AppMain'
12
export { default as Navbar } from './Navbar'
3+
export { default as Settings } from './Settings'
24
export { default as Sidebar } from './Sidebar/index.vue'
35
export { default as TagsView } from './TagsView/index.vue'
4-
export { default as AppMain } from './AppMain'
5-
export { default as Settings } from './Settings'

src/layout/index.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717

1818
<script>
1919
import RightPanel from '@/components/RightPanel'
20-
import { Navbar, Sidebar, AppMain, TagsView, Settings } from './components'
20+
import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
2121
import ResizeMixin from './mixin/ResizeHandler'
2222
import { mapState } from 'vuex'
2323
2424
export default {
2525
name: 'Layout',
2626
components: {
27-
RightPanel,
27+
AppMain,
2828
Navbar,
29+
RightPanel,
30+
Settings,
2931
Sidebar,
30-
AppMain,
31-
TagsView,
32-
Settings
32+
TagsView
3333
},
3434
mixins: [ResizeMixin],
3535
computed: {

0 commit comments

Comments
 (0)