RenewCert.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <script setup lang="ts">
  2. import type { AutoCertOptions } from '@/api/auto_cert'
  3. import { useGlobalStore } from '@/pinia'
  4. import ObtainCertLive from '@/views/site/site_edit/components/Cert/ObtainCertLive.vue'
  5. import { message } from 'ant-design-vue'
  6. const props = defineProps<{
  7. options: AutoCertOptions
  8. }>()
  9. const emit = defineEmits<{
  10. renewed: [void]
  11. }>()
  12. const modalVisible = ref(false)
  13. const modalClosable = ref(true)
  14. const refObtainCertLive = useTemplateRef('refObtainCertLive')
  15. const saveCert = inject<() => Promise<void>>('saveCert')!
  16. async function issueCert() {
  17. await saveCert()
  18. modalVisible.value = true
  19. const { name, domains, key_type } = props.options
  20. refObtainCertLive.value?.issue_cert(name!, domains, key_type).then(() => {
  21. message.success($gettext('Renew successfully'))
  22. emit('renewed')
  23. })
  24. }
  25. const globalStore = useGlobalStore()
  26. const { processingStatus } = storeToRefs(globalStore)
  27. </script>
  28. <template>
  29. <div>
  30. <AButton
  31. type="primary"
  32. ghost
  33. class="mb-6"
  34. :disabled="processingStatus.auto_cert_processing"
  35. @click="issueCert"
  36. >
  37. {{ $gettext('Renew Certificate') }}
  38. </AButton>
  39. <span v-if="processingStatus.auto_cert_processing" class="ml-4">
  40. {{ $gettext('AutoCert is running, please wait...') }}
  41. </span>
  42. <AModal
  43. v-model:open="modalVisible"
  44. :title="$gettext('Renew Certificate')"
  45. :mask-closable="modalClosable"
  46. :footer="null"
  47. :closable="modalClosable"
  48. :width="600"
  49. force-render
  50. >
  51. <ObtainCertLive
  52. ref="refObtainCertLive"
  53. v-model:modal-closable="modalClosable"
  54. v-model:modal-visible="modalVisible"
  55. :options
  56. />
  57. </AModal>
  58. </div>
  59. </template>
  60. <style lang="less" scoped>
  61. .control-btn {
  62. display: flex;
  63. justify-content: flex-end;
  64. }
  65. </style>