Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import VCharts from 'v-charts'
Vue.use(VCharts);
import VueClipboards from 'vue-clipboards';
Vue.use(VueClipboards);
import fullscreen from 'vue-fullscreen'
Vue.use(fullscreen);
import BackToTop from 'vue-backtotop'
Vue.use(BackToTop)
import VeeValidate, { Validator } from "vee-validate";
import zh_CN from "vee-validate/dist/locale/zh_CN";
Validator.localize("zh_CN", zh_CN);
Vue.use(VeeValidate, {
locale: "zh_CN",
// delay: 500,
dictionary: {
zh_CN: {
messages: {
required: field => `${field} 不能为空`,
confirmed: (field, targetField) => `${field} 和 ${targetField} 不匹配`,
regex: field => `${field} 不符合要求格式`
}
}
}
});
import $ from 'jquery'
$.ajaxSetup({ cache: false });
// rules https://baianat.github.io/vee-validate/guide/rules.html
const validationMessages = {
en: {
messages: {
required: () => $t('The field is required'),
min_value: (fieldName: string, params: number[]) => `The field value must be ${ params[0] } or larger`,
max_value: (fieldName: string, params: number[]) => `The field value must be ${ params[0] } or less`,
date_format: (fieldName: string, params: number[]) => `The date must be in ${ params[0] } format`,
alpha_num: () => $t('This field may only contain alphabetic characters or numbers')
}
}
};
// Override and merge the dictionaries
Validator.localize(validationMessages);
regex: (field) => field + ' is illegal'
},
attributes: {
Description: 'Description',
Name: 'Name'
// lifeCycle: '生命周期',
// maintainers: '运维人员',
// strictCharacter: '严格字符',
// looseCharacter: '宽松字符',
// number: '数字',
// ipAddress: 'ip地址',
// commonName: '名称'
}
}
}
Validator.localize(dictionary)
export default dictionary
import store from './store'
import i18n from './lang' // Internationalization
import './icons' // icon
import './errorLog' // error log
import './permission' // permission control
import './mock' // simulation data
import * as filters from './filters' // global filters
import Vant from 'vant'
import 'vant/lib/index.css'
import VeeValidate, { Validator } from 'vee-validate' // 引入校验框架
import zh_CN from '@/utils/vee-validate-zh_CN'
Validator.localize('zh_CN', zh_CN)
Vue.use(VeeValidate, {
locale: 'zh_CN'
})
Vue.use(Vant)
// register global utility filters.
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key])
})
Vue.config.productionTip = false
new Vue({
el: '#app',
router,
//设置验证的提示消息
import { Validator } from 'vee-validate'
//引入设置cookie的方法
import { setToken } from "@/utils/auth"
const dict = {
custom: {
user: {
required: '您的用户名不能为空'
},
password: {
required: () => '您的密码不能为空'
}
}
}
Validator.localize('en',dict) // changes the locale
//引入发请求的模块
import request from '@/utils/request'
export default {
name: "Login",
data(){
return {
LoginForm:{
user:'',
password:''
}
}
},
methods:{
//登录方法
login:function(){
//首先拿到验证成功失败的结果,如果成功了,再进行登录,如果失败了,则进行消息提示...
import Vue from 'vue'
import App from './App'
import router from './router'
import store from '@/store'
import VeeValidate, { Validator } from 'vee-validate'
import tr from 'vee-validate/dist/locale/tr'
import VueLoading from 'vuex-loading'
// import '@/firebase'
import { AUTH } from '@/firebase'
Vue.config.productionTip = false
Validator.localize('tr', tr)
Vue.use(VueLoading)
Vue.use(VeeValidate, {
events: 'input'
})
let app
AUTH.onAuthStateChanged(() => {
if (!app) {
app = new Vue({
el: '#app',
router,
store,
vueLoading: new VueLoading({ useVuex: true }),
template: '',
components: { App }
setLocale({ commit }, payload) {
commit(types.SUCCESS, null)
commit(types.ERROR, null)
i18n.locale = payload
Validator.localize(payload)
window.localStorage.setItem('locale', JSON.stringify(payload))
commit(types.SET_LOCALE, payload)
}
}
import Vue from 'vue'
import VeeValidate, {Validator} from 'vee-validate'
import zh from 'vee-validate/dist/locale/zh_CN'
import en from 'vee-validate/dist/locale/en'
Validator.localize('en-US', en)
Validator.localize('zh-CN', zh)
Validator.localize({
'zh-CN': {
messages: {
required: '不能为空',
numeric: '仅允许数字',
alpha:'只能包含字母字符',
max: function (n, e) {
return '不能超出' + e[0] + '字符'
},
min: function (n, e) {
return '不能少于' + e[0] + '字符'
},
between: function(n,e){
return '必须在'+e[0]+','+e[1]+'之间'
},
email: '必须为有效邮箱'
Vue.use(Vuetify)
import VCharts from 'v-charts'
Vue.use(VCharts)
import VueTheMask from 'vue-the-mask'
Vue.use(VueTheMask)
import VeeValidate, {Validator} from 'vee-validate'
Vue.use(VeeValidate);
import VueDialog from '@/helpers/VueDialog'
Vue.mixin(VueDialog)
import VeeLocale_pt_BR from 'vee-validate/dist/locale/pt_BR'
Validator.localize('pt_BR', VeeLocale_pt_BR)
import Element from 'element-ui'
Vue.use(Element)
Vue.config.productionTip = false
Axios.interceptors.response.use(null, function (error) {
const status = error.response && error.response.status
if (status === 401) {
Auth.logOut()
}
return Promise.reject(error);
})
Axios.interceptors.request.use(function (config) {
import Vue from 'vue'
import VeeValidate, {Validator} from 'vee-validate'
import zh from 'vee-validate/dist/locale/zh_CN'
import en from 'vee-validate/dist/locale/en'
Validator.localize('en-US', en)
Validator.localize('zh-CN', zh)
Validator.localize({
'zh-CN': {
messages: {
required: '不能为空',
numeric: '仅允许数字',
alpha:'只能包含字母字符',
max: function (n, e) {
return '不能超出' + e[0] + '字符'
},
min: function (n, e) {
return '不能少于' + e[0] + '字符'
},
between: function(n,e){
return '必须在'+e[0]+','+e[1]+'之间'
},
email: '必须为有效邮箱'
}