mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: standardize formatting and improve readability in Vue components
This commit is contained in:
parent
5eea07dc8b
commit
1869b47dde
|
|
@ -30,7 +30,8 @@
|
|||
:loading="loading"
|
||||
@click="up"
|
||||
>
|
||||
{{ $t('common.steps.prev') }}</el-button
|
||||
{{ $t('common.steps.prev') }}
|
||||
</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="base_form_list.length > 0 && active == 'data_source'"
|
||||
|
|
@ -48,24 +49,26 @@
|
|||
{{ $t('views.document.buttons.import') }}
|
||||
</el-button>
|
||||
<el-button v-if="active == 'result'" type="primary" @click="goDocument">{{
|
||||
$t('views.knowledge.ResultSuccess.buttons.toDocument')
|
||||
}}</el-button>
|
||||
$t('views.knowledge.ResultSuccess.buttons.toDocument')
|
||||
}}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, provide, type Ref, nextTick } from 'vue'
|
||||
import {computed, ref, provide, type Ref, nextTick} from 'vue'
|
||||
import DataSource from '@/views/knowledge-workflow/component/action/DataSource.vue'
|
||||
import Result from '@/views/knowledge-workflow/component/action/Result.vue'
|
||||
import applicationApi from '@/api/application/application'
|
||||
import KnowledgeBase from '@/views/knowledge-workflow/component/action/KnowledgeBase.vue'
|
||||
import { WorkflowType } from '@/enums/application'
|
||||
import {WorkflowType} from '@/enums/application'
|
||||
|
||||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
||||
import {loadSharedApi} from '@/utils/dynamics-api/shared-api'
|
||||
import permissionMap from '@/permission'
|
||||
import { MsgError } from '@/utils/message'
|
||||
import { t } from '@/locales'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import {MsgError} from '@/utils/message'
|
||||
import {t} from '@/locales'
|
||||
import {useRoute, useRouter} from 'vue-router'
|
||||
|
||||
provide('upload', (file: any, loading?: Ref<boolean>) => {
|
||||
return applicationApi.postUploadFile(file, id, 'KNOWLEDGE', loading)
|
||||
})
|
||||
|
|
@ -73,7 +76,7 @@ const key = ref<number>(0)
|
|||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const {
|
||||
params: { id, folderId },
|
||||
params: {id, folderId},
|
||||
/*
|
||||
id 为 knowledge_id
|
||||
*/
|
||||
|
|
@ -127,6 +130,9 @@ const up = () => {
|
|||
active.value = 'data_source'
|
||||
})
|
||||
}
|
||||
const isShared = computed(() => {
|
||||
return folderId === 'share'
|
||||
})
|
||||
|
||||
const permissionPrecise = computed(() => {
|
||||
return permissionMap['knowledge'][apiType.value]
|
||||
|
|
@ -136,7 +142,7 @@ const upload = () => {
|
|||
if (permissionPrecise.value.doc_create(id)) {
|
||||
ActionRef.value.validate().then(() => {
|
||||
form_data.value[active.value] = ActionRef.value.get_data()
|
||||
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
||||
loadSharedApi({type: 'knowledge', isShared: isShared.value, systemType: apiType.value})
|
||||
.workflowAction(id, form_data.value, loading)
|
||||
.then((ok: any) => {
|
||||
action_id.value = ok.data.id
|
||||
|
|
@ -164,6 +170,6 @@ const goDocument = () => {
|
|||
}).href
|
||||
window.open(newUrl)
|
||||
}
|
||||
defineExpose({ close, open })
|
||||
defineExpose({close, open})
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
|
|||
|
|
@ -24,12 +24,15 @@
|
|||
@close="closeWrite(row)"
|
||||
/>
|
||||
<el-tag v-if="index === 0" class="default-tag ml-4">{{
|
||||
$t('workflow.setting.latestRelease')
|
||||
}}</el-tag>
|
||||
$t('workflow.setting.latestRelease')
|
||||
}}
|
||||
</el-tag>
|
||||
</h5>
|
||||
<el-text type="info" class="color-secondary flex align-center mt-8">
|
||||
<el-avatar :size="20" class="avatar-grey mr-4">
|
||||
<el-icon><UserFilled /></el-icon>
|
||||
<el-icon>
|
||||
<UserFilled/>
|
||||
</el-icon>
|
||||
</el-avatar>
|
||||
{{ row.publish_user_name }}
|
||||
</el-text>
|
||||
|
|
@ -50,7 +53,9 @@
|
|||
{{ $t('common.edit') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click="refreshVersion(row)">
|
||||
<el-icon class="color-secondary"><RefreshLeft /></el-icon>
|
||||
<el-icon class="color-secondary">
|
||||
<RefreshLeft/>
|
||||
</el-icon>
|
||||
{{ $t('workflow.setting.restoreCurrentVersion') }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
|
|
@ -72,17 +77,17 @@
|
|||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { datetimeFormat } from '@/utils/time'
|
||||
import { MsgSuccess, MsgError } from '@/utils/message'
|
||||
import { t } from '@/locales'
|
||||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
||||
import {ref, onMounted, computed} from 'vue'
|
||||
import {useRoute} from 'vue-router'
|
||||
import {datetimeFormat} from '@/utils/time'
|
||||
import {MsgSuccess, MsgError} from '@/utils/message'
|
||||
import {t} from '@/locales'
|
||||
import {loadSharedApi} from '@/utils/dynamics-api/shared-api'
|
||||
import permissionMap from '@/permission'
|
||||
|
||||
const route = useRoute()
|
||||
const {
|
||||
params: { id, folderId },
|
||||
params: {id, folderId},
|
||||
} = route as any
|
||||
const apiType = computed(() => {
|
||||
if (route.path.includes('shared')) {
|
||||
|
|
@ -124,12 +129,16 @@ function closeWrite(item: any) {
|
|||
item['writeStatus'] = false
|
||||
}
|
||||
|
||||
const isShared = computed(() => {
|
||||
return folderId === 'share'
|
||||
})
|
||||
|
||||
function editName(val: string, item: any) {
|
||||
if (val) {
|
||||
const obj = {
|
||||
name: val,
|
||||
}
|
||||
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
||||
loadSharedApi({type: 'knowledge', isShared: isShared.value, systemType: apiType.value})
|
||||
.updateKnowledgeVersion(id as string, item.id, obj, loading)
|
||||
.then(() => {
|
||||
MsgSuccess(t('common.modifySuccess'))
|
||||
|
|
@ -142,7 +151,7 @@ function editName(val: string, item: any) {
|
|||
}
|
||||
|
||||
function getList() {
|
||||
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
||||
loadSharedApi({type: 'knowledge', isShared: isShared.value, systemType: apiType.value})
|
||||
.listKnowledgeVersion(id, loading)
|
||||
.then((res: any) => {
|
||||
LogData.value = res.data
|
||||
|
|
@ -161,6 +170,7 @@ onMounted(() => {
|
|||
top: 57px;
|
||||
height: calc(100vh - 57px);
|
||||
z-index: 9;
|
||||
|
||||
.list-height {
|
||||
height: calc(100vh - 120px);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,28 +6,30 @@
|
|||
<h4 class="ellipsis" style="max-width: 300px" :title="detail?.name">{{ detail?.name }}</h4>
|
||||
<div v-if="showHistory && disablePublic">
|
||||
<el-text type="info" class="ml-16 color-secondary"
|
||||
>{{ $t('workflow.info.previewVersion') }}
|
||||
{{ currentVersion.name || datetimeFormat(currentVersion.update_time) }}</el-text
|
||||
>{{ $t('workflow.info.previewVersion') }}
|
||||
{{ currentVersion.name || datetimeFormat(currentVersion.update_time) }}
|
||||
</el-text
|
||||
>
|
||||
</div>
|
||||
<el-text type="info" class="ml-16 color-secondary" v-else-if="saveTime"
|
||||
>{{ $t('workflow.info.saveTime') }}{{ datetimeFormat(saveTime) }}</el-text
|
||||
>{{ $t('workflow.info.saveTime') }}{{ datetimeFormat(saveTime) }}
|
||||
</el-text
|
||||
>
|
||||
</div>
|
||||
<div v-if="showHistory && disablePublic">
|
||||
<el-button type="primary" class="mr-8" @click="refreshVersion()">
|
||||
{{ $t('workflow.setting.restoreVersion') }}
|
||||
</el-button>
|
||||
<el-divider direction="vertical" />
|
||||
<el-divider direction="vertical"/>
|
||||
<el-button text @click="closeHistory">
|
||||
<el-icon>
|
||||
<Close />
|
||||
<Close/>
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-button @click="showPopover = !showPopover">
|
||||
<AppIcon iconName="app-add-outlined" class="mr-4" />
|
||||
<AppIcon iconName="app-add-outlined" class="mr-4"/>
|
||||
{{ $t('workflow.setting.addComponent') }}
|
||||
</el-button>
|
||||
<el-button @click="clickShowDebug" :disabled="showDebug" v-if="permissionPrecise.debug(id)">
|
||||
|
|
@ -64,7 +66,7 @@
|
|||
<AppIcon iconName="app-save-outlined" class="color-secondary"></AppIcon>
|
||||
{{ $t('workflow.setting.autoSave') }}
|
||||
<div class="ml-4">
|
||||
<el-switch size="small" v-model="isSave" @change="changeSave" />
|
||||
<el-switch size="small" v-model="isSave" @change="changeSave"/>
|
||||
</div>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
|
|
@ -85,7 +87,7 @@
|
|||
</el-collapse-transition>
|
||||
<!-- 主画布 -->
|
||||
<div class="workflow-main" ref="workflowMainRef">
|
||||
<workflow ref="workflowRef" v-if="detail" :data="detail?.work_flow" />
|
||||
<workflow ref="workflowRef" v-if="detail" :data="detail?.work_flow"/>
|
||||
</div>
|
||||
<!-- 调试 -->
|
||||
<el-collapse-transition>
|
||||
|
|
@ -100,9 +102,9 @@
|
|||
:size="32"
|
||||
style="background: none"
|
||||
>
|
||||
<img :src="resetUrl(detail?.icon)" alt="" />
|
||||
<img :src="resetUrl(detail?.icon)" alt=""/>
|
||||
</el-avatar>
|
||||
<LogoIcon v-else height="32px" />
|
||||
<LogoIcon v-else height="32px"/>
|
||||
</div>
|
||||
|
||||
<h4 class="ellipsis" style="max-width: 270px" :title="detail?.name">
|
||||
|
|
@ -120,7 +122,7 @@
|
|||
</el-button>
|
||||
<el-button link @click="showDebug = false">
|
||||
<el-icon :size="20" class="color-secondary">
|
||||
<Close />
|
||||
<Close/>
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
|
|
@ -140,37 +142,39 @@
|
|||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onBeforeMount, onBeforeUnmount, computed, nextTick, provide } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import type { Action } from 'element-plus'
|
||||
import {ref, onBeforeMount, onBeforeUnmount, computed, nextTick, provide} from 'vue'
|
||||
import {useRouter, useRoute} from 'vue-router'
|
||||
import type {Action} from 'element-plus'
|
||||
import Workflow from '@/workflow/index.vue'
|
||||
import DropdownMenu from '@/components/workflow-dropdown-menu/index.vue'
|
||||
import ExecutionRecord from '@/views/knowledge-workflow/component/execution-record/ExecutionRecordDrawer.vue'
|
||||
import ExecutionRecord
|
||||
from '@/views/knowledge-workflow/component/execution-record/ExecutionRecordDrawer.vue'
|
||||
import PublishHistory from '@/views/knowledge-workflow/component/PublishHistory.vue'
|
||||
import { isAppIcon, resetUrl } from '@/utils/common'
|
||||
import { MsgSuccess, MsgError, MsgConfirm } from '@/utils/message'
|
||||
import { datetimeFormat } from '@/utils/time'
|
||||
import { mapToUrlParams } from '@/utils/application'
|
||||
import {isAppIcon, resetUrl} from '@/utils/common'
|
||||
import {MsgSuccess, MsgError, MsgConfirm} from '@/utils/message'
|
||||
import {datetimeFormat} from '@/utils/time'
|
||||
import {mapToUrlParams} from '@/utils/application'
|
||||
import useStore from '@/stores'
|
||||
import { KnowledgeWorkFlowInstance } from '@/workflow/common/validate'
|
||||
import { hasPermission } from '@/utils/permission'
|
||||
import {KnowledgeWorkFlowInstance} from '@/workflow/common/validate'
|
||||
import {hasPermission} from '@/utils/permission'
|
||||
import DebugVue from './component/DebugDrawer.vue'
|
||||
import { t } from '@/locales'
|
||||
import { ComplexPermission, Permission } from '@/utils/permission/type'
|
||||
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||
import {t} from '@/locales'
|
||||
import {ComplexPermission, Permission} from '@/utils/permission/type'
|
||||
import {EditionConst, PermissionConst, RoleConst} from '@/utils/permission/data'
|
||||
import permissionMap from '@/permission'
|
||||
import { WorkflowMode } from '@/enums/application'
|
||||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
||||
import { knowledgeBaseNode } from '@/workflow/common/data'
|
||||
import { de } from 'element-plus/es/locale'
|
||||
import {WorkflowMode} from '@/enums/application'
|
||||
import {loadSharedApi} from '@/utils/dynamics-api/shared-api'
|
||||
import {knowledgeBaseNode} from '@/workflow/common/data'
|
||||
import {de} from 'element-plus/es/locale'
|
||||
|
||||
provide('getResourceDetail', () => detail)
|
||||
provide('workflowMode', WorkflowMode.Knowledge)
|
||||
provide('loopWorkflowMode', WorkflowMode.KnowledgeLoop)
|
||||
const { theme } = useStore()
|
||||
const {theme} = useStore()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const {
|
||||
params: { id, folderId },
|
||||
params: {id, folderId},
|
||||
/*
|
||||
folderId 可以区分 resource-management shared还是 workspace
|
||||
*/
|
||||
|
|
@ -239,9 +243,11 @@ function back() {
|
|||
go()
|
||||
}
|
||||
}
|
||||
|
||||
const openListAction = () => {
|
||||
ListActionRef.value?.open(id)
|
||||
}
|
||||
|
||||
function clickoutsideHistory() {
|
||||
if (!disablePublic.value) {
|
||||
showHistory.value = false
|
||||
|
|
@ -309,6 +315,7 @@ function onmousedown(item: any) {
|
|||
function clickoutside() {
|
||||
showPopover.value = false
|
||||
}
|
||||
|
||||
const publish = () => {
|
||||
workflowRef.value
|
||||
?.validate()
|
||||
|
|
@ -321,10 +328,14 @@ const publish = () => {
|
|||
MsgError(e.toString())
|
||||
return
|
||||
}
|
||||
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
||||
.putKnowledgeWorkflow(id, { work_flow: workflow })
|
||||
loadSharedApi({type: 'knowledge', isShared: isShared.value, systemType: apiType.value})
|
||||
.putKnowledgeWorkflow(id, {work_flow: workflow})
|
||||
.then(() => {
|
||||
return loadSharedApi({ type: 'knowledge', systemType: apiType.value }).publish(
|
||||
return loadSharedApi({
|
||||
type: 'knowledge',
|
||||
isShared: isShared.value,
|
||||
systemType: apiType.value
|
||||
}).publish(
|
||||
id,
|
||||
{},
|
||||
loading,
|
||||
|
|
@ -340,15 +351,15 @@ const publish = () => {
|
|||
if (typeof err_message == 'string') {
|
||||
MsgError(
|
||||
res.node.properties?.stepName +
|
||||
` ${t('workflow.node').toLowerCase()} ` +
|
||||
err_message.toLowerCase(),
|
||||
` ${t('workflow.node').toLowerCase()} ` +
|
||||
err_message.toLowerCase(),
|
||||
)
|
||||
} else {
|
||||
const keys = Object.keys(err_message)
|
||||
MsgError(
|
||||
node.properties?.stepName +
|
||||
` ${t('workflow.node').toLowerCase()} ` +
|
||||
err_message[keys[0]]?.[0]?.message.toLowerCase(),
|
||||
` ${t('workflow.node').toLowerCase()} ` +
|
||||
err_message[keys[0]]?.[0]?.message.toLowerCase(),
|
||||
)
|
||||
}
|
||||
})
|
||||
|
|
@ -362,8 +373,8 @@ const publish = () => {
|
|||
const keys = Object.keys(err_message)
|
||||
MsgError(
|
||||
node.properties?.stepName +
|
||||
` ${t('workflow.node')},` +
|
||||
err_message[keys[0]]?.[0]?.message,
|
||||
` ${t('workflow.node')},` +
|
||||
err_message[keys[0]]?.[0]?.message,
|
||||
)
|
||||
}
|
||||
})
|
||||
|
|
@ -397,18 +408,23 @@ const clickShowDebug = () => {
|
|||
const keys = Object.keys(err_message)
|
||||
MsgError(
|
||||
node.properties?.stepName +
|
||||
` ${t('workflow.node')},` +
|
||||
err_message[keys[0]]?.[0]?.message,
|
||||
` ${t('workflow.node')},` +
|
||||
err_message[keys[0]]?.[0]?.message,
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getGraphData() {
|
||||
return workflowRef.value?.getGraphData()
|
||||
}
|
||||
|
||||
const isShared = computed(() => {
|
||||
return folderId === 'share'
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
||||
loadSharedApi({type: 'knowledge', isShared: isShared.value, systemType: apiType.value})
|
||||
.getKnowledgeDetail(id)
|
||||
.then((res: any) => {
|
||||
detail.value = res.data
|
||||
|
|
@ -417,27 +433,27 @@ function getDetail() {
|
|||
detail.value.tts_type = res.data.tts_type
|
||||
saveTime.value = res.data?.update_time
|
||||
if (!detail.value.work_flow || !('nodes' in detail.value.work_flow)) {
|
||||
detail.value.work_flow = { nodes: [knowledgeBaseNode] }
|
||||
detail.value.work_flow = {nodes: [knowledgeBaseNode]}
|
||||
}
|
||||
detail.value.work_flow?.nodes
|
||||
?.filter((v: any) => v.id === 'knowledge-base-node')
|
||||
.map((v: any) => {
|
||||
apiInputParams.value = v.properties.api_input_field_list
|
||||
? v.properties.api_input_field_list.map((v: any) => {
|
||||
return {
|
||||
name: v.variable,
|
||||
value: v.default_value,
|
||||
}
|
||||
})
|
||||
return {
|
||||
name: v.variable,
|
||||
value: v.default_value,
|
||||
}
|
||||
})
|
||||
: v.properties.input_field_list
|
||||
? v.properties.input_field_list
|
||||
.filter((v: any) => v.assignment_method === 'api_input')
|
||||
.map((v: any) => {
|
||||
return {
|
||||
name: v.variable,
|
||||
value: v.default_value,
|
||||
}
|
||||
})
|
||||
.filter((v: any) => v.assignment_method === 'api_input')
|
||||
.map((v: any) => {
|
||||
return {
|
||||
name: v.variable,
|
||||
value: v.default_value,
|
||||
}
|
||||
})
|
||||
: []
|
||||
})
|
||||
|
||||
|
|
@ -454,7 +470,7 @@ function saveknowledge(bool?: boolean, back?: boolean) {
|
|||
work_flow: getGraphData(),
|
||||
}
|
||||
loading.value = back || false
|
||||
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
||||
loadSharedApi({type: 'knowledge', isShared: isShared.value, systemType: apiType.value})
|
||||
.putKnowledgeWorkflow(id, obj)
|
||||
.then(() => {
|
||||
saveTime.value = new Date()
|
||||
|
|
@ -470,13 +486,14 @@ function saveknowledge(bool?: boolean, back?: boolean) {
|
|||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
const go = () => {
|
||||
if (route.path.includes('resource-management')) {
|
||||
return router.push({ path: get_resource_management_route() })
|
||||
return router.push({path: get_resource_management_route()})
|
||||
} else if (route.path.includes('shared')) {
|
||||
return router.push({ path: get_shared_route() })
|
||||
return router.push({path: get_shared_route()})
|
||||
} else {
|
||||
return router.push({ path: get_route() })
|
||||
return router.push({path: get_route()})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -570,8 +587,10 @@ const toImportDoc = () => {
|
|||
showConfirmButton: false,
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {})
|
||||
.catch(() => {})
|
||||
.then(() => {
|
||||
})
|
||||
.catch(() => {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue