Skip to content

Commit 34184e0

Browse files
authored
feat(*): 可选链 ?. 双问号??; 添加 babel plugins (#403)
1 parent 0582f21 commit 34184e0

15 files changed

Lines changed: 66 additions & 20 deletions

File tree

babel.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ module.exports = {
99
styleLibraryName: 'theme-chalk',
1010
},
1111
],
12+
'@babel/plugin-proposal-optional-chaining',
13+
'@babel/plugin-proposal-nullish-coalescing-operator',
1214
],
1315
}

package-lock.json

Lines changed: 46 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
},
4040
"devDependencies": {
4141
"@babel/core": "^7.11.4",
42+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
43+
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
4244
"@vue/cli-plugin-babel": "~4.5.0",
4345
"@vue/cli-plugin-eslint": "~4.5.0",
4446
"@vue/cli-plugin-unit-jest": "~4.5.0",

src/component/base/table/lin-table.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export default {
220220
)
221221
}
222222
// 选中-单选
223-
if (this.currentOldRow && this.currentOldRow.key === row.key) {
223+
if (this.currentOldRow?.key === row.key) {
224224
// 取消单选选中
225225
this.$refs.linTable.setCurrentRow()
226226
this.currentOldRow = null
@@ -365,7 +365,7 @@ export default {
365365
tableData: {
366366
handler() {
367367
// 传了分页配置
368-
if (this.pagination && this.pagination.pageSize) {
368+
if (this.pagination?.pageSize) {
369369
this.currentData = this.tableData.filter((item, index) => index < this.pagination.pageSize)
370370
} else {
371371
this.currentData = this.tableData

src/component/base/tinymce/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default {
8686
file,
8787
})
8888
.then(res => {
89-
if (res[0] && res[0].url) {
89+
if (res.length && res[0]?.url) {
9090
success(res[0].url)
9191
}
9292
})

src/component/layout/sidebar/menu-tree.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<el-submenu v-if="item.children && item.children.length > 0" :index="item.path" popper-append-to-body>
2+
<el-submenu v-if="item.children?.length > 0" :index="item.path" popper-append-to-body>
33
<template #title>
44
<i v-if="!filterIcon(item.icon)" :class="item.icon"></i>
55
<img v-else :src="item.icon" class="img-icon" />

src/component/layout/user.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ export default {
333333
},
334334
init() {
335335
const { user } = this.$store.state
336-
this.username = user ? user.username : '未登录'
337-
this.groupName = user.groupName ? user.groupName : '超级管理员'
338-
this.nickname = user && user.nickname ? user.nickname : '佚名'
336+
this.username = user?.username ? user.username : '未登录'
337+
this.groupName = user?.groupName ? user.groupName : '超级管理员'
338+
this.nickname = user?.nickname ? user.nickname : '佚名'
339339
},
340340
goToCenter() {
341341
this.$router.push('/center')

src/component/notify/emitter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Emitter {
1717
const listeners = this.listeners.get(label)
1818
let index
1919

20-
if (listeners && listeners.length) {
20+
if (listeners?.length) {
2121
index = listeners.reduce((i, listener, index) => {
2222
if (typeof listener.callback === 'function' && listener.callback === callback && listener.vm === vm) {
2323
i = index
@@ -37,7 +37,7 @@ class Emitter {
3737
emit(label, ...args) {
3838
const listeners = this.listeners.get(label)
3939

40-
if (listeners && listeners.length) {
40+
if (listeners?.length) {
4141
listeners.forEach(listener => {
4242
listener.callback.call(listener.vm, ...args)
4343
})

src/component/notify/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default {
2323
}
2424

2525
Vue.prototype.$disconnect = () => {
26-
if (observer && observer.reconnection) {
26+
if (observer?.reconnection) {
2727
observer.reconnection = false
2828
}
2929
if (Vue.prototype.$socket) {

src/lin/model/log.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class Log {
3838
if (sCount) {
3939
this.sCount = sCount
4040
}
41-
// lCount && this.lCount = lCount
4241
}
4342

4443
async increaseUpage() {

0 commit comments

Comments
 (0)