120 lines
2.8 KiB
TypeScript
120 lines
2.8 KiB
TypeScript
import {useState} from '#imports';
|
|
import type {CmsWebsite} from "~/api/cms/cmsWebsite/model";
|
|
import type {CmsNavigation} from "~/api/cms/cmsNavigation/model";
|
|
import type {User} from "~/api/system/user/model";
|
|
import type {Company} from "~/api/system/company/model";
|
|
import type {Layout} from "~/api/layout/model";
|
|
import type {Config} from "~/types/global";
|
|
import type {CmsWebsiteField} from "~/api/cms/cmsWebsiteField/model";
|
|
import type {CmsWebsiteSetting} from "~/api/cms/cmsWebsiteSetting/model";
|
|
|
|
// 网站信息
|
|
export const useWebsite = () => useState<CmsWebsite>('website', undefined);
|
|
|
|
// 网站设置
|
|
export const useSetting = () =>
|
|
useState<CmsWebsiteSetting>('setting', () => {
|
|
return {};
|
|
});
|
|
|
|
// 扩展字段
|
|
export const useConfigInfo = () =>
|
|
useState<Config>('config', () => {
|
|
return {
|
|
productParentId: undefined,
|
|
searchCategoryId: undefined
|
|
};
|
|
});
|
|
|
|
// 主导航
|
|
export const useMenu = () =>
|
|
useState<CmsNavigation[]>('menu', () => {
|
|
return [];
|
|
});
|
|
|
|
// 副导航
|
|
export const useSubMenu = () =>
|
|
useState<CmsNavigation[]>('subMenu', () => {
|
|
return [];
|
|
});
|
|
|
|
// 页面元素
|
|
export const usePage = () => useState<CmsNavigation>('page', () => {
|
|
return {};
|
|
});
|
|
|
|
|
|
// 页面布局
|
|
export const useLayout = () => useState<Layout>('layout', () => {
|
|
return {
|
|
showBanner: true
|
|
}
|
|
});
|
|
|
|
// 固钉
|
|
export const useProductAffix = () =>
|
|
useState<boolean>('affixTop', () => {
|
|
return false;
|
|
});
|
|
// 后台管理域名
|
|
export const useSysDomain = () => useState('SysDomain', () => '');
|
|
|
|
// 登录凭证
|
|
export const useToken = () => useState('token', () => {
|
|
if(localStorage.getItem('token')){
|
|
return localStorage.getItem('token')
|
|
}
|
|
return ''
|
|
});
|
|
|
|
// 用户信息
|
|
export const useUser = () =>
|
|
useState<User>('user', () => {
|
|
return {
|
|
userId: 0,
|
|
avatar: '',
|
|
phone: '',
|
|
balance: 0,
|
|
nickname: '',
|
|
gradeId: 0,
|
|
gradeName: '',
|
|
certification: false,
|
|
tenantId: 0,
|
|
tenantName: '',
|
|
};
|
|
});
|
|
|
|
// 企业信息
|
|
export const useCompany = () =>
|
|
useState<Company>('company', () => {
|
|
return {};
|
|
});
|
|
|
|
// 是否显示登录弹窗
|
|
export const useShowLogin = () => useState('showLogin', () => false);
|
|
|
|
// 登录凭证
|
|
export const useIsMobile = () => useState('isMobile', () => false);
|
|
|
|
// 购物车状态
|
|
export const useCart = () => useState<any>('cart', () => {
|
|
return {
|
|
num: 1,
|
|
type: 1,
|
|
payType: 102,
|
|
payPrice: 0,
|
|
month: 1,
|
|
comments: '',
|
|
list: [],
|
|
totalPrice: 0
|
|
};
|
|
});
|
|
|
|
export const useLogo = () => useState<CmsWebsiteField>('logo', () => {
|
|
return {
|
|
siteName: '',
|
|
siteLogo: undefined,
|
|
value: '',
|
|
};
|
|
})
|