index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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="execution">
  19. <basic-container>
  20. <el-alert title="路由配置是非常专业的事情,不建议非工程师操作" type="warning" />
  21. <vue-json-editor v-model="json" :show-btns="false" />
  22. <div align="center">
  23. <el-button @click="edit()">更新</el-button>
  24. </div>
  25. </basic-container>
  26. </div>
  27. </template>
  28. <script>
  29. import vueJsonEditor from "vue-json-editor";
  30. import { fetchList, putObj, refreshObj } from "@/api/admin/route";
  31. export default {
  32. // 注入vueJsonEditor组件
  33. components: {
  34. vueJsonEditor
  35. },
  36. data() {
  37. return {
  38. json: null
  39. };
  40. },
  41. created() {
  42. this.getList();
  43. },
  44. methods: {
  45. getList() {
  46. fetchList().then(response => {
  47. const result = response.data.data;
  48. for (var i = 0; i < result.length; i++) {
  49. const route = result[i];
  50. if (route.predicates) {
  51. const predicates = route.predicates;
  52. route.predicates = JSON.parse(predicates);
  53. }
  54. if (route.filters) {
  55. const filters = route.filters;
  56. route.filters = JSON.parse(filters);
  57. }
  58. }
  59. this.json = result;
  60. });
  61. },
  62. edit() {
  63. putObj(this.json).then(() => {
  64. refreshObj().then(() => {
  65. this.$notify({
  66. title: "成功",
  67. message: "更新成功",
  68. type: "success",
  69. duration: 2000
  70. });
  71. });
  72. });
  73. }
  74. }
  75. };
  76. </script>
  77. <style lang="scss">
  78. div.jsoneditor-contextmenu div.jsoneditor-icon {
  79. position: relative;
  80. }
  81. </style>