import 'vant/es/toast/style/index' import 'vant/es/notify/style/index' import 'vant/es/dialog/style/index' import 'vant/es/image-preview/style/index' import { DatePicker } from 'vant' // 自定义svg 图标组件 import DocIcon from '@/components/docIcon/index' // 设置ant日期选择框为中文样式 import dayjs from 'dayjs' import 'dayjs/locale/zh-cn' dayjs.locale('cn') export function registe(app) { // 自定义组件 app.use(DocIcon) app.config.globalProperties.$idCardHide = idCardHide app.config.globalProperties.$phoneHide = phoneHide app.config.globalProperties.$addrJoin = addrJoin // 日期选择框默认选中当前日期 DatePicker.props.modelValue.default = () => { const now = dayjs() return [now.year(), now.month() + 1, now.date()] } } // idCard 脱敏 function idCardHide(idCard) { if (!idCard || idCard.length < 18) { return idCard } return idCard.substring(0, 6) + '******' + idCard.substring(14) } // phone 脱敏 function phoneHide(phone) { if (!phone || phone.length < 11) { return phone } return phone.substring(0, 3) + '******' + phone.substring(9) } // 地址拼接显示 function addrJoin(str1 = '', str2 = '') { if (!str1 && !str2) return '-' return (str1 ?? '') + (str2 ?? '') }