- 新增地址编辑页面,支持地址智能识别、地图选点、地区选择和默认地址设置 - 实现地址列表页面,支持地址查看、删除、设为默认及选择返回结算页 - 新增售后申请页面,支持退款类型选择、商品选择、原因填写、图片上传和提交审核 - 修复 passport 分包配置,移除不存在分包并补充缺失声明,避免 Taro 编译报错 - 新增地址类型定义,增强前端地址数据结构类型安全 - 优化页面交互体验,完善表单校验及错误提示逻辑 - 统一代码格式与命名规范,保持代码风格一致性
43 lines
874 B
TypeScript
43 lines
874 B
TypeScript
import { useContext } from 'react'
|
|
import AppContext from '@/contexts/AppContext'
|
|
|
|
export interface ThemeConfig {
|
|
/** 当前主题 */
|
|
theme: 'light' | 'dark'
|
|
/** 是否为深色模式 */
|
|
isDark: boolean
|
|
/** 是否为浅色模式 */
|
|
isLight: boolean
|
|
/** 切换主题 */
|
|
toggleTheme: () => void
|
|
/** 设置为浅色主题 */
|
|
setLight: () => void
|
|
/** 设置为深色主题 */
|
|
setDark: () => void
|
|
}
|
|
|
|
/**
|
|
* 主题 Hook
|
|
* 从 AppContext 获取主题状态和切换函数
|
|
*/
|
|
export const useTheme = (): ThemeConfig => {
|
|
const { theme, toggleTheme } = useContext(AppContext)
|
|
|
|
const setLight = () => {
|
|
if (theme !== 'light') toggleTheme()
|
|
}
|
|
|
|
const setDark = () => {
|
|
if (theme !== 'dark') toggleTheme()
|
|
}
|
|
|
|
return {
|
|
theme,
|
|
isDark: theme === 'dark',
|
|
isLight: theme === 'light',
|
|
toggleTheme,
|
|
setLight,
|
|
setDark,
|
|
}
|
|
}
|