From fe3c9b570ecaf3356f976459d63b2fd4857e5858 Mon Sep 17 00:00:00 2001 From: fhysy <1149505133@qq.com> Date: Tue, 5 Aug 2025 17:03:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=BF=90=E7=BB=B4=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=90=E7=BB=B4=E7=AE=A1=E7=90=86=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 关闭tab标签、前端更新检测(后期正式环境开启回来) - 添加网络组件、协议管理、设备接入网关页面(未完成)和对接接口 --- .../src/api/operations/gateway/index.ts | 61 +++ .../src/api/operations/gateway/model.d.ts | 159 ++++++++ .../src/api/operations/network/index.ts | 61 +++ .../src/api/operations/network/model.d.ts | 99 +++++ .../src/api/operations/protocol/index.ts | 61 +++ .../src/api/operations/protocol/model.d.ts | 99 +++++ apps/web-antd/src/preferences.ts | 6 + apps/web-antd/src/views/demo/test/detail.vue | 10 + .../src/views/operations/gateway/data.ts | 170 +++++++++ .../operations/gateway/gateway-drawer.vue | 101 +++++ .../src/views/operations/gateway/index.vue | 182 +++++++++ .../src/views/operations/network/data.ts | 348 ++++++++++++++++++ .../src/views/operations/network/index.vue | 230 ++++++++++++ .../operations/network/network-drawer.vue | 147 ++++++++ .../src/views/operations/protocol/data.ts | 138 +++++++ .../src/views/operations/protocol/index.vue | 190 ++++++++++ .../operations/protocol/protocol-drawer.vue | 101 +++++ 17 files changed, 2163 insertions(+) create mode 100644 apps/web-antd/src/api/operations/gateway/index.ts create mode 100644 apps/web-antd/src/api/operations/gateway/model.d.ts create mode 100644 apps/web-antd/src/api/operations/network/index.ts create mode 100644 apps/web-antd/src/api/operations/network/model.d.ts create mode 100644 apps/web-antd/src/api/operations/protocol/index.ts create mode 100644 apps/web-antd/src/api/operations/protocol/model.d.ts create mode 100644 apps/web-antd/src/views/demo/test/detail.vue create mode 100644 apps/web-antd/src/views/operations/gateway/data.ts create mode 100644 apps/web-antd/src/views/operations/gateway/gateway-drawer.vue create mode 100644 apps/web-antd/src/views/operations/gateway/index.vue create mode 100644 apps/web-antd/src/views/operations/network/data.ts create mode 100644 apps/web-antd/src/views/operations/network/index.vue create mode 100644 apps/web-antd/src/views/operations/network/network-drawer.vue create mode 100644 apps/web-antd/src/views/operations/protocol/data.ts create mode 100644 apps/web-antd/src/views/operations/protocol/index.vue create mode 100644 apps/web-antd/src/views/operations/protocol/protocol-drawer.vue diff --git a/apps/web-antd/src/api/operations/gateway/index.ts b/apps/web-antd/src/api/operations/gateway/index.ts new file mode 100644 index 0000000..3e66dce --- /dev/null +++ b/apps/web-antd/src/api/operations/gateway/index.ts @@ -0,0 +1,61 @@ +import type { GatewayVO, GatewayForm, GatewayQuery } from './model'; + +import type { ID, IDS } from '#/api/common'; +import type { PageResult } from '#/api/common'; + +import { commonExport } from '#/api/helper'; +import { requestClient } from '#/api/request'; + +/** +* 查询设备接入网关列表 +* @param params +* @returns 设备接入网关列表 +*/ +export function gatewayList(params?: GatewayQuery) { + return requestClient.get>('/operations/gateway/list', { params }); +} + +/** + * 导出设备接入网关列表 + * @param params + * @returns 设备接入网关列表 + */ +export function gatewayExport(params?: GatewayQuery) { + return commonExport('/operations/gateway/export', params ?? {}); +} + +/** + * 查询设备接入网关详情 + * @param id id + * @returns 设备接入网关详情 + */ +export function gatewayInfo(id: ID) { + return requestClient.get(`/operations/gateway/${id}`); +} + +/** + * 新增设备接入网关 + * @param data + * @returns void + */ +export function gatewayAdd(data: GatewayForm) { + return requestClient.postWithMsg('/operations/gateway', data); +} + +/** + * 更新设备接入网关 + * @param data + * @returns void + */ +export function gatewayUpdate(data: GatewayForm) { + return requestClient.putWithMsg('/operations/gateway', data); +} + +/** + * 删除设备接入网关 + * @param id id + * @returns void + */ +export function gatewayRemove(id: ID | IDS) { + return requestClient.deleteWithMsg(`/operations/gateway/${id}`); +} diff --git a/apps/web-antd/src/api/operations/gateway/model.d.ts b/apps/web-antd/src/api/operations/gateway/model.d.ts new file mode 100644 index 0000000..42e71d9 --- /dev/null +++ b/apps/web-antd/src/api/operations/gateway/model.d.ts @@ -0,0 +1,159 @@ +import type { PageQuery, BaseEntity } from '#/api/common'; + +export interface GatewayVO { + /** + * 编号 + */ + id: string | number; + + /** + * 启用状态 0 禁用 + */ + enabled: string; + + /** + * 网关名称 + */ + name: string; + + /** + * 接入方式,如: mqtt-server-gateway + */ + provider: string | number; + + /** + * 描述 + */ + description: string; + + /** + * 通道 接入通道(方式),如网络组件 + */ + channel: string; + + /** + * 通道id 接入使用的通道ID,如: 网络组件ID,modbus通道ID + */ + channelId: string | number; + + /** + * 消息协议 消息协议 + */ + protocol: number; + + /** + * 传输协议,如TCP,MQTT,UDP + */ + transport: string; + + /** + * 网关配置 + */ + gatewayConfig: string; + +} + +export interface GatewayForm extends BaseEntity { + /** + * 编号 + */ + id?: string | number; + + /** + * 启用状态 0 禁用 + */ + enabled?: string; + + /** + * 网关名称 + */ + name?: string; + + /** + * 接入方式,如: mqtt-server-gateway + */ + provider?: string | number; + + /** + * 描述 + */ + description?: string; + + /** + * 通道 接入通道(方式),如网络组件 + */ + channel?: string; + + /** + * 通道id 接入使用的通道ID,如: 网络组件ID,modbus通道ID + */ + channelId?: string | number; + + /** + * 消息协议 消息协议 + */ + protocol?: number; + + /** + * 传输协议,如TCP,MQTT,UDP + */ + transport?: string; + + /** + * 网关配置 + */ + gatewayConfig?: string; + +} + +export interface GatewayQuery extends PageQuery { + /** + * 启用状态 0 禁用 + */ + enabled?: string; + + /** + * 网关名称 + */ + name?: string; + + /** + * 接入方式,如: mqtt-server-gateway + */ + provider?: string | number; + + /** + * 描述 + */ + description?: string; + + /** + * 通道 接入通道(方式),如网络组件 + */ + channel?: string; + + /** + * 通道id 接入使用的通道ID,如: 网络组件ID,modbus通道ID + */ + channelId?: string | number; + + /** + * 消息协议 消息协议 + */ + protocol?: number; + + /** + * 传输协议,如TCP,MQTT,UDP + */ + transport?: string; + + /** + * 网关配置 + */ + gatewayConfig?: string; + + /** + * 日期范围参数 + */ + params?: any; +} diff --git a/apps/web-antd/src/api/operations/network/index.ts b/apps/web-antd/src/api/operations/network/index.ts new file mode 100644 index 0000000..6b48ae4 --- /dev/null +++ b/apps/web-antd/src/api/operations/network/index.ts @@ -0,0 +1,61 @@ +import type { NetworkVO, NetworkForm, NetworkQuery } from './model'; + +import type { ID, IDS } from '#/api/common'; +import type { PageResult } from '#/api/common'; + +import { commonExport } from '#/api/helper'; +import { requestClient } from '#/api/request'; + +/** +* 查询网络组件列表 +* @param params +* @returns 网络组件列表 +*/ +export function networkList(params?: NetworkQuery) { + return requestClient.get>('/operations/network/list', { params }); +} + +/** + * 导出网络组件列表 + * @param params + * @returns 网络组件列表 + */ +export function networkExport(params?: NetworkQuery) { + return commonExport('/operations/network/export', params ?? {}); +} + +/** + * 查询网络组件详情 + * @param id id + * @returns 网络组件详情 + */ +export function networkInfo(id: ID) { + return requestClient.get(`/operations/network/${id}`); +} + +/** + * 新增网络组件 + * @param data + * @returns void + */ +export function networkAdd(data: NetworkForm) { + return requestClient.postWithMsg('/operations/network', data); +} + +/** + * 更新网络组件 + * @param data + * @returns void + */ +export function networkUpdate(data: NetworkForm) { + return requestClient.putWithMsg('/operations/network', data); +} + +/** + * 删除网络组件 + * @param id id + * @returns void + */ +export function networkRemove(id: ID | IDS) { + return requestClient.deleteWithMsg(`/operations/network/${id}`); +} diff --git a/apps/web-antd/src/api/operations/network/model.d.ts b/apps/web-antd/src/api/operations/network/model.d.ts new file mode 100644 index 0000000..31917c8 --- /dev/null +++ b/apps/web-antd/src/api/operations/network/model.d.ts @@ -0,0 +1,99 @@ +import type { PageQuery, BaseEntity } from '#/api/common'; + +export interface NetworkVO { + /** + * 编号 + */ + id: string | number; + + /** + * 启用状态 0 禁用 + */ + enabled: string; + + /** + * 组件名称 + */ + name: string; + + /** + * 组件类型 HTTP_SERVER、MQTT_CLIENT 等 + */ + networkType: string; + + /** + * 描述 + */ + description: string; + + /** + * 网络配置 + */ + networkConfig: string; + +} + +export interface NetworkForm extends BaseEntity { + /** + * 编号 + */ + id?: string | number; + + /** + * 启用状态 0 禁用 + */ + enabled?: string; + + /** + * 组件名称 + */ + name?: string; + + /** + * 组件类型 HTTP_SERVER、MQTT_CLIENT 等 + */ + networkType?: string; + + /** + * 描述 + */ + description?: string; + + /** + * 网络配置 + */ + networkConfig?: string; + +} + +export interface NetworkQuery extends PageQuery { + /** + * 启用状态 0 禁用 + */ + enabled?: string; + + /** + * 组件名称 + */ + name?: string; + + /** + * 组件类型 HTTP_SERVER、MQTT_CLIENT 等 + */ + networkType?: string; + + /** + * 描述 + */ + description?: string; + + /** + * 网络配置 + */ + networkConfig?: string; + + /** + * 日期范围参数 + */ + params?: any; +} diff --git a/apps/web-antd/src/api/operations/protocol/index.ts b/apps/web-antd/src/api/operations/protocol/index.ts new file mode 100644 index 0000000..cc78f62 --- /dev/null +++ b/apps/web-antd/src/api/operations/protocol/index.ts @@ -0,0 +1,61 @@ +import type { ProtocolVO, ProtocolForm, ProtocolQuery } from './model'; + +import type { ID, IDS } from '#/api/common'; +import type { PageResult } from '#/api/common'; + +import { commonExport } from '#/api/helper'; +import { requestClient } from '#/api/request'; + +/** +* 查询设备协议列表 +* @param params +* @returns 设备协议列表 +*/ +export function protocolList(params?: ProtocolQuery) { + return requestClient.get>('/operations/protocol/list', { params }); +} + +/** + * 导出设备协议列表 + * @param params + * @returns 设备协议列表 + */ +export function protocolExport(params?: ProtocolQuery) { + return commonExport('/operations/protocol/export', params ?? {}); +} + +/** + * 查询设备协议详情 + * @param id id + * @returns 设备协议详情 + */ +export function protocolInfo(id: ID) { + return requestClient.get(`/operations/protocol/${id}`); +} + +/** + * 新增设备协议 + * @param data + * @returns void + */ +export function protocolAdd(data: ProtocolForm) { + return requestClient.postWithMsg('/operations/protocol', data); +} + +/** + * 更新设备协议 + * @param data + * @returns void + */ +export function protocolUpdate(data: ProtocolForm) { + return requestClient.putWithMsg('/operations/protocol', data); +} + +/** + * 删除设备协议 + * @param id id + * @returns void + */ +export function protocolRemove(id: ID | IDS) { + return requestClient.deleteWithMsg(`/operations/protocol/${id}`); +} diff --git a/apps/web-antd/src/api/operations/protocol/model.d.ts b/apps/web-antd/src/api/operations/protocol/model.d.ts new file mode 100644 index 0000000..1bf63ac --- /dev/null +++ b/apps/web-antd/src/api/operations/protocol/model.d.ts @@ -0,0 +1,99 @@ +import type { PageQuery, BaseEntity } from '#/api/common'; + +export interface ProtocolVO { + /** + * 编号 + */ + id: string | number; + + /** + * 启用状态 0 禁用 + */ + enabled: string; + + /** + * 协议名称 + */ + name: string; + + /** + * 协议包类型 local、jar + */ + protocolType: string; + + /** + * 描述 + */ + description: string; + + /** + * 协议配置 + */ + protocolConfig: string; + +} + +export interface ProtocolForm extends BaseEntity { + /** + * 编号 + */ + id?: string | number; + + /** + * 启用状态 0 禁用 + */ + enabled?: string; + + /** + * 协议名称 + */ + name?: string; + + /** + * 协议包类型 local、jar + */ + protocolType?: string; + + /** + * 描述 + */ + description?: string; + + /** + * 协议配置 + */ + protocolConfig?: string; + +} + +export interface ProtocolQuery extends PageQuery { + /** + * 启用状态 0 禁用 + */ + enabled?: string; + + /** + * 协议名称 + */ + name?: string; + + /** + * 协议包类型 local、jar + */ + protocolType?: string; + + /** + * 描述 + */ + description?: string; + + /** + * 协议配置 + */ + protocolConfig?: string; + + /** + * 日期范围参数 + */ + params?: any; +} diff --git a/apps/web-antd/src/preferences.ts b/apps/web-antd/src/preferences.ts index 43ea7d9..8ded6e4 100644 --- a/apps/web-antd/src/preferences.ts +++ b/apps/web-antd/src/preferences.ts @@ -30,6 +30,10 @@ export const overridesPreferences = defineOverridesPreferences({ * 2. 切换租户登录后不会重新加载菜单 */ // loginExpiredMode: 'modal', + // 是否开启检查更新 + enableCheckUpdates: false, + // 检查更新的时间间隔,单位为分钟 + checkUpdatesInterval: 1, }, footer: { /** @@ -42,6 +46,8 @@ export const overridesPreferences = defineOverridesPreferences({ * 标签tab 持久化 关闭 */ persist: false, + // 隐藏tab显示 + enable: false, // styleType: 'card', }, theme: { diff --git a/apps/web-antd/src/views/demo/test/detail.vue b/apps/web-antd/src/views/demo/test/detail.vue new file mode 100644 index 0000000..e4221e6 --- /dev/null +++ b/apps/web-antd/src/views/demo/test/detail.vue @@ -0,0 +1,10 @@ + + + diff --git a/apps/web-antd/src/views/operations/gateway/data.ts b/apps/web-antd/src/views/operations/gateway/data.ts new file mode 100644 index 0000000..ea0bb74 --- /dev/null +++ b/apps/web-antd/src/views/operations/gateway/data.ts @@ -0,0 +1,170 @@ +import type { FormSchemaGetter } from '#/adapter/form'; +import type { VxeGridProps } from '#/adapter/vxe-table'; + + +export const querySchema: FormSchemaGetter = () => [ + { + component: 'Input', + fieldName: 'enabled', + label: '启用状态 0 禁用', + }, + { + component: 'Input', + fieldName: 'name', + label: '网关名称', + }, + { + component: 'Input', + fieldName: 'provider', + label: '接入方式,如: mqtt-server-gateway', + }, + { + component: 'Input', + fieldName: 'description', + label: '描述', + }, + { + component: 'Input', + fieldName: 'channel', + label: '通道 接入通道(方式),如网络组件', + }, + { + component: 'Input', + fieldName: 'channelId', + label: '通道id 接入使用的通道ID,如: 网络组件ID,modbus通道ID', + }, + { + component: 'Input', + fieldName: 'protocol', + label: '消息协议 消息协议', + }, + { + component: 'Input', + fieldName: 'transport', + label: '传输协议,如TCP,MQTT,UDP', + }, + { + component: 'Textarea', + fieldName: 'gatewayConfig', + label: '网关配置', + }, +]; + +// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新 +// export const columns: () => VxeGridProps['columns'] = () => [ +export const columns: VxeGridProps['columns'] = [ + { type: 'checkbox', width: 60 }, + { + title: '编号', + field: 'id', + }, + { + title: '启用状态 0 禁用', + field: 'enabled', + }, + { + title: '网关名称', + field: 'name', + }, + { + title: '接入方式,如: mqtt-server-gateway', + field: 'provider', + }, + { + title: '描述', + field: 'description', + }, + { + title: '通道 接入通道(方式),如网络组件', + field: 'channel', + }, + { + title: '通道id 接入使用的通道ID,如: 网络组件ID,modbus通道ID', + field: 'channelId', + }, + { + title: '消息协议 消息协议', + field: 'protocol', + }, + { + title: '传输协议,如TCP,MQTT,UDP', + field: 'transport', + }, + { + title: '网关配置', + field: 'gatewayConfig', + }, + { + field: 'action', + fixed: 'right', + slots: { default: 'action' }, + title: '操作', + width: 180, + }, +]; + +export const drawerSchema: FormSchemaGetter = () => [ + { + label: '编号', + fieldName: 'id', + component: 'Input', + dependencies: { + show: () => false, + triggerFields: [''], + }, + }, + { + label: '启用状态 0 禁用', + fieldName: 'enabled', + component: 'Input', + rules: 'required', + }, + { + label: '网关名称', + fieldName: 'name', + component: 'Input', + rules: 'required', + }, + { + label: '接入方式,如: mqtt-server-gateway', + fieldName: 'provider', + component: 'Input', + rules: 'required', + }, + { + label: '描述', + fieldName: 'description', + component: 'Input', + rules: 'required', + }, + { + label: '通道 接入通道(方式),如网络组件', + fieldName: 'channel', + component: 'Input', + rules: 'required', + }, + { + label: '通道id 接入使用的通道ID,如: 网络组件ID,modbus通道ID', + fieldName: 'channelId', + component: 'Input', + rules: 'required', + }, + { + label: '消息协议 消息协议', + fieldName: 'protocol', + component: 'Input', + rules: 'required', + }, + { + label: '传输协议,如TCP,MQTT,UDP', + fieldName: 'transport', + component: 'Input', + rules: 'required', + }, + { + label: '网关配置', + fieldName: 'gatewayConfig', + component: 'Textarea', + rules: 'required', + }, +]; diff --git a/apps/web-antd/src/views/operations/gateway/gateway-drawer.vue b/apps/web-antd/src/views/operations/gateway/gateway-drawer.vue new file mode 100644 index 0000000..334c696 --- /dev/null +++ b/apps/web-antd/src/views/operations/gateway/gateway-drawer.vue @@ -0,0 +1,101 @@ + + + + diff --git a/apps/web-antd/src/views/operations/gateway/index.vue b/apps/web-antd/src/views/operations/gateway/index.vue new file mode 100644 index 0000000..4e4cabb --- /dev/null +++ b/apps/web-antd/src/views/operations/gateway/index.vue @@ -0,0 +1,182 @@ + + + diff --git a/apps/web-antd/src/views/operations/network/data.ts b/apps/web-antd/src/views/operations/network/data.ts new file mode 100644 index 0000000..647b187 --- /dev/null +++ b/apps/web-antd/src/views/operations/network/data.ts @@ -0,0 +1,348 @@ +import type { FormSchemaGetter } from '#/adapter/form'; +import type { VxeGridProps } from '#/adapter/vxe-table'; + +const networkTypeOptions = [ + { label: 'MQTT客户端', value: 'MQTT_CLIENT' }, + { label: 'HTTP服务', value: 'HTTP_SERVER' }, +]; + +const enabledOptions = [ + { label: '启用', value: '1' }, + { label: '禁用', value: '0' }, +]; + +// HTTP服务配置字段 +const httpServerFields = [ + { + label: '本地地址', + fieldName: 'localAddress', + component: 'Input', + componentProps: { + placeholder: '请输入本地地址', + disabled: true, + }, + defaultValue: '0.0.0.0', + help: '绑定到服务器上的网卡地址,绑定到所有网卡:0.0.0.0', + rules: 'required', + dependencies: { + triggerFields: ['networkType'], + show: (values: any) => values.networkType === 'HTTP_SERVER', + }, + }, + { + label: '本地端口', + fieldName: 'localPort', + component: 'InputNumber', + componentProps: { + placeholder: '请选择本地端口', + min: 1, + }, + rules: 'required', + help: '监听指定端口的请求', + dependencies: { + triggerFields: ['networkType'], + show: (values) => values.networkType === 'HTTP_SERVER', + }, + }, + { + label: '公网地址', + fieldName: 'publicAddress', + component: 'Input', + componentProps: { + placeholder: '请输入公网地址', + }, + rules: 'required', + help: '对外提供访问的地址,内网环境时填写服务器的内网IP地址', + dependencies: { + triggerFields: ['networkType'], + show: (values) => values.networkType === 'HTTP_SERVER', + }, + }, + { + label: '公网端口', + fieldName: 'publicPort', + component: 'InputNumber', + componentProps: { + placeholder: '请输入端口', + min: 1, + }, + rules: 'required', + help: '对外提供访问的端口', + dependencies: { + triggerFields: ['networkType'], + show: (values) => values.networkType === 'HTTP_SERVER', + }, + }, + { + label: '开启TLS', + fieldName: 'enableTls', + component: 'RadioGroup', + componentProps: { + buttonStyle: 'solid', + optionType: 'button', + options: [ + { label: '是', value: '1' }, + { label: '否', value: '0' }, + ], + }, + defaultValue: '0', + rules: 'required', + dependencies: { + triggerFields: ['networkType'], + show: (values) => values.networkType === 'HTTP_SERVER', + }, + }, +]; + +// MQTT客户端配置字段 +const mqttClientFields = [ + { + label: '远程地址', + fieldName: 'remoteAddress', + component: 'Input', + componentProps: { + placeholder: '请输入远程地址', + }, + rules: 'required', + dependencies: { + triggerFields: ['networkType'], + show: (values: any) => values.networkType === 'MQTT_CLIENT', + }, + }, + { + label: '远程端口', + fieldName: 'remotePort', + component: 'InputNumber', + componentProps: { + placeholder: '请输入远程端口', + min: 1, + }, + rules: 'required', + dependencies: { + triggerFields: ['networkType'], + show: (values: any) => values.networkType === 'MQTT_CLIENT', + }, + }, + { + label: 'ClientId', + fieldName: 'clientId', + component: 'Input', + componentProps: { + placeholder: '请输入ClientId', + }, + rules: 'required', + dependencies: { + triggerFields: ['networkType'], + show: (values: any) => values.networkType === 'MQTT_CLIENT', + }, + }, + { + label: '用户名', + fieldName: 'username', + component: 'Input', + componentProps: { + placeholder: '请输入用户名', + }, + rules: 'required', + dependencies: { + triggerFields: ['networkType'], + show: (values: any) => values.networkType === 'MQTT_CLIENT', + }, + }, + { + label: '密码', + fieldName: 'password', + component: 'InputPassword', + componentProps: { + placeholder: '请输入密码', + }, + rules: 'required', + dependencies: { + triggerFields: ['networkType'], + show: (values: any) => values.networkType === 'MQTT_CLIENT', + }, + }, + { + label: '订阅前缀', + fieldName: 'subscriptionPrefix', + component: 'Input', + componentProps: { + placeholder: '请输入订阅前缀', + }, + help: '当连接的服务为EMQ时,可能需要使用共享的订阅前缀,如:$queue或$share', + rules: 'required', + dependencies: { + triggerFields: ['networkType'], + show: (values: any) => values.networkType === 'MQTT_CLIENT', + }, + }, + { + label: '最大消息长度', + fieldName: 'maxMessageLength', + component: 'InputNumber', + componentProps: { + placeholder: '请输入最大消息长度', + min: 1, + }, + defaultValue: 8192, + help: '单次收发消息的最大长度,单位:字节;设置过大可能会影响性能', + rules: 'required', + dependencies: { + triggerFields: ['networkType'], + show: (values: any) => values.networkType === 'MQTT_CLIENT', + }, + }, + { + label: '开启TLS', + fieldName: 'enableTls', + component: 'RadioGroup', + componentProps: { + buttonStyle: 'solid', + optionType: 'button', + options: [ + { label: '是', value: '1' }, + { label: '否', value: '0' }, + ], + }, + defaultValue: '0', + rules: 'required', + dependencies: { + triggerFields: ['networkType'], + show: (values: any) => values.networkType === 'MQTT_CLIENT', + }, + }, +]; + +export const querySchema: FormSchemaGetter = () => [ + { + component: 'Input', + fieldName: 'name', + label: '组件名称', + }, + { + component: 'Select', + componentProps: { + allowClear: true, + filterOption: true, + options: enabledOptions, + placeholder: '请选择', + showSearch: true, + }, + fieldName: 'enabled', + label: '启用状态', + }, + { + component: 'Select', + componentProps: { + allowClear: true, + filterOption: true, + options: networkTypeOptions, + placeholder: '请选择', + showSearch: true, + }, + fieldName: 'networkType', + label: '网络类型', + }, +]; + +// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新 +// export const columns: () => VxeGridProps['columns'] = () => [ +export const columns: VxeGridProps['columns'] = [ + { type: 'checkbox', width: 60 }, + { + title: '编号', + field: 'id', + }, + { + title: '组件名称', + field: 'name', + }, + { + title: '网络类型', + field: 'networkType', + slots: { default: 'networkType' }, + }, + { + title: '启用状态', + field: 'enabled', + slots: { default: 'enabled' }, + }, + { + title: '描述', + field: 'description', + }, + { + field: 'action', + fixed: 'right', + slots: { default: 'action' }, + title: '操作', + width: 180, + }, +]; + +// 基础字段 +const baseFields = [ + { + label: '编号', + fieldName: 'id', + component: 'Input', + dependencies: { + show: () => false, + triggerFields: [''], + }, + }, + { + label: '组件名称', + fieldName: 'name', + component: 'Input', + componentProps: { + placeholder: '请输入名称', + }, + rules: 'required', + }, + { + label: '网络类型', + fieldName: 'networkType', + component: 'Select', + componentProps: { + allowClear: true, + filterOption: true, + options: networkTypeOptions, + placeholder: '请选择网络类型', + showSearch: true, + }, + rules: 'selectRequired', + }, + { + label: '启用状态', + fieldName: 'enabled', + component: 'RadioGroup', + componentProps: { + buttonStyle: 'solid', + options: enabledOptions, + optionType: 'button', + }, + defaultValue: '1', + rules: 'required', + }, + { + label: '描述', + fieldName: 'description', + component: 'Textarea', + componentProps: { + placeholder: '请输入描述', + rows: 3, + }, + }, +]; + +export const drawerSchema: FormSchemaGetter = () => [ + ...baseFields, + // HTTP服务配置字段 + ...httpServerFields, + // MQTT客户端配置字段 + ...mqttClientFields, +]; + +// 导出字段配置供组件使用 +export { httpServerFields, mqttClientFields }; diff --git a/apps/web-antd/src/views/operations/network/index.vue b/apps/web-antd/src/views/operations/network/index.vue new file mode 100644 index 0000000..cd75f2b --- /dev/null +++ b/apps/web-antd/src/views/operations/network/index.vue @@ -0,0 +1,230 @@ + + + + + diff --git a/apps/web-antd/src/views/operations/network/network-drawer.vue b/apps/web-antd/src/views/operations/network/network-drawer.vue new file mode 100644 index 0000000..6b9893d --- /dev/null +++ b/apps/web-antd/src/views/operations/network/network-drawer.vue @@ -0,0 +1,147 @@ + + + diff --git a/apps/web-antd/src/views/operations/protocol/data.ts b/apps/web-antd/src/views/operations/protocol/data.ts new file mode 100644 index 0000000..9d7f066 --- /dev/null +++ b/apps/web-antd/src/views/operations/protocol/data.ts @@ -0,0 +1,138 @@ +import type { FormSchemaGetter } from '#/adapter/form'; +import type { VxeGridProps } from '#/adapter/vxe-table'; + +const enabledOptions = [ + { label: '启用', value: '1' }, + { label: '禁用', value: '0' }, +]; + +const protocolTypeOptions = [ + { label: 'local', value: 'local' }, + { label: 'jar', value: 'jar' }, +]; + +export const querySchema: FormSchemaGetter = () => [ + { + component: 'Input', + fieldName: 'name', + label: '协议名称', + }, + { + component: 'Select', + componentProps: { + allowClear: true, + filterOption: true, + options: protocolTypeOptions, + placeholder: '请选择', + showSearch: true, + }, + fieldName: 'protocolType', + label: '协议包类型', + }, + { + component: 'Select', + componentProps: { + allowClear: true, + filterOption: true, + options: enabledOptions, + placeholder: '请选择', + showSearch: true, + }, + fieldName: 'enabled', + label: '启用状态', + }, +]; + +// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新 +// export const columns: () => VxeGridProps['columns'] = () => [ +export const columns: VxeGridProps['columns'] = [ + { type: 'checkbox', width: 60 }, + { + title: '编号', + field: 'id', + }, + { + title: '协议名称', + field: 'name', + }, + { + title: '协议包类型', + slots: { default: 'protocolType' }, + field: 'protocolType', + }, + { + title: '协议配置', + field: 'protocolConfig', + }, + { + title: '启用状态', + slots: { default: 'enabled' }, + field: 'enabled', + }, + { + title: '描述', + field: 'description', + }, + { + field: 'action', + fixed: 'right', + slots: { default: 'action' }, + title: '操作', + width: 180, + }, +]; + +export const drawerSchema: FormSchemaGetter = () => [ + { + label: '编号', + fieldName: 'id', + component: 'Input', + dependencies: { + show: () => false, + triggerFields: [''], + }, + }, + { + label: '协议名称', + fieldName: 'name', + component: 'Input', + rules: 'required', + }, + { + label: '协议包类型', + fieldName: 'protocolType', + component: 'Select', + componentProps: { + allowClear: true, + filterOption: true, + options: protocolTypeOptions, + placeholder: '请选择', + showSearch: true, + }, + rules: 'selectRequired', + }, + { + label: '协议配置', + fieldName: 'protocolConfig', + component: 'Textarea', + rules: 'required', + }, + { + label: '启用状态', + fieldName: 'enabled', + component: 'Select', + componentProps: { + allowClear: true, + filterOption: true, + options: enabledOptions, + placeholder: '请选择', + showSearch: true, + }, + rules: 'required', + }, + { + label: '描述', + fieldName: 'description', + component: 'Textarea', + }, +]; diff --git a/apps/web-antd/src/views/operations/protocol/index.vue b/apps/web-antd/src/views/operations/protocol/index.vue new file mode 100644 index 0000000..2d45d6e --- /dev/null +++ b/apps/web-antd/src/views/operations/protocol/index.vue @@ -0,0 +1,190 @@ + + + diff --git a/apps/web-antd/src/views/operations/protocol/protocol-drawer.vue b/apps/web-antd/src/views/operations/protocol/protocol-drawer.vue new file mode 100644 index 0000000..ab88cf1 --- /dev/null +++ b/apps/web-antd/src/views/operations/protocol/protocol-drawer.vue @@ -0,0 +1,101 @@ + + + +