Selaa lähdekoodia

更新后端网关和服务治理相关页面

reghao 2 viikkoa sitten
vanhempi
commit
ac411d94a9

+ 10 - 16
src/api/tnb.js

@@ -2,34 +2,28 @@ import { get, post } from '@/utils/request'
 
 const tfApi = {
   getZkApi: '/api/admin/tnb/zk',
-  getZkServiceApi: '/api/admin/tnb/zookeeper',
-  getDubboApi: '/api/admin/tnb/zk/dubbo',
-  getSpringCloudApi: '/api/admin/tnb/eureka/springcloud',
-  getSpringcloudApi: '/api/admin/tnb/eureka/springcloud',
-  gatewayRouteApi: '/api/admin/tnb/gw/route',
+  dubboApi: '/api/admin1/zookeeper',
+  springCloudApi: '/api/admin1/nacos',
+  gatewayRouteApi: '/api/admin1/gateway',
   getArticlesApi: '/api/content/admin/video/all'
 }
 
 export function getZkList() {
-  return get(tfApi.getZkApi)
-}
-
-export function getZkService(queryInfo) {
-  return get(tfApi.getZkServiceApi, queryInfo)
+  return get(tfApi.dubboApi + '/list')
 }
 
 export function getDubboList() {
-  return get(tfApi.getDubboApi)
+  return get(tfApi.dubboApi + '/dubbo')
 }
 
-export function getSpringCloudList() {
-  return get(tfApi.getSpringCloudApi)
+export function getSpringCloudServices() {
+  return get(tfApi.springCloudApi + '/services')
 }
 
-export function getSpringcloudList() {
-  return get(tfApi.getSpringcloudApi)
+export function getSpringCloudInstances(queryParams) {
+  return get(tfApi.springCloudApi + '/instances', queryParams)
 }
 
 export function getGatewayRoute() {
-  return get(tfApi.gatewayRouteApi)
+  return get(tfApi.gatewayRouteApi + '/route')
 }

+ 4 - 4
src/router/background_backend.js

@@ -4,8 +4,8 @@ const Background = () => import('views/admin/Background')
 
 // 后端系统
 const AdminGateway = () => import('views/admin/backend/AdminGateway')
-const AdminDubboService = () => import('views/admin/backend/AdminDubboService')
-const AdminSpringCloudService = () => import('views/admin/backend/AdminSpringCloudService')
+const AdminDubbo = () => import('views/admin/backend/AdminDubbo')
+const AdminSpringCloud = () => import('views/admin/backend/AdminSpringCloud')
 const AdminBackendLog = () => import('views/admin/backend/AdminBackendLog')
 const AdminAccessLog = () => import('views/admin/backend/AdminAccessLog')
 const NginxLog = () => import('views/devops/srv/NginxLog')
@@ -33,7 +33,7 @@ export default {
       name: 'DubboService',
       title: 'Dubbo服务',
       icon: 'el-icon-loading',
-      component: AdminDubboService,
+      component: AdminDubbo,
       meta: { needAuth: true, roles: ['tnb_admin'] }
     },
     {
@@ -41,7 +41,7 @@ export default {
       name: 'SpringCloudService',
       title: 'SpringCloud服务',
       icon: 'el-icon-loading',
-      component: AdminSpringCloudService,
+      component: AdminSpringCloud,
       meta: { needAuth: true, roles: ['tnb_admin'] }
     },
     {

+ 6 - 6
src/views/admin/backend/AdminDubboService.vue → src/views/admin/backend/AdminDubbo.vue

@@ -3,7 +3,7 @@
     <el-header height="220">
       <el-row style="margin-top: 10px">
         <el-select
-          v-model="queryInfo.path"
+          v-model="queryParams.path"
           clearable
           placeholder="查询条件"
           style="margin-left: 5px"
@@ -89,13 +89,13 @@
 </template>
 
 <script>
-import { getDubboList, getZkList, getZkService } from '@/api/tnb'
+import {getDubboList, getZkList} from '@/api/tnb'
 
 export default {
   name: 'AdminDubboService',
   data() {
     return {
-      queryInfo: {
+      queryParams: {
         path: null
       },
       // 屏幕宽度, 为了控制分页条的大小
@@ -167,14 +167,14 @@ export default {
       this.showEditScopeDialog = false
     },
     onSelectChange() {
-      this.dataList = []
-      getZkService(this.queryInfo).then(resp => {
+      /* this.dataList = []
+      getZkService(this.queryParams).then(resp => {
         if (resp.code === 0) {
           this.dataList = resp.data
         } else {
           this.$message.error(resp.msg)
         }
-      })
+      })*/
     },
     handleClose() {
     }

+ 49 - 47
src/views/admin/backend/AdminSpringCloudService.vue → src/views/admin/backend/AdminSpringCloud.vue

@@ -2,6 +2,7 @@
   <el-container>
     <el-header height="220">
       <h3>SpringCloud 服务</h3>
+      <el-button icon="el-icon-refresh" class="btn-reset" @click="onRefresh">刷新</el-button>
     </el-header>
     <el-main>
       <el-table
@@ -15,24 +16,16 @@
           type="index"
         />
         <el-table-column
-          prop="instanceId"
-          label="实例 ID"
+          prop="serviceName"
+          label="服务名"
         />
         <el-table-column
-          prop="appName"
-          label="应用"
+          prop="healthyCount"
+          label="健康实例"
         />
         <el-table-column
-          prop="hostPort"
-          label="节点地址"
-        />
-        <el-table-column
-          prop="lastUpdateTime"
-          label="最近更新"
-        />
-        <el-table-column
-          prop="lastDirtyTime"
-          label="最近脏数据"
+          prop="unhealthyCount"
+          label="不健康实例"
         />
         <el-table-column
           fixed="right"
@@ -42,13 +35,8 @@
           <template slot-scope="scope">
             <el-button
               size="mini"
-              @click="handleEdit(scope.$index, scope.row)"
-            >编辑</el-button>
-            <el-button
-              size="mini"
-              type="danger"
-              @click="handleDelete(scope.$index, scope.row)"
-            >删除</el-button>
+              @click="handleEdit(scope.row)"
+            >详情</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -56,19 +44,38 @@
 
     <el-dialog
       append-to-body
-      :visible.sync="showServiceDialog"
+      :title="dialogTitle"
+      :visible.sync="showInstanceDialog"
+      :before-close="handleClose"
       width="70%"
       center
     >
+      <template>
+        <el-table
+          :data="serviceList"
+          border
+          style="width: 100%"
+        >
+          <el-table-column
+            fixed="left"
+            label="No"
+            type="index"
+          />
+          <el-table-column
+            prop="instanceAddr"
+            label="实例地址"
+          />
+        </el-table>
+      </template>
     </el-dialog>
   </el-container>
 </template>
 
 <script>
-import { getSpringCloudList } from '@/api/tnb'
+import { getSpringCloudInstances, getSpringCloudServices } from '@/api/tnb'
 
 export default {
-  name: 'AdminSpringCloudService',
+  name: 'AdminSpringCloud',
   data() {
     return {
       queryInfo: {
@@ -84,7 +91,8 @@ export default {
       nextId: 0,
       serviceList: [],
       // **********************************************************************
-      showServiceDialog: false,
+      dialogTitle: null,
+      showInstanceDialog: false,
       form: {
         videoId: null,
         scope: 1
@@ -97,7 +105,8 @@ export default {
   },
   methods: {
     getData() {
-      getSpringCloudList().then(resp => {
+      this.dataList = []
+      getSpringCloudServices().then(resp => {
         if (resp.code === 0) {
           this.dataList = resp.data
         } else {
@@ -114,30 +123,23 @@ export default {
       // 回到顶部
       scrollTo(0, 0)
     },
-    handleEdit(index, row) {
-      this.$message.info('handleEdit')
-    },
-    handleDelete(index, row) {
-      this.$confirm('确定要删除 ' + row.title + '?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        this.$message.info('handleDelete')
-      }).catch(() => {
-        this.$message({
-          type: 'info',
-          message: '已取消'
-        })
+    handleEdit(row) {
+      const queryParams = {}
+      queryParams.serviceName = row.serviceName
+      getSpringCloudInstances(queryParams).then(resp => {
+        if (resp.code === 0) {
+          this.serviceList = resp.data
+          this.dialogTitle = row.serviceName
+          this.showInstanceDialog = true
+          console.log(this.serviceList)
+        } else {
+          this.$message.warning(resp.msg)
+        }
       })
     },
-    onUpdateScope() {
-      this.showServiceDialog = false
-    },
-    onSelectChange() {
-      this.$message.info(this.queryInfo)
-    },
     handleClose() {
+      this.showInstanceDialog = false
+      this.serviceList = []
     }
   }
 }