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

@ -23,18 +23,18 @@
step-strictly step-strictly
/> />
<span class="ml-4">{{ <span class="ml-4">{{
$t('views.applicationOverview.appInfo.LimitDialog.timesDays') $t('views.applicationOverview.appInfo.LimitDialog.timesDays')
}}</span> }}</span>
</el-form-item> </el-form-item>
<!-- 身份验证 --> <!-- 身份验证 -->
<el-form-item :label="$t('views.applicationOverview.appInfo.LimitDialog.authentication')"> <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-form-item>
<el-radio-group <el-radio-group
v-if="form.authentication" v-if="form.authentication"
v-model="form.authentication_value.type" v-model="form.authentication_value.type"
class="card__radio" class="card__radio"
@change="(val: string) => val === 'password'" @change="firstGeneration"
> >
<el-card <el-card
shadow="never" shadow="never"
@ -71,7 +71,9 @@
text text
style="margin: 0 4px 0 0 !important" style="margin: 0 4px 0 0 !important"
> >
<el-icon><RefreshRight /></el-icon> <el-icon>
<RefreshRight/>
</el-icon>
</el-button> </el-button>
</el-tooltip> </el-tooltip>
</template> </template>
@ -107,7 +109,7 @@
> >
<el-checkbox-group v-model="form.authentication_value.login_value"> <el-checkbox-group v-model="form.authentication_value.login_value">
<template v-for="t in auth_list" :key="t.value"> <template v-for="t in auth_list" :key="t.value">
<el-checkbox :label="t.label" :value="t.value" /> <el-checkbox :label="t.label" :value="t.value"/>
</template> </template>
</el-checkbox-group> </el-checkbox-group>
</el-form-item> </el-form-item>
@ -131,7 +133,7 @@
</el-form> </el-form>
<template #footer> <template #footer>
<div> <div>
<el-button @click.prevent="dialogVisible = false">{{ $t('common.cancel') }} </el-button> <el-button @click.prevent="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="submit(limitFormRef)" :loading="loading"> <el-button type="primary" @click="submit(limitFormRef)" :loading="loading">
{{ $t('common.save') }} {{ $t('common.save') }}
</el-button> </el-button>
@ -140,18 +142,18 @@
</el-drawer> </el-drawer>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from 'vue' import {ref, watch} from 'vue'
import { useRoute, useRouter } from 'vue-router' import {useRoute, useRouter} from 'vue-router'
import type { FormInstance, FormRules } from 'element-plus' import type {FormInstance, FormRules} from 'element-plus'
import applicationApi from '@/api/application/application' import applicationApi from '@/api/application/application'
import { MsgSuccess } from '@/utils/message' import {MsgSuccess} from '@/utils/message'
import { t } from '@/locales' import {t} from '@/locales'
import { copyClick } from '@/utils/clipboard' import {copyClick} from '@/utils/clipboard'
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const { const {
params: { id }, params: {id},
} = route } = route
const emit = defineEmits(['refresh']) const emit = defineEmits(['refresh'])
@ -226,6 +228,7 @@ const submit = async (formEl: FormInstance | undefined) => {
} }
}) })
} }
function generateAuthenticationValue(length: number = 10) { function generateAuthenticationValue(length: number = 10) {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
const randomValues = new Uint8Array(length) const randomValues = new Uint8Array(length)
@ -234,18 +237,18 @@ function generateAuthenticationValue(length: number = 10) {
.map((value) => chars[value % chars.length]) .map((value) => chars[value % chars.length])
.join('') .join('')
} }
function refreshAuthentication() { function refreshAuthentication() {
form.value.authentication_value.password_value = generateAuthenticationValue() form.value.authentication_value.password_value = generateAuthenticationValue()
} }
function firstGeneration() { function firstGeneration() {
console.log('firstGeneration') if (form.value.authentication && form.value.authentication_value.type === 'password' && !form.value.authentication_value.password_value) {
if (form.value.authentication && !form.value.authentication_value) { form.value.authentication_value.password_value = generateAuthenticationValue()
form.value.authentication_value = generateAuthenticationValue()
} }
} }
defineExpose({ open }) defineExpose({open})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.authentication-append-input { .authentication-append-input {