dl_site_nuxt/store/index.js

57 lines
1.3 KiB
JavaScript
Raw Normal View History

const routeMap = {
'dym': 'separate', // 单页面
'xp': 'inquiry', // 询盘栏目
'wz': 'article-page', // 文章栏目
'cp': 'products' // 产品栏目
}
export const state = () => ({
locales: ['en', 'zh'],
locale: 'en',
menuTree: [],
2025-07-29 21:29:20 +08:00
footerInfo: {},
footerPordCategory: [],
device: ''
})
export const mutations = {
SET_LANG (state, locale) {
if (state.locales.includes(locale)) {
state.locale = locale
this.$cookies.set('lang', locale)
}
},
SET_FOOTER_INFO (state, info) {
state.footerInfo = info
},
2025-07-29 21:29:20 +08:00
SET_FOOTER_PRODCAT (state, list) {
state.footerPordCategory = list
},
SET_MENU_TREE (state, tree) {
state.menuTree = [
{label:'Home', to: '/', children: []}
]
const fn = (list) => {
list.forEach(item => {
if (item.catgLevel===1) {
item.to = `/${routeMap[item.catgType]}?maxCatgId=${item.id}&title=${item.label}`
} else {
item.to = `/${routeMap[item.catgType]}?&catgId=${item.id}&maxCatgId=${item.maxParentId}&title=${item.label}`
}
if (item.children.length) {
fn(item.children)
}
})
}
fn(tree)
state.menuTree = [...state.menuTree, ...tree]
},
SET_DEVICE (state, isMob) {
2025-09-16 17:08:49 +08:00
state.device = isMob ? '移动端' : '电脑端'
}
}
export const actions = {
}