perf: Optimize front-end code

This commit is contained in:
wangdan-fit2cloud 2025-08-19 18:51:09 +08:00 committed by GitHub
parent 3c46251eae
commit 7fcd8d4fce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
40 changed files with 751 additions and 604 deletions

View File

@ -372,7 +372,7 @@ const imageExtensions = ['JPG', 'JPEG', 'PNG', 'GIF', 'BMP']
const documentExtensions = ['PDF', 'DOCX', 'TXT', 'XLS', 'XLSX', 'MD', 'HTML', 'CSV']
const videoExtensions: any = []
const audioExtensions = ['MP3', 'WAV', 'OGG', 'AAC', 'M4A']
let otherExtensions = ref(['PPT', 'DOC'])
const otherExtensions = ref(['PPT', 'DOC'])
const getAcceptList = () => {
const { image, document, audio, video, other } = props.applicationDetails.file_upload_setting
@ -554,7 +554,7 @@ const switchMicrophone = (status: boolean) => {
}
}
const TouchEnd = (bool?: Boolean) => {
const TouchEnd = (bool?: boolean) => {
if (bool) {
stopRecording()
recorderStatus.value = 'STOP'

View File

@ -99,7 +99,7 @@ const menus = ref([
*/
const clearSelectedText = () => {
if (window.getSelection) {
var selection = window.getSelection()
const selection = window.getSelection()
if (selection) {
selection.removeAllRanges()
}

View File

@ -106,7 +106,7 @@ watch(
function handleInputFieldList() {
dynamicsFormRefresh.value++
let default_value: any = {}
const default_value: any = {}
props.application.work_flow?.nodes
?.filter((v: any) => v.id === 'base-node')
.map((v: any) => {
@ -312,8 +312,8 @@ const validate = () => {
}
const validate_query = () => {
// query
let msg = []
for (let f of apiInputFieldList.value) {
const msg = []
for (const f of apiInputFieldList.value) {
if (f.required && !api_form_data_context.value[f.field]) {
msg.push(f.field)
}
@ -328,9 +328,9 @@ const validate_query = () => {
}
const initRouteQueryValue = () => {
for (let f of apiInputFieldList.value) {
for (const f of apiInputFieldList.value) {
if (!api_form_data_context.value[f.field]) {
let _value = getRouteQueryValue(f.field)
const _value = getRouteQueryValue(f.field)
if (_value != null) {
api_form_data_context.value[f.field] = _value
}

View File

@ -277,7 +277,7 @@ function sendMessage(val: string, other_params_data?: any, chat?: chatType): Pro
return userFormRef.value
?.validate()
.then((ok) => {
let userFormData = accessToken
const userFormData = accessToken
? JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
: {}
const newData = Object.keys(form_data.value).reduce((result: any, key: string) => {
@ -640,7 +640,7 @@ const handleScroll = () => {
onMounted(() => {
if (isUserInput.value && localStorage.getItem(`${accessToken}userForm`)) {
let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
const userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
form_data.value = userFormData
}
if (window.speechSynthesis) {

View File

@ -19,7 +19,11 @@ const emit = defineEmits(['click'])
const back: any = router.options.history.state.back
function jump() {
if (props.to === '-1') {
back ? router.push(back) : router.go(-1)
if (back) {
router.push(back)
} else {
router.go(-1)
}
} else if (props.to) {
router.push(props.to as RouteLocationRaw)
} else {

View File

@ -149,6 +149,8 @@ const resourceType = computed(() => {
return 'model'
} else if (props.source === 'TOOL') {
return 'tool'
} else {
return 'application'
}
})

View File

@ -44,8 +44,7 @@ function evalParseOption(option_json: any) {
if (option_json.style) {
style.value = option_json.style
}
let option = {}
echarts
const option = {}
tmp.value = echarts
eval(option_json.option)
return option

View File

@ -20,7 +20,7 @@ onMounted(() => {
range.selectNode(htmlRef.value)
const scripts = htmlRef.value.getElementsByTagName('script')
if (scripts) {
var documentFragment = range.createContextualFragment(
const documentFragment = range.createContextualFragment(
[...scripts]
.map((item: HTMLElement) => {
htmlRef.value?.removeChild(item)

View File

@ -28,7 +28,7 @@
import { ref, computed, watch } from 'vue'
defineOptions({ name: 'MdEditorMagnify' })
const props = defineProps<{
title: String
title: string
modelValue: any
}>()
const emit = defineEmits(['update:modelValue', 'submitDialog'])

View File

@ -61,8 +61,8 @@ import useStore from '@/stores'
import { t } from '@/locales'
const props = defineProps<{
data?: {
type: Object
default: () => {}
type: object
default: () => null
}
apiType: 'systemShare' | 'workspace' | 'systemManage'
isApplication?: boolean,

View File

@ -98,13 +98,12 @@ function settingApiKey(row: any) {
function deleteApiKey(row: any) {
MsgConfirm(
// @ts-ignore
`${t('views.applicationOverview.appInfo.APIKeyDialog.msgConfirm1')}: ${row.secret_key}?`,
t('views.applicationOverview.appInfo.APIKeyDialog.msgConfirm2'),
{
confirmButtonText: t('common.confirm'),
cancelButtonText: t('common.cancel'),
confirmButtonClass: 'color-danger',
confirmButtonClass: 'danger',
},
)
.then(() => {

View File

@ -104,7 +104,7 @@ const submit = async (formEl: FormInstance | undefined) => {
.putAccessToken(id as string, form.value, loading)
.then(() => {
emit('refresh')
// @ts-ignore
MsgSuccess(t('common.settingSuccess'))
dialogVisible.value = false
})

View File

@ -118,7 +118,7 @@ const submit = async (formEl: FormInstance | undefined) => {
.putAccessToken(id as string, obj, loading)
.then(() => {
emit('refresh')
// @ts-ignore
MsgSuccess(t('common.settingSuccess'))
dialogVisible.value = false
})

View File

@ -113,7 +113,7 @@ const submit = async (formEl: FormInstance | undefined) => {
apiCall.then(() => {
emit('refresh')
//@ts-ignore
MsgSuccess(t('common.settingSuccess'))
dialogVisible.value = false
})

View File

@ -68,7 +68,6 @@ const props = defineProps({
const statisticsType = computed(() => [
{
id: 'customerCharts',
// @ts-ignore
name: t('views.applicationOverview.monitor.charts.customerTotal'),
icon: 'app-user',
background: '#EBF1FF',

View File

@ -255,7 +255,6 @@ const shareUrl = computed(
const dayOptions = [
{
value: 7,
// @ts-ignore
label: t('views.applicationOverview.monitor.pastDayOptions.past7Days'),
},
{
@ -373,7 +372,6 @@ function refreshAccessToken() {
const obj = {
access_token_reset: true,
}
// @ts-ignore
const str = t('views.applicationOverview.appInfo.refreshToken.refreshSuccess')
updateAccessToken(obj, str)
})

View File

@ -603,7 +603,6 @@ const onChange = (file: any, fileList: UploadFiles, attr: string) => {
//1 10 MB
const isLimit = file?.size / 1024 / 1024 < 10
if (!isLimit) {
// @ts-ignore
MsgError(t('common.EditAvatarDialog.fileSizeExceeded'))
return false
} else {
@ -675,7 +674,6 @@ const submit = async (formEl: FormInstance | undefined) => {
.putXpackAccessToken(id as string, fd, loading)
.then(() => {
emit('refresh')
// @ts-ignore
MsgSuccess(t('common.settingSuccess'))
dialogVisible.value = false
})

View File

@ -227,7 +227,6 @@ const submit = async (formEl: FormInstance | undefined) => {
.putAccessToken(id as string, obj, loading)
.then(() => {
emit('refresh')
// @ts-ignore
MsgSuccess(t('common.settingSuccess'))
dialogVisible.value = false
})

View File

@ -218,7 +218,9 @@ function back() {
saveApplication(true, true)
})
.catch((action: Action) => {
action === 'cancel' && go()
if (action === 'cancel') {
go()
}
})
} else {
go()
@ -275,7 +277,11 @@ function openHistory() {
}
function changeSave(bool: boolean) {
bool ? initInterval() : closeInterval()
if (bool) {
initInterval()
} else {
closeInterval()
}
localStorage.setItem('workflowAutoSave', bool.toString())
}

View File

@ -474,7 +474,6 @@ const permissionPrecise = computed(() => {
return permissionMap['application'][apiType.value]
})
// @ts-ignore
const defaultPrompt = t('views.application.form.prompt.defaultPrompt', {
data: '{data}',
question: '{question}',

View File

@ -60,7 +60,6 @@ import useStore from '@/stores'
const router = useRouter()
const { common, user } = useStore()
// @ts-ignore
const defaultPrompt = t('views.application.form.prompt.defaultPrompt', {
data: '{data}',
question: '{question}',
@ -69,7 +68,7 @@ const applicationFormRef = ref()
const loading = ref(false)
const dialogVisible = ref<boolean>(false)
// @ts-ignore
const applicationForm = ref<ApplicationFormType>({
name: '',
desc: '',

View File

@ -109,7 +109,6 @@ const { user } = useStore()
const router = useRouter()
const emit = defineEmits(['refresh'])
// @ts-ignore
const defaultPrompt = t('views.application.form.prompt.defaultPrompt', {
data: '{data}',
question: '{question}',

View File

@ -205,7 +205,6 @@ const noReferencesformRef = ref()
const defaultValue = {
ai_questioning: '{question}',
// @ts-ignore
designated_answer: t('views.application.dialog.designated_answer'),
}

View File

@ -259,7 +259,6 @@ const formRef = ref()
const dayOptions = [
{
value: 7,
// @ts-ignore
label: t('views.applicationOverview.monitor.pastDayOptions.past7Days'), // 使 t
},
{

View File

@ -8,7 +8,7 @@
:before-close="close"
append-to-body
>
<template #header="{ close, titleId, titleClass }">
<template #header>
<el-breadcrumb separator=">">
<el-breadcrumb-item>
<span @click="toSelectProvider" class="select-provider">

View File

@ -7,7 +7,7 @@
:destroy-on-close="true"
:before-close="close"
>
<template #header="{ close, titleId, titleClass }">
<template #header>
<el-breadcrumb separator=">">
<el-breadcrumb-item
><span class="active-breadcrumb">{{

View File

@ -66,7 +66,7 @@ import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import permissionMap from '@/permission'
const props = defineProps<{
title: String
title: string
apiType: 'systemShare' | 'workspace' | 'systemManage'
}>()

View File

@ -64,9 +64,9 @@ import permissionMap from '@/permission'
const props = defineProps<{
paragraphId: String
docId: String
knowledgeId: String
paragraphId: string
docId: string
knowledgeId: string
apiType: 'systemShare' | 'workspace' | 'systemManage'
}>()

View File

@ -62,7 +62,7 @@
container=".paragraph-scollbar"
@click="handleClick"
>
<template v-for="(item, index) in paragraphDetail" :key="item.id">
<template v-for="(item) in paragraphDetail" :key="item.id">
<el-anchor-link :href="`#m${item.id}`" :title="item.title" v-if="item.title">
<span :title="item.title">
{{ item.title }}

View File

@ -204,7 +204,9 @@ function associationClick(item: any) {
function searchHandle() {
paginationConfig.current_page = 1
paragraphList.value = []
currentDocument.value && getParagraphList(currentDocument.value)
if (currentDocument.value) {
getParagraphList(currentDocument.value)
}
}
function clickDocumentHandle(item: any) {
@ -222,7 +224,10 @@ function getDocument() {
documentList.value = res.data
currentDocument.value =
cloneDocumentList.value?.length > 0 ? cloneDocumentList.value[0].id : ''
currentDocument.value && getParagraphList(currentDocument.value)
if (currentDocument.value) {
getParagraphList(currentDocument.value)
}
})
}

View File

@ -363,7 +363,6 @@ function mapToUrlParams(map: any[]) {
function deleteApplication(row: any) {
MsgConfirm(
// @ts-ignore
`${t('views.application.delete.confirmTitle')}${row.name} ?`,
t('views.application.delete.confirmMessage'),
{

View File

@ -367,7 +367,7 @@ const search_type_change = () => {
}
function getRequestParams() {
let obj: any = {
const obj: any = {
name: model_search_form.value.name,
create_user: model_search_form.value.create_user,
model_type: model_search_form.value.model_type,

View File

@ -313,7 +313,6 @@ const rules = reactive<FormRules>({
const onChange = (file: any, fileList: UploadFiles, attr: string) => {
const isLimit = file?.size / 1024 / 1024 < 10
if (!isLimit) {
// @ts-ignore
MsgError(t('theme.fileMessageError'))
return false
} else {

View File

@ -1,6 +1,6 @@
<template>
<el-dialog modal-class="authorized-workspace" v-model="centerDialogVisible" width="840">
<template #header="{ titleId, titleClass }">
<template #header>
<h4 class="mb-8">{{ $t('views.shared.authorized_workspace') }}</h4>
<el-text class="color-secondary lighter">{{ $t('views.shared.authorized_tip') }}</el-text>
</template>
@ -11,7 +11,7 @@
<el-radio value="BLACK_LIST">{{ $t('views.shared.BLACK_LIST') }}</el-radio>
</el-radio-group>
<p class="mb-8 lighter mt-16">{{ $t('views.shared.select_workspace') }}</p>
<div class="flex border" v-loading="loading" style="overflow: hidden;">
<div class="flex border" v-loading="loading" style="overflow: hidden">
<div class="border-r">
<el-input
v-model="search"
@ -69,7 +69,7 @@
</el-button>
</div>
<el-scrollbar max-height="250" wrap-class="p-16 pt-0">
<template v-for="ele in checkedWorkspace">
<template v-for="(ele, index) in checkedWorkspace" :key="index">
<div class="flex-between">
<div class="flex align-center">
<AppIcon iconName="app-workspace"></AppIcon>
@ -97,7 +97,6 @@
import { ref, computed } from 'vue'
import type { CheckboxValueType } from 'element-plus'
import authorizationApi from '@/api/system-shared/authorization'
import workspaceApi from '@/api/workspace/workspace'
import { loadPermissionApi } from '@/utils/dynamics-api/permission-api.ts'
const checkAll = ref(false)
@ -137,7 +136,7 @@ const open = async ({ id }: any, type = 'Knowledge') => {
])
workspace.value = systemWorkspaceList.data as any
listType.value = (authList.data || {}).authentication_type || 'WHITE_LIST'
let workspace_id_list = (authList.data || {}).workspace_id_list || []
const workspace_id_list = (authList.data || {}).workspace_id_list || []
checkedWorkspace.value = workspace.value.filter((ele) => workspace_id_list.includes(ele.id))
handleCheckedWorkspaceChange(checkedWorkspace.value)
loading.value = false

View File

@ -3,7 +3,7 @@
<KnowledgeListContainer>
<template #header>
<el-breadcrumb separator-icon="ArrowRight">
<el-breadcrumb-item>{{ t('views.shared.shared_resources') }}</el-breadcrumb-item>
<el-breadcrumb-item>{{ $t('views.shared.shared_resources') }}</el-breadcrumb-item>
<el-breadcrumb-item>
<h5 class="ml-4 color-text-primary">{{ t('views.knowledge.title') }}</h5>
</el-breadcrumb-item>
@ -18,8 +18,6 @@ import { onMounted, ref, reactive, computed } from 'vue'
import KnowledgeListContainer from '@/views/knowledge/component/KnowledgeListContainer.vue'
import { t } from '@/locales'
onMounted(() => {})
</script>

View File

@ -3,7 +3,7 @@
<ContentContainer>
<template #header>
<el-breadcrumb separator-icon="ArrowRight">
<el-breadcrumb-item>{{ t('views.shared.shared_resources') }}</el-breadcrumb-item>
<el-breadcrumb-item>{{ $t('views.shared.shared_resources') }}</el-breadcrumb-item>
<el-breadcrumb-item>
<h5 class="ml-4 color-text-primary">{{ t('views.model.title') }}</h5>
</el-breadcrumb-item>
@ -18,7 +18,6 @@
<script lang="ts" setup>
import { onMounted, ref, computed } from 'vue'
import { t } from '@/locales'
import modelListContainer from '@/views/model/index.vue'
onMounted(() => {})

View File

@ -4,7 +4,7 @@
<template #header>
<el-space wrap>
<el-breadcrumb separator-icon="ArrowRight">
<el-breadcrumb-item>{{ t('views.shared.shared_resources') }}</el-breadcrumb-item>
<el-breadcrumb-item>{{ $t('views.shared.shared_resources') }}</el-breadcrumb-item>
<el-breadcrumb-item>
<h5 class="ml-4 color-text-primary">{{ t('views.tool.title') }}</h5>
</el-breadcrumb-item>
@ -26,7 +26,6 @@ import { onMounted, ref, reactive, computed } from 'vue'
import ToolListContainer from '@/views/tool/component/ToolListContainer.vue'
import { t } from '@/locales'
import useStore from '@/stores'
const { tool } = useStore()

View File

@ -281,7 +281,6 @@ const daterangeValue = ref('')
const dayOptions = [
{
value: 7,
// @ts-ignore
label: t('views.applicationOverview.monitor.pastDayOptions.past7Days'), // 使 t
},
{
@ -380,7 +379,7 @@ function handleSizeChange() {
}
function getRequestParams() {
let obj: any = {
const obj: any = {
start_time: daterange.value.start_time,
end_time: daterange.value.end_time,
}
@ -408,7 +407,7 @@ function getList() {
function getMenuList() {
return operateLog.getMenuList().then((res) => {
let arr: any[] = res.data
const arr: any[] = res.data
arr
.filter((item, index, self) => index === self.findIndex((i) => i['menu'] === item['menu']))
.forEach((ele) => {

View File

@ -106,7 +106,6 @@ const onChange = (file: any) => {
//110MB
const isLimit = file?.size / 1024 / 1024 < 10
if (!isLimit) {
// @ts-ignore
MsgError(t('common.EditAvatarDialog.fileSizeExceeded'))
return false
} else {