Skip to content

Commit 91799e6

Browse files
committed
feat(template): add selection box; add scheme and host field for reverse_proxy 0xJacky#608
1 parent 77666f4 commit 91799e6

File tree

20 files changed

+474
-136
lines changed

20 files changed

+474
-136
lines changed

.air.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bin = "tmp/main"
1313
# Customize binary.
1414
full_bin = "APP_ENV=dev APP_USER=air ./tmp/main"
1515
# Watch these filename extensions.
16-
include_ext = ["go", "tpl", "tmpl", "html", "toml", "po"]
16+
include_ext = ["go", "tpl", "tmpl", "html", "toml", "po", "conf"]
1717
# Ignore these filename extensions or directories.
1818
exclude_dir = ["assets", "tmp", "vendor", "app/node_modules", "upload", "docs", "resources", ".idea"]
1919
# Watch these directories if you specified.

api/template/template.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ func GetTemplateConfList(c *gin.Context) {
6666

6767
func GetTemplateBlockList(c *gin.Context) {
6868
configList, err := template.GetTemplateList("block")
69-
7069
if err != nil {
7170
api.ErrHandler(c, err)
7271
return

app/src/api/template.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@ import type { NgxDirective, NgxLocation, NgxServer } from '@/api/ngx'
44

55
export interface Variable {
66
type?: string
7-
name?: { [key: string]: string }
7+
name?: Record<string, string>
88
// eslint-disable-next-line @typescript-eslint/no-explicit-any
99
value?: any
10+
mask?: Record<string, Record<string, string>>
1011
}
1112

1213
export interface Template extends NgxServer {
1314
name: string
14-
description: { [key: string]: string }
15+
description: Record<string, string>
1516
author: string
1617
filename: string
17-
variables: {
18-
[key: string]: Variable
19-
}
18+
variables: Record<string, Variable>
2019
custom: string
2120
locations?: NgxLocation[]
2221
directives?: NgxDirective[]

app/src/views/certificate/WildcardCertificate.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const step = ref(0)
1313
const visible = ref(false)
1414
const data = ref({}) as Ref<AutoCertOptions>
1515
const issuing_cert = ref(false)
16+
const domain = ref('')
1617
1718
provide('issuing_cert', issuing_cert)
1819
function open() {
@@ -22,6 +23,7 @@ function open() {
2223
challenge_method: 'dns01',
2324
key_type: '2048',
2425
} as AutoCertOptions
26+
domain.value = ''
2527
}
2628
2729
defineExpose({
@@ -32,7 +34,6 @@ const modalVisible = ref(false)
3234
const modalClosable = ref(true)
3335
3436
const refObtainCertLive = ref()
35-
const domain = ref('')
3637
3738
const computedDomain = computed(() => {
3839
return `*.${domain.value}`

app/src/views/domain/ngx_conf/LocationEditor.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,9 @@ function duplicate(index: number) {
173173
.ant-collapse-header {
174174
align-items: center;
175175
}
176+
177+
:deep(.ant-collapse-header-text) {
178+
width: 100%;
179+
overflow: hidden;
180+
}
176181
</style>

app/src/views/domain/ngx_conf/config_template/ConfigTemplate.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,21 @@ provide('ngx_directives', ngx_directives)
119119
>
120120
<p>{{ $gettext('Author') }}: {{ data.author }}</p>
121121
<p>{{ $gettext('Description') }}: {{ trans_description(data) }}</p>
122-
<TemplateForm v-model:data="data.variables" />
123-
<template v-if="data.custom">
124-
<h2>{{ $gettext('Custom') }}</h2>
122+
<TemplateForm v-model="data.variables" />
123+
<div
124+
v-if="data.custom"
125+
class="mb-4"
126+
>
127+
<h3>{{ $gettext('Custom') }}</h3>
125128
<CodeEditor
126129
v-model:content="data.custom"
127130
default-height="150px"
128131
/>
129-
</template>
132+
</div>
130133
<DirectiveEditor
131134
v-if="data.directives"
132135
readonly
133136
/>
134-
<br>
135137
<LocationEditor
136138
v-if="data.locations"
137139
:locations="data.locations"

app/src/views/domain/ngx_conf/config_template/TemplateForm.vue

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,8 @@
22
import TemplateFormItem from '@/views/domain/ngx_conf/config_template/TemplateFormItem.vue'
33
import type { Variable } from '@/api/template'
44
5-
const props = defineProps<{
6-
data: {
7-
[key: string]: Variable
8-
}
9-
}>()
10-
11-
const emit = defineEmits<{
12-
'update:data': [data: {
13-
[key: string]: Variable
14-
}]
15-
}>()
16-
17-
const data = computed({
18-
get() {
19-
return props.data
20-
},
21-
set(v) {
22-
emit('update:data', v)
23-
},
5+
const data = defineModel<Record<string, Variable>>({
6+
default: () => {},
247
})
258
</script>
269

@@ -29,7 +12,7 @@ const data = computed({
2912
<TemplateFormItem
3013
v-for="(_, k) in data"
3114
:key="k"
32-
v-model:data="data[k]"
15+
v-model="data[k]"
3316
:name="k.toString()"
3417
/>
3518
</AForm>

app/src/views/domain/ngx_conf/config_template/TemplateFormItem.vue

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,32 @@ import _ from 'lodash'
44
import { useSettingsStore } from '@/pinia'
55
import type { Variable } from '@/api/template'
66
7-
const props = defineProps<{
8-
data: Variable
9-
name: string
10-
}>()
11-
12-
const emit = defineEmits<{
13-
'update:data': [data: Variable]
14-
}>()
15-
16-
const data = computed({
17-
get() {
18-
return props.data
19-
},
20-
set(v) {
21-
emit('update:data', v)
22-
},
7+
const data = defineModel<Variable>({
8+
default: () => {},
239
})
2410
2511
const { language } = storeToRefs(useSettingsStore())
2612
2713
const trans_name = computed(() => {
28-
return props.data?.name?.[language.value] ?? props.data?.name?.en ?? ''
14+
return data.value?.name?.[language.value] ?? data.value?.name?.en ?? ''
2915
})
3016
3117
const build_template = inject('build_template') as () => void
3218
33-
const value = computed(() => props.data.value)
19+
const value = computed(() => data.value.value)
3420
3521
watch(value, _.throttle(build_template, 500))
22+
23+
const selectOptions = computed(() => {
24+
return Object.keys(data.value?.mask || {}).map(k => {
25+
const label = data.value.mask?.[k]?.[language.value] ?? data.value.mask?.[k]?.en ?? ''
26+
27+
return {
28+
label,
29+
value: k,
30+
}
31+
})
32+
})
3633
</script>
3734

3835
<template>
@@ -41,6 +38,11 @@ watch(value, _.throttle(build_template, 500))
4138
v-if="data.type === 'string'"
4239
v-model:value="data.value"
4340
/>
41+
<ASelect
42+
v-else-if="data.type === 'select'"
43+
v-model:value="data.value"
44+
:options="selectOptions"
45+
/>
4446
<ASwitch
4547
v-else-if="data.type === 'boolean'"
4648
v-model:checked="data.value"

docs/.vitepress/config/zh_TW.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const zhTWConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
3131
items: [
3232
{text: '構建', link: '/zh_TW/guide/build'},
3333
{text: '專案結構', link: '/zh_TW/guide/project-structure'},
34+
{text: '配置模板', link: '/zh_TW/guide/nginx-ui-template'},
3435
{text: '貢獻程式碼', link: '/zh_TW/guide/contributing'}
3536
]
3637
},

0 commit comments

Comments
 (0)