feat: Phase 3 - API layer + Pinia stores + app integration
- HTTP client (axios interceptors, token mgmt, typed APIs) - Pinia stores: token, user (login/logout), app (dark mode, sidebar) - globalConfig TS types + Window augmentation - Vue Router (hash history, auth guard) - Login/Home/Mine pages (Vant UI) - Vant integration + globalConfig dev script - Build passes (vue-tsc + vite)
This commit is contained in:
167
src/config/types.ts
Normal file
167
src/config/types.ts
Normal file
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* 全局配置类型声明
|
||||
*
|
||||
* 声明 window.globalConfig 的完整 TypeScript 类型,
|
||||
* 该配置由 public/config/globalConfig.js 在页面加载时注入。
|
||||
* 同时扩展 Window 接口,使得 TypeScript 能够正确识别
|
||||
* window.globalConfig 及其子属性。
|
||||
*
|
||||
* @module config/types
|
||||
*/
|
||||
|
||||
// ══════════════════════════════════════════════
|
||||
// 全局配置子模块类型
|
||||
// ══════════════════════════════════════════════
|
||||
|
||||
/** 系统基础配置 */
|
||||
export interface SystemConfig {
|
||||
/** 系统名称(登录页、系统左上角展示) */
|
||||
name: string
|
||||
/** 系统编码(在集成管控平台中的子系统编码) */
|
||||
id: string
|
||||
/** Bucket 名称(用于图片等静态资源存储) */
|
||||
buckName: string
|
||||
/** 系统版本号 */
|
||||
version: string
|
||||
/** 系统 Logo 地址 */
|
||||
logo?: string
|
||||
/** 系统首页标题 */
|
||||
homeTitle?: string
|
||||
/** 系统描述 */
|
||||
description?: string
|
||||
}
|
||||
|
||||
/** API 接口配置 */
|
||||
export interface ApiConfig {
|
||||
/** API 后端基础地址 */
|
||||
baseURL: string
|
||||
/** API 主机地址(图片上传下载等场景) */
|
||||
host: string
|
||||
/** WebSocket 连接地址 */
|
||||
wsURL?: string
|
||||
/** 请求超时时间(毫秒) */
|
||||
timeout?: number
|
||||
}
|
||||
|
||||
/** 地图服务配置 */
|
||||
export interface MapConfig {
|
||||
/** 地图类型(如 'tdt' 天地图、'amap' 高德、'baidu' 百度) */
|
||||
type: string
|
||||
/** 地图服务地址 */
|
||||
url: string
|
||||
/** 地图默认中心点坐标 [经度, 纬度] */
|
||||
center?: [number, number]
|
||||
/** 地图默认缩放级别 */
|
||||
zoom?: number
|
||||
/** 地图最大缩放级别 */
|
||||
maxZoom?: number
|
||||
/** 地图最小缩放级别 */
|
||||
minZoom?: number
|
||||
/** 地图瓦片地址 */
|
||||
tileUrl?: string
|
||||
/** 天地图 Key(type 为 tdt 时使用) */
|
||||
tdtKey?: string
|
||||
/** 地图样式地址 */
|
||||
styleUrl?: string
|
||||
/** 是否开启地图注记 */
|
||||
label?: boolean
|
||||
}
|
||||
|
||||
/** 管网配置 */
|
||||
export interface PipeConfig {
|
||||
/** 管网数据服务地址 */
|
||||
url?: string
|
||||
/** 管网默认图层 */
|
||||
defaultLayer?: string
|
||||
/** 管网高亮颜色 */
|
||||
highlightColor?: string
|
||||
/** 管网选中颜色 */
|
||||
selectedColor?: string
|
||||
/** 管道直径范围 */
|
||||
diameterRange?: [number, number]
|
||||
/** 是否展示管网标注 */
|
||||
showLabel?: boolean
|
||||
/** 管网数据版本 */
|
||||
version?: string
|
||||
}
|
||||
|
||||
/** 打卡配置 */
|
||||
export interface ClockInConfig {
|
||||
/** 打卡范围半径(米) */
|
||||
radius?: number
|
||||
/** 打卡地点列表 */
|
||||
locations?: Array<{
|
||||
/** 地点名称 */
|
||||
name: string
|
||||
/** 经度 */
|
||||
lng: number
|
||||
/** 纬度 */
|
||||
lat: number
|
||||
/** 有效范围半径(米) */
|
||||
radius?: number
|
||||
}>
|
||||
/** 是否开启拍照打卡 */
|
||||
needPhoto?: boolean
|
||||
/** 是否开启定位验证 */
|
||||
needLocation?: boolean
|
||||
/** 打卡时间限制(如 '09:00-18:00') */
|
||||
timeRange?: string
|
||||
}
|
||||
|
||||
/** 新简易运维系统配置 */
|
||||
export interface XjyhSysConfig {
|
||||
/** 是否启用新简易运维 */
|
||||
enabled?: boolean
|
||||
/** 运维系统地址 */
|
||||
url?: string
|
||||
/** 运维系统 AppId */
|
||||
appId?: string
|
||||
/** 运维系统密钥 */
|
||||
secret?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局配置对象类型
|
||||
*
|
||||
* 由 public/config/globalConfig.js 在页面加载时注入到
|
||||
* window.globalConfig,并在应用启动时通过接口获取远程配置
|
||||
* 进行合并。
|
||||
*/
|
||||
export interface GlobalConfig {
|
||||
/** 系统基础配置 */
|
||||
system: SystemConfig
|
||||
/** API 接口配置 */
|
||||
api: ApiConfig
|
||||
/** 地图服务配置 */
|
||||
map: MapConfig
|
||||
/** 管网配置 */
|
||||
pipe: PipeConfig
|
||||
/** 打卡配置 */
|
||||
clockIn: ClockInConfig
|
||||
/** 新简易运维系统配置 */
|
||||
xjyhSys: XjyhSysConfig
|
||||
/** 设备类型配置(key 为类型编码,value 为类型名称) */
|
||||
sbType: Record<string, string>
|
||||
/** 地图加载类型配置 */
|
||||
loadMapType: string
|
||||
/** 其他扩展配置(预留字段) */
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
// ══════════════════════════════════════════════
|
||||
// Window 接口扩展
|
||||
// ══════════════════════════════════════════════
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
/**
|
||||
* 运行时全局配置对象
|
||||
*
|
||||
* 由 public/config/globalConfig.js 在 index.html 中通过
|
||||
* `<script>` 标签注入,前端启动时合并远程配置后使用。
|
||||
*/
|
||||
globalConfig: GlobalConfig
|
||||
}
|
||||
}
|
||||
|
||||
export {}
|
||||
Reference in New Issue
Block a user