浏览代码

fix: ngx_directives not update #218

0xJacky 1 年之前
父节点
当前提交
26788f301f

+ 7 - 2
app/src/views/domain/DomainAdd.vue

@@ -34,7 +34,7 @@ function init() {
   })
 }
 
-function save() {
+async function save() {
   return ngx.build_config(ngx_config).then(r => {
     // eslint-disable-next-line promise/no-nesting
     domain.save(ngx_config.name, { name: ngx_config.name, content: r.content, overwrite: true }).then(() => {
@@ -82,8 +82,13 @@ async function next() {
   await save()
   current_step.value++
 }
+
+const ngx_directives = computed(() => {
+  return ngx_config.servers[0].directives
+})
+
 provide('save_site_config', save)
-provide('ngx_directives', ngx_config.servers[0].directives)
+provide('ngx_directives', ngx_directives)
 provide('ngx_config', ngx_config)
 </script>
 

+ 5 - 1
app/src/views/domain/ngx_conf/config_template/ConfigTemplate.vue

@@ -72,8 +72,12 @@ function build_template() {
   })
 }
 
+const ngx_directives = computed(() => {
+  return data.value?.directives
+})
+
 provide('build_template', build_template)
-provide('ngx_directives', data.value?.directives)
+provide('ngx_directives', ngx_directives)
 </script>
 
 <template>

+ 2 - 2
app/src/views/domain/ngx_conf/directive/DirectiveEditor.vue

@@ -1,7 +1,7 @@
 <script setup lang="ts">
 import { useGettext } from 'vue3-gettext'
 import Draggable from 'vuedraggable'
-import { provide } from 'vue'
+import type { ComputedRef } from 'vue'
 import DirectiveAdd from './DirectiveAdd.vue'
 import DirectiveEditorItem from '@/views/domain/ngx_conf/directive/DirectiveEditorItem.vue'
 import type { NgxDirective } from '@/api/ngx'
@@ -13,7 +13,7 @@ defineProps<{
 const { $gettext } = useGettext()
 const current_idx = ref(-1)
 
-const ngx_directives = inject('ngx_directives') as NgxDirective[]
+const ngx_directives = inject('ngx_directives') as ComputedRef<NgxDirective[]>
 
 provide('current_idx', current_idx)
 </script>