fix: ngx_directives not update #218

This commit is contained in:
0xJacky 2023-12-06 00:09:01 +08:00
parent 4bab7b243d
commit 26788f301f
No known key found for this signature in database
GPG key ID: B6E4A6E4A561BAF0
3 changed files with 14 additions and 5 deletions

View file

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

View file

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

View file

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