perf: Optimize application setting switch button control

This commit is contained in:
wangdan-fit2cloud 2025-04-02 18:09:47 +08:00 committed by GitHub
parent e364d6e373
commit 21d2a44090
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 37 additions and 19 deletions

View File

@ -172,7 +172,7 @@ export default {
feishu: { feishu: {
selectDocument: 'Select Document', selectDocument: 'Select Document',
tip1: 'Supports document and table types, including TXT, Markdown, PDF, DOCX, HTML, XLS, XLSX, CSV, and ZIP formats;', tip1: 'Supports document and table types, including TXT, Markdown, PDF, DOCX, HTML, XLS, XLSX, CSV, and ZIP formats;',
tip2: 'The system does not store the original documents. Before importing a document, it is recommended to standardize the paragraph segmentation markings of the document.', tip2: 'The system does not store original documents. Before importing, Please ensure the document follows standardized paragraph markers',
allCheck: 'Select All', allCheck: 'Select All',
errorMessage1: 'Please select a document' errorMessage1: 'Please select a document'
} }

View File

@ -24,7 +24,11 @@
<el-table-column :label="$t('common.status.label')" width="70"> <el-table-column :label="$t('common.status.label')" width="70">
<template #default="{ row }"> <template #default="{ row }">
<div @click.stop> <div @click.stop>
<el-switch size="small" v-model="row.is_active" @change="changeState($event, row)" /> <el-switch
size="small"
v-model="row.is_active"
:before-change="() => changeState(row)"
/>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
@ -104,16 +108,22 @@ function deleteApiKey(row: any) {
.catch(() => {}) .catch(() => {})
} }
function changeState(bool: Boolean, row: any) { function changeState(row: any) {
const obj = { const obj = {
is_active: bool is_active: !row.is_active
} }
const str = bool const str = obj.is_active
? t('views.applicationOverview.appInfo.APIKeyDialog.enabledSuccess') ? t('views.applicationOverview.appInfo.APIKeyDialog.enabledSuccess')
: t('views.applicationOverview.appInfo.APIKeyDialog.disabledSuccess') : t('views.applicationOverview.appInfo.APIKeyDialog.disabledSuccess')
overviewApi.putAPIKey(id as string, row.id, obj, loading).then((res) => { overviewApi
.putAPIKey(id as string, row.id, obj, loading)
.then((res) => {
MsgSuccess(str) MsgSuccess(str)
getApiKeyList() getApiKeyList()
return true
})
.catch(() => {
return false
}) })
} }

View File

@ -54,7 +54,7 @@
inline-prompt inline-prompt
:active-text="$t('views.applicationOverview.appInfo.openText')" :active-text="$t('views.applicationOverview.appInfo.openText')"
:inactive-text="$t('views.applicationOverview.appInfo.closeText')" :inactive-text="$t('views.applicationOverview.appInfo.closeText')"
@change="changeState($event)" :before-change="() => changeState(accessToken.is_active)"
/> />
</div> </div>
@ -148,7 +148,12 @@
{{ $t('views.applicationOverview.monitor.monitoringStatistics') }} {{ $t('views.applicationOverview.monitor.monitoringStatistics') }}
</h4> </h4>
<div class="mb-16"> <div class="mb-16">
<el-select v-model="history_day" class="mr-12" @change="changeDayHandle" style="width:180px"> <el-select
v-model="history_day"
class="mr-12"
@change="changeDayHandle"
style="width: 180px"
>
<el-option <el-option
v-for="item in dayOptions" v-for="item in dayOptions"
:key="item.value" :key="item.value"
@ -331,13 +336,19 @@ function refreshAccessToken() {
} }
function changeState(bool: Boolean) { function changeState(bool: Boolean) {
const obj = { const obj = {
is_active: bool is_active: !bool
} }
const str = bool ? t('common.status.enableSuccess') : t('common.status.disableSuccess') const str = obj.is_active ? t('common.status.enableSuccess') : t('common.status.disableSuccess')
updateAccessToken(obj, str) updateAccessToken(obj, str)
.then(() => {
return true
})
.catch(() => {
return false
})
} }
function updateAccessToken(obj: any, str: string) { async function updateAccessToken(obj: any, str: string) {
applicationApi.putAccessToken(id as string, obj, loading).then((res) => { applicationApi.putAccessToken(id as string, obj, loading).then((res) => {
accessToken.value = res?.data accessToken.value = res?.data
MsgSuccess(str) MsgSuccess(str)

View File

@ -5,7 +5,7 @@
</template> </template>
<div class="create-dataset__main flex" v-loading="loading"> <div class="create-dataset__main flex" v-loading="loading">
<div class="create-dataset__component main-calc-height"> <div class="create-dataset__component main-calc-height">
<div class="upload-document p-24"> <div class="upload-document p-24" style="min-width: 850px">
<h4 class="title-decoration-1 mb-8"> <h4 class="title-decoration-1 mb-8">
{{ $t('views.document.feishu.selectDocument') }} {{ $t('views.document.feishu.selectDocument') }}
</h4> </h4>
@ -41,7 +41,7 @@
@change="handleAllCheckChange" @change="handleAllCheckChange"
/> />
</div> </div>
<div style="height: calc(100vh - 430px)"> <div style="height: calc(100vh - 450px)">
<el-scrollbar> <el-scrollbar>
<el-tree <el-tree
:props="props" :props="props"

View File

@ -508,9 +508,6 @@ const open = (data: any) => {
visible.value = true visible.value = true
setTimeout(() => { setTimeout(() => {
showEditor.value = true showEditor.value = true
nextTick(() => {
onDragHandle()
})
}, 100) }, 100)
} }