mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-10 18:05:48 +02:00
fix(confilg-template): build template error #989
This commit is contained in:
parent
70fe8fdec1
commit
28ed291250
3 changed files with 9 additions and 11 deletions
|
@ -3,7 +3,7 @@ import type { Variable } from '@/api/template'
|
||||||
import TemplateFormItem from './TemplateFormItem.vue'
|
import TemplateFormItem from './TemplateFormItem.vue'
|
||||||
|
|
||||||
const data = defineModel<Record<string, Variable>>({
|
const data = defineModel<Record<string, Variable>>({
|
||||||
default: () => {},
|
default: reactive({}),
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ export const useConfigTemplateStore = defineStore('configTemplate', () => {
|
||||||
|
|
||||||
const variables = computed(() => data.value?.variables ?? {})
|
const variables = computed(() => data.value?.variables ?? {})
|
||||||
|
|
||||||
function __buildTemplate(name: string) {
|
function __buildTemplate() {
|
||||||
template.build_block(name, variables.value).then(r => {
|
template.build_block(data.value.filename, variables.value).then(r => {
|
||||||
data.value.directives = r.directives
|
data.value.directives = r.directives
|
||||||
data.value.locations = r.locations
|
data.value.locations = r.locations
|
||||||
data.value.custom = r.custom
|
data.value.custom = r.custom
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"github.com/uozi-tech/cosy/logger"
|
"github.com/uozi-tech/cosy/logger"
|
||||||
cSettings "github.com/uozi-tech/cosy/settings"
|
cSettings "github.com/uozi-tech/cosy/settings"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
@ -40,14 +39,13 @@ func GetTemplateInfo(path, name string) (configListItem ConfigInfoItem) {
|
||||||
Filename: name,
|
Filename: name,
|
||||||
}
|
}
|
||||||
|
|
||||||
file, _ := templ.DistFS.Open(filepath.Join(path, name))
|
file, err := templ.DistFS.Open(filepath.Join(path, name))
|
||||||
|
if err != nil {
|
||||||
|
logger.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
defer func(file fs.File) {
|
defer file.Close()
|
||||||
err := file.Close()
|
|
||||||
if err != nil {
|
|
||||||
logger.Error(err)
|
|
||||||
}
|
|
||||||
}(file)
|
|
||||||
|
|
||||||
r := bufio.NewReader(file)
|
r := bufio.NewReader(file)
|
||||||
lineBytes, _, err := r.ReadLine()
|
lineBytes, _, err := r.ReadLine()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue