前端转vue
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FastDevelopModal.vue 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <a-modal v-model:visible="showModal" title="快速开发面板" :footer="null" @cancel="onCancel" width="60%">
  3. <a-spin :spinning="loading">
  4. <section :style="{ height: '400px' }">
  5. <a-tabs>
  6. <a-tab-pane tab="模板">
  7. <div style="margin-bottom:20px">
  8. <a-space>
  9. <a-input v-model:value="v" placeholder="请输入页面名称" :style="{ width: '200px' }" />
  10. <a-button type="primary" @click="createV">创建view</a-button>
  11. </a-space>
  12. </div>
  13. <div>
  14. <a-space>
  15. <a-input v-model:value="c" placeholder="请输入组件名称" :style="{ width: '200px' }" />
  16. <a-button type="primary" @click="createC">创建component</a-button>
  17. </a-space>
  18. </div>
  19. </a-tab-pane>
  20. </a-tabs>
  21. </section>
  22. </a-spin>
  23. </a-modal>
  24. </template>
  25. <script lang="ts">
  26. import { ref, watch } from 'vue'
  27. import * as api from './service'
  28. export default {
  29. props: {
  30. isShow: {
  31. type: Boolean,
  32. default: false
  33. }
  34. },
  35. setup(props, { emit }) {
  36. const v = ref('')
  37. const c = ref('')
  38. const loading = ref(false)
  39. const onCancel = () => {
  40. emit('close')
  41. }
  42. const createV = () => {
  43. if (v.value) {
  44. loading.value = true
  45. api.createV(v.value)
  46. } else {
  47. alert('请输入页面名称')
  48. }
  49. }
  50. const createC = () => {
  51. if (c.value) {
  52. loading.value = true
  53. api.createC(c.value)
  54. } else {
  55. alert('请输入组件名称')
  56. }
  57. }
  58. const showModal = ref<boolean>(false)
  59. watch(
  60. () => props.isShow,
  61. (newVal) => {
  62. showModal.value = newVal
  63. },
  64. {
  65. immediate: true,
  66. },
  67. );
  68. return {
  69. onCancel,
  70. createV,
  71. createC,
  72. c,
  73. v,
  74. loading,
  75. showModal
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="less">
  81. </style>