index.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <!--
  2. - Copyright (c) 2018-2025, lengleng All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions are met:
  6. -
  7. - Redistributions of source code must retain the above copyright notice,
  8. - this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. - notice, this list of conditions and the following disclaimer in the
  11. - documentation and/or other materials provided with the distribution.
  12. - Neither the name of the pig4cloud.com developer nor the names of its
  13. - contributors may be used to endorse or promote products derived from
  14. - this software without specific prior written permission.
  15. - Author: lengleng (wangiegie@gmail.com)
  16. -->
  17. <template>
  18. <div class="app-container pull-auto">
  19. <basic-container>
  20. <el-alert
  21. title="路由配置是非常专业的事情,不建议非工程师操作"
  22. type="warning">
  23. </el-alert>
  24. <vue-json-editor v-model="json" :show-btns="false"></vue-json-editor>
  25. <div align="center">
  26. <el-button @click="edit()">更新</el-button>
  27. </div>
  28. </basic-container>
  29. </div>
  30. </template>
  31. <script>
  32. import vueJsonEditor from 'vue-json-editor'
  33. import {fetchList, putObj, fallback} from '@/api/route'
  34. export default {
  35. data() {
  36. return {
  37. json: null
  38. }
  39. },
  40. // 注入vueJsonEditor组件
  41. components: {
  42. vueJsonEditor
  43. },
  44. created() {
  45. this.getList()
  46. },
  47. methods: {
  48. getList() {
  49. fetchList().then(response => {
  50. let result = response.data.data;
  51. for (var i = 0; i < result.length; i++) {
  52. let route = result[i]
  53. if(route.predicates){
  54. let predicates = route.predicates
  55. route.predicates = JSON.parse(predicates)
  56. }
  57. if(route.filters){
  58. let filters = route.filters
  59. route.filters = JSON.parse(filters)
  60. }
  61. }
  62. this.json = result
  63. })
  64. },
  65. edit() {
  66. putObj(this.json).then(response => {
  67. this.$notify({
  68. title: '成功',
  69. message: '更新成功',
  70. type: 'success',
  71. duration: 2000
  72. })
  73. })
  74. }
  75. }
  76. }
  77. </script>