initial
This commit is contained in:
16
layers/ui/plugins/dayjs.ts
Normal file
16
layers/ui/plugins/dayjs.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import dayjs from 'dayjs'
|
||||
import dayjsLocaleDataPlugin from 'dayjs/plugin/localeData'
|
||||
import dayjsTodayPlugin from 'dayjs/plugin/isToday'
|
||||
import dayjsIsBetweenPlugin from 'dayjs/plugin/isBetween'
|
||||
import dayjsUpdateLocalePlugin from 'dayjs/plugin/updateLocale'
|
||||
import dayjsCustomParseFormatPlugin from 'dayjs/plugin/customParseFormat'
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
dayjs.extend(dayjsLocaleDataPlugin)
|
||||
dayjs.extend(dayjsTodayPlugin)
|
||||
dayjs.extend(dayjsIsBetweenPlugin)
|
||||
dayjs.extend(dayjsUpdateLocalePlugin)
|
||||
dayjs.extend(dayjsCustomParseFormatPlugin)
|
||||
|
||||
return {}
|
||||
})
|
||||
13
layers/ui/plugins/global-config.ts
Normal file
13
layers/ui/plugins/global-config.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { NuxtLink } from '#components'
|
||||
import { provideGlobalConfig } from '#imports'
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
provideGlobalConfig(
|
||||
computed(() => ({
|
||||
LINK_COMPONENT: NuxtLink,
|
||||
})),
|
||||
nuxtApp.vueApp,
|
||||
)
|
||||
|
||||
return {}
|
||||
})
|
||||
21
layers/ui/plugins/i18n.ts
Normal file
21
layers/ui/plugins/i18n.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { Composer } from 'vue-i18n'
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
const i18n = nuxtApp.$i18n as Composer
|
||||
|
||||
if (i18n) {
|
||||
i18n.mergeLocaleMessage('ru', {
|
||||
'ui.select.selected': 'Выбрано: {0}',
|
||||
'ui.select.select_option': 'Выбрать',
|
||||
'ui.search': 'Поиск',
|
||||
})
|
||||
|
||||
i18n.mergeLocaleMessage('en', {
|
||||
'ui.select.selected': 'Selected: {0}',
|
||||
'ui.select.select_option': 'Select',
|
||||
'ui.search': 'Search',
|
||||
})
|
||||
}
|
||||
|
||||
return {}
|
||||
})
|
||||
7
layers/ui/plugins/notify.ts
Normal file
7
layers/ui/plugins/notify.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import notify from '../components/notification/notify'
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
notify._context = nuxtApp.vueApp._context
|
||||
|
||||
return {}
|
||||
})
|
||||
33
layers/ui/plugins/vee-validate.ts
Normal file
33
layers/ui/plugins/vee-validate.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import * as defaultRules from '@vee-validate/rules'
|
||||
import { configure, defineRule } from 'vee-validate'
|
||||
import type { Composer } from 'vue-i18n'
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
for (const rule in defaultRules) {
|
||||
if (['default', 'url'].includes(rule))
|
||||
continue
|
||||
|
||||
defineRule(rule, defaultRules[rule])
|
||||
}
|
||||
|
||||
defineRule('url', (value, params): boolean => {
|
||||
const optionalProtocol = Array.isArray(params) ? params[0] : params.optionalProtocol
|
||||
|
||||
if (optionalProtocol)
|
||||
return /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/.test(value)
|
||||
|
||||
return defaultRules.url(value, params)
|
||||
})
|
||||
|
||||
const i18n = nuxtApp.$i18n as Composer
|
||||
|
||||
if (i18n) {
|
||||
configure({
|
||||
generateMessage: (context) => {
|
||||
return i18n.t(`validation.${context.rule!.name}`, context.rule!.params)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return {}
|
||||
})
|
||||
Reference in New Issue
Block a user