Commit 597da35f authored by youjie's avatar youjie

根据域名渲染菜单

parent 59741d29
......@@ -3,11 +3,12 @@
</template>
<script lang="ts">
import { defineComponent, onBeforeUnmount } from 'vue';
import { defineComponent, onBeforeUnmount,provide } from 'vue';
import { useQuasar, QSpinnerFacebook } from 'quasar'
import { useI18n } from 'vue-i18n'
import axios from 'axios';
import { DirtionmaryHelper } from './config/dictionary';
import { getDomainName } from './utils/validate'
export default defineComponent({
name: 'App',
setup(props, context) {
......@@ -17,6 +18,10 @@ export default defineComponent({
if (localStorage.vuex) {
localStorage.clear()
}
// 存储当前域名
provide(DirtionmaryHelper.DOMAIN_NAME, getDomainName())
onBeforeUnmount(() => {
if (timer !== void 0) {
clearTimeout(timer)
......
import { boot } from 'quasar/wrappers'
import { createI18n } from 'vue-i18n'
import { getDomainName } from '../utils/validate'
import messages from 'src/i18n'
export type MessageLanguages = keyof typeof messages;
......@@ -20,9 +20,14 @@ declare module 'vue-i18n' {
// define the number format schema
export interface DefineNumberFormat {}
}
let Language
if(getDomainName()){
Language = localStorage.getItem('lanuage') ?? 'zhTW'
}else{
Language = localStorage.getItem('lanuage') ?? 'zhSW'
}
const i18n = createI18n({
locale: localStorage.getItem('lanuage') ?? 'zhTW',
locale: Language,
legacy: false,
warnHtmlInMessage:false,
warnHtmlMessage:false,
......
<template>
<div class="text-center">
<!-- <img src="../assets/images/lg-logo.png" style="height:200px;"/> -->
<img src="../assets/images/home.png" style="width: 50%;"/>
<img v-if="isDomainName_PIC" src="../assets/images/home.png" style="width: 50%;"/>
<img v-else src="../assets/images/home-hp.png" style="width: 50%;"/>
<!-- <div class="q-mt-lg text-h3 text-grey-4 text-center">歡迎使用PIC同業預定系統</div> -->
</div>
</template>
<script lang="ts">
import { defineComponent, PropType, computed, ref, toRef, Ref } from 'vue'
import { defineComponent, PropType, computed, reactive, toRefs, ref, toRef, Ref, inject } from 'vue'
import { Todo, Meta } from './models'
import { DirtionmaryHelper } from '../config/dictionary'
function useClickCount() {
const clickCount = ref(0)
......@@ -45,7 +47,14 @@ export default defineComponent({
}
},
setup(props) {
return { ...useClickCount(), ...useDisplayTodo(toRef(props, 'todos')) }
const data = reactive({
isDomainName_PIC:true
})
// 根据域名渲染logo
data.isDomainName_PIC = inject(DirtionmaryHelper.DOMAIN_NAME)
return { ...useClickCount(), ...useDisplayTodo(toRef(props, 'todos')),...toRefs(data), }
}
})
</script>
......@@ -37,7 +37,7 @@
</template>
<script lang="ts">
import { defineComponent, ref, reactive, toRefs, provide, onMounted } from 'vue'
import { defineComponent, ref, reactive, toRefs, provide, onMounted, inject } from 'vue'
import { useMenus, Menu } from '../../utils/menus'
import { getLangs } from "../../utils/tools";
import { SitLang } from '../../@types';
......@@ -46,6 +46,7 @@
import { UserActionsType } from '../../store/modules/user/actions';
import useScrollModule from '../../module/scrollbar/scrollModule'
import svgIcon from '../global/svg-icon.vue'
import { DirtionmaryHelper } from '../../config/dictionary';
export default defineComponent({
components: { svgIcon },
name: 'user-info',
......@@ -64,7 +65,13 @@
scrollStyle: {} as any,
})
data.scrollStyle = useScrollModule().scrollStyle
data.menus = useMenus.getMenus()
// 根据域名渲染菜单
const menList = useMenus.getMenus().filter(x=>{
return x.id == 16
})
data.menus = !inject(DirtionmaryHelper.DOMAIN_NAME)?menList:useMenus.getMenus()
data.langs=getLangs()
if(data.langs && data.langs.length>0){
data.currentLang = data.langs.find(x=> x.langLocale==locale.value) ?? {};
......
......@@ -5,9 +5,10 @@
</template>
<script lang="ts">
import { defineComponent,ref,reactive, toRefs } from 'vue'
import { defineComponent,ref,reactive, toRefs, inject } from 'vue'
import navItem from './nav-item.vue'
import { useMenus, Menu } from '../../utils/menus'
import { DirtionmaryHelper } from '../../config/dictionary';
export default defineComponent({
components: { navItem },
name: 'navs',
......@@ -15,7 +16,12 @@ export default defineComponent({
const data = reactive({
menus: [] as Menu[]
})
data.menus = useMenus.getMenus()
// 根据域名渲染菜单
const menList = useMenus.getMenus().filter(x=>{
return x.id == 16
})
data.menus = !inject(DirtionmaryHelper.DOMAIN_NAME)?menList:useMenus.getMenus()
return {...toRefs(data)}
}
......
......@@ -100,6 +100,10 @@ class DirtionmaryHelper {
/**
* 幸福存折详情
*/
static readonly PASSBOOK_DETAILS = "passbookDetails"
static readonly PASSBOOK_DETAILS = "passbookDetails"
/**
* 域名
*/
static readonly DOMAIN_NAME = "domainName"
}
export { userDictionmary,DirtionmaryHelper }
This diff is collapsed.
<template>
<q-layout view="lHh lpr lFf" style="background: #f5f8fa">
<q-header reveal class="bg-white text-white q-px-md q-py-sm">
<q-toolbar>
......@@ -37,7 +37,8 @@
<q-drawer show-if-above v-model="leftDrawerOpen" style="background: #1e1e2d; width: 265px" side="left" class="column">
<div style="box-sizing: border-box; height: 66px; border-bottom: 1px dashed #444" class="row items-center q-px-md desktop-only">
<img src="../assets/images/pic-log.png" alt="" style="height: 30px" />
<img v-if="isDomainName_PIC" src="../assets/images/pic-log.png" alt="" style="height: 30px" />
<img v-else src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1679454107000_656.png" alt="" style="height: 30px" />
<!-- <div class="text-white text-weight-bold text-subtitle1 q-ml-md">{{ $t('siteName') }}</div> -->
</div>
<q-scroll-area :thumb-style="scrollStyle.thumbStyle" :bar-style="scrollStyle.barStyle" class="col nav-list q-pl-lg">
......@@ -81,8 +82,8 @@ export default {
components: { svgIcon, Navs,userInfo,Notifications },
setup() {
const leftDrawerOpen = ref(false)
const data = reactive({
userInfo: {} as any,
leftDrawerOpen: false,
......@@ -90,8 +91,12 @@ export default {
timer: 0,
isDadge: true,
version:'',
isDomainName_PIC:true
})
// 根据域名渲染logo
data.isDomainName_PIC = inject(DirtionmaryHelper.DOMAIN_NAME)
const childPageTitle = ref('')
provide(DirtionmaryHelper.PAGE_TITLE_KEY ,childPageTitle)
const activeMenu=ref(0)
......@@ -101,9 +106,9 @@ export default {
// //console.log(getStoreGetter<UserGetter>('user', 'getUser'),'....')
// return getStoreGetter<UserGetter>('user', 'getUser')
// })
data.scrollStyle = useScrollModule().scrollStyle
const scrollAreaRef = ref()
const scrollArea = reactive({
pagesTop: 0
......@@ -114,7 +119,7 @@ export default {
scrollAreaRef.value.setScrollPosition('vertical', n, 100)
}
)
const methods = {
toggleLeftDrawer() {
data.leftDrawerOpen = !data.leftDrawerOpen
......
......@@ -4,7 +4,8 @@
<div style="width:450px;" class="column justify-between content-between">
<div :class="{'row':$q.platform.is.desktop,'column':$q.platform.is.mobile}">
<div class="col" :class="{'text-center q-mb-md':$q.platform.is.mobile}">
<img src="../../assets/images/jvs-log.png" style="width:80%;" />
<img v-if="isDomainName_PIC" src="../../assets/images/jvs-log.png" style="width:80%;" />
<img v-else src="http://imgfile.oytour.com/Upload/WebSite/202303170746500900000000054.png" style="width:80%;" />
</div>
</div>
<div class="q-py-xxl full-width">
......@@ -65,16 +66,18 @@
</template>
<script lang="ts">
import { defineComponent, reactive, ref } from 'vue'
import { defineComponent, reactive, ref, inject } from 'vue'
import useLgoinModule from '../../module/user/loginModule'
import useMetaModule from '../../module/meta/metaModule'
import { useI18n } from 'vue-i18n'
import { getLangs } from "../../utils/tools";
import { SitLang } from '../../@types';
import { useQuasar } from 'quasar';
import { DirtionmaryHelper } from '../../config/dictionary'
export default defineComponent({
setup() {
//TODO: 缺陷,验证与提交应该使用Form表单来完成,不应该进行单个验证
let { userModel, usernameRef, passwordRef, userValidateRule, loginSubmit, stateManager } = useLgoinModule()
let { setTitle } = useMetaModule()
......@@ -83,8 +86,13 @@ export default defineComponent({
setTitle(t("login.pageTitle"))
const data=reactive({
currentLang: {} as SitLang,
langs:[] as SitLang[]
langs:[] as SitLang[],
isDomainName_PIC:true
})
// 根据域名渲染logo
data.isDomainName_PIC = inject(DirtionmaryHelper.DOMAIN_NAME)
data.langs=getLangs()
if(data.langs && data.langs.length>0){
data.currentLang = data.langs.find(x=> x.langLocale==locale.value) ?? {};
......
import { SitLang, StandardStatus, RoomType, OrderType, DinnerType, HotelType, SendType } from './../@types/index';
import { i18n } from '../boot/i18n'
import { getDomainName } from '../utils/validate'
const {t} =i18n.global
/**
* @description 按照需要写入 必要可以注入全局
......@@ -356,7 +357,7 @@ export function moneyFormat (num:any, decimal = 2, split = ','):any {
var res = ''
var dotIndex = String(num).indexOf('.')
if (dotIndex === -1) { // 整数
res = thousandFormat(String(num)) + '.' + '0'.repeat(decimal)
res = thousandFormat(String(num)) + '.' + '0'.repeat(decimal)
} else {
const numStr = String((Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal)) // 四舍五入,然后固定保留2位小数
const decimals = numStr.slice(dotIndex, dotIndex + decimal + 1) // 截取小数位
......@@ -469,7 +470,13 @@ export function getLangs() {
quasarLang:'zh-TW'
}
let langs:SitLang[]=[]
// zhSw,enUs
langs.push(zhTw,koHG,jaRB)
// 根据域名渲染简体
if(!getDomainName()){
langs.push(zhSw)
}else{
langs.push(zhTw,koHG,jaRB)
}
return langs
}
......@@ -33,19 +33,19 @@ export function validatAlphabetsName(str: string) {
return reg.test(str)
}
export function isEmail(account:string):boolean {
let serchfind:boolean;
let regexp = new RegExp(/^(([^<>()\[\]\\.,;:\[email protected]"]+(\.[^<>()\[\]\\.,;:\[email protected]"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
serchfind = regexp.test(account);
return serchfind
export function isEmail(account:string):boolean {
let serchfind:boolean;
let regexp = new RegExp(/^(([^<>()\[\]\\.,;:\[email protected]"]+(\.[^<>()\[\]\\.,;:\[email protected]"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
serchfind = regexp.test(account);
return serchfind
}
export function isPhone(account:string):boolean {
let serchfind:boolean;
export function isPhone(account:string):boolean {
let serchfind:boolean;
let regexp = new RegExp(/^((13|14|15|16|17|18|19)[0-9]{1}\d{8})$/);
serchfind = regexp.test(account);
return serchfind
}
serchfind = regexp.test(account);
return serchfind
}
/** 比对数组是否相同 */
export function compareArray(arrA: any[], arrB: any[]) {
......@@ -62,3 +62,15 @@ export function compareArray(arrA: any[], arrB: any[]) {
}
return isSame
}
/** 获取当前域名 localhost、pic.oytour.com、sell.oytour.com*/
export function getDomainName() {
let domainNameUrl = window.location.hostname;
if(domainNameUrl=='localhost'){
return true
}else if(domainNameUrl=='pic.oytour.com'){
return true
}else if(domainNameUrl=='sell.oytour.com'){
return false
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment