Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
29c1c791d4 | |||
40019568f0 | |||
db065073e2 |
@@ -14,8 +14,11 @@ type Export struct {
|
|||||||
Global *Global `json:"global" label:"全局配置" binding:"required"`
|
Global *Global `json:"global" label:"全局配置" binding:"required"`
|
||||||
Server *Server `json:"server" label:"服务端配置" binding:"required"`
|
Server *Server `json:"server" label:"服务端配置" binding:"required"`
|
||||||
Clients []Client `json:"clients" label:"客户端" binding:"omitempty"`
|
Clients []Client `json:"clients" label:"客户端" binding:"omitempty"`
|
||||||
|
Other []Other `json:"other" label:"其他" binding:"omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Global
|
||||||
|
// @description: 全局配置
|
||||||
type Global struct {
|
type Global struct {
|
||||||
MTU int `json:"MTU" label:"MTU" binding:"required"`
|
MTU int `json:"MTU" label:"MTU" binding:"required"`
|
||||||
ConfigFilePath string `json:"configFilePath" label:"配置文件路径" binding:"required"`
|
ConfigFilePath string `json:"configFilePath" label:"配置文件路径" binding:"required"`
|
||||||
@@ -26,6 +29,8 @@ type Global struct {
|
|||||||
Table string `json:"table" label:"table" binding:"omitempty"`
|
Table string `json:"table" label:"table" binding:"omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Server
|
||||||
|
// @description: 服务端信息
|
||||||
type Server struct {
|
type Server struct {
|
||||||
IpScope []string `json:"ipScope" label:"ipScope" binding:"min=1,dive,required"`
|
IpScope []string `json:"ipScope" label:"ipScope" binding:"min=1,dive,required"`
|
||||||
ListenPort int `json:"listenPort" label:"listenPort" binding:"required"`
|
ListenPort int `json:"listenPort" label:"listenPort" binding:"required"`
|
||||||
@@ -35,6 +40,8 @@ type Server struct {
|
|||||||
PostDownScript string `json:"postDownScript" label:"postDownScript" binding:"omitempty"`
|
PostDownScript string `json:"postDownScript" label:"postDownScript" binding:"omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Client
|
||||||
|
// @description: 客户端信息
|
||||||
type Client struct {
|
type Client struct {
|
||||||
Name string `json:"name" label:"name" binding:"required"`
|
Name string `json:"name" label:"name" binding:"required"`
|
||||||
Email string `json:"email" label:"email" binding:"omitempty"`
|
Email string `json:"email" label:"email" binding:"omitempty"`
|
||||||
@@ -52,3 +59,11 @@ type Client struct {
|
|||||||
Enabled *constant.Status `json:"enabled" label:"enabled" binding:"required"`
|
Enabled *constant.Status `json:"enabled" label:"enabled" binding:"required"`
|
||||||
OfflineMonitoring *constant.Status `json:"offlineMonitoring" label:"offlineMonitoring" binding:"required"`
|
OfflineMonitoring *constant.Status `json:"offlineMonitoring" label:"offlineMonitoring" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Other
|
||||||
|
// @description: 其他配置
|
||||||
|
type Other struct {
|
||||||
|
Code string `json:"code" label:"code" binding:"required"`
|
||||||
|
Data string `json:"data" label:"data" binding:"required"`
|
||||||
|
Describe string `json:"describe" label:"describe" binding:"omitempty"`
|
||||||
|
}
|
||||||
|
@@ -152,6 +152,13 @@ func (s setting) Export() (data vo.Export, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询其他配置
|
||||||
|
var others []vo.Other
|
||||||
|
if err = s.Model(&model.Setting{}).Where("code not in ?", []string{"WG_SETTING", "WG_SERVER"}).Find(&others).Error; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data.Other = others
|
||||||
cj, _ := json.Marshal(clients)
|
cj, _ := json.Marshal(clients)
|
||||||
_ = json.Unmarshal(cj, &data.Clients)
|
_ = json.Unmarshal(cj, &data.Clients)
|
||||||
|
|
||||||
@@ -219,5 +226,17 @@ func (s setting) Import(data *vo.Export, loginUser *vo.User) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 其他配置写入
|
||||||
|
for _, v := range data.Other {
|
||||||
|
if err = s.SetData(&model.Setting{
|
||||||
|
Code: v.Code,
|
||||||
|
Data: v.Data,
|
||||||
|
Describe: v.Describe,
|
||||||
|
}); err != nil {
|
||||||
|
slog.Errorf("其他配置[%s]导入失败: %v", v.Code, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@@ -85,14 +85,14 @@
|
|||||||
{{ cip }}
|
{{ cip }}
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="可访问IP:">
|
<!-- <n-form-item label="可访问IP:">-->
|
||||||
<n-button v-if="row.allowedIps.length <= 0" dashed size="small">
|
<!-- <n-button v-if="row.allowedIps.length <= 0" dashed size="small">-->
|
||||||
-
|
<!-- - -->
|
||||||
</n-button>
|
<!-- </n-button>-->
|
||||||
<n-button v-else dashed mr-2 type="warning" v-for="aip in row.allowedIps" size="small">
|
<!-- <n-button v-else dashed mr-2 type="warning" v-for="aip in row.allowedIps" size="small">-->
|
||||||
{{ aip }}
|
<!-- {{ aip }}-->
|
||||||
</n-button>
|
<!-- </n-button>-->
|
||||||
</n-form-item>
|
<!-- </n-form-item>-->
|
||||||
<n-form-item label="创建人:">
|
<n-form-item label="创建人:">
|
||||||
<n-button color="#54150F" dashed size="small">
|
<n-button color="#54150F" dashed size="small">
|
||||||
{{ row.createUser }}
|
{{ row.createUser }}
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
禁用
|
禁用
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="离线监听:">
|
<n-form-item label="离线通知:">
|
||||||
<n-button v-if="row.offlineMonitoring === 1" color="#067748" round :bordered="false" size="small">
|
<n-button v-if="row.offlineMonitoring === 1" color="#067748" round :bordered="false" size="small">
|
||||||
启用
|
启用
|
||||||
</n-button>
|
</n-button>
|
||||||
@@ -114,12 +114,12 @@
|
|||||||
禁用
|
禁用
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item class="timeItem" label="时间:">
|
<!-- <n-form-item class="timeItem" label="时间:">-->
|
||||||
<n-space vertical>
|
<!-- <n-space vertical>-->
|
||||||
<span> 创建时间: {{ row.createdAt }}</span>
|
<!-- <span> 创建时间: {{ row.createdAt }}</span>-->
|
||||||
<span> 更新时间: {{ row.updatedAt }}</span>
|
<!-- <span> 更新时间: {{ row.updatedAt }}</span>-->
|
||||||
</n-space>
|
<!-- </n-space>-->
|
||||||
</n-form-item>
|
<!-- </n-form-item>-->
|
||||||
</n-form>
|
</n-form>
|
||||||
</div>
|
</div>
|
||||||
</n-card>
|
</n-card>
|
||||||
@@ -228,12 +228,18 @@
|
|||||||
<n-radio :value="0" :checked="editModalForm.enabled === 0" @change="editModalForm.enabled = 0">禁用</n-radio>
|
<n-radio :value="0" :checked="editModalForm.enabled === 0" @change="editModalForm.enabled = 0">禁用</n-radio>
|
||||||
</n-radio-group>
|
</n-radio-group>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="离线监听" path="offlineMonitoring">
|
<n-form-item label="离线通知" path="offlineMonitoring">
|
||||||
<n-radio-group :value="editModalForm.offlineMonitoring">
|
<n-radio-group :value="editModalForm.offlineMonitoring">
|
||||||
<n-radio :value="1" :checked="editModalForm.offlineMonitoring === 1" @change="editModalForm.offlineMonitoring = 1">启用</n-radio>
|
<n-radio :value="1" :checked="editModalForm.offlineMonitoring === 1" @change="editModalForm.offlineMonitoring = 1">启用</n-radio>
|
||||||
<n-radio :value="0" :checked="editModalForm.offlineMonitoring === 0" @change="editModalForm.offlineMonitoring = 0">禁用</n-radio>
|
<n-radio :value="0" :checked="editModalForm.offlineMonitoring === 0" @change="editModalForm.offlineMonitoring = 0">禁用</n-radio>
|
||||||
</n-radio-group>
|
</n-radio-group>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
<n-form-item class="timeItem" label="时间:">
|
||||||
|
<n-space vertical>
|
||||||
|
<span> 创建时间: {{ editModalForm.createdAt }}</span>
|
||||||
|
<span> 更新时间: {{ editModalForm.updatedAt }}</span>
|
||||||
|
</n-space>
|
||||||
|
</n-form-item>
|
||||||
<n-button type="info" style="margin-left: 40%" @click="updateClient()">确认</n-button>
|
<n-button type="info" style="margin-left: 40%" @click="updateClient()">确认</n-button>
|
||||||
</n-form>
|
</n-form>
|
||||||
</n-modal>
|
</n-modal>
|
||||||
@@ -319,7 +325,7 @@
|
|||||||
<n-radio :value="0" :checked="addModalForm.enabled === 0" @change="addModalForm.enabled = 0">禁用</n-radio>
|
<n-radio :value="0" :checked="addModalForm.enabled === 0" @change="addModalForm.enabled = 0">禁用</n-radio>
|
||||||
</n-radio-group>
|
</n-radio-group>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="离线监听" path="offlineMonitoring">
|
<n-form-item label="离线通知" path="offlineMonitoring">
|
||||||
<n-radio-group :value="addModalForm.offlineMonitoring">
|
<n-radio-group :value="addModalForm.offlineMonitoring">
|
||||||
<n-radio :value="1" :checked="addModalForm.offlineMonitoring === 1" @change="addModalForm.offlineMonitoring = 1">启用</n-radio>
|
<n-radio :value="1" :checked="addModalForm.offlineMonitoring === 1" @change="addModalForm.offlineMonitoring = 1">启用</n-radio>
|
||||||
<n-radio :value="0" :checked="addModalForm.offlineMonitoring === 0" @change="addModalForm.offlineMonitoring = 0">禁用</n-radio>
|
<n-radio :value="0" :checked="addModalForm.offlineMonitoring === 0" @change="addModalForm.offlineMonitoring = 0">禁用</n-radio>
|
||||||
@@ -440,7 +446,9 @@ const editModalForm = ref({
|
|||||||
presharedKey: ''
|
presharedKey: ''
|
||||||
},
|
},
|
||||||
enabled: 1,
|
enabled: 1,
|
||||||
offlineMonitoring: 1
|
offlineMonitoring: 1,
|
||||||
|
createdAt: '',
|
||||||
|
updatedAt: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
// 添加模态框的数据集
|
// 添加模态框的数据集
|
||||||
@@ -576,6 +584,8 @@ function openEditModal(row) {
|
|||||||
editModalForm.value.keys.presharedKey = row.keys.presharedKey
|
editModalForm.value.keys.presharedKey = row.keys.presharedKey
|
||||||
editModalForm.value.enabled = row.enabled
|
editModalForm.value.enabled = row.enabled
|
||||||
editModalForm.value.offlineMonitoring = row.offlineMonitoring
|
editModalForm.value.offlineMonitoring = row.offlineMonitoring
|
||||||
|
editModalForm.value.createdAt = row.createdAt
|
||||||
|
editModalForm.value.updatedAt = row.updatedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更改客户端信息
|
// 更改客户端信息
|
||||||
|
@@ -174,6 +174,9 @@
|
|||||||
<n-radio :value="false" :checked="editFormModel.data[index] === false" @change="editFormModel.data[index] = false">否</n-radio>
|
<n-radio :value="false" :checked="editFormModel.data[index] === false" @change="editFormModel.data[index] = false">否</n-radio>
|
||||||
</n-radio-group>
|
</n-radio-group>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
<n-form-item label="配置描述">
|
||||||
|
<n-input v-model:value="editFormModel.describe" />
|
||||||
|
</n-form-item>
|
||||||
<n-form-item>
|
<n-form-item>
|
||||||
<n-button type="info" @click="updateSetting">确认</n-button>
|
<n-button type="info" @click="updateSetting">确认</n-button>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
Reference in New Issue
Block a user