fix: improve formatting and readability in XPackLimitDrawer.vue

This commit is contained in:
wxg0103 2025-07-15 11:04:32 +08:00
parent 11b7672bf4
commit 5a8c7a0e00

View File

@ -28,13 +28,13 @@
</el-form-item>
<!-- 身份验证 -->
<el-form-item :label="$t('views.applicationOverview.appInfo.LimitDialog.authentication')">
<el-switch size="small" v-model="form.authentication" @change="firstGeneration"></el-switch>
<el-switch size="small" v-model="form.authentication"></el-switch>
</el-form-item>
<el-radio-group
v-if="form.authentication"
v-model="form.authentication_value.type"
class="card__radio"
@change="(val: string) => val === 'password'"
@change="firstGeneration"
>
<el-card
shadow="never"
@ -71,7 +71,9 @@
text
style="margin: 0 4px 0 0 !important"
>
<el-icon><RefreshRight /></el-icon>
<el-icon>
<RefreshRight/>
</el-icon>
</el-button>
</el-tooltip>
</template>
@ -226,6 +228,7 @@ const submit = async (formEl: FormInstance | undefined) => {
}
})
}
function generateAuthenticationValue(length: number = 10) {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
const randomValues = new Uint8Array(length)
@ -234,14 +237,14 @@ function generateAuthenticationValue(length: number = 10) {
.map((value) => chars[value % chars.length])
.join('')
}
function refreshAuthentication() {
form.value.authentication_value.password_value = generateAuthenticationValue()
}
function firstGeneration() {
console.log('firstGeneration')
if (form.value.authentication && !form.value.authentication_value) {
form.value.authentication_value = generateAuthenticationValue()
if (form.value.authentication && form.value.authentication_value.type === 'password' && !form.value.authentication_value.password_value) {
form.value.authentication_value.password_value = generateAuthenticationValue()
}
}