add filters
This commit is contained in:
parent
455d5ed520
commit
b6594cdf3b
17
src/filters/index.ts
Normal file
17
src/filters/index.ts
Normal file
@ -0,0 +1,17 @@
|
||||
// Set utils function parseTime to filter
|
||||
export { parseTime } from '@/utils'
|
||||
|
||||
// Filter for article status
|
||||
export const articleStatusFilter = (status: string) => {
|
||||
const statusMap: { [key: string]: string } = {
|
||||
published: 'success',
|
||||
draft: 'info',
|
||||
deleted: 'danger'
|
||||
}
|
||||
return statusMap[status]
|
||||
}
|
||||
|
||||
// Filter to uppercase the first character
|
||||
export const uppercaseFirstChar = (str: string) => {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||
}
|
@ -15,6 +15,7 @@ import '@/icons/components'
|
||||
import '@/permission'
|
||||
import { AppModule } from '@/store/modules/app'
|
||||
import * as directives from '@/directives'
|
||||
import * as filters from '@/filters'
|
||||
|
||||
Vue.use(ElementUI, {
|
||||
size: AppModule.size,
|
||||
@ -29,6 +30,10 @@ Vue.use(SvgIcon, {
|
||||
Object.keys(directives).forEach(key => {
|
||||
Vue.directive(key, (directives as { [key: string ]: DirectiveOptions })[key])
|
||||
})
|
||||
// Register global filter functions
|
||||
Object.keys(filters).forEach(key => {
|
||||
Vue.filter(key, (filters as { [key: string ]: Function })[key])
|
||||
})
|
||||
// Register global directives
|
||||
Vue.config.productionTip = false
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user