chore(mobile-h5): add existing H5 app sources to the monorepo

Track the weighbridge mobile-h5 codebase (excluding node_modules, dist, and local .env) so subsequent adaptation tasks can evolve it in-repo.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-08-03 22:28:53 +08:00
1 parent f8f9c0ceff
commit a4b13fa2bc
91 files changed
+15791

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import { defineStore } from 'pinia'
import { MenuListType } from '@/types/menu'
interface MenuState {
menuList: MenuListType[]
menuWidth: string
}
export const useMenuStore = defineStore({
id: 'menuStore',
state: (): MenuState => ({
menuList: [],
menuWidth: ''
}),
getters: {
getMenuList(): MenuListType[] {
return this.menuList
}
},
actions: {
setMenuList(list: []) {
this.menuList = list
},
setMenuWidth(width: string) {
this.menuWidth = width
}
}
})
+267
View File
@@ -0,0 +1,267 @@
import { defineStore } from 'pinia'
import { MenuThemeType } from '@/types/store'
import AppConfig from '@/config'
import { SystemThemeEnum, MenuThemeEnum, MenuTypeEnum, ContainerWidthEnum } from '@/enums/appEnum'
import { colourBlend, handleElementThemeColor } from '@/utils/colors'
import { getSysStorage } from '@/utils/storage'
import { useCeremony } from '@/composables/useCeremony'
const { defaultMenuWidth, defaultCustomRadius, defaultTabStyle } = AppConfig.systemSetting
export interface SettingState {
menuType: MenuTypeEnum // 菜单类型
menuOpenWidth: number // 菜单展开宽度
systemThemeType: SystemThemeEnum // 全局主题类型 light dark
systemThemeMode: SystemThemeEnum // 全局主题模式 light dark auto
menuThemeType: MenuThemeEnum // 菜单主题类型
systemThemeColor: string // 系统主题颜色
boxBorderMode: boolean // 盒子模式 border | shadow
uniqueOpened: boolean // 是否开启手风琴模式
showMenuButton: boolean // 是否显示菜单展开按钮
showRefreshButton: boolean // 是否显示页面刷新按钮
showCrumbs: boolean // 是否显示全局面包屑
autoClose: boolean // 设置后是否自动关闭窗口
showWorkTab: boolean // 是否显示多标签
showLanguage: boolean // 是否显示多语言选择
showNprogress: boolean // 是否显示顶部进度条
colorWeak: boolean // 是否显示顶部进度条
showSettingGuide: boolean // 是否显示设置引导
pageTransition: string // 页面切换动画
tabStyle: string // 标签页风格
menuOpen: boolean // 菜单是否展开
refresh: boolean
watermarkVisible: boolean // 水印是否显示
customRadius: string // 自定义圆角
holidayFireworksLoaded: boolean // 是否加载完礼花
showFestivalText: boolean // 是否显示节日文本
festivalDate: string // 节日日期
dualMenuShowText: boolean // 双列菜单是否显示文本
containerWidth: ContainerWidthEnum // 容器宽度
}
export const useSettingStore = defineStore({
id: 'settingStore',
state: (): SettingState => ({
menuType: MenuTypeEnum.TOP,
menuOpenWidth: defaultMenuWidth,
systemThemeType: SystemThemeEnum.LIGHT,
systemThemeMode: SystemThemeEnum.LIGHT,
menuThemeType: MenuThemeEnum.DESIGN,
boxBorderMode: true,
uniqueOpened: true,
systemThemeColor: AppConfig.elementPlusTheme.primary,
showMenuButton: true,
showRefreshButton: true,
showCrumbs: true,
autoClose: false,
showWorkTab: true,
showLanguage: true,
showNprogress: true,
colorWeak: false,
showSettingGuide: true,
pageTransition: 'slide-right',
tabStyle: defaultTabStyle,
menuOpen: true,
refresh: false,
watermarkVisible: false,
customRadius: defaultCustomRadius,
holidayFireworksLoaded: false,
showFestivalText: false,
festivalDate: '',
dualMenuShowText: false,
containerWidth: ContainerWidthEnum.FULL
}),
getters: {
getMenuTheme(): MenuThemeType {
const list = AppConfig.themeList.filter((item) => item.theme === this.menuThemeType)
if (this.isDark) {
return AppConfig.darkMenuStyles[0]
} else {
return list[0]
}
},
// 是否为暗黑模式
isDark(): boolean {
return this.systemThemeType === SystemThemeEnum.DARK
},
// 获取菜单展开宽度
getMenuOpenWidth(): string {
return this.menuOpenWidth + 'px' || defaultMenuWidth + 'px'
},
// 获取自定义圆角
getCustomRadius(): string {
return this.customRadius + 'rem' || defaultCustomRadius + 'rem'
},
// 节日礼花否显示
isShowFireworks(): boolean {
return this.festivalDate === useCeremony().currentFestivalData.value?.date ? false : true
}
},
actions: {
// 初始化state
initState() {
let sys = getSysStorage()
if (sys) {
sys = JSON.parse(sys)
const { setting } = sys.user
this.menuType = setting.menuType || MenuTypeEnum.TOP
this.menuOpenWidth = Number(setting.menuOpenWidth) || defaultMenuWidth
this.systemThemeType = setting.systemThemeType || SystemThemeEnum.LIGHT
this.systemThemeMode = setting.systemThemeMode || SystemThemeEnum.LIGHT
this.menuThemeType = setting.menuThemeType || MenuThemeEnum.DESIGN
this.containerWidth = setting.containerWidth || ContainerWidthEnum.FULL
this.systemThemeColor = setting.systemThemeColor || AppConfig.elementPlusTheme.primary
this.boxBorderMode = setting.boxBorderMode
this.uniqueOpened = setting.uniqueOpened
this.showMenuButton = setting.showMenuButton
this.showRefreshButton = setting.showRefreshButton
this.showCrumbs = setting.showCrumbs
this.autoClose = setting.autoClose
this.showWorkTab = setting.showWorkTab
this.showLanguage = setting.showLanguage
this.showNprogress = setting.showNprogress
this.colorWeak = setting.colorWeak
this.showSettingGuide = setting.showSettingGuide
this.pageTransition = setting.pageTransition
this.tabStyle = setting.tabStyle || defaultTabStyle
this.menuOpen = setting.menuOpen
this.watermarkVisible = setting.watermarkVisible
this.customRadius = setting.customRadius || defaultCustomRadius
this.holidayFireworksLoaded = setting.holidayFireworksLoaded
this.showFestivalText = setting.showFestivalText
this.festivalDate = setting.festivalDate
this.dualMenuShowText = setting.dualMenuShowText
this.setCustomRadius(this.customRadius)
setElementThemeColor(setting.systemThemeColor)
} else {
this.setCustomRadius(this.customRadius)
setElementThemeColor(AppConfig.elementPlusTheme.primary)
}
},
switchMenuLayouts(type: MenuTypeEnum) {
this.menuType = type
},
setMenuOpenWidth(width: number) {
this.menuOpenWidth = width
},
setGlopTheme(theme: SystemThemeEnum, themeMode: SystemThemeEnum) {
this.systemThemeType = theme
this.systemThemeMode = themeMode
},
switchMenuStyles(theme: MenuThemeEnum) {
this.menuThemeType = theme
},
setElementTheme(theme: string) {
this.systemThemeColor = theme
setElementThemeColor(theme)
},
// 设置盒子模式
setBorderMode() {
this.boxBorderMode = !this.boxBorderMode
},
// 设置容器宽度
setContainerWidth(width: ContainerWidthEnum) {
this.containerWidth = width
},
// 设置菜单是否为手风琴模式
setUniqueOpened() {
this.uniqueOpened = !this.uniqueOpened
},
// 显示侧边栏折叠按钮
setButton() {
this.showMenuButton = !this.showMenuButton
},
// 是否自动关闭个性化设置
setAutoClose() {
this.autoClose = !this.autoClose
},
// 是否显示页面刷新按钮
setShowRefreshButton() {
this.showRefreshButton = !this.showRefreshButton
},
// 是否显示面包屑导航
setCrumbs() {
this.showCrumbs = !this.showCrumbs
},
// 是否显示多标签
setWorkTab(show: boolean) {
this.showWorkTab = show
},
// 是否显示多语言选择
setLanguage() {
this.showLanguage = !this.showLanguage
},
// 是否显示顶部进度条
setNprogress() {
this.showNprogress = !this.showNprogress
},
// 色弱模式
setColorWeak() {
this.colorWeak = !this.colorWeak
},
// 隐藏设置引导
hideSettingGuide() {
this.showSettingGuide = false
},
// 显示设置引导
openSettingGuide() {
this.showSettingGuide = true
},
// 设置页面切换动画
setPageTransition(transition: string) {
this.pageTransition = transition
},
// 设置标签页风格
setTabStyle(style: string) {
this.tabStyle = style
},
// 设置菜单是否展开
setMenuOpen(open: boolean) {
this.menuOpen = open
},
// 刷新当前页
reload() {
this.refresh = !this.refresh
},
// 设置水印是否显示
setWatermarkVisible(visible: boolean) {
this.watermarkVisible = visible
},
// 设置自定义圆角
setCustomRadius(radius: string) {
this.customRadius = radius
document.documentElement.style.setProperty('--custom-radius', `${radius}rem`)
},
// 设置是否加载完礼花
setholidayFireworksLoaded(isLoad: boolean) {
this.holidayFireworksLoaded = isLoad
},
// 设置是否显示节日文本
setShowFestivalText(show: boolean) {
this.showFestivalText = show
},
// 设置节日日期
setFestivalDate(date: string) {
this.festivalDate = date
},
// 设置双列菜单是否显示文本
setDualMenuShowText(show: boolean) {
this.dualMenuShowText = show
}
}
})
function setElementThemeColor(color: string) {
const mixColor = '#ffffff'
const elStyle = document.documentElement.style
elStyle.setProperty('--el-color-primary', color)
handleElementThemeColor(color, useSettingStore().isDark)
// 生成更淡一点的颜色
for (let i = 1; i < 16; i++) {
const itemColor = colourBlend(color, mixColor, i / 16)
elStyle.setProperty(`--el-color-primary-custom-${i}`, itemColor)
}
}
+143
View File
@@ -0,0 +1,143 @@
import { defineStore } from 'pinia'
import { LanguageEnum } from '@/enums/appEnum'
import { router, setPageTitle } from '@/router'
import { UserInfo } from '@/types/store'
import { useSettingStore } from './setting'
import { useWorktabStore } from './worktab'
import { getSysStorage } from '@/utils/storage'
import { MenuListType } from '@/types/menu'
interface UserState {
language: LanguageEnum // 语言
isLogin: boolean // 是否登录
isLock: boolean // 是否锁屏
lockPassword: string // 锁屏密码
info: Partial<UserInfo> // 用户信息
searchHistory: MenuListType[] // 搜索历史
accessToken: string // 添加访问令牌
refreshToken: string // 添加刷新令牌
}
export const useUserStore = defineStore({
id: 'userStore',
state: (): UserState => ({
language: LanguageEnum.ZH,
isLogin: false,
isLock: false,
lockPassword: '',
info: {},
searchHistory: [],
accessToken: '',
refreshToken: ''
}),
getters: {
getUserInfo(): Partial<UserInfo> {
return this.info
},
getSettingState() {
return useSettingStore().$state
},
getWorktabState() {
return useWorktabStore().$state
}
},
actions: {
initState() {
let sys = getSysStorage()
if (sys) {
sys = JSON.parse(sys)
const { info, isLogin, language, searchHistory, isLock, lockPassword, refreshToken } =
sys.user
this.info = info || {}
this.isLogin = isLogin || false
this.isLock = isLock || false
this.language = language || LanguageEnum.ZH
this.searchHistory = searchHistory || []
this.lockPassword = lockPassword || ''
this.refreshToken = refreshToken || ''
this.accessToken = sessionStorage.getItem('accessToken') || ''
}
},
// 用户数据持久化存储
saveUserData() {
saveStoreStorage({
user: {
info: this.info,
isLogin: this.isLogin,
language: this.language,
isLock: this.isLock,
lockPassword: this.lockPassword,
searchHistory: this.searchHistory,
refreshToken: this.refreshToken,
worktab: this.getWorktabState,
setting: this.getSettingState
}
})
},
setUserInfo(info: UserInfo) {
this.info = info
},
setLoginStatus(isLogin: boolean) {
this.isLogin = isLogin
// 登录状态改变时立即保存
this.saveUserData()
},
setLanguage(lang: LanguageEnum) {
setPageTitle(router.currentRoute.value)
this.language = lang
},
setSearchHistory(list: Array<MenuListType>) {
this.searchHistory = list
},
setLockStatus(isLock: boolean) {
this.isLock = isLock
},
setLockPassword(password: string) {
this.lockPassword = password
},
setToken(accessToken: string, refreshToken?: string) {
this.accessToken = accessToken
if (refreshToken) {
this.refreshToken = refreshToken
}
sessionStorage.setItem('accessToken', accessToken)
this.saveUserData()
},
logOut() {
setTimeout(() => {
this.info = {}
this.isLogin = false
this.isLock = false
this.lockPassword = ''
this.accessToken = ''
this.refreshToken = ''
sessionStorage.removeItem('accessToken')
useWorktabStore().opened = []
this.saveUserData()
sessionStorage.removeItem('iframeRoutes')
router.push('/login')
}, 300)
}
}
})
function initVersion(version: string) {
const vs = localStorage.getItem('version')
if (!vs) {
localStorage.setItem('version', version)
}
}
// 数据持久化存储
function saveStoreStorage<T>(newData: T) {
const version = import.meta.env.VITE_VERSION
initVersion(version)
const vs = localStorage.getItem('version') || version
const storedData = JSON.parse(localStorage.getItem(`sys-v${vs}`) || '{}')
// 合并新数据与现有数据
const mergedData = { ...storedData, ...newData }
localStorage.setItem(`sys-v${vs}`, JSON.stringify(mergedData))
}
+190
View File
@@ -0,0 +1,190 @@
import { defineStore } from 'pinia'
import { WorkTabType } from '@/types/store'
import { HOME_PAGE } from '@/router/index'
import { router } from '@/router'
import { getSysStorage } from '@/utils/storage'
interface WorktabState {
opened: WorkTabType[]
current: Partial<WorkTabType>
keepAliveExclude: string[]
}
export const useWorktabStore = defineStore({
id: 'worktabStore',
state: (): WorktabState => ({
current: {},
opened: [],
keepAliveExclude: []
}),
actions: {
/**
* 初始化状态,从系统存储中加载工作台配置
*/
initState() {
const sysStorage = getSysStorage()
if (sysStorage) {
const sys = JSON.parse(sysStorage)
const { worktab } = sys.user
this.current = worktab.current || {}
this.opened = worktab.opened || []
this.checkFirstHomePage()
}
},
/**
* 打开或激活一个选项卡
* @param tab 目标选项卡信息
*/
openTab(tab: WorkTabType): void {
this.removeKeepAliveExclude(tab.name as string)
const index = this.opened.findIndex((item) => item.path === tab.path)
if (index === -1) {
this.opened.push({ ...tab })
} else {
const existingTab = this.opened[index]
if (!this.areQueriesEqual(existingTab.query, tab.query)) {
this.opened[index] = {
...existingTab,
query: tab.query,
// 可选:支持更多属性更新
title: tab.title || existingTab.title
}
}
}
this.current = this.opened[index === -1 ? this.opened.length - 1 : index]
},
// 辅助函数
areQueriesEqual(query1: any, query2: any): boolean {
return JSON.stringify(query1) === JSON.stringify(query2)
},
/**
* 关闭指定的选项卡,并处理激活状态和路由跳转
* @param path 要关闭的路由路径
*/
removeTab(path: string) {
const noCurrentTab = this.opened.find((tab) => tab.path === path)
const index = this.opened.findIndex((tab) => tab.path === path)
if (index === -1) return
this.opened.splice(index, 1)
// 若关闭后无选项卡,且关闭的不是首页,则跳转首页
if (!this.opened.length && path !== HOME_PAGE) {
router.push(HOME_PAGE)
return
}
// 若关闭的是当前激活标签,则标记其为缓存排除,并激活相邻标签
if (this.current.path === path) {
if (this.current.name) {
this.addKeepAliveExclude(this.current as WorkTabType)
}
const newIndex = index >= this.opened.length ? this.opened.length - 1 : index
this.current = this.opened[newIndex]
router.push(this.current.path as string)
} else {
if (noCurrentTab?.name) {
this.addKeepAliveExclude(noCurrentTab)
}
}
},
/**
* 关闭当前标签左侧(不包括首页)的所有选项卡
* @param path 当前选项卡的路由路径
*/
removeLeft(path: string) {
const index = this.opened.findIndex((tab) => tab.path === path)
if (index > 1) {
// 保留首页和当前标签
const tabsToRemove = this.opened.slice(1, index)
this.markTabsToRemove(tabsToRemove)
this.opened.splice(1, index - 1)
}
},
/**
* 关闭当前标签右侧的所有选项卡
* @param path 当前选项卡的路由路径
*/
removeRight(path: string) {
const index = this.opened.findIndex((tab) => tab.path === path)
if (index !== -1 && index < this.opened.length - 1) {
const tabsToRemove = this.opened.slice(index + 1)
this.markTabsToRemove(tabsToRemove)
this.opened.splice(index + 1)
}
},
/**
* 关闭除当前标签和首页外的所有选项卡
* @param path 当前选项卡的路由路径
*/
removeOthers(path: string) {
const tabsToRemove = this.opened.filter((tab) => tab.path !== path && tab.path !== HOME_PAGE)
this.markTabsToRemove(tabsToRemove)
this.opened = this.opened.filter((tab) => tab.path === path || tab.path === HOME_PAGE)
},
/**
* 关闭所有选项卡(当传入的 path 不是首页时关闭全部;首页时只保留首页)
* @param path 当前选项卡的路由路径
*/
removeAll(path: string) {
if (path !== HOME_PAGE) {
this.markTabsToRemove(this.opened)
this.current = {}
this.opened = []
router.push(HOME_PAGE)
} else {
const tabsToRemove = this.opened.filter((tab) => tab.path !== HOME_PAGE)
this.markTabsToRemove(tabsToRemove)
this.opened = this.opened.filter((tab) => tab.path === HOME_PAGE)
if (this.opened.length === 0) router.push(HOME_PAGE)
}
},
/**
* 检查第一个选项卡是否为首页,否则清空所有标签并跳转首页
*/
checkFirstHomePage() {
if (this.opened.length && this.opened[0].path !== HOME_PAGE) {
this.removeAll(HOME_PAGE)
}
},
/**
* 将指定选项卡添加到 keepAlive 排除列表中,只有当该选项卡的 keepAlive 为 true 时才进行添加
* @param tab 选项卡对象
*/
addKeepAliveExclude(tab: WorkTabType) {
if (tab.keepAlive && tab.name && !this.keepAliveExclude.includes(tab.name)) {
this.keepAliveExclude.push(tab.name)
}
},
/**
* 从 keepAlive 排除列表中移除指定组件名称
* @param name 路由组件名称
*/
removeKeepAliveExclude(name: string) {
this.keepAliveExclude = this.keepAliveExclude.filter((item) => item !== name)
},
/**
* 将传入的一组选项卡的组件名称标记为排除缓存
* @param tabs 需要标记的选项卡数组
*/
markTabsToRemove(tabs: WorkTabType[]) {
tabs.forEach((tab) => {
if (tab.name) {
this.addKeepAliveExclude(tab)
}
})
}
}
})