1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-22 07:10:09 +01:00

zh-CN Update

This commit is contained in:
Donald Zou 2024-11-02 14:26:47 +06:00
parent 94b597d29a
commit 49467c906d
11 changed files with 65 additions and 45 deletions

View File

@ -1388,7 +1388,7 @@ class DashboardConfig:
elif type(value) in [int, float]: elif type(value) in [int, float]:
self.__config[section][key] = str(value) self.__config[section][key] = str(value)
elif type(value) is list: elif type(value) is list:
self.__config[section][key] = "||".join(value) self.__config[section][key] = "||".join(value).strip("||")
else: else:
self.__config[section][key] = value self.__config[section][key] = value
return self.SaveConfig(), "" return self.SaveConfig(), ""
@ -1416,7 +1416,7 @@ class DashboardConfig:
return True, False return True, False
if section == "WireGuardConfiguration" and key == "autostart": if section == "WireGuardConfiguration" and key == "autostart":
return True, self.__config[section][key].split("||") return True, list(filter(lambda x: len(x) > 0, self.__config[section][key].split("||")))
return True, self.__config[section][key] return True, self.__config[section][key]
@ -1894,7 +1894,7 @@ def API_updateDashboardConfigurationItem():
WireguardConfigurations.clear() WireguardConfigurations.clear()
_getConfigurationList() _getConfigurationList()
return ResponseObject() return ResponseObject(True, data=DashboardConfig.GetConfig(data["section"], data["key"])[1])
@app.get(f'{APP_PREFIX}/api/getDashboardAPIKeys') @app.get(f'{APP_PREFIX}/api/getDashboardAPIKeys')
def API_getDashboardAPIKeys(): def API_getDashboardAPIKeys():

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
<script setup> <script setup>
import {onMounted, ref} from "vue"; import {onMounted, ref} from "vue";
import dayjs from "dayjs"; import dayjs from "dayjs";
import LocaleText from "@/components/text/localeText.vue";
const props = defineProps({ const props = defineProps({
configurationName: String, configurationName: String,
@ -35,7 +36,9 @@ onMounted(() => {
</samp> </samp>
</h6> </h6>
<small class="text-muted"> <small class="text-muted">
{{backups.length}} {{backups.length > 1 ? "Backups": "Backup" }} {{backups.length}}
<LocaleText t="Backups" v-if="backups.length > 1"></LocaleText>
<LocaleText t="Backup" v-else></LocaleText>
</small> </small>
</div> </div>
<h5 class="ms-auto mb-0 dropdownIcon text-muted" :class="{active: showBackups}"> <h5 class="ms-auto mb-0 dropdownIcon text-muted" :class="{active: showBackups}">
@ -59,7 +62,8 @@ onMounted(() => {
</small> </small>
<small > <small >
<i class="bi bi-database me-2"></i> <i class="bi bi-database me-2"></i>
{{b.database? "Yes" : "No" }} <LocaleText t="Yes" v-if="b.database"></LocaleText>
<LocaleText t="No" v-else></LocaleText>
</small> </small>
<small class="text-muted ms-auto"> <small class="text-muted ms-auto">
<i class="bi bi-chevron-right"></i> <i class="bi bi-chevron-right"></i>

View File

@ -105,14 +105,14 @@ const availableIPAddress = computed(() => {
const peersCount = computed(() => { const peersCount = computed(() => {
if (props.selectedConfigurationBackup.database){ if (props.selectedConfigurationBackup.database){
let l = props.selectedConfigurationBackup.databaseContent.split("\n") let l = props.selectedConfigurationBackup.databaseContent.split("\n")
return l.filter(x => x.search('INSERT INTO "(.*)"') >= 0).length return l.filter(x => x.search(`INSERT INTO "${newConfiguration.ConfigurationName}"`) >= 0).length
} }
return 0 return 0
}) })
const restrictedPeersCount = computed(() => { const restrictedPeersCount = computed(() => {
if (props.selectedConfigurationBackup.database){ if (props.selectedConfigurationBackup.database){
let l = props.selectedConfigurationBackup.databaseContent.split("\n") let l = props.selectedConfigurationBackup.databaseContent.split("\n")
return l.filter(x => x.search('INSERT INTO "(.*)_restrict_access"') >= 0).length return l.filter(x => x.search(`INSERT INTO "${newConfiguration.ConfigurationName}_restrict_access"`) >= 0).length
} }
return 0 return 0
}) })
@ -136,7 +136,7 @@ const submitRestore = async () => {
<form class="d-flex flex-column gap-3"> <form class="d-flex flex-column gap-3">
<div class="d-flex flex-column flex-sm-row align-items-start align-items-sm-center gap-3"> <div class="d-flex flex-column flex-sm-row align-items-start align-items-sm-center gap-3">
<h4 class="mb-0"> <h4 class="mb-0">
<LocaleText t="Configuration File"></LocaleText> <LocaleText t="Configuration"></LocaleText>
</h4> </h4>
</div> </div>
<div> <div>
@ -220,7 +220,7 @@ const submitRestore = async () => {
<LocaleText t="IP Address/CIDR"></LocaleText> <LocaleText t="IP Address/CIDR"></LocaleText>
</small> </small>
<small class="ms-auto" :class="[availableIPAddress > 0 ? 'text-success':'text-danger']"> <small class="ms-auto" :class="[availableIPAddress > 0 ? 'text-success':'text-danger']">
{{availableIPAddress}} Available IP Address <LocaleText :t="availableIPAddress + ' Available IP Address'"></LocaleText>
</small> </small>
</label> </label>
<input type="text" class="form-control" <input type="text" class="form-control"
@ -299,14 +299,16 @@ const submitRestore = async () => {
<div class="col-sm"> <div class="col-sm">
<div class="card text-bg-success rounded-3"> <div class="card text-bg-success rounded-3">
<div class="card-body"> <div class="card-body">
<i class="bi bi-person-fill me-2"></i> Contain <strong>{{peersCount}}</strong> Peer{{peersCount > 1 ? 's':''}} <i class="bi bi-person-fill me-2"></i>
<LocaleText t="Contain"></LocaleText> <strong>{{peersCount}}</strong> <LocaleText t="Peer" v-if="peersCount > 1"></LocaleText><LocaleText t="Peer" v-else></LocaleText>
</div> </div>
</div> </div>
</div> </div>
<div class="col-sm"> <div class="col-sm">
<div class="card text-bg-warning rounded-3"> <div class="card text-bg-warning rounded-3">
<div class="card-body"> <div class="card-body">
<i class="bi bi-person-fill-lock me-2"></i> Contain <strong>{{restrictedPeersCount}}</strong> Restricted Peer{{restrictedPeersCount > 1 ? 's':''}} <i class="bi bi-person-fill-lock me-2"></i>
<LocaleText t="Contain"></LocaleText> <strong>{{restrictedPeersCount}}</strong> <LocaleText t="Restricted Peers" v-if="restrictedPeersCount > 1" /><LocaleText t="Restricted Peers" v-else></LocaleText>
</div> </div>
</div> </div>
</div> </div>
@ -318,7 +320,8 @@ const submitRestore = async () => {
:disabled="!validateForm || loading" :disabled="!validateForm || loading"
@click="submitRestore()" @click="submitRestore()"
> >
<i class="bi bi-clock-history me-2"></i> {{ !loading ? 'Restore':'Restoring...'}} <i class="bi bi-clock-history me-2"></i>
<LocaleText :t="!loading ? 'Restore':'Restoring...'"></LocaleText>
</button> </button>
</div> </div>
</div> </div>

View File

@ -78,7 +78,7 @@ export default {
</script> </script>
<template> <template>
<div class="d-flex flex-column gap-2"> <form class="d-flex flex-column gap-2">
<div class="row g-2"> <div class="row g-2">
<div class="col-sm"> <div class="col-sm">
<div class="form-group"> <div class="form-group">
@ -88,6 +88,7 @@ export default {
</small></strong> </small></strong>
</label> </label>
<input type="password" class="form-control" <input type="password" class="form-control"
autocomplete="current-password"
:class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}" :class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}"
v-model="this.value.currentPassword" v-model="this.value.currentPassword"
:id="'currentPassword_' + this.uuid"> :id="'currentPassword_' + this.uuid">
@ -102,6 +103,7 @@ export default {
</small></strong> </small></strong>
</label> </label>
<input type="password" class="form-control" <input type="password" class="form-control"
autocomplete="new-password"
:class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}" :class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}"
v-model="this.value.newPassword" v-model="this.value.newPassword"
:id="'newPassword_' + this.uuid"> :id="'newPassword_' + this.uuid">
@ -116,6 +118,7 @@ export default {
</small></strong> </small></strong>
</label> </label>
<input type="password" class="form-control" <input type="password" class="form-control"
autocomplete="new-password"
:class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}" :class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}"
v-model="this.value.repeatNewPassword" v-model="this.value.repeatNewPassword"
:id="'repeatNewPassword_' + this.uuid"> :id="'repeatNewPassword_' + this.uuid">
@ -128,7 +131,7 @@ export default {
<i class="bi bi-save2-fill me-2"></i> <i class="bi bi-save2-fill me-2"></i>
<LocaleText t="Update Password"></LocaleText> <LocaleText t="Update Password"></LocaleText>
</button> </button>
</div> </form>
</template> </template>
<style scoped> <style scoped>

View File

@ -45,7 +45,6 @@ export default {
handler(newValue){ handler(newValue){
if (newValue){ if (newValue){
fetchGet("/api/getDashboardAPIKeys", {}, (res) => { fetchGet("/api/getDashboardAPIKeys", {}, (res) => {
console.log(res)
if(res.status){ if(res.status){
this.apiKeys = res.data this.apiKeys = res.data
}else{ }else{

View File

@ -13,13 +13,17 @@ const configurations = computed(() => {
}) })
const updateAutostart = async () => { const updateAutostart = async () => {
console.log(data.value)
await fetchPost("/api/updateDashboardConfigurationItem", { await fetchPost("/api/updateDashboardConfigurationItem", {
section: "WireGuardConfiguration", section: "WireGuardConfiguration",
key: "autostart", key: "autostart",
value: data.value value: data.value
}, async (res) => { }, async (res) => {
console.log(res); if (res.status){
store.newMessage("Server", "Start up configurations saved", "success")
data.value = res.data
}else{
store.newMessage("Server", "Start up configurations failed to save", "danger")
}
}) })
} }
@ -29,12 +33,8 @@ const toggle = (c) => {
}else{ }else{
data.value.push(c) data.value.push(c)
} }
}
watch(data, () => {
updateAutostart() updateAutostart()
}) }
</script> </script>
<template> <template>

View File

@ -2,7 +2,6 @@ import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.
export const GetLocale = (key) => { export const GetLocale = (key) => {
const store = DashboardConfigurationStore() const store = DashboardConfigurationStore()
if (store.Locale === null) if (store.Locale === null)
return key return key
const reg = Object.keys(store.Locale) const reg = Object.keys(store.Locale)
@ -10,6 +9,7 @@ export const GetLocale = (key) => {
return key.match(new RegExp('^' + x + '$', 'gi')) !== null return key.match(new RegExp('^' + x + '$', 'gi')) !== null
}) })
if (match.length === 0 || match.length > 1){ if (match.length === 0 || match.length > 1){
// console.log(`[Translation Needed] Language: ${store.Configuration.Server.dashboard_language} \nKey: ${key}`)
return key return key
} }
return key.replace(new RegExp(match[0], 'gi'), store.Locale[match[0]]) return key.replace(new RegExp(match[0], 'gi'), store.Locale[match[0]])

View File

@ -41,7 +41,9 @@ const selectedConfiguration = ref("")
<i class="bi bi-1-circle-fill"></i> <i class="bi bi-1-circle-fill"></i>
</h1> </h1>
<div> <div>
<h4 class="mb-0">Step 1</h4> <h4 class="mb-0">
<LocaleText t="Step 1"></LocaleText>
</h4>
<small class="text-muted"> <small class="text-muted">
<LocaleText t="Select a backup you want to restore" v-if="!confirm"></LocaleText> <LocaleText t="Select a backup you want to restore" v-if="!confirm"></LocaleText>
<LocaleText t="Click to change a backup" v-else></LocaleText> <LocaleText t="Click to change a backup" v-else></LocaleText>
@ -50,7 +52,9 @@ const selectedConfiguration = ref("")
</div> </div>
<Transition name="zoomReversed"> <Transition name="zoomReversed">
<div class="ms-sm-auto" v-if="confirm"> <div class="ms-sm-auto" v-if="confirm">
<small class="text-muted">Selected Backup</small> <small class="text-muted">
<LocaleText t="Selected Backup"></LocaleText>
</small>
<h6> <h6>
<samp>{{selectedConfigurationBackup.filename}}</samp> <samp>{{selectedConfigurationBackup.filename}}</samp>
</h6> </h6>
@ -58,21 +62,7 @@ const selectedConfiguration = ref("")
</Transition> </Transition>
</div> </div>
<div id="step1Detail" v-if="!confirm"> <div id="step1Detail" v-if="!confirm">
<!-- <div class="mb-4">-->
<!-- <h5>Backup of existing WireGuard Configurations</h5>-->
<!-- <hr>-->
<!-- <div class="d-flex gap-3 flex-column">-->
<!-- <BackupGroup-->
<!-- @select="(b) => {selectedConfigurationBackup = b; selectedConfiguration = c; confirm = true}"-->
<!-- :open="selectedConfiguration === c"-->
<!-- :selectedConfigurationBackup="selectedConfigurationBackup"-->
<!-- v-for="c in Object.keys(backups.ExistingConfigurations)"-->
<!-- :configuration-name="c" :backups="backups.ExistingConfigurations[c]"></BackupGroup>-->
<!-- </div>-->
<!-- </div>-->
<div class="mb-4"> <div class="mb-4">
<!-- <h5>Backup of non-existing WireGuard Configurations</h5>-->
<!-- <hr>-->
<div class="d-flex gap-3 flex-column"> <div class="d-flex gap-3 flex-column">
<BackupGroup <BackupGroup
@select="(b) => {selectedConfigurationBackup = b; selectedConfiguration = c; confirm = true}" @select="(b) => {selectedConfigurationBackup = b; selectedConfiguration = c; confirm = true}"
@ -83,7 +73,9 @@ const selectedConfiguration = ref("")
<div v-if="Object.keys(backups.NonExistingConfigurations).length === 0"> <div v-if="Object.keys(backups.NonExistingConfigurations).length === 0">
<div class="card rounded-3"> <div class="card rounded-3">
<div class="card-body"> <div class="card-body">
<p class="mb-0">You don't have any configuration to restore</p> <p class="mb-0">
<LocaleText t="You don't have any configuration to restore"></LocaleText>
</p>
</div> </div>
</div> </div>
</div> </div>

View File

@ -242,5 +242,24 @@
"Is Alive": "在线", "Is Alive": "在线",
"Average / Min / Max Round Trip Time": "平均 / 最低 / 最高来回通讯延迟", "Average / Min / Max Round Trip Time": "平均 / 最低 / 最高来回通讯延迟",
"Sent / Received / Lost Package": "发送 / 接收 / 丢失数据包", "Sent / Received / Lost Package": "发送 / 接收 / 丢失数据包",
"Manual restart of WGDashboard is needed to apply changes on IP Address and Listen Port": "更改 IP 地址或监听端口后需要手动重启 WGDashboard 以使用最新的设置" "Manual restart of WGDashboard is needed to apply changes on IP Address and Listen Port": "更改 IP 地址或监听端口后需要手动重启 WGDashboard 以使用最新的设置",
"Restore Configuration": "恢复配置",
"Step (.*)": "第$1步",
"Select a backup you want to restore": "选择一个您想恢复的配置",
"Click to change a backup": "点击更换备份",
"Selected Backup": "已选择备份",
"You don't have any configuration to restore": "您没有任何配置备份可以恢复",
"Help": "帮助",
"Backups": "个备份",
"Backup": "个备份",
"Yes": "是",
"No": "否",
"Backup not selected": "没有选择备份",
"Confirm \\& edit restore information": "确认和编辑备份信息",
"(.*) Available IP Address": "$1个可用的 IP 地址",
"Database File": "数据库文件",
"Contain": "含有",
"Restricted Peers?": "已限制访问端点",
"Restore": "恢复",
"Restoring": "恢复中..."
} }