|
|
@@ -11,7 +11,7 @@
|
|
|
<a-space size="medium">
|
|
|
<div
|
|
|
class="select_btn"
|
|
|
- v-for="category in ['全部', ...categories]"
|
|
|
+ v-for="category in categories"
|
|
|
:key="category"
|
|
|
:class="{ selected: selectedCategory === category }"
|
|
|
@click="selectCategory(category)"
|
|
|
@@ -21,10 +21,10 @@
|
|
|
</a-space>
|
|
|
</div>
|
|
|
<div class="agents-list-container" ref="agentsListContainer">
|
|
|
- <div class="agent-card" v-for="app in recommendedApps" :key="app.app.id">
|
|
|
- <Icon :name="app.category" alt="icon" class="agent-icon" />
|
|
|
+ <div class="agent-card" v-for="app in filter_agent_list" :key="app.id" @click="handleAgentClick(app)">
|
|
|
+ <Icon :name="app.mode" alt="icon" class="agent-icon" />
|
|
|
<div class="agent-info">
|
|
|
- <div class="agent-title">{{ app.app.name }}</div>
|
|
|
+ <div class="agent-title">{{ app.name }}</div>
|
|
|
<div class="agent-subtitle">{{ app.description }}</div>
|
|
|
</div>
|
|
|
<a-button shape="circle" class="arrow-button">
|
|
|
@@ -40,22 +40,52 @@ import { ref, onMounted, nextTick, onUnmounted } from 'vue';
|
|
|
import { fetchApps } from '../../apis/home';
|
|
|
import { Message } from '../../3rd-libs/arco-vue-libs';
|
|
|
import Icon from '../../components/Icon/Icon.vue';
|
|
|
+import { getConfigField } from '../../config'; // 假设 getConfigField 是从某处导入的
|
|
|
|
|
|
const categories = ref([]);
|
|
|
-const recommendedApps = ref([]);
|
|
|
+const agent_list = ref([]);
|
|
|
+const filter_agent_list = ref([]);
|
|
|
const agentsListContainer = ref(null);
|
|
|
const selectedCategory = ref('全部'); // 默认选中“全部”
|
|
|
+const baseurl = getConfigField('API_BASE_URL');
|
|
|
+const access_token = ref(''); // 假设 access_token 是从某处获取的
|
|
|
|
|
|
const loadApps = async () => {
|
|
|
try {
|
|
|
const response = await fetchApps();
|
|
|
- recommendedApps.value = response.recommended_apps || [];
|
|
|
- categories.value = response.categories || [];
|
|
|
+ agent_list.value = response.data || [];
|
|
|
+
|
|
|
+ // 遍历 mode 并去重
|
|
|
+ const modes = new Set(response.data.map((app) => app.mode));
|
|
|
+ const modeMap = {
|
|
|
+ workflow: '工作流',
|
|
|
+ 'advanced-chat': '高级助手',
|
|
|
+ chat: '聊天助手',
|
|
|
+ 'agent-chat': 'Agent'
|
|
|
+ };
|
|
|
+ categories.value = ['全部', ...Array.from(modes).map((mode) => modeMap[mode] || mode)];
|
|
|
+
|
|
|
+ filterApps(); // 加载应用后进行初次筛选
|
|
|
} catch (error) {
|
|
|
Message.error('加载数据失败');
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const filterApps = () => {
|
|
|
+ if (selectedCategory.value === '全部') {
|
|
|
+ filter_agent_list.value = agent_list.value;
|
|
|
+ } else {
|
|
|
+ const modeMap = {
|
|
|
+ 工作流: 'workflow',
|
|
|
+ 高级聊天: 'advanced-chat',
|
|
|
+ 聊天助手: 'chat',
|
|
|
+ Agent: 'agent-chat'
|
|
|
+ };
|
|
|
+ const selectedMode = modeMap[selectedCategory.value] || selectedCategory.value;
|
|
|
+ filter_agent_list.value = agent_list.value.filter((app) => app.mode === selectedMode);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
const adjustContainerHeight = () => {
|
|
|
if (agentsListContainer.value) {
|
|
|
const windowHeight = window.innerHeight;
|
|
|
@@ -80,7 +110,14 @@ const createAgent = () => {
|
|
|
|
|
|
const selectCategory = (category) => {
|
|
|
selectedCategory.value = category;
|
|
|
- console.log('分类:', category);
|
|
|
+ filterApps(); // 选择分类后进行筛选
|
|
|
+};
|
|
|
+
|
|
|
+const handleAgentClick = (app) => {
|
|
|
+ const iframe_id = app.id;
|
|
|
+ const dify_token = access_token.value;
|
|
|
+ const workflowUrl = `${baseurl}/app/${iframe_id}/workflow?token=${dify_token}`;
|
|
|
+ window.open(workflowUrl, '_blank');
|
|
|
};
|
|
|
</script>
|
|
|
|