diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index 8142a93..d42be7c 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -722,6 +722,40 @@ const local: any = { plemac:'Please enter MAC address', search:'Search', reset:'Reset', + editConfig:'Edit config', + forget:'Forget device', + restart:'Restart device', + adopt:'Adopt device', + addDevice:'Add device', + sn:'Site name', + name:'Device name(optional)', + username:'Device username(optional)', + password:'Device password(optional)', + snFormatError:'A-Z or 13-bit characters from 0-9', + nameFormatError:'Cannot start with space, +、-、@, = characters,cannot end with space, the length is between 1-128', + forgetConfirm:'Are you sure you want to forget your device?', + restartConfirm:'Are you sure you want to restart your device?', + led:'LED', + useSiteSettings:'Site settings', + on:'On', + off:'Off', + longitude:'Longitude(optional)', + latitude:'Latitude(optional)', + address:'Address(optional)', + plesearch:'Search Devicename,IP,Model', + selectSite:'No site', + adoptSuccess:'Adopt success', + adoptError:'Adopt error', + forgetSuccess:'Forget success', + forgetError:'Forget error', + getConfigError:'Get config error', + snRequired:'Site name', + addSuccess:'Add success', + addError:'Add error', + longitudeError:'Longitude error', + latitudeError:'latitude error', + configSuccess:'Config success', + configError:'config error', }, terminal:{ title:'Terminal', diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index ca8f907..734b319 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -722,6 +722,41 @@ const local:any = { plemac:'请输入MAC地址', search:'搜索', reset:'重置', + editConfig:'修改配置', + forget:'忘记设备', + restart:'重启设备', + adopt:'纳管设备', + addDevice:'增加设备', + sn:'站点名称', + name:'设备名称', + username:'设备用户名', + password:'密码', + snFormatError:'A-Z 或 0-9 的 13 位字符', + nameFormatError:'不能以空格、+、-、@、=字符开头,不能以空格结尾,长度在 1-128 之间', + forgetConfirm:'确认要忘记设备吗?', + restartConfirm:'确认要重启设备吗?', + led:'LED', + useSiteSettings:'站点设置', + on:'打开', + off:'关闭', + longitude:'经度(可选)', + latitude:'纬度(可选)', + address:'地址(可选)', + plesearch:'搜索设备名字,站点名字,IP,型号', + selectSite:'无站点', + adoptSuccess:'纳管成功', + adoptError:'纳管失败', + forgetSuccess:'忘记设备成功', + forgetError:'忘记设备失败', + getConfigError:'获取配置失败', + snRequired:'站点名称', + addSuccess:'添加成功', + addError:'添加失败', + longitudeError:'经度错误', + latitudeError:'纬度错误', + configSuccess:'配置成功', + configError:'配置失败', + }, terminal:{ title:'终端设备', diff --git a/src/service/api/auth.ts b/src/service/api/auth.ts index cfee37e..51dada2 100644 --- a/src/service/api/auth.ts +++ b/src/service/api/auth.ts @@ -164,9 +164,9 @@ export function fetchBillList(params: Api.Auth.BillParams) { }); } /** 获取AP设备列表 */ -export function fetchApDeviceList(params: Api.Device.ApDeviceParams) { +export function fetchApDeviceList(siteId: string, params: Omit) { return request({ - url: '/system/device/list', + url: `/system/device/page/${siteId}`, method: 'get', params }); @@ -246,6 +246,69 @@ export function rejectKyc(id: string, userId: number, reason: string) { } }); } +/** 忘记 AP 设备 */ +export function forgetApDevice(siteId: string, deviceMac: string) { + return request({ + url: `/system/device/forget/${siteId}/${deviceMac}`, + method: 'post' + }); +} +/** 添加 AP 设备 */ +export function addApDevice(siteId: string, params: Api.Device.AddApDeviceItem) { + // 确保始终发送包含 devices 数组的请求体 + const requestData: Api.Device.AddApDeviceParams = { + devices: [params] // 即使 params 是空对象,也会发送 { devices: [{}] } + }; + + return request({ + url: `/system/device/add/${siteId}`, + method: 'post', + data: requestData + }); +} +/** 获取站点列表 */ +export function fetchSiteList(params: Api.Site.SiteParams) { + return request({ + url: '/system/site/page', + method: 'get', + params: { + pageNum: params.pageNum, + pageSize: params.pageSize + } + }); +} +/** 更新 AP 设备配置 */ +export function updateApDeviceConfig(siteId: string, mac: string, config: Api.Device.ApDeviceConfigUpdate) { + return request({ + url: `/system/device/updateConfig/${siteId}/${mac}`, + method: 'post', + data: config + }); +} +/** 获取 AP 设备配置 */ +export function getApDeviceConfig(siteId: string, deviceMac: string) { + return request({ + url: `/system/device/getConfig/${siteId}/${deviceMac}`, + method: 'post' + }); +} +/** 纳管 AP 设备 */ +export function adoptApDevice(siteId: string, deviceMac: string, params?: { username?: string; password?: string }) { + return request({ + url: `/system/device/startAdopt/${siteId}/${deviceMac}`, + method: 'post', + data: params + }); +} +/** 获取 WLAN 群组列表 */ +export function fetchWlanGroups(siteId: string) { + return request({ + url: `/system/wlan/group/${siteId}`, + method: 'get' + }); +} + + diff --git a/src/typings/api.d.ts b/src/typings/api.d.ts index 7cb27b1..ece33fa 100644 --- a/src/typings/api.d.ts +++ b/src/typings/api.d.ts @@ -540,21 +540,41 @@ declare namespace Api { namespace Device { interface ApDevice { - id: number; mac: string; - ip: string; name: string; - status: number; + type: string; + subtype: string | null; + deviceSeriesType: number; model: string; + ip: string; + ipv6: string | null; uptime: string; - createBy: string | null; - createTime: string; - updateBy: string | null; - updateTime: string | null; - operate?: string; + status: number; + lastSeen: number; + cpuUtil: number; + memUtil: number; + sn: string; + licenseStatus: number; + tagName: string | null; + uplinkDeviceMac: string | null; + uplinkDeviceName: string | null; + uplinkDevicePort: string | null; + linkSpeed: string | null; + duplex: string | null; + switchConsistent: boolean; + publicIp: string; + firmwareVersion: string; + } + interface ApDeviceListData { + total: number; + rows: ApDevice[]; } - type ApDeviceResponse = App.Service.Response>; + interface ApDeviceResponse { + code: number; + msg: string; + data: ApDeviceListData; + } interface ApDeviceParams { pageNum: number; @@ -591,6 +611,62 @@ declare namespace Api { clientDeviceType?: string; clientMac?: string; } + /** AP设备添加参数 */ + interface AddApDeviceItem { + sn?: string; + name?: string; + username?: string; + password?: string; + } + interface AddApDeviceParams { + devices: AddApDeviceItem[]; + } + interface ApDeviceLocation { + longitude: number; + latitude: number; + address: string; + } + + interface ApDeviceConfigData { + name: string; + ledSetting: number; + tagIds: string[]; + location: ApDeviceLocation; + } + + interface ApDeviceConfigResponse { + code: number; + msg: string; + data: { + name: string; + ledSetting: number; + tagIds: string[]; + location: { + longitude: number; + latitude: number; + address: string; + } + }|null; + } + + interface ApDeviceConfigUpdate { + name?: string; + ledSetting?: number; + tagIds?: string[]; + location?: { + longitude?: number; + latitude?: number; + address?: string; + } + } + interface ApDeviceConfigForm { + name: string; + ledSetting: number; + tagIds?: string[]; + longitude?: number; + latitude?: number; + address?: string; + } } namespace Billing { @@ -696,4 +772,49 @@ declare namespace Api { total: number; } } + namespace Site { + interface SiteInfo { + siteId: string; + name: string; + tagIds: string[]; + region: string; + timeZone: string; + scenario: string; + longitude: number | null; + latitude: number | null; + address: string | null; + type: number; + supportES: boolean; + supportL2: boolean; + } + + interface SiteParams { + pageNum: number; + pageSize: number; + } + + interface SiteListData { + total: number; + rows: SiteInfo[]; + } + + interface SiteResponse { + code: number; + msg: string; + data: SiteListData; + } + } + namespace Wlan { + interface WlanGroup { + wlanId: string; + name: string; + primary: boolean; + } + + interface WlanGroupResponse { + code: number; + msg: string; + data: WlanGroup[]; + } + } } diff --git a/src/typings/auto-imports.d.ts b/src/typings/auto-imports.d.ts index 2b589f5..dc09ea3 100644 --- a/src/typings/auto-imports.d.ts +++ b/src/typings/auto-imports.d.ts @@ -10,11 +10,13 @@ declare global { const $notification: typeof import('ant-design-vue')['notification'] const EffectScope: typeof import('vue')['EffectScope'] const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate'] + const addApDevice: typeof import('../service/api/auth')['addApDevice'] const addData: typeof import('../service/api/dictData')['addData'] const addJob: typeof import('../service/api/job')['addJob'] const addPackage: typeof import('../service/api/auth')['addPackage'] const addRateLimit: typeof import('../service/api/auth')['addRateLimit'] const addThemeVarsToHtml: typeof import('../store/modules/theme/shared')['addThemeVarsToHtml'] + const adoptApDevice: typeof import('../service/api/auth')['adoptApDevice'] const afterAll: typeof import('vitest')['afterAll'] const afterEach: typeof import('vitest')['afterEach'] const approveKyc: typeof import('../service/api/auth')['approveKyc'] @@ -141,17 +143,21 @@ declare global { const fetchRateLimitList: typeof import('../service/api/auth')['fetchRateLimitList'] const fetchRefreshToken: typeof import('../service/api/auth')['fetchRefreshToken'] const fetchRegister: typeof import('../service/api/auth')['fetchRegister'] + const fetchSiteList: typeof import('../service/api/auth')['fetchSiteList'] const fetchTerminalList: typeof import('../service/api/auth')['fetchTerminalList'] + const fetchWlanGroups: typeof import('../service/api/auth')['fetchWlanGroups'] const filterAuthRoutesByRoles: typeof import('../store/modules/route/shared')['filterAuthRoutesByRoles'] const filterTabsById: typeof import('../store/modules/tab/shared')['filterTabsById'] const filterTabsByIds: typeof import('../store/modules/tab/shared')['filterTabsByIds'] const findTabByRouteName: typeof import('../store/modules/tab/shared')['findTabByRouteName'] + const forgetApDevice: typeof import('../service/api/auth')['forgetApDevice'] const formatBandwidth: typeof import('../utils/units')['formatBandwidth'] const formatStorage: typeof import('../utils/units')['formatStorage'] const formatTime: typeof import('../utils/units')['formatTime'] const getActivePinia: typeof import('pinia')['getActivePinia'] const getAllTabs: typeof import('../store/modules/tab/shared')['getAllTabs'] const getAntdTheme: typeof import('../store/modules/theme/shared')['getAntdTheme'] + const getApDeviceConfig: typeof import('../service/api/auth')['getApDeviceConfig'] const getBreadcrumbsByRoute: typeof import('../store/modules/route/shared')['getBreadcrumbsByRoute'] const getCacheRouteNames: typeof import('../store/modules/route/shared')['getCacheRouteNames'] const getCurrentInstance: typeof import('vue')['getCurrentInstance'] @@ -283,6 +289,7 @@ declare global { const unref: typeof import('vue')['unref'] const unrefElement: typeof import('@vueuse/core')['unrefElement'] const until: typeof import('@vueuse/core')['until'] + const updateApDeviceConfig: typeof import('../service/api/auth')['updateApDeviceConfig'] const updateBillRule: typeof import('../service/api/auth')['updateBillRule'] const updateData: typeof import('../service/api/dictData')['updateData'] const updateJob: typeof import('../service/api/job')['updateJob'] diff --git a/src/views/device/apdevice/modules/device-search.vue b/src/views/device/apdevice/modules/device-search.vue index 8c4d5e2..2a5d640 100644 --- a/src/views/device/apdevice/modules/device-search.vue +++ b/src/views/device/apdevice/modules/device-search.vue @@ -1,21 +1,12 @@