diff --git a/index.html b/index.html index e8c39c0..c1570df 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,15 @@ - + - - yuto-water-h5 + + 舆图智慧水务
+ + diff --git a/package-lock.json b/package-lock.json index 4b95b16..5cb5df8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,8 @@ "supercluster": "^8.0.1", "uuid": "^14.0.0", "vant": "^4.9.24", - "vue": "^3.5.34" + "vue": "^3.5.34", + "vue-router": "^4.6.4" }, "devDependencies": { "@types/node": "^24.12.3", @@ -5035,6 +5036,27 @@ } } }, + "node_modules/vue-router": { + "version": "4.6.4", + "resolved": "http://mirrors.tencentyun.com/npm/vue-router/-/vue-router-4.6.4.tgz", + "integrity": "sha512-Hz9q5sa33Yhduglwz6g9skT8OBPii+4bFn88w6J+J4MfEo4KRRpmiNG/hHHkdbRFlLBOqxN8y8gf2Fb0MTUgVg==", + "license": "MIT", + "dependencies": { + "@vue/devtools-api": "^6.6.4" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "vue": "^3.5.0" + } + }, + "node_modules/vue-router/node_modules/@vue/devtools-api": { + "version": "6.6.4", + "resolved": "http://mirrors.tencentyun.com/npm/@vue/devtools-api/-/devtools-api-6.6.4.tgz", + "integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==", + "license": "MIT" + }, "node_modules/vue-tsc": { "version": "3.3.5", "dev": true, diff --git a/package.json b/package.json index c2832d2..5527d59 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "supercluster": "^8.0.1", "uuid": "^14.0.0", "vant": "^4.9.24", - "vue": "^3.5.34" + "vue": "^3.5.34", + "vue-router": "^4.6.4" }, "devDependencies": { "@types/node": "^24.12.3", diff --git a/public/config/globalConfig.dev.js b/public/config/globalConfig.dev.js new file mode 100644 index 0000000..7226831 --- /dev/null +++ b/public/config/globalConfig.dev.js @@ -0,0 +1,148 @@ +/** + * @Description: 全局配置(开发环境) + * + * 此文件在 index.html 中通过 + + diff --git a/src/api/common.ts b/src/api/common.ts new file mode 100644 index 0000000..90a98b1 --- /dev/null +++ b/src/api/common.ts @@ -0,0 +1,139 @@ +/** + * 通用 API + * + * 包含文件上传、字典查询、验证码获取、系统配置等公共接口。 + * + * @module api/common + */ + +import { post, get } from '@/utils/http' + +// ══════════════════════════════════════════════ +// 请求参数类型 +// ══════════════════════════════════════════════ + +/** 文件上传响应 */ +export interface UploadResult { + /** 文件在服务器上的存储名称 */ + fileName: string + /** 文件可访问的完整 URL */ + url: string +} + +/** 字典项 */ +export interface DictItem { + /** 字典标签(显示用) */ + dictLabel: string + /** 字典值(存储用) */ + dictValue: string + /** 字典类型 */ + dictType?: string + /** CSS 类名(用于表格回显样式) */ + cssClass?: string + /** 列表样式 */ + listClass?: string + /** 是否默认 */ + isDefault?: string + /** 排序号 */ + dictSort?: number +} + +/** 验证码图片响应 */ +export interface CaptchaResult { + /** 验证码唯一标识,登录时需要回传 */ + uuid: string + /** Base64 编码的验证码图片 */ + img: string + /** 是否开启验证码 */ + captchaEnabled: boolean +} + +/** 系统配置项 */ +export interface ConfigItem { + /** 参数键名 */ + configKey: string + /** 参数值 */ + configValue: string +} + +// ══════════════════════════════════════════════ +// API 方法 +// ══════════════════════════════════════════════ + +/** + * 上传文件 + * + * 支持图片、文档等文件上传,使用 FormData 格式。 + * + * @param file - 要上传的文件对象 + * @returns 上传结果,包含文件名和访问 URL + */ +export function uploadFile(file: File): Promise { + const formData = new FormData() + formData.append('file', file) + + return post('/common/upload', formData, { + headers: { 'Content-Type': 'multipart/form-data' }, + }) +} + +/** + * 批量上传文件 + * @param files - 文件对象数组 + * @returns 上传结果数组 + */ +export async function uploadFiles(files: File[]): Promise { + const results: UploadResult[] = [] + for (const file of files) { + const result = await uploadFile(file) + results.push(result) + } + return results +} + +/** + * 获取字典数据 + * + * 根据字典类型查询对应的字典项列表,用于下拉框、单选框等组件的数据源。 + * + * @param dictType - 字典类型标识,如 'sys_user_sex' + * @returns 字典项数组 + */ +export function getDictData(dictType: string): Promise { + return get('/system/dict/data/type', { dictType }) +} + +/** + * 根据字典类型获取字典数据(RESTful 风格) + * @param dictType - 字典类型标识 + * @returns 字典项数组 + */ +export function getDictDataByType(dictType: string): Promise { + return get(`/system/dict/data/type/${dictType}`) +} + +/** + * 获取验证码图片 + * @returns 验证码信息(uuid 和 base64 图片) + */ +export function getCaptcha(): Promise { + return get('/captchaImage') +} + +/** + * 根据配置键获取系统配置值 + * @param configKey - 配置键名 + * @returns 配置项的值 + */ +export function getConfigValue(configKey: string): Promise { + return get(`/system/config/configKey/${configKey}`) +} + +/** + * 获取系统配置项详情 + * @param configKey - 配置键名 + * @returns 配置项完整信息 + */ +export function getConfigItem(configKey: string): Promise { + return get(`/system/config/configKey/${configKey}`) +} diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..a716ca1 --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,43 @@ +/** + * API 模块聚合入口 + * + * 统一导出所有 API 子模块的方法和类型,业务代码只需 + * `import { login, getUserInfo } from '@/api'` 即可使用。 + * + * @module api + */ + +// ── 用户模块 ── +export { + login, + getUserInfo, + logout, + resetPassword, +} from './user' +export type { + LoginParams, + LoginResult, + ResetPasswordParams, + UserInfo, +} from './user' + +// ── 通用模块 ── +export { + uploadFile, + uploadFiles, + getDictData, + getDictDataByType, + getCaptcha, + getConfigValue, + getConfigItem, +} from './common' +export type { + UploadResult, + DictItem, + CaptchaResult, + ConfigItem, +} from './common' + +// ── HTTP 工具(便捷导出) ── +export { getToken, setToken, removeToken } from '@/utils/http' +export type { ApiResponse } from '@/utils/http' diff --git a/src/api/user.ts b/src/api/user.ts new file mode 100644 index 0000000..cf1478a --- /dev/null +++ b/src/api/user.ts @@ -0,0 +1,105 @@ +/** + * 用户相关 API + * + * 包含登录、获取用户信息、退出登录、重置密码等用户模块接口。 + * + * @module api/user + */ + +import { post, get } from '@/utils/http' + +// ══════════════════════════════════════════════ +// 请求参数类型 +// ══════════════════════════════════════════════ + +/** 登录请求参数 */ +export interface LoginParams { + /** 用户名 */ + username: string + /** 密码 */ + password: string + /** 验证码 */ + code?: string + /** 验证码唯一标识 */ + uuid?: string +} + +/** 重置密码请求参数 */ +export interface ResetPasswordParams { + /** 旧密码 */ + oldPassword: string + /** 新密码 */ + newPassword: string +} + +// ══════════════════════════════════════════════ +// 响应数据类型 +// ══════════════════════════════════════════════ + +/** 登录返回结果 */ +export interface LoginResult { + /** 认证 Token */ + token: string +} + +/** 用户信息 */ +export interface UserInfo { + /** 用户 ID */ + userId: string | number + /** 用户名 */ + userName: string + /** 昵称 */ + nickName: string + /** 头像地址 */ + avatar: string + /** 手机号 */ + phonenumber?: string + /** 邮箱 */ + email?: string + /** 性别(0-男 1-女 2-未知) */ + sex?: string + /** 部门名称 */ + deptName?: string + /** 角色列表 */ + roles?: string[] + /** 权限列表 */ + permissions?: string[] +} + +// ══════════════════════════════════════════════ +// API 方法 +// ══════════════════════════════════════════════ + +/** + * 用户登录 + * @param params - 登录参数(用户名、密码、验证码等) + * @returns 返回包含 Token 的登录结果 + */ +export function login(params: LoginParams): Promise { + return post('/login', params) +} + +/** + * 获取当前登录用户信息 + * @returns 用户详细信息 + */ +export function getUserInfo(): Promise { + return get('/getInfo') +} + +/** + * 退出登录 + * @returns Promise + */ +export function logout(): Promise { + return post('/logout') +} + +/** + * 重置密码 + * @param params - 旧密码和新密码 + * @returns Promise + */ +export function resetPassword(params: ResetPasswordParams): Promise { + return post('/system/user/profile/resetPwd', params) +} diff --git a/src/config/types.ts b/src/config/types.ts new file mode 100644 index 0000000..bb05c05 --- /dev/null +++ b/src/config/types.ts @@ -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 + /** 地图加载类型配置 */ + loadMapType: string + /** 其他扩展配置(预留字段) */ + [key: string]: unknown +} + +// ══════════════════════════════════════════════ +// Window 接口扩展 +// ══════════════════════════════════════════════ + +declare global { + interface Window { + /** + * 运行时全局配置对象 + * + * 由 public/config/globalConfig.js 在 index.html 中通过 + * ` + + + + diff --git a/src/views/login/index.vue b/src/views/login/index.vue new file mode 100644 index 0000000..ceed395 --- /dev/null +++ b/src/views/login/index.vue @@ -0,0 +1,153 @@ + + + + + diff --git a/src/views/mine/index.vue b/src/views/mine/index.vue new file mode 100644 index 0000000..2898dd7 --- /dev/null +++ b/src/views/mine/index.vue @@ -0,0 +1,77 @@ + + + + +