ソースを参照

删除环境变量配置,优化API请求地址,更新代理卡片数据处理逻辑,新增图标文件,调整分类筛选功能

张涛 1 年間 前
コミット
0c48f70edb

+ 0 - 1
.env

@@ -1 +0,0 @@
-VITE_TARGET_URL=http://smartai.com:8163/

+ 1 - 2
public/config.js

@@ -4,8 +4,7 @@ window.DMX_VERSION = '1.0.1';
  * API请求地址
  * 配置项最后一个字符 无需是 / 即,无需以 / 结束
  */
-window.API_BASE_URL = import.meta.env.VITE_TARGET_URL || 'http://smartai.com:8163';
-
+window.API_BASE_URL = 'http://smartai.com:8163';
 window.featureConfigs = [
   {
     name: '智能问答',

+ 1 - 1
src/apis/home.js

@@ -2,7 +2,7 @@ import request from '../base/ajax';
 
 export const fetchApps = () => {
   return request({
-    url: '/console/api/explore/apps',
+    url: '/console/api/apps',
     method: 'get'
   });
 };

+ 0 - 0
src/assets/image/icons/Programming.png → src/assets/image/icons/advanced-chat.png


+ 0 - 0
src/assets/image/icons/Agent.png → src/assets/image/icons/agent-chat.png


+ 0 - 0
src/assets/image/icons/Assistant.png → src/assets/image/icons/chat.png


+ 45 - 8
src/modules/home/agent_card.vue

@@ -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>
 

+ 2 - 5
vite.config.mjs

@@ -18,9 +18,6 @@ import { config_compression, config_imagemin } from './scripts/vite-conf';
 
 // https://vitejs.dev/config/
 export default defineConfig(({ mode }) => {
-  const env = loadEnv(mode, process.cwd());
-  const targetUrl = env.VITE_TARGET_URL || 'http://smartai.com:8163/';
-
   return {
     /**
      * 项目根目录
@@ -37,7 +34,7 @@ export default defineConfig(({ mode }) => {
       host: '0.0.0.0', // IP配置,支持从IP启动
       proxy: {
         '/console': {
-          target: targetUrl,
+          target: 'http://smartai.com:8163',
           // target: 'http://192.168.20.119:9303',
           changeOrigin: true,
           onProxyReq: (proxyReq, req, res) => {
@@ -49,7 +46,7 @@ export default defineConfig(({ mode }) => {
           rewrite: (path) => path.replace(/^\/proxy_url/, '')
         },
         '/api/': {
-          target: targetUrl,
+          target: 'http://smartai.com:8163',
           // target: 'http://192.168.20.119:9303',
           changeOrigin: true,
           secure: false,