Skip to content

Commit f249927

Browse files
authored
feat: update global filters (#411)
1 parent 34184e0 commit f249927

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

src/lin/filter/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function checkAddZone(num) {
66
return num < 10 ? `0${num.toString()}` : num
77
}
88

9-
const globalFilter = {
9+
export const filters = {
1010
filterAddress(value) {
1111
// 过滤地址
1212
if (!value) return value
@@ -98,8 +98,3 @@ const globalFilter = {
9898
return Utils.cutString(value, len)
9999
},
100100
}
101-
102-
export const filters = Object.keys(globalFilter).reduce((pre, cur) => {
103-
pre[cur] = cur
104-
return pre
105-
}, {})

src/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { createApp } from 'vue'
22
import ElementPlus from 'element-plus'
33

44
import '@/config/global'
5-
import '@/lin/plugin'
5+
import 'lin/plugin'
6+
import { filters } from 'lin/filter'
67
import permissionDirective from '@/lin/directive/authorize'
78

89
import App from '@/app.vue'
@@ -28,6 +29,8 @@ app.component('l-icon', LIcon)
2829
app.component('sticky-top', StickyTop)
2930
app.component('source-code', SourceCode)
3031

32+
app.config.globalProperties.$filters = filters
33+
3134
app.directive('permission', permissionDirective)
3235

3336
app.mount('#app')

src/view/log/log.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<aside>
5252
<p class="things" v-html="log.message"></p>
5353
<p class="brief">
54-
<span class="text-yellow">{{ log.username }}</span> {{ filters.dateTimeFormatter(log.time) }}
54+
<span class="text-yellow">{{ log.username }}</span> {{ $filters.dateTimeFormatter(log.time) }}
5555
</p>
5656
</aside>
5757
</section>
@@ -80,7 +80,6 @@ import { computed, ref, reactive, watch, onMounted, toRefs } from 'vue'
8080
8181
import logModel from 'lin/model/log'
8282
import { searchLogKeyword } from 'lin/util/search'
83-
import { filters } from 'lin/filter'
8483
import LinSearch from '@/component/base/search/lin-search'
8584
import LinDatePicker from '@/component/base/date-picker/lin-date-picker'
8685
@@ -297,7 +296,6 @@ export default {
297296
logs,
298297
more,
299298
loading,
300-
filters,
301299
finished,
302300
backInit,
303301
nextPage,

0 commit comments

Comments
 (0)