Browse Source

Merge branch 'develop' of xuyiping/kpt-system-web into master

xuyiping 9 months ago
parent
commit
5c5d8d1dbe

+ 0 - 1
docker/.dockerignore → .dockerignore

@@ -1,6 +1,5 @@
 node_modules
 .DS_Store
-dist
 .npmrc
 .cache
 

+ 123 - 0
.drone.yml

@@ -0,0 +1,123 @@
+kind: pipeline
+type: docker
+name: test
+
+steps:
+  - name: build
+    image: plugins/docker:20.14.2
+    volumes:
+      - name: hosts
+        path: /etc/hosts
+      - name: docker-ca
+        path: /etc/docker
+      - name: docker-sock
+        path: /var/run/docker.sock
+    settings:
+      username:
+        from_secret: aliyuncs_username
+      password:
+        from_secret: aliyuncs_password
+      repo: registry.cn-hangzhou.aliyuncs.com/kpt-event/kpt-system-web
+      registry: registry.cn-hangzhou.aliyuncs.com
+      tags: [test]
+  - name: ssh commands
+    image: appleboy/drone-ssh
+    settings:
+      host: 192.168.1.70
+      username: tmrwatch
+      password:
+        from_secret: ssh_password
+      port: 22
+      script:
+        - cd /data/docker-compose/kpt-system-web/
+        - echo "123456" | ./restart.sh
+trigger:
+  branch:
+    include:
+      - feature/*
+  event:
+    include:
+      - push
+volumes:
+  - name: docker-ca
+    host:
+      path: /etc/docker
+  - name: docker-sock
+    host:
+      path: /var/run/docker.sock
+---
+kind: pipeline
+type: docker
+name: product
+steps:
+  - name: build
+    image: plugins/docker:20.14.2
+    volumes:
+      - name: hosts
+        path: /etc/hosts
+      - name: docker-ca
+        path: /etc/docker
+      - name: docker-sock
+        path: /var/run/docker.sock
+    settings:
+      username:
+        from_secret: aliyuncs_username
+      password:
+        from_secret: aliyuncs_password
+      repo: registry.cn-hangzhou.aliyuncs.com/kpt-event/kpt-system-web
+      registry: registry.cn-hangzhou.aliyuncs.com
+      tag:
+        - latest
+        - ${DRONE_BRANCH##release/}
+trigger:
+  branch:
+    include:
+      - release/*
+  event:
+    include:
+      - push
+volumes:
+  - name: docker-ca
+    host:
+      path: /etc/docker
+  - name: docker-sock
+    host:
+      path: /var/run/docker.sock
+---
+kind: pipeline
+type: docker
+name: hotfix
+
+steps:
+  - name: build
+    image: plugins/docker:20.14.2
+    volumes:
+      - name: hosts
+        path: /etc/hosts
+      - name: docker-ca
+        path: /etc/docker
+      - name: docker-sock
+        path: /var/run/docker.sock
+    settings:
+      username:
+        from_secret: aliyuncs_username
+      password:
+        from_secret: aliyuncs_password
+      repo: registry.cn-hangzhou.aliyuncs.com/kpt-event/kpt-system-web
+      registry: registry.cn-hangzhou.aliyuncs.com
+      tag:
+        - latest
+trigger:
+  branch:
+    include:
+      - hotfix/*
+  event:
+    include:
+      - push
+volumes:
+  - name: docker-ca
+    host:
+      path: /etc/docker
+  - name: docker-sock
+    host:
+      path: /var/run/docker.sock

+ 3 - 3
.env

@@ -2,15 +2,15 @@ VITE_BASE_URL=/
 
 VITE_APP_NAME=CopartnerAdmin
 
-VITE_APP_TITLE=Copartner事件驱动系统
+VITE_APP_TITLE=Copartner后台管理系统
 
-VITE_APP_DESC=CopartnerAdmin是一个事件驱动中后台管理系统
+VITE_APP_DESC=CopartnerAdmin是一个后台管理系统
 
 # 权限路由模式: static | dynamic
 VITE_AUTH_ROUTE_MODE=static
 
 # 路由首页(根路由重定向), 用于static模式的权限路由,dynamic模式取决于后端返回的路由首页
-VITE_ROUTE_HOME_PATH=/dashboard/analysis
+VITE_ROUTE_HOME_PATH=/mqtt/pasture
 
 # iconify图标作为组件的前缀
 VITE_ICON_PREFFIX=icon

+ 0 - 272
CHANGELOG.md

@@ -1,272 +0,0 @@
-# Changelog
-
-All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
-
-### [0.9.9](https://github.com/honghuangdc/soybean-admin/compare/v0.9.8...v0.9.9) (2023-03-13)
-
-
-### Features
-
-* **hooks:** add useNaiveTable ([cc13fcc](https://github.com/honghuangdc/soybean-admin/commit/cc13fcc8aaaf667902d69350ad0de3cc16c261ab))
-* **projects:** custom unocss colors support opacity ([488e6e3](https://github.com/honghuangdc/soybean-admin/commit/488e6e32045d995361b898ef3d384dafcb069008))
-* **projects:** new layout,tab and add update theme settings ([912c353](https://github.com/honghuangdc/soybean-admin/commit/912c3531c5d7a3ab30e15d39bed98ca9b20131ab))
-
-
-### Bug Fixes
-
-* **components:** 修复iconSelect选择器点击事件失效 ([7e505f9](https://github.com/honghuangdc/soybean-admin/commit/7e505f9b96f5380b6c27b4c2ee2ab0698c4eedc4))
-* **components:** 页面跳转被拦截, 则会出现 tab 页签与页面不一致的问题 ([bd5dd2c](https://github.com/honghuangdc/soybean-admin/commit/bd5dd2cf28a0943721c397d70c53fe3988a4f81a))
-* **components:** refresh cached routes ([b0f98e4](https://github.com/honghuangdc/soybean-admin/commit/b0f98e4bfac31751dd39a7dec203277db813694b))
-* **projects:** fix eslint svg cause incorrect icon render ([0b5afda](https://github.com/honghuangdc/soybean-admin/commit/0b5afda287a0eea57daa8d35409297e2cbf6d578))
-* **projects:** fix github bug-report ([f73e3f6](https://github.com/honghuangdc/soybean-admin/commit/f73e3f648decf5632fe5193e825b1f912c5f6153))
-* **projects:** fix pwa logo ([bf2f617](https://github.com/honghuangdc/soybean-admin/commit/bf2f6172554337450c4a300b8bdb580d3e25ad45))
-* **projects:** not only `/login` claim dynamic path scenario , but also others , eg:/user/1 ([6059891](https://github.com/honghuangdc/soybean-admin/commit/60598915561f1bad6ffba0dc102f0a776be52f0d))
-* **projects:** sortRoutes recursively ([9188941](https://github.com/honghuangdc/soybean-admin/commit/918894147ab739b4592e8c76378246e28c46491a))
-* **projects:** the length of routes children list should greater than 0 ([e1afc10](https://github.com/honghuangdc/soybean-admin/commit/e1afc10b80243a5d8d270a351a37a0a2d159f167))
-* **utils:** make AxiosRequestConfig optional for request.handleDelete() ([4a6fec8](https://github.com/honghuangdc/soybean-admin/commit/4a6fec8af0b44b546f81ec41d7a5947371e189b2))
-
-### [0.9.8](https://github.com/honghuangdc/soybean-admin/compare/v0.9.7...v0.9.8) (2023-01-15)
-
-
-### Features
-
-* 新增 affix 属性,用于将其固定在tab卡 ([e772ff0](https://github.com/honghuangdc/soybean-admin/commit/e772ff05fb6ef513bd37cd9b1e245ea72f0ad6d2))
-* **projects:** add compress script [添加压缩命令] ([be6d431](https://github.com/honghuangdc/soybean-admin/commit/be6d431485a5688bd1ed567e11c1ca35ab9259b0))
-* **projects:** add generate logo script ([25daa23](https://github.com/honghuangdc/soybean-admin/commit/25daa236064c9a76677dbf16bc6d9717b1e0040f))
-* **projects:** add new route plugin @soybeanjs/vite-plugin-vue-page-route [集成新的路由插件] ([3131e00](https://github.com/honghuangdc/soybean-admin/commit/3131e00f0f4a66756f547892a8d312cde3aaf868))
-* **projects:** add script about generating png logo from [添加根据svg生成png图标的命令] ([70aeefe](https://github.com/honghuangdc/soybean-admin/commit/70aeefea02fcc13c152ee9d7a1197381bac724b9))
-* setting 页面新增 是否显示footer的开关 ([d064f62](https://github.com/honghuangdc/soybean-admin/commit/d064f6285a6d1616d7606f1390d5f01819b258bb))
-
-
-### Bug Fixes
-
-* **components:** 修复路由在path中包含重复路单词径菜单时,被激活会错误展开 ([264da00](https://github.com/honghuangdc/soybean-admin/commit/264da00e5d2cd8139907c2ac11a046649d942f4b))
-* count can't display when endValue is 0. ([0282feb](https://github.com/honghuangdc/soybean-admin/commit/0282feb1730724ba66c2e57ab354099afa074e81))
-* **projects:** 修复动态路由模式下路由不排序的问题 ([58b27c9](https://github.com/honghuangdc/soybean-admin/commit/58b27c96932ba89b362138a6056a82c25a7be282))
-* **projects:** 修复tabs在static路由模式下可以关闭首页 ([7211a17](https://github.com/honghuangdc/soybean-admin/commit/7211a17a8158b01a1f6dd6c83591f86d76633de0))
-* **projects:** add router-page.d.ts to git [将router-page.d.ts添加git提交] ([7a58035](https://github.com/honghuangdc/soybean-admin/commit/7a5803551419f65ca55ba797b49273b3a0dc6067))
-* **projects:** fix login success message [修复登录成功的消息提示] ([810398a](https://github.com/honghuangdc/soybean-admin/commit/810398abb882613f82ba385e8a7666cf8b86d92d))
-* **projects:** fix router when the dynamic routes api was failed [修复当动态路由接口失败后路由异常问题] ([f2b580f](https://github.com/honghuangdc/soybean-admin/commit/f2b580fc067e81202238bf8079a13ff014b0b329))
-* **projects:** fix vite-pwa plugin config ([94098d0](https://github.com/honghuangdc/soybean-admin/commit/94098d02e8cec12e3c9f9331ece154b65d1c9150))
-* remove height limit h-360px ([b5c570a](https://github.com/honghuangdc/soybean-admin/commit/b5c570adf55fd235dcec49bc20837623b1d5d3c4))
-* set password attributes ([a9a3703](https://github.com/honghuangdc/soybean-admin/commit/a9a37036d58274385a779e6460f7be281dafdcaf))
-
-### [0.9.7](https://github.com/honghuangdc/soybean-admin/compare/v0.9.6...v0.9.7) (2022-11-07)
-
-
-### Features
-
-* **projects:** 全局搜索菜单及消息通知适配移动端 ([97e2ffd](https://github.com/honghuangdc/soybean-admin/commit/97e2ffddf4ac047133dc016a91ac07556e562d29))
-* **projects:** 实现用户管理页面 ([472f93b](https://github.com/honghuangdc/soybean-admin/commit/472f93bfc111e8ca94adef823b8cc12e4f8cd2c6))
-* **projects:** 适配移动端,修复Tab关闭图标的bug ([296b154](https://github.com/honghuangdc/soybean-admin/commit/296b154be5dfe410b3cfca9afaeeaf9c47de3e0c)), closes [#87](https://github.com/honghuangdc/soybean-admin/issues/87) [#106](https://github.com/honghuangdc/soybean-admin/issues/106) [#109](https://github.com/honghuangdc/soybean-admin/issues/109) [#111](https://github.com/honghuangdc/soybean-admin/issues/111)
-* **projects:** 添加请求适配adapter层应用的示例页面 ([8d11a6a](https://github.com/honghuangdc/soybean-admin/commit/8d11a6affcfa37344011a6aaf3d6e005546f0e61))
-* **projects:** 添加生产的主题配置缓存 ([718c362](https://github.com/honghuangdc/soybean-admin/commit/718c36263e451a39bca6da6c33657a09515ffbcc))
-* **projects:** 添加系统管理的页面 ([c33b5eb](https://github.com/honghuangdc/soybean-admin/commit/c33b5ebfefbb3ae507141bd2e9414231fd1512d4))
-* **projects:** 添加组件名称,调整vue文件里面的类型声明位置 ([f64bc91](https://github.com/honghuangdc/soybean-admin/commit/f64bc91ce285c7a9806ed0f6ae970d9b598fd0cb))
-* **projects:** 添加provide、inject上下文示例 ([a444731](https://github.com/honghuangdc/soybean-admin/commit/a444731e9eef43022930c3550dcfc058e70a2941))
-* **projects:** 系统消息组件代码优化 ([9518372](https://github.com/honghuangdc/soybean-admin/commit/9518372fe0431d4e08a5f40d1b2982691fbb4107))
-* **projects:** 增加返回顶部功能 ([894b0f1](https://github.com/honghuangdc/soybean-admin/commit/894b0f1c182a36ad1774a8144bf50dd4e0b62a46))
-* **projects:** 增加系统消息组件 ([afa0134](https://github.com/honghuangdc/soybean-admin/commit/afa0134fdd63c253e102bc129e275d16ca25508e))
-* **projects:** add constant route page without login status[添加未登录可访问的固定路由示例页面] ([78efd77](https://github.com/honghuangdc/soybean-admin/commit/78efd7793a241811065caf56edf7e68aea58bc8c))
-* **projects:** add pinia setup syntax example: setup-store[添加setup syntax的pinia示例setup-store] ([82c4b09](https://github.com/honghuangdc/soybean-admin/commit/82c4b09b9411390f97c2d10bb211c66ed9656b63))
-* **projects:** import i18n [引入i18n] ([b632b7f](https://github.com/honghuangdc/soybean-admin/commit/b632b7ffed5c6d6ec15c23c8cce030bf669c554f))
-* **projects:** new router system [新的路由系统] ([c7b6a3f](https://github.com/honghuangdc/soybean-admin/commit/c7b6a3fbecd1ba051833e4e47b75a06935f212c8))
-* **projects:** refactor icon system, unify icon usage [重构图标系统,统一图标用法] ([811f820](https://github.com/honghuangdc/soybean-admin/commit/811f820644053606e50624c2f184f9669f3eff7e))
-* **projects:** support constant route without login status[支持未登录状态下访问自定义的固定路由] ([a539112](https://github.com/honghuangdc/soybean-admin/commit/a539112a0f53183ee073d4eb9034ef48209fe30c))
-* **projects:** useNaiveTable函数:类型部分 ([02992dc](https://github.com/honghuangdc/soybean-admin/commit/02992dc02d105cbfcebbea397438c68db1fa8177))
-* **tabs:** 多页签增加关闭所有 ([8237adb](https://github.com/honghuangdc/soybean-admin/commit/8237adb9c0b187911df37d6d99fd84718bc3ea8f))
-
-
-### Bug Fixes
-
-* **deps:** decrease @types/node version to fix TS type error [降低@types/node版本修复TS的类型错误] ([149d22a](https://github.com/honghuangdc/soybean-admin/commit/149d22a4a491ca5fc6c52375046e9f1cb86ee76d))
-* **projects:** 修复多个后端服务时的本地代理 ([2aba58c](https://github.com/honghuangdc/soybean-admin/commit/2aba58c973e5d0ea975443a8b22c9d94283d4fb9))
-* **projects:** 修复构建后mockjs对xhr的影响问题 ([7757285](https://github.com/honghuangdc/soybean-admin/commit/77572855c3f7161697f42e6da36771c15707f0ab))
-* **projects:** 修复图标的TS类型 ([dbd6760](https://github.com/honghuangdc/soybean-admin/commit/dbd676095b42aaebc783d5c89478306a453195a5))
-* **projects:** 修复eslint规则 ([d7f5bf3](https://github.com/honghuangdc/soybean-admin/commit/d7f5bf3373e7884b8dc2c696a2c36e9cf27ad64b))
-* **projects:** 修复import.meta.env的TS类型 ([1994262](https://github.com/honghuangdc/soybean-admin/commit/19942625d58e673126db5249488555de71d18457))
-* **projects:** 修复tab不显示路由首页的问题 ([a792bb5](https://github.com/honghuangdc/soybean-admin/commit/a792bb5cb3c388ba3b93e17bab8f42d23cd5df4a))
-* **projects:** 修复TS类型问题 ([16dce9a](https://github.com/honghuangdc/soybean-admin/commit/16dce9a4ce4d3aa822d70f6e5199eb9c86e33ad9))
-* **projects:** add iconify json ([8a1ec93](https://github.com/honghuangdc/soybean-admin/commit/8a1ec938e7a26728919024e9f5b7b0af2b270aba))
-* **svg-icon:** 自定义图标在Dropdown组件下hover状态无法显示图标 ([0523f08](https://github.com/honghuangdc/soybean-admin/commit/0523f0838246041bfc09130e21369bd777f63682))
-* **utils:** 修复iconifyRender ([c37d0ac](https://github.com/honghuangdc/soybean-admin/commit/c37d0ac7887a3451b8558fc4aa6c05ed3b0ef74f))
-
-### [0.9.6](https://github.com/honghuangdc/soybean-admin/compare/v0.9.5...v0.9.6) (2022-06-15)
-
-
-### Features
-
-* **projects:** 本地svg动态渲染图标 ([c3c975e](https://github.com/honghuangdc/soybean-admin/commit/c3c975ee1142987b7ded0107bf91d0080d5651fe)), closes [#61](https://github.com/honghuangdc/soybean-admin/issues/61)
-* **projects:** 上下结构,菜单支持横向滚动 ([808051b](https://github.com/honghuangdc/soybean-admin/commit/808051b29dd682e1cbcf0e211774efb9cc12713a))
-* **projects:** 新增Antv G2图表示例 ([2d64a2e](https://github.com/honghuangdc/soybean-admin/commit/2d64a2e57c8d83c8d06f210eeefef8f31b3abeb9))
-* **projects:** 增加设置当前Tab页签名称功能 ([487213b](https://github.com/honghuangdc/soybean-admin/commit/487213b64853765e2bd186474e4607572624a33e))
-
-
-### Bug Fixes
-
-* **projects:** 设置tab标题导致meta属性丢失 ([efcfa57](https://github.com/honghuangdc/soybean-admin/commit/efcfa576d52a7eab644f3b4c65af153442887fab))
-* **projects:** 修复顶部菜单的位置失效问题 ([4ee0d94](https://github.com/honghuangdc/soybean-admin/commit/4ee0d94f1bde83c788fc0dcb084402359c04fb1b))
-
-### [0.9.5](https://github.com/honghuangdc/soybean-admin/compare/v0.9.4...v0.9.5) (2022-06-06)
-
-
-### Features
-
-* **projects:** 支持同一路由根据不同query和hash同时显示不同Tab ([4122685](https://github.com/honghuangdc/soybean-admin/commit/4122685803f8a0a485682d16cec74e27945adc47)), closes [#64](https://github.com/honghuangdc/soybean-admin/issues/64)
-* **projects:** 动态路由根路由重定向只需取决于后端返回的路由首页 ([434ab1c](https://github.com/honghuangdc/soybean-admin/commit/434ab1c560b260f8a19895405eb1d3c3313052d7))
-* **projects:** 补充更多的ECharts示例 ([c776249](https://github.com/honghuangdc/soybean-admin/commit/c7762490def77695bedf179ffc63e3e95d15e14d))
-* **projects:** 添加百度地图、升级依赖 ([39854a4](https://github.com/honghuangdc/soybean-admin/commit/39854a492b9cce71e0c7ed52af9985cb4abd6a97))
-* **projects:** 添加插件页面:图表 ([0a46ea0](https://github.com/honghuangdc/soybean-admin/commit/0a46ea08443f6b879434e925d440cf07e9494fcb))
-* **projects:** 添加自动跟随系统主题设置 ([ba07b69](https://github.com/honghuangdc/soybean-admin/commit/ba07b695dd9dc5d3f8ebf57d0f2e69d624994962))
-* **projects:** 添加antv g2图表示例 ([44b022a](https://github.com/honghuangdc/soybean-admin/commit/44b022aefd7dbb4c34886814cf04767450dec026))
-* **projects:** 引入echarts替换antvG2plot ([e7ad086](https://github.com/honghuangdc/soybean-admin/commit/e7ad08685e8ac52a8906fc94e656192275f9764c))
-* **route:** 路由meta新增activeMenu属性 ([ebd16a4](https://github.com/honghuangdc/soybean-admin/commit/ebd16a4d1ab1a95a27838a2d4f20cc1d1e7309ae))
-
-
-### Bug Fixes
-
-* **projects:** 修复@antv/g2生产环境报错 ([4558c24](https://github.com/honghuangdc/soybean-admin/commit/4558c24d1c1e1faa3326650fc16e6baf384509ac))
-* **projects:** 修复插件不存在的错误提示 ([7165282](https://github.com/honghuangdc/soybean-admin/commit/716528206e9f63e873607d0afd59d83f6984e3fe))
-* **projects:** 修复权限切换路由数据未更新的问题 ([60f9125](https://github.com/honghuangdc/soybean-admin/commit/60f912508b0e685957fb22ef0ed1f83272847263))
-* **projects:** 修复页面切换时导致的溢出滚动条 ([e023306](https://github.com/honghuangdc/soybean-admin/commit/e0233061d3bca236b4c4bb462ce00f7ca186b9fa))
-* **route:** 当为左侧混合菜单时activeMenu无效情况 ([3e4f9e2](https://github.com/honghuangdc/soybean-admin/commit/3e4f9e282442073447c5c24c33d65bc6130978ee))
-
-### [0.9.4](https://github.com/honghuangdc/soybean-admin/compare/v0.9.3...v0.9.4) (2022-04-28)
-
-
-### Features
-
-* **layouts:** 添加侧边栏/头部的反转模式来增加对比度 ([861c8b9](https://github.com/honghuangdc/soybean-admin/commit/861c8b9852e0097a1f6b79ac2c10d19add123bde))
-* **layouts:** 添加侧边栏/头部的反转模式来增加对比度 ([3c8dd77](https://github.com/honghuangdc/soybean-admin/commit/3c8dd772f89d2b656a42c4f7164e581acdb2b1a5))
-* **projects:** 插件方式按需引入naiveUI ([6bed9ea](https://github.com/honghuangdc/soybean-admin/commit/6bed9ead38af6d58f6cd9e520db848ae5cbfa4db))
-* **projects:** 登录页背景图片位置适配移动端 ([24010d0](https://github.com/honghuangdc/soybean-admin/commit/24010d05fb1ff51cb5e5d94ffe310206a9638711))
-* **projects:** 登录页面适配移动端 ([ec0776e](https://github.com/honghuangdc/soybean-admin/commit/ec0776e268cd3d1031e9ecd794abce271a675793))
-* **projects:** 权限完善及权限示例页面 ([807448a](https://github.com/honghuangdc/soybean-admin/commit/807448aec5b041535fe4fbac90eca1138b2f439c))
-* **projects:** 添加请求适配器的请求示例 ([bed4292](https://github.com/honghuangdc/soybean-admin/commit/bed4292ed380e77ac428ab057abc42eceb72af53))
-* **projects:** 新增静态路由 ([ca2dfa6](https://github.com/honghuangdc/soybean-admin/commit/ca2dfa6185aa7a4e58184bcfef2a1246a52f88fd))
-* **projects:** 引入unocss替换windicss ([c9d3e5a](https://github.com/honghuangdc/soybean-admin/commit/c9d3e5a3fdf59179dcfc122ab8369c492ea7832e))
-* **projects:** HTML lang 修改为 zh-cmn-Hans ([b9c5c34](https://github.com/honghuangdc/soybean-admin/commit/b9c5c349790b1e83a7acd1f2c53a86c9221944ff))
-* **projects:** HTML lang 修改为 zh-cmn-Hans ([dbeb595](https://github.com/honghuangdc/soybean-admin/commit/dbeb595c0b9fc11e7d166a7684af37cc971f1a11))
-* **projects:** mock添加权限过滤 ([7f4350a](https://github.com/honghuangdc/soybean-admin/commit/7f4350aeb673dab59192584177a897aacebe4b28))
-
-
-### Bug Fixes
-
-* **projects:** 去除从环境文件引入端口号导致的错误 ([2d6d179](https://github.com/honghuangdc/soybean-admin/commit/2d6d179d669ea71cca3fe97ac840e4856bff4051))
-* **projects:** 全局搜索弹窗弹出时动画闪屏问题 ([bb1bbf2](https://github.com/honghuangdc/soybean-admin/commit/bb1bbf272438f4ed440735118c6a9ec04c7d109f))
-* **projects:** 添加.npmrc修复无法获取自动引入的全局组件声明类型 ([e8488e4](https://github.com/honghuangdc/soybean-admin/commit/e8488e4d5237e5e03ec07ff07d03115389d5b1ef))
-* **projects:** 添加获取路由组件文件未找到时的错误提示 ([219f87f](https://github.com/honghuangdc/soybean-admin/commit/219f87f46758f328f26697f66d8583f49c0d41de))
-* **projects:** 修复获取vite环境变量的方式 ([46e1ae7](https://github.com/honghuangdc/soybean-admin/commit/46e1ae7825b2b204ce3cdd63b3c64f39bff096d0))
-* **projects:** 修复路由守卫的动态路由逻辑 ([e6c26fc](https://github.com/honghuangdc/soybean-admin/commit/e6c26fcb4ae085f9fd7d7eb9183ddba020d0b5da))
-* **projects:** 修复样式 ([e899914](https://github.com/honghuangdc/soybean-admin/commit/e8999144266761b3b701442975c3c00251240d53))
-* **projects:** 修复在新版vite下环境变量获取不到的问题 ([3fb13ca](https://github.com/honghuangdc/soybean-admin/commit/3fb13ca9e710549d2ddeb774fe08fabd27d5ae11))
-* **projects:** 修复vite alias ([cd7ca8f](https://github.com/honghuangdc/soybean-admin/commit/cd7ca8f4c77ac8c753b753ba698a9573d6c37bf9))
-
-### [0.9.3](https://github.com/honghuangdc/soybean-admin/compare/v0.9.2...v0.9.3) (2022-03-12)
-
-
-### Features
-
-* **components:** svgIcon,添加type,调整size方案 ([ce4e039](https://github.com/honghuangdc/soybean-admin/commit/ce4e039f48001b47a2933e807f5410a9573781b9))
-* **projects:** 引入soybean-admin-tab、去除vite-plugin-svg-icons,用unplugin-icons实现自定义svg的iconify写法、代码优化 ([a1a57a1](https://github.com/honghuangdc/soybean-admin/commit/a1a57a185ce5004888ca4e1611973665ee46980b))
-* **projects:** 新增子菜单图标和多页签图标 ([f5c56c3](https://github.com/honghuangdc/soybean-admin/commit/f5c56c355ce41157b20ed0a10272a28e6d8b2b49))
-* **projects:** 新增自定义svg图标动态渲染 ([f83c7b5](https://github.com/honghuangdc/soybean-admin/commit/f83c7b59b893ab6e210188e92c4177b3d01392ce))
-* **projects:** 添加naiveUI按需引入 ([a810ef8](https://github.com/honghuangdc/soybean-admin/commit/a810ef85b19e4b74f3ddb3c69d17c050e556ee90))
-* **projects:** 添加SvgIcon,配置vite plugin ([378d55a](https://github.com/honghuangdc/soybean-admin/commit/378d55ac0e11cdf115ce3cb8e281d60f7fc4ff7a))
-* **projects:** 添加全局组件自动引入注册 ([f5a043b](https://github.com/honghuangdc/soybean-admin/commit/f5a043b11a403927828ae922bdae411a4e5ae3c6))
-* **projects:** 添加网络代理 ([094dca9](https://github.com/honghuangdc/soybean-admin/commit/094dca961f608404352ac360f44496423d88dae8))
-* **projects:** 重构项目的TS类型架构,去除interface文件夹 ([8191490](https://github.com/honghuangdc/soybean-admin/commit/8191490f39fc011096edd77c3156eb4fe33d4e1c))
-
-
-### Bug Fixes
-
-* **components:** 修复组件LoadingEmptyWrapper适应暗黑模式 ([811b15e](https://github.com/honghuangdc/soybean-admin/commit/811b15e672c9d69e9c5789eb11ab2db7bd729f37))
-* **components:** 组件LoadingEmptyWrapper添加背景颜色动画过渡 ([7add5c2](https://github.com/honghuangdc/soybean-admin/commit/7add5c2edfcabadb77084179d464b849d880d5e6))
-* **projects:** 修复 BASE_URL 没有生效的问题 ([72d7dcf](https://github.com/honghuangdc/soybean-admin/commit/72d7dcfa5ee8dc6f3601f4d65c6aca9ad2cc5d5c))
-* **projects:** 修复页面切换动画开关不生效 ([9d4ed61](https://github.com/honghuangdc/soybean-admin/commit/9d4ed617fb80095e521d8063718283459711118f))
-* **projects:** 修复页面切换动画无变化 ([c4546bd](https://github.com/honghuangdc/soybean-admin/commit/c4546bdfa303f1e89c0d7ddd46b54e4ec5170096))
-
-### [0.9.2](https://github.com/honghuangdc/soybean-admin/compare/v0.9.1...v0.9.2) (2022-02-11)
-
-
-### Features
-
-* **projects:** 迁移全局搜索菜单功能 ([554d7fd](https://github.com/honghuangdc/soybean-admin/commit/554d7fd6114b9cf6df571c3cb02f4cb0cc6dcfd4))
-
-
-### Bug Fixes
-
-* **components:** 修复Tab在移动端设备无法点击的问题 ([2c9660f](https://github.com/honghuangdc/soybean-admin/commit/2c9660fdbf9a84e980db0aff5cd0aed0f75963ca))
-* **projects:** 修复分析页和工作台的布局问题 ([e93b94c](https://github.com/honghuangdc/soybean-admin/commit/e93b94cb2435a130bb1d94a703328af342cd24c9))
-* **projects:** 修复项目配置拷贝功能 ([a7a269d](https://github.com/honghuangdc/soybean-admin/commit/a7a269d6a61ccd25883e6bb69639d39e0260587d))
-* **projects:** vite配置修复 ([facc00e](https://github.com/honghuangdc/soybean-admin/commit/facc00e8b4998dc8bd338e3b63a652b4bfe2ed3e))
-
-### [0.9.1](https://github.com/honghuangdc/soybean-admin/compare/v0.1.3...v0.9.1) (2022-01-23)
-
-
-### Features
-
-* **projects:** 新版重构完成 ([68b4230](https://github.com/honghuangdc/soybean-admin/commit/68b42304d5964246775c7a82dcc1406c5db7a4e4))
-
-### [0.1.3](https://github.com/honghuangdc/soybean-admin/compare/v0.1.2...v0.1.3) (2022-01-23)
-
-
-### Bug Fixes
-
-* **projects:** 修复未登录时会调用获取用户路由的接口 ([21bab1f](https://github.com/honghuangdc/soybean-admin/commit/21bab1f7c30611fe59dc91c7a73050ccb49a4658))
-* **projects:** 修复路由守卫的动态路由逻辑 ([b61b0ce](https://github.com/honghuangdc/soybean-admin/commit/b61b0ce25fdcbaf29ca64cbcc467e12faa947625))
-
-### [0.1.2](https://github.com/honghuangdc/soybean-admin/compare/v0.1.1...v0.1.2) (2022-01-21)
-
-
-### Features
-
-* **projects:** 添加缓存主题色 ([3709297](https://github.com/honghuangdc/soybean-admin/commit/37092974d37b2e661d4cbf9d27c89b5e99119cd7))
-* **projects:** 添加页面缓存、记录在tab中的缓存页面的滚动条位置 ([1d63a83](https://github.com/honghuangdc/soybean-admin/commit/1d63a838226df4f48e7f2a15b5a05d4b496d3c69))
-
-### [0.1.1](https://github.com/honghuangdc/soybean-admin/compare/v0.0.5...v0.1.1) (2022-01-20)
-
-
-### Features
-
-* **projects:** theme store完成 ([bf020a8](https://github.com/honghuangdc/soybean-admin/commit/bf020a82580e6b1fbda1cc1e0bd6176770434884))
-* **projects:** 主题配置抽屉: 迁移其他功能 ([6d132c5](https://github.com/honghuangdc/soybean-admin/commit/6d132c59770e925cfc61217dcefa5b4d937604df))
-* **projects:** 主题配置抽屉:迁移暗黑模式、布局模式、添加颜色选择面板 ([912bfdf](https://github.com/honghuangdc/soybean-admin/commit/912bfdf4390ab624d3f8e343be88e8c1cf7ab5b6))
-* **projects:** 创建自定义布局组件SoybeanLayout ([0653fb1](https://github.com/honghuangdc/soybean-admin/commit/0653fb144fe9d49f24ef4fe6e4a58de6de342b78))
-* **projects:** 初始化加载效果:应用主题颜色 ([035fa11](https://github.com/honghuangdc/soybean-admin/commit/035fa114c9fd638cf467e6a73a8e4c558f503deb))
-* **projects:** 图标选择器增加扩展树形 ([041012b](https://github.com/honghuangdc/soybean-admin/commit/041012b3ee04d960c1e38895839225613f7af377))
-* **projects:** 增加Icon选择器组件 ([9472b51](https://github.com/honghuangdc/soybean-admin/commit/9472b51811f419e9139de81c73f2c71d170700c2))
-* **projects:** 增加全局搜索菜单功能 ([b9ce691](https://github.com/honghuangdc/soybean-admin/commit/b9ce69130b12712013228326f883e2d973e4e46a))
-* **projects:** 增加项目文档外链 ([1901a0b](https://github.com/honghuangdc/soybean-admin/commit/1901a0bfb7bfa516dfda552675397ddec96b8d4b))
-* **projects:** 多级路由的所有子路由转换成二级路由 ([85b55bb](https://github.com/honghuangdc/soybean-admin/commit/85b55bb37a0a06e2645b96ed81aefe463127121a))
-* **projects:** 引入mockjs ([9bc682d](https://github.com/honghuangdc/soybean-admin/commit/9bc682dae878c084e38a0e2c9a4a2de171023c48))
-* **projects:** 新增BasicLayout布局 ([006467a](https://github.com/honghuangdc/soybean-admin/commit/006467a0626f427da3f516d90c15bf1e1eef0e55))
-* **projects:** 添加cryptojs,对本地缓存数据进行加密 ([7a0648d](https://github.com/honghuangdc/soybean-admin/commit/7a0648dba55a98f61f4d81696307d86c82a1d34d))
-* **projects:** 添加NaiveProvider组件 ([c804b21](https://github.com/honghuangdc/soybean-admin/commit/c804b21ceb92133c6ea7cc64c87521cc164e40ce))
-* **projects:** 添加侧边菜单 ([e25afe2](https://github.com/honghuangdc/soybean-admin/commit/e25afe2fadfe86b9330ee02190a4e40b8321714c))
-* **projects:** 添加头部折叠按钮 ([a090d39](https://github.com/honghuangdc/soybean-admin/commit/a090d398fc071e246b92d0da80883cf5cbedba0e))
-* **projects:** 添加常用组件、composables函数 ([230a50a](https://github.com/honghuangdc/soybean-admin/commit/230a50a4cf4d2ebb62b19d6324234243cf6b2f0d))
-* **projects:** 添加抽屉 ([10e4d81](https://github.com/honghuangdc/soybean-admin/commit/10e4d81bd6a0b35d8cfb4f7a1e981f8ef6ab87cc))
-* **projects:** 添加表格页面示例 ([51c744c](https://github.com/honghuangdc/soybean-admin/commit/51c744c8e2c8ed9691e92e35b6a88582f22c30d8))
-* **projects:** 添加路由跳转浏览器新标签 ([987cef3](https://github.com/honghuangdc/soybean-admin/commit/987cef336338987f2e6f0d5aba8f6d4602b297ca))
-* **projects:** 登录页面开始迁移 ([f5a36a0](https://github.com/honghuangdc/soybean-admin/commit/f5a36a05cb626ec62115283f1d2c534b2a787bdd))
-* **projects:** 细节完善 ([cc290ac](https://github.com/honghuangdc/soybean-admin/commit/cc290accc29282e9ba655356e2695b6ca4b23605))
-* **projects:** 细节完善、迁移页面 ([ce531ce](https://github.com/honghuangdc/soybean-admin/commit/ce531ce5dda0b4a1024aa6bd3d68835b59760d57))
-* **projects:** 菜单搜索增加大小写转换 ([2907868](https://github.com/honghuangdc/soybean-admin/commit/29078689b0652cf4ae852c93d8601a157579adcc))
-* **projects:** 请求拦截器添加刷新token ([839b82b](https://github.com/honghuangdc/soybean-admin/commit/839b82ba8b052b02e24bcfe6da54160609a4fd4b))
-* **projects:** 路由页面跳转权限完成 ([0d2a562](https://github.com/honghuangdc/soybean-admin/commit/0d2a5629e89c73a32d6c79f04b51543e1513e006))
-* **projects:** 迁移多页签 ([28efbdb](https://github.com/honghuangdc/soybean-admin/commit/28efbdbc70733d22011a0eee084d35711429d188))
-* **projects:** 迁移登录完成 ([b93b80c](https://github.com/honghuangdc/soybean-admin/commit/b93b80cb4b35268dfb6a09517a2494af24748dac))
-* **projects:** 集成naiveUI主题配置,将css vars添加至html ([2c19684](https://github.com/honghuangdc/soybean-admin/commit/2c196841bd8527d7acccefe6a7545e0a49d532f7))
-* **projects:** 面包屑 ([09c7658](https://github.com/honghuangdc/soybean-admin/commit/09c7658c21c7dda461dbb528e85b638b5a7dfacd))
-
-
-### Bug Fixes
-
-* **deps:** 降低vite版本 ([c9c5ca9](https://github.com/honghuangdc/soybean-admin/commit/c9c5ca9989eddb084f2706155473123c5dcfc334))
-* **projects:** 修复redirect-not-found子路由 ([5bfb819](https://github.com/honghuangdc/soybean-admin/commit/5bfb8199b463d9ca6430577b5c493c0b78967aa9))
-* **projects:** 修复vertical-mix布局、重构初始化的loading ([579e074](https://github.com/honghuangdc/soybean-admin/commit/579e07400e1b9a52934ed808a37c8579a41e8e74))
-* **projects:** 修复网络请求错误空信息的提示 ([ff9216b](https://github.com/honghuangdc/soybean-admin/commit/ff9216b621aaef0a8203386fa1c3ca5477a2edea))
-* **projects:** 修复面包屑数据 ([28b5d22](https://github.com/honghuangdc/soybean-admin/commit/28b5d224010a28669ad3a1919fc49f6e2dc808cd))
-* **projects:** 去除Layout组件冗余代码 ([0e783bc](https://github.com/honghuangdc/soybean-admin/commit/0e783bcf7be0b3a083fe950adfb0afc72b510f97))
-* **projects:** 请求相关细节修复 ([2ad1ad3](https://github.com/honghuangdc/soybean-admin/commit/2ad1ad32b8410d84902a33d825032c282ca6df86))

+ 17 - 0
Dockerfile

@@ -0,0 +1,17 @@
+FROM node:18.12-alpine as build
+WORKDIR /app/kpt-system-web
+ENV NODE_OPTIONS="--max-old-space-size=4096"
+COPY . .
+RUN mkdir -p /root/.local/share/pnpm/store/v3/files && chown -R $(whoami) /root/.local/share/pnpm/store/v3/
+RUN npm install -g pnpm && npm install -g typescript@5.1.6
+RUN echo "declare module 'lodash-es';" > types.d.ts
+RUN pnpm config set registry https://registry.npmmirror.com
+RUN pnpm update vue-demi@latest
+RUN pnpm install --fetch-timeout 60000
+RUN pnpm build 
+
+FROM nginx:alpine as prod
+WORKDIR /app/kpt-system-web
+COPY --from=build /app/kpt-system-web/dist/ /usr/share/nginx/html/
+COPY --from=build /app/kpt-system-web/nginx.conf /etc/nginx/conf.d/default.conf
+EXPOSE 80

+ 11 - 8
Makefile

@@ -1,15 +1,18 @@
 ImageTag ?=v0.9.6
-SoybeanAdminImg ?= soybeanjs/soybean-admin:$(ImageTag)
+KptSystemWebImg ?=kpt-event/kpt-system-web:$(ImageTag)
 
 VERSION=$(shell git rev-parse --short HEAD)
 
-soybean-admin: soybean-admin-build soybean-admin-push
-
-soybean-admin-build:
-	docker build --build-arg version=$(VERSION) -t ${SoybeanAdminImg} -f docker/Dockerfile .
-
-soybean-admin-push:
-	docker push ${SoybeanAdminImg}
+img-build:
+	pnpm i && pnpm build
+	docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
+	#docker buildx create --use --name mybuilder
+	docker buildx inspect mybuilder --bootstrap
+	#docker build --build-arg version=$(VERSION) -t ${KptSystemWebImg} -f ./Dockerfile .
+	docker buildx build --build-arg version=$(VERSION) -t ${KptSystemWebImg} -f ./Dockerfile --platform=linux/arm64 -o type=docker .
+	docker tag ${KptSystemWebImg}  registry.cn-hangzhou.aliyuncs.com/${KptSystemWebImg}
+	docker push registry.cn-hangzhou.aliyuncs.com/${KptSystemWebImg}
+	docker rmi ${KptSystemWebImg} registry.cn-hangzhou.aliyuncs.com/${KptSystemWebImg}
 
 # run tauri app:
 run:

+ 3 - 3
README.md

@@ -6,7 +6,7 @@
 - 克隆代码
 
 ```bash
-git clone https://github.com/honghuangdc/soybean-admin.git
+git clone http://kpt.kptyun.cn:3000/xuyiping/kpt-system-web.git
 ```
 
 - 安装依赖
@@ -32,10 +32,10 @@ pnpm build
 - Docker 部署 Soybean
 
 ```bash
-docker run --name soybean -p 80:80 -d soybeanjs/soybean-admin:v0.9.6
+docker run --name soybean -p 80:80 -d registry.cn-hangzhou.aliyuncs.com/kpt-event/kpt-system-web:latest
 ```
 
-- 访问 SoybeanAdmin
+- 访问 kpt-system-web
 
 打开本地浏览器访问`http://localhost`
 

+ 0 - 24
docker/Dockerfile

@@ -1,24 +0,0 @@
-FROM node:16.17.0 as builder
-
-ENV WORKDIR=/soybean-admin
-
-WORKDIR $WORKDIR
-
-COPY ./ $WORKDIR/
-
-ARG version
-ENV COMMITID=$version
-
-RUN npm i -g pnpm
-
-RUN pnpm install
-RUN pnpm build
-
-FROM nginx:alpine as prod
-
-RUN mkdir /soybean
-
-COPY --from=builder /soybean-admin/dist /soybean-admin
-COPY --from=builder /soybean-admin/docker/nginx.conf /etc/nginx/nginx.conf
-
-EXPOSE 80

+ 0 - 54
docker/nginx.conf

@@ -1,54 +0,0 @@
-user  nginx;
-worker_processes  1;
-error_log  /var/log/nginx/error.log warn;
-pid        /var/run/nginx.pid;
-
-events {
-  worker_connections  1024;
-}
-
-http {
-  include       /etc/nginx/mime.types;
-  default_type  application/octet-stream;
-  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
-                    '$status $body_bytes_sent "$http_referer" '
-                    '"$http_user_agent" "$http_x_forwarded_for"';
-  access_log  /var/log/nginx/access.log  main;
-  sendfile        on;
-  keepalive_timeout  65;
-
-  server {
-    listen       80;
-    server_name  localhost;
-
-    location / {
-      # 不缓存html,防止程序更新后缓存继续生效
-      if ($request_filename ~* .*\.(?:htm|html)$) {
-        add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
-        access_log on;
-      }
-      root   /soybean-admin/;
-      index  index.html index.htm;
-      try_files $uri $uri/ /index.html;
-    }
-
-    # location /soybean/soybean-webserver/v1 {
-    #     proxy_set_header Host $host;
-    #     proxy_set_header X-Real-IP $remote_addr;
-    #     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-    #     proxy_set_header REMOTE-HOST $remote_addr;
-
-    #     # 后台接口地址
-    #     proxy_pass http://192.168.1.99:30597/v1;
-    #     proxy_redirect default;
-    #     add_header Access-Control-Allow-Origin *;
-    #     add_header Access-Control-Allow-Headers X-Requested-With;
-    #     add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
-    # }
-
-    error_page   500 502 503 504  /50x.html;
-    location = /50x.html {
-      root   /usr/share/nginx/html;
-    }
-  }
-}

+ 24 - 0
images.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+set -e
+
+ImageTag=$1
+if [ -n "$ImageTag" ]
+then
+  echo "当前镜像tag: $ImageTag"
+else
+  echo "请输入当前镜像tag"
+  exit
+fi
+
+### go build
+echo "============ go build start ================"
+make img-build ImageTag="${ImageTag}"
+echo "============push images end ================"
+
+
+export DOCKER_CLI_EXPERIMENTAL=enabled
+docker buildx version
+docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
+
+docker buildx create --use --name mybuilder
+docker buildx inspect mybuilder --bootstrap

+ 1 - 2
mock/api/index.ts

@@ -1,5 +1,4 @@
 import auth from './auth';
 import route from './route';
-import management from './management';
 
-export default [...auth, ...route, ...management];
+export default [...auth, ...route];

+ 0 - 33
mock/api/management.ts

@@ -1,33 +0,0 @@
-import { mock } from 'mockjs';
-import type { MockMethod } from 'vite-plugin-mock';
-
-const apis: MockMethod[] = [
-  {
-    url: '/mock/getAllUserList',
-    method: 'post',
-    response: (): Service.MockServiceResult<ApiUserManagement.User[]> => {
-      const data = mock({
-        'list|1000': [
-          {
-            id: '@id',
-            userName: '@cname',
-            'age|18-56': 56,
-            'gender|1': ['0', '1', null],
-            phone:
-              /^[1](([3][0-9])|([4][01456789])|([5][012356789])|([6][2567])|([7][0-8])|([8][0-9])|([9][012356789]))[0-9]{8}$/,
-            'email|1': ['@email("qq.com")', null],
-            'userStatus|1': ['1', '2', '3', '4', null]
-          }
-        ]
-      });
-
-      return {
-        code: 200,
-        message: 'ok',
-        data: data.list
-      };
-    }
-  }
-];
-
-export default apis;

+ 32 - 0
nginx.conf

@@ -0,0 +1,32 @@
+server {
+   listen       80;
+   listen  [::]:80;
+   server_name  localhost;
+
+   gzip on;
+   gzip_static on;
+   gzip_comp_level 6;
+   gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
+
+   location / {
+        root /usr/share/nginx/html;
+        #index index.html;
+        try_files $uri $uri/ /index.html;
+        client_max_body_size 300m;   #最大接受300m文件以内的
+        client_body_timeout 20s;
+   }
+
+   location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css){
+       root    /usr/share/nginx/html;
+       expires 7d;
+   }
+
+   #error_page  404              /404.html;
+
+   # redirect server error pages to the static page /50x.html
+   #
+   error_page   500 502 503 504  /50x.html;
+   location = /50x.html {
+      root   /usr/share/nginx/html;
+   }
+}

+ 1 - 1
package.json

@@ -70,7 +70,7 @@
     "form-data": "^4.0.0",
     "lodash-es": "^4.17.21",
     "naive-ui": "2.34.3",
-    "pinia": "^2.0.33",
+    "pinia": "2.0.36",
     "print-js": "^1.6.0",
     "qs": "^6.11.1",
     "swiper": "^9.1.0",

File diff suppressed because it is too large
+ 312 - 231
pnpm-lock.yaml


+ 2 - 31
src/constants/business.ts

@@ -161,35 +161,6 @@ export const WorkflowIsShowLabels: Record<BackgroundWorkflow.IsShowKey, string>
   2: '否'
 };
 
-export const MqttAuthIsShowLabels: Record<ApiMqttAuth.IsShowKey, string> = {
-  0: '无效',
-  1: '是',
-  2: '否'
-};
-
-export const MqttTopicIsShowLabels: Record<ApiMqttAuth.IsShowKey, string> = {
-  0: '无效',
-  1: '是',
-  2: '否'
-};
-
-export const MqttUserIsShowLabels: Record<ApiMqttAuth.IsShowKey, string> = {
-  0: '无效',
-  1: '是',
-  2: '否'
-};
-
-export const MqttPastureIsShowLabels: Record<ApiMqttAuth.IsShowKey, string> = {
-  0: '无效',
-  1: '是',
-  2: '否'
-};
-
-export const MqttPastureOptions: Common.OptionWithKey<ApiMqttAuth.IsShowKey>[] = [
-  { value: 1, label: MqttPastureIsShowLabels['1'] },
-  { value: 2, label: MqttPastureIsShowLabels['2'] }
-];
-
 /** 主题动作 */
 export const userTopicAccessLabel: Record<ApiMqttUser.IsAccessKey, string> = {
   1: '发布',
@@ -205,8 +176,8 @@ export const UserTopicAccessOptions: Common.OptionWithKey<ApiMqttUser.IsAccessKe
 
 /** 主题动作 */
 export const topicAccessLabel: Record<ApiMqttTopic.AccessKey, string> = {
-  1: '发布',
-  2: '订阅'
+  1: '订阅',
+  2: '发布'
 };
 
 export const TopicAccessOptions: Common.OptionWithKey<ApiMqttTopic.AccessKey>[] = [

+ 0 - 10
src/router/modules/mqtt.ts

@@ -23,16 +23,6 @@ const mqtt: AuthRoute.Route = {
         icon: 'icon-park-outline:topic'
       }
     },
-    {
-      name: 'mqtt_category',
-      path: '/mqtt/category',
-      component: 'self',
-      meta: {
-        title: '分类管理',
-        requiresAuth: true,
-        icon: 'carbon:category'
-      }
-    },
     {
       name: 'mqtt_authentication',
       path: '/mqtt/authentication',

+ 0 - 36
src/service/api/mqtt.adapter.ts

@@ -1,27 +1,3 @@
-export function adapterOfMqttAuthList(data: Mqtt.Auth[] | null): ApiMqttAuth.Auth[] {
-  if (!data) return [];
-  return data.map(item => {
-    const field: ApiMqttAuth.Auth = {
-      index: item.id,
-      key: item.id,
-      ...item
-    };
-    return field;
-  });
-}
-
-export function adapterOfMqttTopicList(data: Mqtt.Topic[] | null): ApiMqttTopic.Topic[] {
-  if (!data) return [];
-  return data.map(item => {
-    const field: ApiMqttTopic.Topic = {
-      index: item.id,
-      key: item.id,
-      ...item
-    };
-    return field;
-  });
-}
-
 export function adapterOfMqttUserList(data: Mqtt.User[] | null): ApiMqttUser.User[] {
   if (!data) return [];
   return data.map(item => {
@@ -34,18 +10,6 @@ export function adapterOfMqttUserList(data: Mqtt.User[] | null): ApiMqttUser.Use
   });
 }
 
-export function adapterOfMqttPastureList(data: Mqtt.Pasture[] | null): ApiMqttPasture.Pasture[] {
-  if (!data) return [];
-  return data.map(item => {
-    const field: ApiMqttPasture.Pasture = {
-      index: item.id,
-      key: item.id,
-      ...item
-    };
-    return field;
-  });
-}
-
 export function adapterOfMqttPastureEnumList(data: Common.OptionWithKey<any>[] | null): Common.OptionWithKey<any>[] {
   if (!data) return [];
   return data;

+ 31 - 20
src/service/api/mqtt.ts

@@ -1,12 +1,8 @@
 import { adapter } from '@/utils';
 import {
-  adapterOfMqttAuthList,
   adapterOfMqttCategoryEnumList,
   adapterOfMqttCategoryList,
-  adapterOfMqttPastureEnumList,
-  adapterOfMqttPastureList,
   adapterOfMqttTopicEnumList,
-  adapterOfMqttTopicList,
   adapterOfMqttUserList
 } from '@/service/api/mqtt.adapter';
 import { backgroundRequest } from '../request';
@@ -17,11 +13,11 @@ export const fetchMqttAuthList = async (
   pageSize: number | undefined,
   params: Mqtt.SearchAuth | null
 ) => {
-  const data = await backgroundRequest.post<Mqtt.Auth[] | null>(
+  const data = await backgroundRequest.post<Mqtt.AuthData | null>(
     `/mqtt/auth/list?page=${page}&page_size=${pageSize}`,
     params
   );
-  return adapter(adapterOfMqttAuthList, data);
+  return data;
 };
 
 /** 删除用户鉴权列表 */
@@ -45,13 +41,13 @@ export const fetchMqttTopicList = async (
   pageSize: number | undefined,
   topic_name: string
 ) => {
-  const data = await backgroundRequest.post<Mqtt.Topic[] | null>(
+  const data = await backgroundRequest.post<Mqtt.TopicData | null>(
     `/mqtt/topic/list?page=${page}&page_size=${pageSize}`,
     {
       topic_name
     }
   );
-  return adapter(adapterOfMqttTopicList, data);
+  return data;
 };
 
 /** 添加topic */
@@ -87,12 +83,13 @@ export const mqttUserEdit = (param: Mqtt.User) => {
 };
 
 /** 获取牧场列表 */
-export const fetchMqttPastureList = async (page: number, pageSize: number, name: string) => {
-  const data = await backgroundRequest.post<Mqtt.Pasture[] | null>(
+export const fetchMqttPastureList = async (page: number, pageSize: number, pasture_name: string) => {
+  const data = await backgroundRequest.post<Mqtt.PastureData | null>(
     `/mqtt/pasture/list?page=${page}&page_size=${pageSize}`,
-    { name }
+    { pasture_name }
   );
-  return adapter(adapterOfMqttPastureList, data);
+
+  return data;
 };
 
 /** 添加牧场 */
@@ -105,14 +102,9 @@ export const mqttPastureEdit = (param: Mqtt.Pasture) => {
   return backgroundRequest.post<ApiBoolean.OK | null>('/mqtt/pasture/edit', param);
 };
 
-export const pastureEnumList = async () => {
-  const data = await backgroundRequest.get<Common.OptionWithKey<any>[] | null>('/mqtt/pasture/enum/list');
-  return adapter(adapterOfMqttPastureEnumList, data);
-};
-
-export const topicEnumList = async (access: number | null) => {
+export const topicEnumList = async (access: number | null, pastureId: number | null) => {
   const data = await backgroundRequest.get<Common.OptionWithKey<any>[] | null>(
-    `/mqtt/topic/enum/list?access=${access}`
+    `/mqtt/topic/enum/list?access=${access}&pasture_id=${pastureId}`
   );
   return adapter(adapterOfMqttTopicEnumList, data);
 };
@@ -137,6 +129,25 @@ export const mqttCategoryEdit = (param: Mqtt.Category) => {
 };
 
 export const categoryEnumList = async () => {
-  const data = await backgroundRequest.get<Common.OptionWithKey<any>[] | null>('/mqtt/topic-category/enum/list');
+  const data = await backgroundRequest.get<Common.OptionWithKey<any>[] | null>('/mqtt/enum/list?type=2');
+  return adapter(adapterOfMqttCategoryEnumList, data);
+};
+
+export const groupEnumList = async () => {
+  const data = await backgroundRequest.get<Common.OptionWithKey<any>[] | null>('/mqtt/enum/list?type=2');
+  return adapter(adapterOfMqttCategoryEnumList, data);
+};
+
+export const groupPastureEnumList = async (group_id: string) => {
+  const groupPastureList = await backgroundRequest.get<Common.OptionWithKey<any>[] | null>(
+    `/mqtt/group/pasture/list/${group_id}`
+  );
+  return adapter(adapterOfMqttTopicEnumList, groupPastureList);
+};
+
+export const groupTopicEnumList = async (pastureId: number, access: number) => {
+  const data = await backgroundRequest.get<Common.OptionWithKey<any>[] | null>(
+    `/mqtt/topic/enum/list?pasture_id=${pastureId}&access=${access}`
+  );
   return adapter(adapterOfMqttCategoryEnumList, data);
 };

+ 8 - 2
src/service/request/index.ts

@@ -5,8 +5,14 @@ const { url, proxyPattern } = getServiceEnvConfig(import.meta.env);
 
 const isHttpProxy = import.meta.env.VITE_HTTP_PROXY === 'Y';
 
-export const request = createRequest({ baseURL: isHttpProxy ? proxyPattern : url });
+export const request = createRequest({
+  baseURL: isHttpProxy ? proxyPattern : url
+});
 
 export const mockRequest = createRequest({ baseURL: '/mock' });
 
-export const backgroundRequest = createRequest({ baseURL: 'http://192.168.1.96:8001/api/v1' });
+export const backgroundRequest = createRequest({
+  baseURL: 'http://vernamq8085.kptyun.com/api/v1'
+});
+/* export const backgroundRequest = createRequest({ baseURL: 'http://192.168.1.96:8000/api/v1' });
+ */

+ 0 - 32
src/typings/business.d.ts

@@ -136,14 +136,6 @@ declare namespace ApiMqttAuth {
     /** 表格的key(id) */
     key: number;
   }
-
-  /**
-   * 是否启动
-   * 0 无效
-   * 1:是
-   * 2: 否 */
-
-  type IsShowKey = NonNullable<Auth['is_show']>;
 }
 
 declare namespace ApiMqttTopic {
@@ -154,13 +146,6 @@ declare namespace ApiMqttTopic {
     key: number;
   }
 
-  /**
-   * 是否启动
-   * 0 无效
-   * 1:是
-   * 2: 否
-   */
-  type IsShowKey = NonNullable<Topic['is_show']>;
   type AccessKey = NonNullable<Topic['access']>;
 }
 
@@ -189,23 +174,6 @@ declare namespace ApiMqttUser {
   type IsAccessKey = NonNullable<User['access']>;
 }
 
-declare namespace ApiMqttPasture {
-  interface Pasture extends Mqtt.Pasture {
-    /** 序号 */
-    index: number;
-    /** 表格的key(id) */
-    key: number;
-  }
-
-  /**
-   * 是否启动
-   * 0 无效
-   * 1:是
-   * 2: 否
-   */
-  type IsGroupKey = NonNullable<Pasture['is_group']>;
-}
-
 declare namespace ApiMqttCategory {
   interface Category extends Mqtt.Category {
     /** 序号 */

+ 36 - 14
src/typings/mqtt.d.ts

@@ -3,25 +3,34 @@ declare namespace Mqtt {
     id: number;
     client_id: string | null;
     mount_point: string | null;
-    user_name: string | null;
+    user_name: string;
     password: string;
     pasture_id: number | null;
     pasture_name: string | null;
-    publish_topic_ids: [] | null;
-    subscribe_topic_ids: [] | null;
+    pub_topic_id: number | null;
+    sub_topic_id: number | null;
     access: number | null;
     publish_acl: string | null;
     subscribe_acl: string | null;
-    is_show: number | null;
     created_at_format: string | null;
     updated_at_format: string | null;
+    pub_topic_ids: [] | null;
+    sub_topic_ids: [] | null;
+    key: number;
+  }
+
+  interface AuthData {
+    page: number;
+    page_size: number;
+    list: Auth[];
+    count: number;
   }
 
   interface SearchAuth {
-    pasture_name: string | null;
-    user_name: string | null;
-    publish_topic_name: string | null;
-    subscribe_topic_name: string | null;
+    pasture_name: string;
+    user_name: string;
+    pub_topic_name: string;
+    sub_topic_name: string;
   }
 
   interface User {
@@ -39,26 +48,39 @@ declare namespace Mqtt {
 
   interface Topic {
     id: number;
-    category_id: number | null;
-    category_name: string | null;
+    pasture_id: number | null;
+    pasture_name: string | null;
     topic_name: string | null;
     topic_template: string | null;
     access: number | null;
     is_show: number | null;
     created_at_format: string | null;
     updated_at_format: string | null;
+    key: number;
+  }
+
+  interface TopicData {
+    page: number;
+    page_size: number;
+    list: Topic[];
+    count: number;
   }
 
   interface Pasture {
     id: number;
-    name: string | null;
+    pasture_name: string | null;
     short_name: string | null;
-    address: string | null;
-    is_group: number | null;
     is_show: number | null;
-    group_id: number | null;
     created_at_format: string | null;
     updated_at_format: string | null;
+    key: number;
+  }
+
+  interface PastureData {
+    page: number;
+    page_size: number;
+    list: Pasture[];
+    count: number;
   }
 
   interface Category {

+ 2 - 2
src/typings/page-route.d.ts

@@ -59,8 +59,8 @@ declare namespace PageRoute {
     | 'management_user'
     | 'mqtt'
     | 'mqtt_authentication'
-    | 'mqtt_pasture'
     | 'mqtt_category'
+    | 'mqtt_pasture'
     | 'mqtt_topic'
     | 'multi-menu'
     | 'multi-menu_first'
@@ -121,8 +121,8 @@ declare namespace PageRoute {
     | 'management_route'
     | 'management_user'
     | 'mqtt_authentication'
-    | 'mqtt_pasture'
     | 'mqtt_category'
+    | 'mqtt_pasture'
     | 'mqtt_topic'
     | 'multi-menu_first_second-new_third'
     | 'multi-menu_first_second'

+ 1 - 1
src/views/index.ts

@@ -38,8 +38,8 @@ export const views: Record<
   management_route: () => import('./management/route/index.vue'),
   management_user: () => import('./management/user/index.vue'),
   mqtt_authentication: () => import('./mqtt/authentication/index.vue'),
+  mqtt_category: () => import('./mqtt/category/index.vue'),
   mqtt_pasture: () => import('./mqtt/pasture/index.vue'),
-  mqtt_category: () => import('./mqtt/topic-category/index.vue'),
   mqtt_topic: () => import('./mqtt/topic/index.vue'),
   'multi-menu_first_second-new_third': () => import('./multi-menu/first/second-new/third/index.vue'),
   'multi-menu_first_second': () => import('./multi-menu/first/second/index.vue'),

+ 91 - 43
src/views/mqtt/authentication/components/table-action-modal.vue

@@ -1,24 +1,27 @@
 <template>
-  <n-modal v-model:show="modalVisible" preset="card" :title="title" class="w-700px">
+  <n-modal v-model:show="modalVisible" preset="card" :title="title" class="w-800px">
     <n-form ref="formRef" label-placement="left" :label-width="90" :model="formModel" :rules="rules">
       <n-grid :cols="50" :x-gap="18">
-        <n-form-item-grid-item :span="18" label="客户端ID" size="large" path="client_id">
-          <n-input v-model:value="formModel.client_id" />
-        </n-form-item-grid-item>
         <n-form-item-grid-item :span="18" label="牧场名称" size="large" path="pasture_id">
-          <n-select v-model:value="formModel.pasture_id" :options="pastureEnumListData" />
+          <n-select v-model:value="formModel.pasture_id" :options="groupEnumListData" clearable />
         </n-form-item-grid-item>
         <n-form-item-grid-item :span="18" label="用户名称" size="large" path="user_name">
           <n-input v-model:value="formModel.user_name" />
         </n-form-item-grid-item>
-        <n-form-item-grid-item :span="18" label="用户密码" size="large" path="user_name">
+        <n-form-item-grid-item :span="18" label="用户密码" size="large" path="password">
           <n-input v-model:value="formModel.password" type="password" />
         </n-form-item-grid-item>
-        <n-form-item-grid-item :span="18" label="订阅主题名(topic)" size="large" path="topic_ids">
-          <n-select v-model:value="formModel.subscribe_topic_ids" multiple :options="subscribeTopicEnumListData" />
+        <n-form-item-grid-item :span="18" label="订阅主题名(sub)" size="large" path="sub_topic_ids">
+          <n-select v-model:value="formModel.sub_topic_ids" multiple :options="subscribeTopicEnumListData" />
+        </n-form-item-grid-item>
+        <n-form-item-grid-item v-if="formModel.id" :span="18" label="订阅主题名(sub)" size="large" path="sub_topic_id">
+          <n-select v-model:value="formModel.sub_topic_ids" multiple :options="subscribeTopicEnumListData" />
+        </n-form-item-grid-item>
+        <n-form-item-grid-item :span="18" label="发布主题名(pub)" size="large" path="pub_topic_ids">
+          <n-select v-model:value="formModel.pub_topic_ids" multiple :options="publishTopicEnumListData" />
         </n-form-item-grid-item>
-        <n-form-item-grid-item :span="18" label="发布主题名(topic)" size="large" path="topic_ids">
-          <n-select v-model:value="formModel.publish_topic_ids" multiple :options="publishTopicEnumListData" />
+        <n-form-item-grid-item v-if="formModel.id" :span="18" label="发布主题名(pub)" size="large" path="pub_topic_id">
+          <n-select v-model:value="formModel.pub_topic_id" multiple :options="publishTopicEnumListData" />
         </n-form-item-grid-item>
       </n-grid>
       <n-space class="w-full pt-16px" :size="24" justify="end">
@@ -31,9 +34,9 @@
 
 <script setup lang="ts">
 import { computed, ref, reactive, watch } from 'vue';
-import type { FormInst, FormItemRule, SelectOption } from 'naive-ui';
+import type { FormInst, SelectOption, FormItemRule } from 'naive-ui';
 import { createRequiredFormRule } from '@/utils';
-import { mqttAuthAdd, mqttAuthEdit } from '@/service/api/mqtt';
+import { mqttAuthAdd, mqttAuthEdit, groupTopicEnumList } from '@/service/api/mqtt';
 import { MD5 } from '@/utils/crypto';
 export interface Props {
   /** 弹窗可见性 */
@@ -46,15 +49,25 @@ export interface Props {
   type?: 'add' | 'edit';
   /** 编辑的表格行数据 */
   editData?: Mqtt.Auth | null;
-  pastureEnumListData: SelectOption[];
-  subscribeTopicEnumListData: SelectOption[];
-  publishTopicEnumListData: SelectOption[];
+  groupEnumListData: SelectOption[];
 }
 
 export type ModalType = NonNullable<Props['type']>;
-
 defineOptions({ name: 'TableActionModal' });
 
+const subscribeTopicEnumListData = ref<SelectOption[]>([]);
+const publishTopicEnumListData = ref<SelectOption[]>([]);
+const sub = 1; // 订阅
+const pub = 2; // 发布
+
+function setSubTopicEnumList(data: SelectOption[]) {
+  subscribeTopicEnumListData.value = data;
+}
+
+function setPubTopicEnumList(data: SelectOption[]) {
+  publishTopicEnumListData.value = data;
+}
+
 const props = withDefaults(defineProps<Props>(), {
   type: 'add',
   editData: null
@@ -80,8 +93,8 @@ const closeModal = () => {
 };
 
 const titles: Record<ModalType, string> = {
-  add: '添加用户',
-  edit: '编辑用户'
+  add: '添加鉴权',
+  edit: '编辑鉴权'
 };
 
 const title = computed(() => {
@@ -99,36 +112,20 @@ type FormModel = Pick<
   | 'user_name'
   | 'password'
   | 'client_id'
-  | 'publish_topic_ids'
-  | 'subscribe_topic_ids'
+  | 'pub_topic_id'
+  | 'sub_topic_id'
   | 'publish_acl'
   | 'subscribe_acl'
   | 'access'
-  | 'is_show'
+  | 'key'
+  | 'pub_topic_ids'
+  | 'sub_topic_ids'
   | 'created_at_format'
   | 'updated_at_format'
 >;
 
 const formModel = reactive<FormModel>(createDefaultFormModel());
 
-const rules: Record<keyof FormModel, FormItemRule | FormItemRule[]> = {
-  pasture_id: createRequiredFormRule('请选择牧场'),
-  user_name: createRequiredFormRule('请输入用户名称'),
-  password: createRequiredFormRule('请输入用户密码'),
-  client_id: createRequiredFormRule('请输入客户端id'),
-  publish_topic_ids: createRequiredFormRule('请选择topic模板'),
-  subscribe_topic_ids: createRequiredFormRule('请选择topic模板'),
-  access: createRequiredFormRule('请选择topic权限'),
-  is_show: createRequiredFormRule(),
-  mount_point: createRequiredFormRule(),
-  pasture_name: createRequiredFormRule(),
-  subscribe_acl: createRequiredFormRule(),
-  publish_acl: createRequiredFormRule(),
-  created_at_format: createRequiredFormRule(),
-  updated_at_format: createRequiredFormRule(),
-  id: createRequiredFormRule()
-};
-
 function createDefaultFormModel(): FormModel {
   return {
     id: 0,
@@ -138,17 +135,39 @@ function createDefaultFormModel(): FormModel {
     user_name: '',
     password: '',
     client_id: '',
-    publish_topic_ids: [],
-    subscribe_topic_ids: [],
+    pub_topic_id: 0,
+    sub_topic_id: 0,
+    pub_topic_ids: [],
+    sub_topic_ids: [],
     access: 0,
-    is_show: 1,
     publish_acl: '',
     subscribe_acl: '',
     created_at_format: '',
-    updated_at_format: ''
+    updated_at_format: '',
+    key: 0
   };
 }
 
+const rules: Record<keyof FormModel, FormItemRule | FormItemRule[]> = {
+  pasture_name: createRequiredFormRule('请输入牧场名称'),
+  created_at_format: createRequiredFormRule(),
+  updated_at_format: createRequiredFormRule(),
+  id: createRequiredFormRule(),
+  mount_point: createRequiredFormRule(),
+  pasture_id: createRequiredFormRule('请输入牧场名称'),
+  user_name: createRequiredFormRule('请输入用户名称'),
+  password: createRequiredFormRule('请输入用户密码'),
+  client_id: createRequiredFormRule(),
+  pub_topic_id: createRequiredFormRule(),
+  sub_topic_id: createRequiredFormRule(),
+  publish_acl: createRequiredFormRule(),
+  subscribe_acl: createRequiredFormRule(),
+  access: createRequiredFormRule(),
+  key: createRequiredFormRule(),
+  pub_topic_ids: createRequiredFormRule('请选择发布主题'),
+  sub_topic_ids: createRequiredFormRule('请选择订阅主题')
+};
+
 function handleUpdateFormModel(model: Partial<FormModel>) {
   Object.assign(formModel, model);
 }
@@ -181,6 +200,7 @@ async function handleSubmit() {
   }
 
   if (props.type === 'edit') {
+    formModel.password = MD5(formModel.password).toString();
     const data = mqttAuthEdit(formModel);
     data.then(res => {
       if (res.data?.success) {
@@ -191,6 +211,24 @@ async function handleSubmit() {
   closeModal();
 }
 
+async function subTopicOptions(newPastureId: number) {
+  const { data } = await groupTopicEnumList(newPastureId, sub);
+  if (data) {
+    setTimeout(() => {
+      setSubTopicEnumList(data);
+    }, 100);
+  }
+}
+
+async function pubTopicOptions(newPastureId: number) {
+  const { data } = await groupTopicEnumList(newPastureId, pub);
+  if (data) {
+    setTimeout(() => {
+      setPubTopicEnumList(data);
+    }, 100);
+  }
+}
+
 watch(
   () => props.visible,
   newValue => {
@@ -199,6 +237,16 @@ watch(
     }
   }
 );
+
+watch(
+  () => formModel.pasture_id,
+  newPastureId => {
+    if (newPastureId && newPastureId > 0) {
+      subTopicOptions(newPastureId);
+      pubTopicOptions(newPastureId);
+    }
+  }
+);
 </script>
 
 <style scoped></style>

+ 60 - 89
src/views/mqtt/authentication/index.vue

@@ -10,26 +10,23 @@
         </n-space>
         <n-space align="center" :size="18">
           <n-input-group>
-            <n-input v-model:value="formValue.subscribe_topic_name" placeholder="输入订阅主题名称" />
-            <n-input v-model:value="formValue.publish_topic_name" placeholder="输入发布主题名称" />
             <n-input v-model:value="formValue.user_name" placeholder="输入用户姓名" />
             <n-input v-model:value="formValue.pasture_name" placeholder="输入牧场名称" />
             <n-button type="primary" @click="handleSearch">搜索</n-button>
           </n-input-group>
-          <n-button size="small" type="primary" @click="getTableData">
+          <n-button size="small" type="primary" @click="getTableData(1, 10)">
             <icon-mdi-refresh class="mr-4px text-16px" :class="{ 'animate-spin': loading }" />
             刷新表格
           </n-button>
         </n-space>
       </n-space>
-      <n-data-table :columns="columns" :data="tableData" :loading="loading" :pagination="pagination" />
+      <n-data-table remote :columns="columns" :data="tableData" :loading="loading" :pagination="pagination" />
       <table-action-modal
         v-model:visible="visible"
         :type="modalType"
         :edit-data="editData"
-        :pasture-enum-list-data="pastureEnumListData"
-        :subscribe-topic-enum-list-data="subscribeTopicEnumListData"
-        :publish-topic-enum-list-data="publishTopicEnumListData"
+        :group-enum-list-data="groupEnumListData"
+        @update:visible="handleModalVisibilityChange"
       />
     </n-card>
   </div>
@@ -38,47 +35,53 @@
 <script setup lang="tsx">
 import { reactive, ref } from 'vue';
 import type { Ref } from 'vue';
-import { NButton, NSpace, NTag, NPopconfirm } from 'naive-ui';
+import { NButton, NSpace, NPopconfirm } from 'naive-ui';
 import type { DataTableColumns, PaginationProps, SelectOption } from 'naive-ui';
-import { MqttAuthIsShowLabels } from '@/constants';
 import { useBoolean, useLoading } from '@/hooks';
-import { fetchMqttAuthList, mqttAuthDelete, pastureEnumList, topicEnumList } from '@/service/api/mqtt';
+import { fetchMqttAuthList, groupEnumList, mqttAuthDelete } from '@/service/api/mqtt';
 import TableActionModal from '../authentication/components/table-action-modal.vue';
 import type { ModalType } from '../authentication/components/table-action-modal.vue';
 
 const { loading, startLoading, endLoading } = useLoading(false);
 const { bool: visible, setTrue: openModal } = useBoolean();
 const formValue = ref<Mqtt.SearchAuth>({
-  publish_topic_name: '',
-  subscribe_topic_name: '',
+  pub_topic_name: '',
+  sub_topic_name: '',
   pasture_name: '',
   user_name: ''
 });
 
-const tableData = ref<ApiMqttAuth.Auth[]>([]);
+const tableData = ref<Mqtt.Auth[]>([]);
 const editData = ref<Mqtt.Auth | null>(null);
 const modalType = ref<ModalType>('add');
-const pastureEnumListData = ref<SelectOption[]>([]);
-const subscribeTopicEnumListData = ref<SelectOption[]>([]);
-const publishTopicEnumListData = ref<SelectOption[]>([]);
-
-function setPastureList(data: SelectOption[]) {
-  pastureEnumListData.value = data;
-}
-
-function setSubscribeTopicList(data: SelectOption[]) {
-  subscribeTopicEnumListData.value = data;
-}
+const groupEnumListData = ref<SelectOption[]>([]);
+const defaultPage = ref(1);
+const defaultPageSize = ref(10);
+const pagination: PaginationProps = reactive({
+  page: defaultPage.value,
+  pageSize: defaultPageSize.value,
+  itemCount: 100,
+  showSizePicker: true,
+  pageSizes: [10, 15, 20, 30, 50],
+  onChange: (page: number) => {
+    pagination.page = page;
+    getTableData(page, Number(pagination.pageSize));
+  },
+  onUpdatePageSize: (pageSize: number) => {
+    pagination.pageSize = pageSize;
+    getTableData(Number(pagination.page), pageSize);
+  }
+});
 
-function setPublishTopicList(data: SelectOption[]) {
-  publishTopicEnumListData.value = data;
+function setGroupList(data: SelectOption[]) {
+  groupEnumListData.value = data;
 }
 
 function setEditData(data: Mqtt.Auth | null) {
   editData.value = data;
 }
 
-function setTableData(data: ApiMqttAuth.Auth[]) {
+function setTableData(data: Mqtt.Auth[]) {
   tableData.value = data;
 }
 
@@ -86,38 +89,27 @@ function setModalType(type: ModalType) {
   modalType.value = type;
 }
 
-async function getTableData() {
+async function getTableData(page: number, pageSize: number) {
   startLoading();
-  // eslint-disable-next-line @typescript-eslint/no-use-before-define
-  const { data } = await fetchMqttAuthList(pagination.page, pagination.pageSize, formValue.value);
+  const { data } = await fetchMqttAuthList(page, pageSize, formValue.value);
   if (data) {
-    setTableData(data);
+    setTableData(data.list);
+    pagination.pageCount = Math.ceil(data.count / data.list.length);
+    pagination.itemCount = data.count;
+    pagination.page = data.page;
+    pagination.pageSize = data.page_size;
     endLoading();
   } else {
     endLoading();
   }
 }
 
-async function getPastureEnumList() {
-  const { data } = await pastureEnumList();
+async function getGroupEnumList() {
+  const { data } = await groupEnumList();
   if (data) {
     setTimeout(() => {
-      setPastureList(data);
-    }, 1000);
-  }
-}
-
-async function getTopicByPublishEnumList() {
-  const { data } = await topicEnumList(1);
-  if (data) {
-    setPublishTopicList(data);
-  }
-}
-
-async function getTopicBySubscribeEnumList() {
-  const { data } = await topicEnumList(2);
-  if (data) {
-    setSubscribeTopicList(data);
+      setGroupList(data);
+    }, 100);
   }
 }
 
@@ -127,7 +119,7 @@ const columns: Ref<DataTableColumns<ApiMqttAuth.Auth>> = ref([
     align: 'center'
   },
   {
-    key: 'index',
+    key: 'key',
     title: '序号',
     align: 'center'
   },
@@ -152,7 +144,7 @@ const columns: Ref<DataTableColumns<ApiMqttAuth.Auth>> = ref([
     align: 'center'
   },
   {
-    key: 'subscribe_topic_name_stings',
+    key: 'sub_topic_name',
     title: '订阅topic名称',
     align: 'center'
   },
@@ -162,31 +154,15 @@ const columns: Ref<DataTableColumns<ApiMqttAuth.Auth>> = ref([
     align: 'center'
   },
   {
-    key: 'publish_topic_name_stings',
+    key: 'pub_topic_name',
     title: '发布topic名称',
     align: 'center'
   },
   {
     key: 'publish_acl',
-    title: '订阅topic',
+    title: '发布topic',
     align: 'center'
   },
-  {
-    key: 'is_show',
-    title: '是否启用',
-    align: 'center',
-    render: row => {
-      if (row.is_show) {
-        const tagTypes: Record<ApiMqttAuth.IsShowKey, NaiveUI.ThemeColor> = {
-          '0': 'error',
-          '1': 'success',
-          '2': 'warning'
-        };
-        return <NTag type={tagTypes[row.is_show]}>{MqttAuthIsShowLabels[row.is_show]}</NTag>;
-      }
-      return <span></span>;
-    }
-  },
   {
     key: 'actions',
     title: '操作',
@@ -213,28 +189,16 @@ const columns: Ref<DataTableColumns<ApiMqttAuth.Auth>> = ref([
   }
 ]) as Ref<DataTableColumns<ApiMqttAuth.Auth>>;
 
-const pagination: PaginationProps = reactive({
-  page: 1,
-  pageSize: 10,
-  showSizePicker: true,
-  pageSizes: [10, 15, 20, 25, 30],
-  onChange: (page: number) => {
-    pagination.page = page;
-  },
-  onUpdatePageSize: (pageSize: number) => {
-    pagination.pageSize = pageSize;
-    pagination.page = 1;
-  }
-});
-
 async function handleSearch() {
   if (!formValue.value) {
     window.$message?.warning('请输入相关名称');
   } else {
     startLoading();
+    formValue.value.pasture_name = formValue.value.pasture_name.trim();
+    formValue.value.user_name = formValue.value.user_name.trim();
     const { data } = await fetchMqttAuthList(pagination.page, pagination.pageSize, formValue.value);
     if (data) {
-      setTableData(data);
+      setTableData(data.list);
       endLoading();
     } else {
       endLoading();
@@ -243,6 +207,7 @@ async function handleSearch() {
 }
 
 function handleEditTable(rowId: number) {
+  getGroupEnumList();
   const findItem = tableData.value.find(item => item.id === rowId);
   if (findItem) {
     setEditData(findItem);
@@ -258,19 +223,25 @@ function handleDeleteTable(rowId: number) {
       window.$message?.success('删除成功!');
     }
   });
-  init();
+  setTimeout(() => {
+    init();
+  }, 100);
+}
+
+function handleModalVisibilityChange() {
+  setTimeout(() => {
+    getTableData(defaultPage.value, defaultPageSize.value);
+  }, 200);
 }
 
 function handleAddTable() {
+  getGroupEnumList();
   openModal();
   setModalType('add');
 }
 
 function init() {
-  getTableData();
-  getPastureEnumList();
-  getTopicByPublishEnumList();
-  getTopicBySubscribeEnumList();
+  getTableData(defaultPage.value, defaultPageSize.value);
 }
 
 // 初始化

+ 0 - 0
src/views/mqtt/topic-category/components/table-action-modal.vue → src/views/mqtt/category/components/table-action-modal.vue


+ 3 - 20
src/views/mqtt/topic-category/index.vue → src/views/mqtt/category/index.vue

@@ -28,13 +28,12 @@
 <script setup lang="tsx">
 import { reactive, ref } from 'vue';
 import type { Ref } from 'vue';
-import { NButton, NSpace, NTag } from 'naive-ui';
+import { NButton, NSpace } from 'naive-ui';
 import type { DataTableColumns, PaginationProps } from 'naive-ui';
-import { MqttTopicIsShowLabels } from '@/constants';
 import { useBoolean, useLoading } from '@/hooks';
 import { fetchMqttCategoryList } from '@/service/api/mqtt';
-import TableActionModal from '../topic-category/components/table-action-modal.vue';
-import type { ModalType } from '../topic-category/components/table-action-modal.vue';
+import TableActionModal from '../category/components/table-action-modal.vue';
+import type { ModalType } from '../category/components/table-action-modal.vue';
 
 const { loading, startLoading, endLoading } = useLoading(false);
 const { bool: visible, setTrue: openModal } = useBoolean();
@@ -77,22 +76,6 @@ const columns: Ref<DataTableColumns<ApiMqttCategory.Category>> = ref([
     title: '创建时间',
     align: 'center'
   },
-  {
-    key: 'is_show',
-    title: '是否启用',
-    align: 'center',
-    render: row => {
-      if (row.is_show) {
-        const tagTypes: Record<ApiMqttCategory.IsShowKey, NaiveUI.ThemeColor> = {
-          '0': 'error',
-          '1': 'success',
-          '2': 'warning'
-        };
-        return <NTag type={tagTypes[row.is_show]}>{MqttTopicIsShowLabels[row.is_show]}</NTag>;
-      }
-      return <span></span>;
-    }
-  },
   {
     key: 'actions',
     title: '操作',

+ 14 - 32
src/views/mqtt/pasture/components/table-action-modal.vue

@@ -2,20 +2,12 @@
   <n-modal v-model:show="modalVisible" preset="card" :title="title" class="w-700px">
     <n-form ref="formRef" label-placement="left" :label-width="100" :model="formModel" :rules="rules">
       <n-grid :cols="48" :x-gap="18">
-        <n-form-item-grid-item :span="25" label="牧场名称" path="name">
-          <n-input v-model:value="formModel.name" />
+        <n-form-item-grid-item :span="25" label="牧场名称" size="large" path="name">
+          <n-input v-model:value="formModel.pasture_name" />
         </n-form-item-grid-item>
-        <n-form-item-grid-item :span="25" label="牧场简称" path="short_name">
+        <n-form-item-grid-item :span="25" label="牧场简称(英文)" size="large" path="short_name">
           <n-input v-model:value="formModel.short_name" />
         </n-form-item-grid-item>
-        <n-form-item-grid-item :span="25" label="地址" path="address">
-          <n-input v-model:value="formModel.address" />
-        </n-form-item-grid-item>
-        <n-form-item-grid-item :span="25" label="是否启用" path="is_show">
-          <n-radio-group v-model:value="formModel.is_show">
-            <n-radio v-for="item in MqttPastureOptions" :key="item.value" :value="item.value">{{ item.label }}</n-radio>
-          </n-radio-group>
-        </n-form-item-grid-item>
       </n-grid>
       <n-space class="w-full pt-16px" :size="24" justify="end">
         <n-button class="w-72px" @click="closeModal">取消</n-button>
@@ -28,9 +20,9 @@
 <script setup lang="ts">
 import { computed, ref, reactive, watch } from 'vue';
 import type { FormInst, FormItemRule } from 'naive-ui';
-import { MqttPastureOptions } from '@/constants';
 import { createRequiredFormRule } from '@/utils';
 import { mqttPastureAdd, mqttPastureEdit } from '@/service/api/mqtt';
+
 export interface Props {
   /** 弹窗可见性 */
   visible: boolean;
@@ -67,9 +59,11 @@ const modalVisible = computed({
     emit('update:visible', visible);
   }
 });
+
 const closeModal = () => {
   modalVisible.value = false;
 };
+
 const titles: Record<ModalType, string> = {
   add: '添加牧场',
   edit: '编辑牧场'
@@ -83,42 +77,30 @@ const formRef = ref<HTMLElement & FormInst>();
 
 type FormModel = Pick<
   Mqtt.Pasture,
-  | 'id'
-  | 'name'
-  | 'short_name'
-  | 'address'
-  | 'is_show'
-  | 'is_group'
-  | 'group_id'
-  | 'created_at_format'
-  | 'updated_at_format'
+  'id' | 'pasture_name' | 'short_name' | 'is_show' | 'created_at_format' | 'updated_at_format' | 'key'
 >;
 
 const formModel = reactive<FormModel>(createDefaultFormModel());
 
 const rules: Record<keyof FormModel, FormItemRule | FormItemRule[]> = {
-  name: createRequiredFormRule('请输入牧场名称'),
-  short_name: createRequiredFormRule(),
-  address: createRequiredFormRule(),
+  pasture_name: createRequiredFormRule('请输入牧场名称'),
+  short_name: createRequiredFormRule('请输入牧场简称'),
   is_show: createRequiredFormRule(),
-  is_group: createRequiredFormRule(),
   created_at_format: createRequiredFormRule(),
   updated_at_format: createRequiredFormRule(),
-  group_id: createRequiredFormRule(),
-  id: createRequiredFormRule()
+  id: createRequiredFormRule(),
+  key: createRequiredFormRule()
 };
 
 function createDefaultFormModel(): FormModel {
   return {
     id: 0,
-    name: '',
+    pasture_name: '',
     short_name: '',
-    address: '',
     is_show: 1,
-    is_group: 0,
-    group_id: 0,
     created_at_format: '',
-    updated_at_format: ''
+    updated_at_format: '',
+    key: 0
   };
 }
 

+ 52 - 51
src/views/mqtt/pasture/index.vue

@@ -10,17 +10,26 @@
         </n-space>
         <n-space align="center" :size="18">
           <n-input-group>
-            <n-input v-model:value="PastureName" />
+            <n-input v-model:value="pastureName" placeholder="输入牧场名称" />
             <n-button type="primary" @click="handleSearch">搜索</n-button>
           </n-input-group>
-          <n-button size="small" type="primary" @click="getTableData">
+          <n-button
+            size="small"
+            type="primary"
+            @click="getTableData(Number(pagination.page), Number(pagination.pageSize))"
+          >
             <icon-mdi-refresh class="mr-4px text-16px" :class="{ 'animate-spin': loading }" />
             刷新表格
           </n-button>
         </n-space>
       </n-space>
-      <n-data-table :columns="columns" :data="tableData" :loading="loading" :pagination="pagination" />
-      <table-action-modal v-model:visible="visible" :type="modalType" :edit-data="editData" />
+      <n-data-table remote :columns="columns" :data="tableData" :loading="loading" :pagination="pagination" />
+      <table-action-modal
+        v-model:visible="visible"
+        :type="modalType"
+        :edit-data="editData"
+        @update:visible="handleModalVisibilityChange"
+      />
     </n-card>
   </div>
 </template>
@@ -28,9 +37,8 @@
 <script setup lang="tsx">
 import { reactive, ref } from 'vue';
 import type { Ref } from 'vue';
-import { NButton, NSpace, NTag } from 'naive-ui';
+import { NButton, NSpace } from 'naive-ui';
 import type { DataTableColumns, PaginationProps } from 'naive-ui';
-import { MqttPastureIsShowLabels } from '@/constants';
 import { useBoolean, useLoading } from '@/hooks';
 import { fetchMqttPastureList } from '@/service/api/mqtt';
 import TableActionModal from '../pasture/components/table-action-modal.vue';
@@ -38,65 +46,35 @@ import type { ModalType } from '../pasture/components/table-action-modal.vue';
 
 const { loading, startLoading, endLoading } = useLoading(false);
 const { bool: visible, setTrue: openModal } = useBoolean();
-const PastureName = ref('');
+const pastureName = ref('');
 const tableData = ref<Mqtt.Pasture[]>([]);
+const defaultPage = ref(1);
+const defaultPageSize = ref(10);
+
 function setTableData(data: Mqtt.Pasture[]) {
   tableData.value = data;
 }
 
-async function getTableData() {
-  startLoading();
-  const { data } = await fetchMqttPastureList(1, 10, PastureName.value);
-  if (data) {
-    setTimeout(() => {
-      setTableData(data);
-      endLoading();
-    }, 1000);
-  } else {
-    endLoading();
-  }
-}
-
 const columns: Ref<DataTableColumns<Mqtt.Pasture>> = ref([
   {
     type: 'selection',
     align: 'center'
   },
   {
-    key: 'index',
+    key: 'id',
     title: '序号',
     align: 'center'
   },
   {
-    key: 'name',
-    title: '名称',
+    key: 'pasture_name',
+    title: '牧场名称',
     align: 'center'
   },
   {
     key: 'short_name',
-    title: '简称',
+    title: '简称(英文)',
     align: 'center'
   },
-  {
-    key: 'address',
-    title: '地址',
-    align: 'center'
-  },
-  {
-    key: 'is_group',
-    title: '是否是集团',
-    align: 'center',
-    render: row => {
-      if (row.is_group) {
-        const tagTypes: Record<ApiMqttPasture.IsGroupKey, NaiveUI.ThemeColor> = {
-          '1': 'success',
-          '2': 'warning'
-        };
-        return <NTag type={tagTypes[row.is_group]}>{MqttPastureIsShowLabels[row.is_group]}</NTag>;
-      }
-      return <span></span>;
-    }
-  },
   {
     key: 'created_at_format',
     title: '创建时间',
@@ -144,29 +122,52 @@ function handleEditTable(rowId: number) {
 }
 
 const pagination: PaginationProps = reactive({
-  page: 1,
-  pageSize: 10,
+  page: defaultPage.value,
+  pageSize: defaultPageSize.value,
+  itemCount: 100,
   showSizePicker: true,
-  pageSizes: [10, 15, 20, 25, 30],
+  pageSizes: [10, 15, 20, 30, 50],
   onChange: (page: number) => {
     pagination.page = page;
+    getTableData(page, Number(pagination.pageSize));
   },
   onUpdatePageSize: (pageSize: number) => {
     pagination.pageSize = pageSize;
-    pagination.page = 1;
+    getTableData(Number(pagination.page), pageSize);
   }
 });
 
 function handleSearch() {
-  if (!PastureName.value) {
+  if (!pastureName.value) {
     window.$message?.warning('请输入牧场名称');
   } else {
-    startLoading();
+    getTableData(defaultPage.value, defaultPageSize.value);
   }
 }
 
+function handleModalVisibilityChange() {
+  getTableData(defaultPage.value, defaultPageSize.value);
+}
+
 function init() {
-  getTableData();
+  getTableData(defaultPage.value, defaultPageSize.value);
+}
+
+async function getTableData(page: number, pageSize: number) {
+  startLoading();
+  const { data } = await fetchMqttPastureList(page, pageSize, pastureName.value.trim());
+  if (data) {
+    setTimeout(() => {
+      setTableData(data.list);
+      pagination.pageCount = Math.ceil(data.count / data.list.length);
+      pagination.itemCount = data.count;
+      pagination.page = data.page;
+      pagination.pageSize = data.page_size;
+      endLoading();
+    }, 100);
+  } else {
+    endLoading();
+  }
 }
 
 // 初始化

+ 14 - 11
src/views/mqtt/topic/components/table-action-modal.vue

@@ -2,8 +2,8 @@
   <n-modal v-model:show="modalVisible" preset="card" :title="title" class="w-700px">
     <n-form ref="formRef" label-placement="left" :label-width="100" :model="formModel" :rules="rules">
       <n-grid :cols="48" :x-gap="18">
-        <n-form-item-grid-item :span="25" label="分类名称" size="large" path="category_id">
-          <n-select v-model:value="formModel.category_id" size="large" :options="categoryEnumListData" />
+        <n-form-item-grid-item :span="25" label="集团名称" size="large" path="pasture_id">
+          <n-select v-model:value="formModel.pasture_id" size="large" :options="groupTopicEnumListData" />
         </n-form-item-grid-item>
         <n-form-item-grid-item :span="25" label="topic名称" size="large" path="topic_name">
           <n-input v-model:value="formModel.topic_name" />
@@ -42,7 +42,7 @@ export interface Props {
   type?: 'add' | 'edit';
   /** 编辑的表格行数据 */
   editData?: Mqtt.Topic | null;
-  categoryEnumListData: SelectOption[];
+  groupTopicEnumListData: SelectOption[];
 }
 
 export type ModalType = NonNullable<Props['type']>;
@@ -85,41 +85,44 @@ const formRef = ref<HTMLElement & FormInst>();
 type FormModel = Pick<
   Mqtt.Topic,
   | 'id'
-  | 'category_id'
-  | 'category_name'
+  | 'pasture_id'
+  | 'pasture_name'
   | 'topic_name'
   | 'topic_template'
   | 'is_show'
   | 'access'
   | 'created_at_format'
   | 'updated_at_format'
+  | 'key'
 >;
 
 const formModel = reactive<FormModel>(createDefaultFormModel());
 
 const rules: Record<keyof FormModel, FormItemRule | FormItemRule[]> = {
-  category_id: createRequiredFormRule('请选择分类名称'),
-  category_name: createRequiredFormRule('请选择分类名称1'),
+  pasture_id: createRequiredFormRule('请选择牧场名称'),
+  pasture_name: createRequiredFormRule('请选择集团名称1'),
   topic_name: createRequiredFormRule('请输入主题名称'),
   topic_template: createRequiredFormRule('请输入topic'),
   access: createRequiredFormRule('请选择主题动作'),
   is_show: createRequiredFormRule(),
   created_at_format: createRequiredFormRule(),
   updated_at_format: createRequiredFormRule(),
-  id: createRequiredFormRule()
+  id: createRequiredFormRule(),
+  key: createRequiredFormRule()
 };
 
 function createDefaultFormModel(): FormModel {
   return {
     id: 0,
-    category_id: null,
-    category_name: '',
+    pasture_id: null,
+    pasture_name: '',
     topic_name: '',
     topic_template: '',
     is_show: 1,
     access: 1,
     created_at_format: '',
-    updated_at_format: ''
+    updated_at_format: '',
+    key: 0
   };
 }
 

+ 52 - 38
src/views/mqtt/topic/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="h-full overflow-hidden">
-    <n-card title="消息主题模板" :bordered="false" class="rounded-16px shadow-sm">
+    <n-card title="topic配置" :bordered="false" class="rounded-16px shadow-sm">
       <n-space class="pb-12px" justify="space-between">
         <n-space>
           <n-button type="primary" @click="handleAddTable">
@@ -10,10 +10,10 @@
         </n-space>
         <n-space align="center" :size="18">
           <n-input-group>
-            <n-input v-model:value="topicName" placeholder="输入主题名称" />
+            <n-input v-model:value="topicName" placeholder="输入topic名称" />
             <n-button type="primary" @click="handleSearch">搜索</n-button>
           </n-input-group>
-          <n-button size="small" type="primary" @click="getTableData">
+          <n-button size="small" type="primary" @click="getTableData(1, 10)">
             <icon-mdi-refresh class="mr-4px text-16px" :class="{ 'animate-spin': loading }" />
             刷新表格
           </n-button>
@@ -24,7 +24,8 @@
         v-model:visible="visible"
         :type="modalType"
         :edit-data="editData"
-        :category-enum-list-data="categoryEnumListData"
+        :group-topic-enum-list-data="groupTopicEnumListData"
+        @update:visible="handleModalVisibilityChange"
       />
     </n-card>
   </div>
@@ -44,36 +45,57 @@ import type { ModalType } from '../topic/components/table-action-modal.vue';
 const { loading, startLoading, endLoading } = useLoading(false);
 const { bool: visible, setTrue: openModal } = useBoolean();
 const topicName = ref('');
-const tableData = ref<ApiMqttTopic.Topic[]>([]);
-const categoryEnumListData = ref<SelectOption[]>([]);
+const tableData = ref<Mqtt.Topic[]>([]);
+const groupTopicEnumListData = ref<SelectOption[]>([]);
+const defaultPage = ref(1);
+const defaultPageSize = ref(10);
+const pagination: PaginationProps = reactive({
+  page: defaultPage.value,
+  pageSize: defaultPageSize.value,
+  itemCount: 100,
+  showSizePicker: true,
+  pageSizes: [10, 15, 20, 30, 50],
+  onChange: (page: number) => {
+    pagination.page = page;
+    getTableData(page, Number(pagination.pageSize));
+  },
+  onUpdatePageSize: (pageSize: number) => {
+    pagination.pageSize = pageSize;
+    getTableData(Number(pagination.page), pageSize);
+  }
+});
 
-function setTableData(data: ApiMqttTopic.Topic[]) {
+function setTableData(data: Mqtt.Topic[]) {
   tableData.value = data;
 }
 
-function setCategoryList(data: SelectOption[]) {
-  categoryEnumListData.value = data;
+function setGroupTopicList(data: SelectOption[]) {
+  groupTopicEnumListData.value = data;
 }
 
-async function getTableData() {
+async function getTableData(page: number, pageSize: number) {
   startLoading();
-  const { data } = await fetchMqttTopicList(1, 10, topicName.value);
+  const { data } = await fetchMqttTopicList(page, pageSize, topicName.value.trim());
   if (data) {
     setTimeout(() => {
-      setTableData(data);
+      setTableData(data.list);
+      pagination.pageCount = Math.ceil(data.count / data.list.length);
+      pagination.itemCount = data.count;
+      pagination.page = data.page;
+      pagination.pageSize = data.page_size;
       endLoading();
-    }, 1000);
+    }, 100);
   } else {
     endLoading();
   }
 }
 
-async function getCategoryEnumList() {
+async function getGroupTopicEnumList() {
   const { data } = await categoryEnumList();
   if (data) {
     setTimeout(() => {
-      setCategoryList(data);
-    }, 1000);
+      setGroupTopicList(data);
+    }, 100);
   }
 }
 
@@ -83,13 +105,13 @@ const columns: Ref<DataTableColumns<ApiMqttTopic.Topic>> = ref([
     align: 'center'
   },
   {
-    key: 'index',
+    key: 'key',
     title: '序号',
     align: 'center'
   },
   {
-    key: 'category_name',
-    title: '分类名称',
+    key: 'pasture_name',
+    title: '牧场名称',
     align: 'center'
   },
   {
@@ -148,14 +170,14 @@ const columns: Ref<DataTableColumns<ApiMqttTopic.Topic>> = ref([
   }
 ]) as Ref<DataTableColumns<ApiMqttTopic.Topic>>;
 
-const editData = ref<ApiMqttTopic.Topic | null>(null);
+const editData = ref<Mqtt.Topic | null>(null);
 const modalType = ref<ModalType>('add');
 
 function setModalType(type: ModalType) {
   modalType.value = type;
 }
 
-function setEditData(data: ApiMqttTopic.Topic | null) {
+function setEditData(data: Mqtt.Topic | null) {
   editData.value = data;
 }
 
@@ -184,20 +206,6 @@ function handleDeleteTable(rowId: number) {
   init();
 }
 
-const pagination: PaginationProps = reactive({
-  page: 1,
-  pageSize: 10,
-  showSizePicker: true,
-  pageSizes: [10, 15, 20, 25, 30],
-  onChange: (page: number) => {
-    pagination.page = page;
-  },
-  onUpdatePageSize: (pageSize: number) => {
-    pagination.pageSize = pageSize;
-    pagination.page = 1;
-  }
-});
-
 async function handleSearch() {
   if (!topicName.value) {
     window.$message?.warning('请输入主题名称');
@@ -206,7 +214,7 @@ async function handleSearch() {
     startLoading();
     const { data } = await fetchMqttTopicList(pagination.page, pagination.pageSize, topicName.value.trim());
     if (data) {
-      setTableData(data);
+      setTableData(data.list);
       endLoading();
     } else {
       endLoading();
@@ -214,9 +222,15 @@ async function handleSearch() {
   }
 }
 
+function handleModalVisibilityChange() {
+  setTimeout(() => {
+    getTableData(defaultPage.value, defaultPageSize.value);
+  }, 200);
+}
+
 function init() {
-  getTableData();
-  getCategoryEnumList();
+  getTableData(defaultPage.value, defaultPageSize.value);
+  getGroupTopicEnumList();
 }
 
 // 初始化

Some files were not shown because too many files changed in this diff