Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 15 additions & 172 deletions ui/src/views/application-overview/component/DisplaySettingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,99 +8,15 @@
<el-form label-position="top" ref="displayFormRef" :model="form">
<el-form-item>
<el-space direction="vertical" alignment="start">
<el-checkbox v-model="form.show_source" label="显示知识来源" />
<el-checkbox
v-model="form.show_history"
label="显示历史记录"
v-if="user.isEnterprise()"
/>
<el-checkbox
v-model="form.draggable"
label="可拖拽位置(浮窗模式)"
v-if="user.isEnterprise()"
/>
<el-checkbox
v-model="form.show_guide"
label="显示引导图(浮窗模式)"
v-if="user.isEnterprise()"
v-model="form.show_source"
:label="isWorkFlow(detail.type) ? '显示执行详情' : '显示知识来源'"
/>
</el-space>
</el-form-item>
<el-form-item label="对话头像" v-if="user.isEnterprise()">
<div class="flex mt-8">
<div class="border border-r-4 mr-16" style="padding: 8px">
<el-image
v-if="imgUrl.avatar"
:src="imgUrl.avatar"
alt=""
fit="cover"
style="width: 50px; height: 50px; display: block"
/>
<LogoIcon v-else height="50px" style="width: 50px; height: 50px; display: block" />
</div>

<el-upload
ref="uploadRef"
action="#"
:auto-upload="false"
:show-file-list="false"
accept="image/jpeg, image/png, image/gif"
:on-change="(file: any, fileList: any) => onChange(file, fileList, 'avatar')"
>
<el-button icon="Upload">{{
$t('views.applicationOverview.appInfo.EditAvatarDialog.upload')
}}</el-button>
<template #tip>
<div class="el-upload__tip info" style="margin-top: 0">
建议尺寸 32*32,支持 JPG、PNG、GIF,大小不超过 10 MB
</div>
</template>
</el-upload>
</div>
</el-form-item>
<el-form-item label="浮窗入口图标" v-if="user.isEnterprise()">
<div class="flex mt-8">
<div class="border border-r-4 mr-16" style="padding: 8px">
<el-image
v-if="imgUrl.float_icon"
:src="imgUrl.float_icon"
alt=""
fit="cover"
style="width: 50px; height: 50px; display: block"
/>
<img
v-else
src="@/assets/logo/logo.svg"
height="50px"
style="width: 50px; height: 50px; display: block"
/>
</div>

<el-upload
ref="uploadRef"
action="#"
:auto-upload="false"
:show-file-list="false"
accept="image/jpeg, image/png, image/gif"
:on-change="(file: any, fileList: any) => onChange(file, fileList, 'float_icon')"
>
<el-button icon="Upload">{{
$t('views.applicationOverview.appInfo.EditAvatarDialog.upload')
}}</el-button>
<template #tip>
<div class="el-upload__tip info" style="margin-top: 0">
建议尺寸 32*32,支持 JPG、PNG、GIF,大小不超过 10 MB
</div>
</template>
</el-upload>
</div>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button v-if="user.isEnterprise()" type="primary" @click.prevent="resetForm" link
>恢复默认
</el-button>
<el-button @click.prevent="dialogVisible = false"
>{{ $t('views.applicationOverview.appInfo.LimitDialog.cancelButtonText') }}
</el-button>
Expand All @@ -116,11 +32,9 @@ import { ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import type { FormInstance, FormRules, UploadFiles } from 'element-plus'
import applicationApi from '@/api/application'
import applicationXpackApi from '@/api/application-xpack'
import { isWorkFlow } from '@/utils/application'
import { MsgSuccess, MsgError } from '@/utils/message'
import { t } from '@/locales'
import useStore from '@/stores'
const { user } = useStore()

const route = useRoute()
const {
Expand All @@ -129,33 +43,13 @@ const {

const emit = defineEmits(['refresh'])

const defaultSetting = {
show_source: false,
show_history: true,
draggable: true,
show_guide: true,
avatar: '',
float_icon: ''
}

const displayFormRef = ref()
const form = ref<any>({
show_source: false
})

const xpackForm = ref<any>({
show_source: false,
show_history: false,
draggable: false,
show_guide: false,
avatar: '',
float_icon: ''
})

const imgUrl = ref<any>({
avatar: '',
float_icon: ''
})
const detail = ref<any>(null)

const dialogVisible = ref<boolean>(false)
const loading = ref(false)
Expand All @@ -165,50 +59,12 @@ watch(dialogVisible, (bool) => {
form.value = {
show_source: false
}
imgUrl.value = {
avatar: '',
float_icon: ''
}
}
})

function resetForm() {
form.value = {
...defaultSetting
}
imgUrl.value = {
avatar: '',
float_icon: ''
}
}

const onChange = (file: any, fileList: UploadFiles, attr: string) => {
//1、判断文件大小是否合法,文件限制不能大于 10 MB
const isLimit = file?.size / 1024 / 1024 < 10
if (!isLimit) {
// @ts-ignore
MsgError(t('views.applicationOverview.appInfo.EditAvatarDialog.fileSizeExceeded'))
return false
} else {
xpackForm.value[attr] = file.raw
imgUrl.value[attr] = URL.createObjectURL(file.raw)
}
}

const open = (data: any) => {
if (user.isEnterprise()) {
xpackForm.value.show_source = data.show_source
xpackForm.value.show_history = data.show_history
xpackForm.value.draggable = data.draggable
xpackForm.value.show_guide = data.show_guide
xpackForm.value.avatar = data.avatar
xpackForm.value.float_icon = data.float_icon
imgUrl.value.avatar = data.avatar
imgUrl.value.float_icon = data.float_icon
form.value = xpackForm.value
} else {
form.value.show_source = data.show_source
}
const open = (data: any, content: any) => {
detail.value = content
form.value.show_source = data.show_source

dialogVisible.value = true
}
Expand All @@ -217,28 +73,15 @@ const submit = async (formEl: FormInstance | undefined) => {
if (!formEl) return
await formEl.validate((valid, fields) => {
if (valid) {
if (user.isEnterprise()) {
let fd = new FormData()
Object.keys(form.value).map((item) => {
fd.append(item, form.value[item])
})
applicationXpackApi.putAccessToken(id as string, fd, loading).then((res) => {
emit('refresh')
// @ts-ignore
MsgSuccess(t('views.applicationOverview.appInfo.LimitDialog.settingSuccessMessage'))
dialogVisible.value = false
})
} else {
const obj = {
show_source: form.value.show_source
}
applicationApi.putAccessToken(id as string, obj, loading).then((res) => {
emit('refresh')
// @ts-ignore
MsgSuccess(t('views.applicationOverview.appInfo.LimitDialog.settingSuccessMessage'))
dialogVisible.value = false
})
const obj = {
show_source: form.value.show_source
}
applicationApi.putAccessToken(id as string, obj, loading).then((res) => {
emit('refresh')
// @ts-ignore
MsgSuccess(t('views.applicationOverview.appInfo.LimitDialog.settingSuccessMessage'))
dialogVisible.value = false
})
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@
</el-card>

<el-space direction="vertical" alignment="start" :size="2">
<el-checkbox v-model="form.show_source" label="显示知识来源" />
<el-checkbox
v-model="form.show_source"
:label="isWorkFlow(detail.type) ? '显示执行详情' : '显示知识来源'"
/>
<el-checkbox v-model="form.show_history" label="显示历史记录" />
<el-checkbox v-model="form.show_guide" label="显示引导图(浮窗模式)" />
<el-checkbox v-model="form.disclaimer" label="免责声明" @change="changeDisclaimer" />
Expand Down Expand Up @@ -298,7 +301,7 @@
import { computed, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import type { FormInstance, FormRules, UploadFiles } from 'element-plus'
import { isAppIcon } from '@/utils/application'
import { isAppIcon, isWorkFlow } from '@/utils/application'
import applicationXpackApi from '@/api/application-xpack'
import { MsgSuccess, MsgError } from '@/utils/message'
import { t } from '@/locales'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code snippet has a few minor adjustments:

  1. Typographical Error: In the first el-checkbox, add quotes around the label to fix '显示知识来源'.
  2. Import Statement: Ensure the import statement for applicationXpackApi is correct.
  3. Variable Usage: Use isWorkFlow(detail.type) correctly in setting the checkbox label.

Here's the corrected version of the code:

@@ -264,7 +264,10 @@
           </el-card>
 
           <el-space direction="vertical" alignment="start" :size="2">
-            <el-checkbox v-model="form.show_source" label="'显示知识来源'" />
+            <el-checkbox v-model="form.show_source"
+                         :label="isWorkFlow(detail.type) ? '显示执行详情' : '显示知识来源'"
+                       />
             <el-checkbox v-model="form.show_history" label="显示历史记录" />
             <el-checkbox v-model="form.show_guide" label="显示引导图(浮窗模式)" />
             <el-checkbox v-model="form.disclaimer" label="免责声明" @change="changeDisclaimer" />
@@ -298,7 +301,7 @@
 import { computed, ref, watch } from 'vue'
 import { useRoute } from 'vue-router'
 import type { FormInstance, FormRules, UploadFiles } from 'element-plus'
-import { isAppIcon } from '@/utils/application'
+import { isAppIcon, isWorkFlow } from '@/utils/application'
 import applicationXpackApi from '@/api/application-xpack'
 import { MsgSuccess, MsgError } from '@/utils/message'
 import { t } from '@/locales'

These changes address the typographical error and ensure that isWorkFlow(detail.type) is used correctly in setting the checkbox label.

Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/application-overview/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ function openDisplaySettingDialog() {
if (user.isEnterprise()) {
XPackDisplaySettingDialogRef.value?.open(accessToken.value, detail.value)
} else {
DisplaySettingDialogRef.value?.open(accessToken.value)
DisplaySettingDialogRef.value?.open(accessToken.value, detail.value)
}
}
function openEditAvatar() {
Expand Down
Loading