178 lines
5.8 KiB
Vue
178 lines
5.8 KiB
Vue
|
|
|
|
|
|
|
|
<!-- =========================================================================================
|
|
File Name: App.vue
|
|
Description: Main vue file - APP
|
|
----------------------------------------------------------------------------------------
|
|
Item Name: Vuexy - Vuejs, HTML & Laravel Admin Dashboard Template
|
|
Author: Pixinvent
|
|
Author URL: http://www.themeforest.net/user/pixinvent
|
|
========================================================================================== -->
|
|
|
|
|
|
<template>
|
|
<div id="app" :class="vueAppClasses">
|
|
<router-view @setAppClasses="setAppClasses" />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import themeConfig from '@/../themeConfig.js'
|
|
import jwt from '@/http/requests/auth/jwt/index.js'
|
|
import axios from "@/axios"
|
|
export default {
|
|
data () {
|
|
return {
|
|
vueAppClasses: []
|
|
}
|
|
},
|
|
watch: {
|
|
'$store.state.theme' (val) {
|
|
this.toggleClassInBody(val)
|
|
},
|
|
'$vs.rtl' (val) {
|
|
document.documentElement.setAttribute('dir', val ? 'rtl' : 'ltr')
|
|
}
|
|
},
|
|
methods: {
|
|
toggleClassInBody (className) {
|
|
if (className === 'dark') {
|
|
if (document.body.className.match('theme-semi-dark')) document.body.classList.remove('theme-semi-dark')
|
|
document.body.classList.add('theme-dark')
|
|
} else if (className === 'semi-dark') {
|
|
if (document.body.className.match('theme-dark')) document.body.classList.remove('theme-dark')
|
|
document.body.classList.add('theme-semi-dark')
|
|
} else {
|
|
if (document.body.className.match('theme-dark')) document.body.classList.remove('theme-dark')
|
|
if (document.body.className.match('theme-semi-dark')) document.body.classList.remove('theme-semi-dark')
|
|
}
|
|
},
|
|
setAppClasses (classesStr) {
|
|
this.vueAppClasses.push(classesStr)
|
|
},
|
|
handleWindowResize () {
|
|
this.$store.commit('UPDATE_WINDOW_WIDTH', window.innerWidth)
|
|
|
|
// Set --vh property
|
|
document.documentElement.style.setProperty('--vh', `${window.innerHeight * 0.01}px`)
|
|
},
|
|
handleScroll () {
|
|
this.$store.commit('UPDATE_WINDOW_SCROLL_Y', window.scrollY)
|
|
}
|
|
},
|
|
mounted () {
|
|
this.toggleClassInBody(themeConfig.theme)
|
|
this.$store.commit('UPDATE_WINDOW_WIDTH', window.innerWidth)
|
|
|
|
const vh = window.innerHeight * 0.01
|
|
// Then we set the value in the --vh custom property to the root of the document
|
|
document.documentElement.style.setProperty('--vh', `${vh}px`)
|
|
},
|
|
async created() {
|
|
|
|
try{
|
|
let {data} = await axios.get('/permission/user')
|
|
await this.$store.dispatch("access/setPermissions", data.permission)
|
|
delete data.permission
|
|
localStorage.setItem('userInfo',JSON.stringify(data))
|
|
}
|
|
catch (e) {
|
|
console.log("eeeee: ",e)
|
|
}
|
|
//console.log("this ==> ", this);
|
|
const dict = {
|
|
attributes: {
|
|
old: "رمز عبور فعلی",
|
|
confirm_password: "تکرار رمز عبور فعلی",
|
|
password: "رمز عبور",
|
|
email: 'ایمیل',
|
|
mobile: 'موبایل',
|
|
fname: 'نام',
|
|
phone: 'تلفن',
|
|
zip: 'کد پستی',
|
|
address: 'آدرس',
|
|
state: 'استان',
|
|
city: 'شهر',
|
|
company: 'دریافت کننده',
|
|
lname: 'نام خانوادگی',
|
|
},
|
|
messages: {
|
|
required: (field) => `وارد کردن ${field} الزامی است`,
|
|
email: (field) => 'ایمیل وارد شده نامعتبر می باشد',
|
|
min: (field) => 'مقدار ورودی صحیح نیست',
|
|
max: (field) => 'مقدار ورودی صحیح نیست',
|
|
alpha_dash: (field) => 'مقدار ورودی صحیح نیست',
|
|
digits: (field) => 'مقدار ورودی صحیح نیست'
|
|
}
|
|
};
|
|
this.$validator.localize('fa', dict);
|
|
// jwt
|
|
jwt.init()
|
|
|
|
//const dir = this.$vs.rtl ? 'rtl' : 'ltr'
|
|
// document.documentElement.setAttribute('dir', dir)
|
|
|
|
window.addEventListener('resize', this.handleWindowResize)
|
|
window.addEventListener('scroll', this.handleScroll)
|
|
|
|
// Auth0
|
|
try {
|
|
await this.$auth.renewTokens()
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
|
|
},
|
|
// async created () {
|
|
//
|
|
// //console.log("this ==> ", this);
|
|
// const dict = {
|
|
// attributes: {
|
|
// old: "رمز عبور فعلی",
|
|
// confirm_password: "تکرار رمز عبور فعلی",
|
|
// password: "رمز عبور",
|
|
// email: 'ایمیل',
|
|
// mobile: 'موبایل',
|
|
// fname: 'نام',
|
|
// phone: 'تلفن',
|
|
// zip: 'کد پستی',
|
|
// address: 'آدرس',
|
|
// state: 'استان',
|
|
// city: 'شهر',
|
|
// company: 'دریافت کننده',
|
|
// lname: 'نام خانوادگی',
|
|
// },
|
|
// messages: {
|
|
// required: (field) => `وارد کردن ${field} الزامی است`,
|
|
// email: (field) => 'ایمیل وارد شده نامعتبر می باشد',
|
|
// min: (field) => 'مقدار ورودی صحیح نیست',
|
|
// max: (field) => 'مقدار ورودی صحیح نیست',
|
|
// alpha_dash: (field) => 'مقدار ورودی صحیح نیست',
|
|
// digits: (field) => 'مقدار ورودی صحیح نیست'
|
|
// }
|
|
// };
|
|
// this.$validator.localize('fa', dict);
|
|
//
|
|
// // jwt
|
|
// jwt.init()
|
|
//
|
|
// const dir = this.$vs.rtl ? 'rtl' : 'ltr'
|
|
// document.documentElement.setAttribute('dir', dir)
|
|
//
|
|
// window.addEventListener('resize', this.handleWindowResize)
|
|
// window.addEventListener('scroll', this.handleScroll)
|
|
//
|
|
// // Auth0
|
|
// try { await this.$auth.renewTokens() } catch (e) { console.error(e) }
|
|
//
|
|
// },
|
|
destroyed () {
|
|
window.removeEventListener('resize', this.handleWindowResize)
|
|
window.removeEventListener('scroll', this.handleScroll)
|
|
}
|
|
}
|
|
|
|
</script>
|