Просмотр исходного кода

:sparkles: 添加新特性。 图形化路由控制

冷冷 6 лет назад
Родитель
Сommit
e664230bfd

+ 61 - 60
package.json

@@ -1,62 +1,63 @@
 {
-    "name": "avue-cli",
-    "version": "2.0.0",
-    "private": true,
-    "scripts": {
-        "serve": "vue-cli-service serve",
-        "build": "vue-cli-service build",
-        "lint": "vue-cli-service lint",
-        "test:unit": "vue-cli-service test:unit",
-        "test:e2e": "vue-cli-service test:e2e"
-    },
-    "dependencies": {
-        "@smallwei/avue": "^1.1.21-beta1",
-        "avue-plugin-transfer": "^0.0.2",
-        "avue-plugin-ueditor": "^0.0.1",
-        "axios": "^0.18.0",
-        "babel-loader": "^8.0.2",
-        "babel-plugin-transform-runtime": "^6.23.0",
-        "babel-polyfill": "^6.26.0",
-        "classlist-polyfill": "^1.2.0",
-        "driver.js": "^0.6.2",
-        "element-ui": "^2.4.6",
-        "file-saver": "^1.3.8",
-        "html2canvas": "^1.0.0-alpha.12",
-        "js-cookie": "^2.2.0",
-        "mockjs": "^1.0.1-beta3",
-        "moment": "^2.22.2",
-        "nprogress": "^0.2.0",
-        "script-loader": "^0.7.2",
-        "vue": "^2.5.16",
-        "vue-axios": "^2.1.2",
-        "vue-clipboard2": "^0.2.1",
-        "vue-json-tree-view": "^2.1.4",
-        "vue-quill-editor": "^3.0.6",
-        "vue-router": "^3.0.1",
-        "vuedraggable": "^2.16.0",
-        "vuex": "^3.0.1",
-        "xlsx": "^0.13.3"
-    },
-    "devDependencies": {
-        "@vue/cli-plugin-babel": "^3.0.0",
-        "@vue/cli-plugin-e2e-cypress": "^3.0.0",
-        "@vue/cli-plugin-eslint": "^3.0.0",
-        "@vue/cli-plugin-unit-mocha": "^3.0.0",
-        "@vue/cli-service": "^3.0.0",
-        "@vue/test-utils": "^1.0.0-beta.20",
-        "chai": "^4.1.2",
-        "node-sass": "^4.9.0",
-        "sass-loader": "^7.0.1",
-        "vue-template-compiler": "^2.5.17"
-    },
-    "lint-staged": {
-        "*.js": [
-            "vue-cli-service lint",
-            "git add"
-        ],
-        "*.vue": [
-            "vue-cli-service lint",
-            "git add"
-        ]
-    }
+  "name": "avue-cli",
+  "version": "2.0.0",
+  "private": true,
+  "scripts": {
+    "serve": "vue-cli-service serve",
+    "build": "vue-cli-service build",
+    "lint": "vue-cli-service lint",
+    "test:unit": "vue-cli-service test:unit",
+    "test:e2e": "vue-cli-service test:e2e"
+  },
+  "dependencies": {
+    "@smallwei/avue": "^1.1.21-beta1",
+    "avue-plugin-transfer": "^0.0.2",
+    "avue-plugin-ueditor": "^0.0.1",
+    "axios": "^0.18.0",
+    "babel-loader": "^8.0.2",
+    "babel-plugin-transform-runtime": "^6.23.0",
+    "babel-polyfill": "^6.26.0",
+    "classlist-polyfill": "^1.2.0",
+    "driver.js": "^0.6.2",
+    "element-ui": "^2.4.6",
+    "file-saver": "^1.3.8",
+    "html2canvas": "^1.0.0-alpha.12",
+    "js-cookie": "^2.2.0",
+    "mockjs": "^1.0.1-beta3",
+    "moment": "^2.22.2",
+    "nprogress": "^0.2.0",
+    "script-loader": "^0.7.2",
+    "vue": "^2.5.16",
+    "vue-axios": "^2.1.2",
+    "vue-clipboard2": "^0.2.1",
+    "vue-json-editor": "^1.2.3",
+    "vue-json-tree-view": "^2.1.4",
+    "vue-quill-editor": "^3.0.6",
+    "vue-router": "^3.0.1",
+    "vuedraggable": "^2.16.0",
+    "vuex": "^3.0.1",
+    "xlsx": "^0.13.3"
+  },
+  "devDependencies": {
+    "@vue/cli-plugin-babel": "^3.0.0",
+    "@vue/cli-plugin-e2e-cypress": "^3.0.0",
+    "@vue/cli-plugin-eslint": "^3.0.0",
+    "@vue/cli-plugin-unit-mocha": "^3.0.0",
+    "@vue/cli-service": "^3.0.0",
+    "@vue/test-utils": "^1.0.0-beta.20",
+    "chai": "^4.1.2",
+    "node-sass": "^4.9.0",
+    "sass-loader": "^7.0.1",
+    "vue-template-compiler": "^2.5.17"
+  },
+  "lint-staged": {
+    "*.js": [
+      "vue-cli-service lint",
+      "git add"
+    ],
+    "*.vue": [
+      "vue-cli-service lint",
+      "git add"
+    ]
+  }
 }

+ 12 - 35
src/api/route.js

@@ -19,45 +19,22 @@ import request from '@/router/axios'
 
 export function fetchList(query) {
   return request({
-    url: '/admin/route/page',
+    url: '/route',
     method: 'get',
     params: query
   })
 }
-
-export function addObj(obj) {
-  return request({
-    url: '/admin/route/',
-    method: 'post',
-    data: obj
-  })
-}
-
-export function getObj(id) {
-  return request({
-    url: '/admin/route/' + id,
-    method: 'get'
-  })
-}
-
-export function delObj(id) {
-  return request({
-    url: '/admin/route/' + id,
-    method: 'delete'
-  })
-}
-
 export function putObj(obj) {
-  return request({
-    url: '/admin/route',
-    method: 'put',
-    data: obj
-  })
+    return request({
+        url: '/route',
+        method: 'put',
+        data: obj
+    })
 }
-
-export function applyObj() {
-  return request({
-    url: '/admin/route/apply',
-    method: 'get'
-  })
+export function fallback(obj) {
+    return request({
+        url: '/route/fallback',
+        method: 'get',
+        data: obj
+    })
 }

+ 33 - 0
src/api/token.js

@@ -0,0 +1,33 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+import request from '@/router/axios'
+
+export function fetchList(query) {
+  return request({
+    url: '/admin/token/page',
+    method: 'get',
+    params: query
+  })
+}
+
+export function delObj(id) {
+  return request({
+    url: '/admin/token/' + id,
+    method: 'delete'
+  })
+}

+ 2 - 2
src/config/env.js

@@ -3,7 +3,7 @@
 const env = process.env
 let baseUrl = '';
 // 图表库为avue和pig2套地址
-let iconfontVersion = ['667895_5lt01cjobo7', '567566_qo5lxgtishg']
+let iconfontVersion = ['667895_4y8d30c1og', '567566_qo5lxgtishg']
 let iconfontUrl = `//at.alicdn.com/t/font_$key.css`;
 let codeUrl = `/code`
 let actUrl = `${window.origin}/act/modeler.html?modelId=`;
@@ -21,4 +21,4 @@ export {
     iconfontVersion,
     codeUrl,
     env
-}
+}

+ 67 - 0
src/const/crud/token.js

@@ -0,0 +1,67 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+const DIC = {
+  vaild: [{
+    label: '否',
+    value: 'false'
+  }, {
+    label: '是',
+    value: 'true'
+  }]
+}
+export const tableOption = {
+  'border': true,
+  'index': true,
+  'indexLabel': '序号',
+  'stripe': true,
+  'menuAlign': 'center',
+  'align': 'center',
+  'addBtn': false,
+  'editBtn': false,
+  'delBtn': false,
+  'dic': [],
+  'column': [{
+    label: '令牌',
+    prop: 'token_value',
+    align: 'center'
+  }, {
+    label: '用户ID',
+    prop: 'user_id',
+    align: 'center'
+  }, {
+    label: '用户名',
+    prop: 'user_name',
+    align: 'center'
+  }, {
+    label: '类型',
+    prop: 'token_type',
+    align: 'center'
+  }, {
+    label: '过期时间',
+    prop: 'expires_in',
+    align: 'center'
+  }, {
+    label: '客户端',
+    prop: 'client_id',
+    align: 'center'
+  }, {
+    label: '授权类型',
+    prop: 'grant_type',
+    align: 'center'
+  }]
+}

+ 2 - 0
src/views/admin/activiti/leave.vue

@@ -84,6 +84,8 @@
   },
   methods: {
     getList() {
+      this.listQuery.orderByField = 'create_time'
+      this.listQuery.isAsc = false
       this.tableLoading = true
       fetchList(this.listQuery).then(response => {
         this.tableData = response.data.records

+ 80 - 0
src/views/admin/route/index.vue

@@ -0,0 +1,80 @@
+<!--
+  -    Copyright (c) 2018-2025, lengleng All rights reserved.
+  -
+  - Redistribution and use in source and binary forms, with or without
+  - modification, are permitted provided that the following conditions are met:
+  -
+  - Redistributions of source code must retain the above copyright notice,
+  - this list of conditions and the following disclaimer.
+  - Redistributions in binary form must reproduce the above copyright
+  - notice, this list of conditions and the following disclaimer in the
+  - documentation and/or other materials provided with the distribution.
+  - Neither the name of the pig4cloud.com developer nor the names of its
+  - contributors may be used to endorse or promote products derived from
+  - this software without specific prior written permission.
+  - Author: lengleng (wangiegie@gmail.com)
+  -->
+
+<template>
+    <div class="app-container pull-auto">
+        <basic-container>
+            <vue-json-editor v-model="json" :show-btns="false"></vue-json-editor>
+            <div align="center">
+                <el-button @click="edit()">更新</el-button>
+                <el-button type="warning" @click="fallback()">回滚</el-button>
+            </div>
+        </basic-container>
+    </div>
+</template>
+<script>
+import vueJsonEditor from 'vue-json-editor'
+import  {fetchList, putObj,fallback} from '@/api/route'
+export default {
+    data () {
+        return {
+            json: null
+        }
+    },
+
+    // 注入vueJsonEditor组件
+    components: {
+        vueJsonEditor
+    },
+
+    created () {
+        this.getList()
+    },
+
+    methods: {
+        getList () {
+            fetchList().then(response => {
+                this.json = response.data
+                console.log(this.json)
+            })
+        },
+
+        fallback (){
+            fallback(this.json).then(response => {
+                this.$notify({
+                    title: '成功',
+                    message: '回滚成功',
+                    type: 'success',
+                    duration: 2000
+                })
+            })
+        },
+
+        edit (){
+            putObj(this.json).then(response => {
+                this.$notify({
+                    title: '成功',
+                    message: '更新成功',
+                    type: 'success',
+                    duration: 2000
+                })
+            })
+        },
+
+    }
+}
+</script>

+ 124 - 0
src/views/admin/token/index.vue

@@ -0,0 +1,124 @@
+<!--
+  -    Copyright (c) 2018-2025, lengleng All rights reserved.
+  -
+  - Redistribution and use in source and binary forms, with or without
+  - modification, are permitted provided that the following conditions are met:
+  -
+  - Redistributions of source code must retain the above copyright notice,
+  - this list of conditions and the following disclaimer.
+  - Redistributions in binary form must reproduce the above copyright
+  - notice, this list of conditions and the following disclaimer in the
+  - documentation and/or other materials provided with the distribution.
+  - Neither the name of the pig4cloud.com developer nor the names of its
+  - contributors may be used to endorse or promote products derived from
+  - this software without specific prior written permission.
+  - Author: lengleng (wangiegie@gmail.com)
+  -->
+
+<template>
+  <div class="app-container pull-auto">
+    <basic-container>
+      <avue-crud ref="crud"
+                 :page="page"
+                 :data="tableData"
+                 :table-loading="tableLoading"
+                 :option="tableOption"
+                 @current-change="currentChange"
+                 @refresh-change="refreshChange"
+                 @size-change="sizeChange"
+                 @row-del="rowDel">
+        <template slot-scope="scope"
+                  slot="menu">
+          <el-button type="danger"
+                     v-if="permissions.sys_client_del"
+                     icon="el-icon-delete"
+                     size="mini"
+                     plain
+                     @click="handleDel(scope.row,scope.index)">删除</el-button>
+        </template>
+      </avue-crud>
+    </basic-container>
+  </div>
+</template>
+
+<script>
+import { fetchList, delObj } from '@/api/token'
+import { tableOption } from '@/const/crud/token'
+import { mapGetters } from 'vuex'
+export default {
+  name: 'token',
+  data() {
+    return {
+      tableData: [],
+      page: {
+        total: 0, // 总页数
+        currentPage: 1, // 当前页数
+        pageSize: 20 // 每页显示多少条
+      },
+      tableLoading: false,
+      tableOption: tableOption
+    }
+  },
+  created() {
+    this.getList()
+  },
+  mounted: function() { },
+  computed: {
+    ...mapGetters(['permissions'])
+  },
+  methods: {
+    getList() {
+      this.tableLoading = true
+      fetchList({
+        page: this.page.currentPage,
+        limit: this.page.pageSize
+      }).then(response => {
+        this.tableData = response.data.records
+        this.page.total = response.data.total
+        this.tableLoading = false
+      })
+    },
+    currentChange(val) {
+      this.page.currentPage = val
+      this.getList()
+    },
+    sizeChange(val) {
+      this.page.pageSize = val
+      this.getList()
+    },
+    handleDel(row, index) {
+      this.$refs.crud.rowDel(row, index)
+    },
+    rowDel: function(row, index) {
+      var _this = this
+      this.$confirm('是否确认删除ID为' + row.token_value, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      })
+        .then(function() {
+          return delObj(row.token_value)
+        })
+        .then(data => {
+          _this.tableData.splice(index, 1)
+          _this.$message({
+            showClose: true,
+            message: '删除成功',
+            type: 'success'
+          })
+        })
+        .catch(function(err) { })
+    },
+    /**
+     * 刷新回调
+     */
+    refreshChange() {
+      this.getList()
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+</style>
+

+ 7 - 0
vue.config.js

@@ -36,6 +36,13 @@ module.exports = {
                     '^/code': '/code'
                 }
             },
+            '/route': {
+                target: url,
+                ws: true,
+                pathRewrite: {
+                    '^/route': '/route'
+                }
+            },
             '/gen': {
                 target: url,
                 ws: true,