Commit aa907fa3 authored by tyyin lan's avatar tyyin lan

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

parent 3dc6fb7e
...@@ -136,6 +136,7 @@ common_module: ...@@ -136,6 +136,7 @@ common_module:
copy_link: 'Copy link' copy_link: 'Copy link'
or: 'or' or: 'or'
search_keyword_empty_tip: 'The search content cannot be empty' search_keyword_empty_tip: 'The search content cannot be empty'
added: 'Added'
dialogue_module: dialogue_module:
continue_question_message: 'You can keep asking questions' continue_question_message: 'You can keep asking questions'
......
...@@ -135,6 +135,7 @@ common_module: ...@@ -135,6 +135,7 @@ common_module:
copy_link: '复制链接' copy_link: '复制链接'
or: '或' or: '或'
search_keyword_empty_tip: '搜索内容不能为空' search_keyword_empty_tip: '搜索内容不能为空'
added: '已添加'
dialogue_module: dialogue_module:
continue_question_message: '你可以继续提问' continue_question_message: '你可以继续提问'
......
...@@ -135,6 +135,7 @@ common_module: ...@@ -135,6 +135,7 @@ common_module:
copy_link: '複製鏈接' copy_link: '複製鏈接'
or: '或' or: '或'
search_keyword_empty_tip: '搜索內容不能為空' search_keyword_empty_tip: '搜索內容不能為空'
added: '已添加'
dialogue_module: dialogue_module:
continue_question_message: '你可以繼續提問' continue_question_message: '你可以繼續提問'
......
...@@ -41,6 +41,7 @@ export function defaultPersonalAppConfigState(): PersonalAppConfigState { ...@@ -41,6 +41,7 @@ export function defaultPersonalAppConfigState(): PersonalAppConfigState {
isCollect: '', isCollect: '',
isSale: '', isSale: '',
agentPublishId: 1, agentPublishId: 1,
unitIds: [],
} }
} }
......
...@@ -48,4 +48,5 @@ export interface PersonalAppConfigState { ...@@ -48,4 +48,5 @@ export interface PersonalAppConfigState {
isSale: string isSale: string
isCopy?: string isCopy?: string
agentPublishId: number agentPublishId: number
unitIds: string[]
} }
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { Search } from '@icon-park/vue-next' 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 { useI18n } from 'vue-i18n'
import type { PersonalAppConfigState } from '@/store/types/personal-app-config'
import { useRouter } from 'vue-router'
interface Props {
currentSelectPluginId: string
}
interface ApplicationInfoInterface { interface ApplicationInfoInterface {
agentId: string agentId: string
...@@ -13,25 +23,24 @@ interface ApplicationInfoInterface { ...@@ -13,25 +23,24 @@ interface ApplicationInfoInterface {
interface ApplicationItemInfoInterface { interface ApplicationItemInfoInterface {
baseInfo: ApplicationInfoInterface baseInfo: ApplicationInfoInterface
unitIds: string[]
} }
defineProps<Props>()
const showModal = defineModel<boolean>('showModal', { default: false }) const showModal = defineModel<boolean>('showModal', { default: false })
const { t } = useI18n() const { t } = useI18n()
const router = useRouter()
const searchKeyword = ref('') const searchKeyword = ref('')
const applicationList = ref<ApplicationInfoInterface[]>([]) const applicationList = ref<ApplicationInfoInterface[]>([])
const getApplicationListLoading = ref(true) const getApplicationListLoading = ref(true)
const currentApplicationPluginOperationLoading = ref('')
watch(showModal, (newVal) => { watch(showModal, (newVal) => {
newVal && getApplicationList() newVal && getApplicationList()
}) })
/* created */
;(function () {
getApplicationList()
})()
function getApplicationList() { function getApplicationList() {
getApplicationListLoading.value = true getApplicationListLoading.value = true
...@@ -46,6 +55,7 @@ function getApplicationList() { ...@@ -46,6 +55,7 @@ function getApplicationList() {
agentTitle: itemInfo.baseInfo.agentTitle, agentTitle: itemInfo.baseInfo.agentTitle,
agentAvatar: itemInfo.baseInfo.agentAvatar, agentAvatar: itemInfo.baseInfo.agentAvatar,
agentDesc: itemInfo.baseInfo.agentDesc, agentDesc: itemInfo.baseInfo.agentDesc,
unitIds: itemInfo.unitIds || [],
} }
}) })
...@@ -73,12 +83,39 @@ function handleSearchAppKeywordClear() { ...@@ -73,12 +83,39 @@ function handleSearchAppKeywordClear() {
} }
function handleAppAddPlugin(agentId: string) { function handleAppAddPlugin(agentId: string) {
console.log('🐽🐽🐽🐽🐽🐽插件使用🐽🐽🐽🐽🐽🐽') currentApplicationPluginOperationLoading.value = agentId
console.log(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() { function handleCreateNewApplication() {
console.log('💥💥💥💥💥💥创建新应用💥💥💥💥💥💥') router.push({ name: 'PersonalAppSetting' })
}
function handleNavigateToAppSetting(agentId: string) {
router.push({ name: 'PersonalAppSetting', params: { agentId } })
} }
</script> </script>
...@@ -116,7 +153,8 @@ function handleCreateNewApplication() { ...@@ -116,7 +153,8 @@ function handleCreateNewApplication() {
<template #default="{ item }"> <template #default="{ item }">
<div <div
:key="item.agentId" :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" /> <img class="h-[46px] w-[46px] rounded-[6px] object-cover" :src="item.agentAvatar" alt="app-cover" />
...@@ -133,7 +171,14 @@ function handleCreateNewApplication() { ...@@ -133,7 +171,14 @@ function handleCreateNewApplication() {
</div> </div>
</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> </div>
</template> </template>
</n-virtual-list> </n-virtual-list>
......
...@@ -176,6 +176,9 @@ function handlePluginUse(pluginId: string) { ...@@ -176,6 +176,9 @@ function handlePluginUse(pluginId: string) {
<n-spin size="large" /> <n-spin size="large" />
</section> </section>
<ApplicationSelectionModal v-model:show-modal="isShowApplicationSelectionModal" /> <ApplicationSelectionModal
v-model:show-modal="isShowApplicationSelectionModal"
:current-select-plugin-id="currentSelectPluginId"
/>
</div> </div>
</template> </template>
...@@ -135,6 +135,7 @@ declare namespace I18n { ...@@ -135,6 +135,7 @@ declare namespace I18n {
copy_link: string copy_link: string
or: string or: string
search_keyword_empty_tip: string search_keyword_empty_tip: string
added: string
dialogue_module: { dialogue_module: {
continue_question_message: string 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