Commit aa907fa3 authored by tyyin lan's avatar tyyin lan

chore: 插件中心操作导航跳转

parent 3dc6fb7e
......@@ -136,6 +136,7 @@ common_module:
copy_link: 'Copy link'
or: 'or'
search_keyword_empty_tip: 'The search content cannot be empty'
added: 'Added'
dialogue_module:
continue_question_message: 'You can keep asking questions'
......
......@@ -135,6 +135,7 @@ common_module:
copy_link: '复制链接'
or: '或'
search_keyword_empty_tip: '搜索内容不能为空'
added: '已添加'
dialogue_module:
continue_question_message: '你可以继续提问'
......
......@@ -135,6 +135,7 @@ common_module:
copy_link: '複製鏈接'
or: '或'
search_keyword_empty_tip: '搜索內容不能為空'
added: '已添加'
dialogue_module:
continue_question_message: '你可以繼續提問'
......
......@@ -41,6 +41,7 @@ export function defaultPersonalAppConfigState(): PersonalAppConfigState {
isCollect: '',
isSale: '',
agentPublishId: 1,
unitIds: [],
}
}
......
......@@ -48,4 +48,5 @@ export interface PersonalAppConfigState {
isSale: string
isCopy?: string
agentPublishId: number
unitIds: string[]
}
<script setup lang="ts">
import { ref, watch } from 'vue'
import { Search } from '@icon-park/vue-next'
import { fetchGetApplicationList } from '@/apis/agent-application'
import {
fetchGetApplicationList,
fetchGetDebugApplicationInfo,
fetchSaveAgentApplication,
} from '@/apis/agent-application'
import { useI18n } from 'vue-i18n'
import type { PersonalAppConfigState } from '@/store/types/personal-app-config'
import { useRouter } from 'vue-router'
interface Props {
currentSelectPluginId: string
}
interface ApplicationInfoInterface {
agentId: string
......@@ -13,25 +23,24 @@ interface ApplicationInfoInterface {
interface ApplicationItemInfoInterface {
baseInfo: ApplicationInfoInterface
unitIds: string[]
}
defineProps<Props>()
const showModal = defineModel<boolean>('showModal', { default: false })
const { t } = useI18n()
const router = useRouter()
const searchKeyword = ref('')
const applicationList = ref<ApplicationInfoInterface[]>([])
const getApplicationListLoading = ref(true)
const currentApplicationPluginOperationLoading = ref('')
watch(showModal, (newVal) => {
newVal && getApplicationList()
})
/* created */
;(function () {
getApplicationList()
})()
function getApplicationList() {
getApplicationListLoading.value = true
......@@ -46,6 +55,7 @@ function getApplicationList() {
agentTitle: itemInfo.baseInfo.agentTitle,
agentAvatar: itemInfo.baseInfo.agentAvatar,
agentDesc: itemInfo.baseInfo.agentDesc,
unitIds: itemInfo.unitIds || [],
}
})
......@@ -73,12 +83,39 @@ function handleSearchAppKeywordClear() {
}
function handleAppAddPlugin(agentId: string) {
console.log('🐽🐽🐽🐽🐽🐽插件使用🐽🐽🐽🐽🐽🐽')
console.log(agentId)
currentApplicationPluginOperationLoading.value = agentId
fetchGetDebugApplicationInfo<PersonalAppConfigState>(agentId)
.then((res) => {
if (res.code !== 0) return ''
const payload = { ...res.data, unitIds: [...(res.data.unitIds || []), agentId] }
fetchSaveAgentApplication(payload)
.then((SaveRes) => {
if (SaveRes.code !== 0) return ''
getApplicationList()
window.$message.success(t('common_module.successful_update'))
router.push({ name: 'PersonalAppSetting', params: { agentId } })
})
.finally(() => {
currentApplicationPluginOperationLoading.value = ''
})
})
.catch(() => {
currentApplicationPluginOperationLoading.value = ''
})
}
function handleCreateNewApplication() {
console.log('💥💥💥💥💥💥创建新应用💥💥💥💥💥💥')
router.push({ name: 'PersonalAppSetting' })
}
function handleNavigateToAppSetting(agentId: string) {
router.push({ name: 'PersonalAppSetting', params: { agentId } })
}
</script>
......@@ -116,7 +153,8 @@ function handleCreateNewApplication() {
<template #default="{ item }">
<div
:key="item.agentId"
class="mb-[18px] box-border flex h-[88px] items-center rounded-[10px] border-[1px] border-solid border-[#ccc] px-[21px]"
class="hover:!border-theme-color mb-[18px] box-border flex h-[88px] cursor-pointer select-none items-center rounded-[10px] border-[1px] border-solid border-[#ccc] px-[21px] transition"
@click="handleNavigateToAppSetting(item.agentId)"
>
<img class="h-[46px] w-[46px] rounded-[6px] object-cover" :src="item.agentAvatar" alt="app-cover" />
......@@ -133,7 +171,14 @@ function handleCreateNewApplication() {
</div>
</div>
<n-button type="primary" @click="handleAppAddPlugin(item.agentId)">{{ t('common_module.add') }}</n-button>
<n-button
type="primary"
:loading="currentApplicationPluginOperationLoading === item.agentId"
:disabled="item.unitIds.includes(currentSelectPluginId)"
@click.stop="handleAppAddPlugin(item.agentId)"
>
{{ t('common_module.add') }}
</n-button>
</div>
</template>
</n-virtual-list>
......
......@@ -176,6 +176,9 @@ function handlePluginUse(pluginId: string) {
<n-spin size="large" />
</section>
<ApplicationSelectionModal v-model:show-modal="isShowApplicationSelectionModal" />
<ApplicationSelectionModal
v-model:show-modal="isShowApplicationSelectionModal"
:current-select-plugin-id="currentSelectPluginId"
/>
</div>
</template>
......@@ -135,6 +135,7 @@ declare namespace I18n {
copy_link: string
or: string
search_keyword_empty_tip: string
added: string
dialogue_module: {
continue_question_message: string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment