Bladeren bron

update docs

tycoding 1 jaar geleden
bovenliggende
commit
ee30339953
3 gewijzigde bestanden met toevoegingen van 121 en 93 verwijderingen
  1. 12 0
      README.md
  2. 96 29
      langchat-ui/src/views/app/columns.ts
  3. 13 64
      langchat-ui/src/views/app/index.vue

+ 12 - 0
README.md

@@ -54,6 +54,18 @@ Copyright (c) 2024-present, TyCoding.
 
 采用GUN GPL-v3开源协议,可以免费学习使用,个人可以免费是接入使用,商业应用请联系作者授权。
 
+## 版本更新
+
+- 2024.7.15 LangChat正式发布、公开仓库
+- 2024.7.19 LangChat完成分离Server、Client端业务架构,保持业务分离
+- 2024.7.21 LangChat完成多存储方案,支持本地、七牛云、阿里云、腾讯云OSS服务
+- 2024.7.30 LangChat开发Web SDK,接入API、WEB消息渠道,支持Iframe嵌入
+- ...
+
+## Star History
+
+[![Star History Chart](https://api.star-history.com/svg?repos=TyCoding/langchat&type=Date)](https://star-history.com/#TyCoding/langchat&Date)
+
 ## 预览
 
 ![](docs/imgs/MIK-fYD77Q.png)

+ 96 - 29
langchat-ui/src/views/app/columns.ts

@@ -1,4 +1,72 @@
 import { FormSchema } from '@/components/Form';
+import router from '@/router';
+import { h } from 'vue';
+import SvgIcon from '@/components/SvgIcon/index.vue';
+
+export enum ChannelEnum {
+  CHANNEL_API = 'CHANNEL_API',
+  CHANNEL_WEB = 'CHANNEL_WEB',
+  CHANNEL_WEIXIN = 'CHANNEL_WEIXIN',
+  CHANNEL_DING = 'CHANNEL_DING',
+}
+
+export async function onInfo(item: any) {
+  if (item.channel === ChannelEnum.CHANNEL_API) {
+    await router.push('/aigc/app/api/' + item.id);
+  }
+  if (item.channel === ChannelEnum.CHANNEL_WEB) {
+    await router.push('/aigc/app/web/' + item.id);
+  }
+  if (item.channel === ChannelEnum.CHANNEL_WEIXIN) {
+    await router.push('/aigc/app/weixin/' + item.id);
+  }
+  if (item.channel === ChannelEnum.CHANNEL_DING) {
+    await router.push('/aigc/app/ding/' + item.id);
+  }
+}
+
+export function renderTitle(channel: string) {
+  if (channel === ChannelEnum.CHANNEL_API) return 'HTTP API渠道';
+  if (channel === ChannelEnum.CHANNEL_WEB) return 'WEB渠道';
+  if (channel === ChannelEnum.CHANNEL_WEIXIN) return '微信渠道';
+  if (channel === ChannelEnum.CHANNEL_DING) return '钉钉渠道';
+}
+
+export function renderIcon(channel: string) {
+  return {
+    render() {
+      if (channel === ChannelEnum.CHANNEL_API) {
+        return h(SvgIcon, {
+          class: 'text-4xl text-blue-500',
+          icon: 'hugeicons:api',
+        });
+      }
+      if (channel === ChannelEnum.CHANNEL_WEB) {
+        return h(SvgIcon, {
+          class: 'text-4xl text-blue-500',
+          icon: 'mdi:web-sync',
+        });
+      }
+      if (channel === ChannelEnum.CHANNEL_WEIXIN) {
+        return h(SvgIcon, {
+          class: 'text-4xl text-green-400',
+          icon: 'uiw:weixin',
+        });
+      }
+      if (channel === ChannelEnum.CHANNEL_DING) {
+        return h(SvgIcon, {
+          class: 'text-4xl text-green-400',
+          icon: 'uiw:weixin',
+        });
+      }
+    },
+  };
+}
+
+export function getKey(apiKey: string) {
+  const key = apiKey;
+  return key.slice(0, 13) + key.slice(13, -4).replace(/./g, '*') + key.slice(-4);
+}
 
 export const formSchemas: FormSchema[] = [
   {
@@ -17,47 +85,46 @@ export const formSchemas: FormSchema[] = [
       options: [
         {
           label: 'API渠道',
-          value: 'CHANNEL_API',
+          value: ChannelEnum.CHANNEL_API,
         },
         {
           label: 'WEB渠道',
-          value: 'CHANNEL_WEB',
+          value: ChannelEnum.CHANNEL_WEB,
         },
         {
           label: '微信渠道',
-          value: 'CHANNEL_WEIXIN',
-        },
-      ],
-    },
-  },
-  {
-    field: 'type',
-    label: '应用类型',
-    component: 'NSelect',
-    rules: [{ required: true, message: '请选择应用类型', trigger: ['blur'] }],
-    componentProps: {
-      placeholder: '请选择应用类型',
-      options: [
-        {
-          label: '窗口模式',
-          value: 'WEB_WINDOW',
+          value: ChannelEnum.CHANNEL_WEIXIN,
         },
         {
-          label: '浮窗模式',
-          value: 'WEB_FLOAT',
-        },
-        {
-          label: 'API模式',
-          value: 'WEB_API',
+          label: '钉钉渠道',
+          value: ChannelEnum.CHANNEL_DING,
         },
       ],
     },
   },
-  {
-    field: 'link',
-    label: '跳转链接',
-    component: 'NInput',
-  },
+  // {
+  //   field: 'type',
+  //   label: '应用类型',
+  //   component: 'NSelect',
+  //   rules: [{ required: true, message: '请选择应用类型', trigger: ['blur'] }],
+  //   componentProps: {
+  //     placeholder: '请选择应用类型',
+  //     options: [
+  //       {
+  //         label: '窗口模式',
+  //         value: 'WEB_WINDOW',
+  //       },
+  //       {
+  //         label: '浮窗模式',
+  //         value: 'WEB_FLOAT',
+  //       },
+  //       {
+  //         label: 'API模式',
+  //         value: 'WEB_API',
+  //       },
+  //     ],
+  //   },
+  // },
   {
     field: 'des',
     label: '应用描述',

+ 13 - 64
langchat-ui/src/views/app/index.vue

@@ -15,19 +15,18 @@
   -->
 
 <script lang="ts" setup>
-  import { h, onMounted, ref } from 'vue';
+  import { onMounted, ref } from 'vue';
   import Edit from './edit.vue';
   import { del as delApi, list as getApiList } from '@/api/app/appApi';
   import { del as delWeb, list as getWebList } from '@/api/app/appWeb';
   import SvgIcon from '@/components/SvgIcon/index.vue';
-  import router from '@/router';
   import { useDialog, useMessage } from 'naive-ui';
   import { copyToClip } from '@/utils/copy';
+  import { ChannelEnum, getKey, onInfo, renderIcon, renderTitle } from '@/views/app/columns';
 
   const editRef = ref();
   const dialog = useDialog();
   const ms = useMessage();
-  const loading = ref(true);
   const groups = ref<any[]>([]);
 
   onMounted(async () => {
@@ -35,61 +34,14 @@
   });
 
   async function fetchData() {
-    loading.value = true;
-    try {
-      const apiArr = await getApiList({});
-      const webArr = await getWebList({});
-      groups.value = [
-        { key: 'CHANNEL_API', value: apiArr as any[] },
-        { key: 'CHANNEL_WEB', value: webArr as any[] },
-        { key: 'CHANNEL_WEIXIN', value: [] as any[] },
-      ];
-    } finally {
-      loading.value = false;
-    }
-  }
-
-  async function onInfo(item: any) {
-    if (item.channel === 'CHANNEL_API') {
-      await router.push('/aigc/app/api/' + item.id);
-    }
-    if (item.channel === 'CHANNEL_WEB') {
-      await router.push('/aigc/app/web/' + item.id);
-    }
-    if (item.channel === 'CHANNEL_WEIXIN') {
-      await router.push('/aigc/app/weixin/' + item.id);
-    }
-  }
-
-  function renderTitle(channel: string) {
-    if (channel === 'CHANNEL_API') return 'HTTP API渠道';
-    if (channel === 'CHANNEL_WEB') return 'WEB渠道';
-    if (channel === 'CHANNEL_WEIXIN') return '微信渠道';
-  }
-
-  function renderIcon(channel: string) {
-    return {
-      render() {
-        if (channel === 'CHANNEL_API') {
-          return h(SvgIcon, {
-            class: 'text-4xl text-blue-500',
-            icon: 'hugeicons:api',
-          });
-        }
-        if (channel === 'CHANNEL_WEB') {
-          return h(SvgIcon, {
-            class: 'text-4xl text-blue-500',
-            icon: 'mdi:web-sync',
-          });
-        }
-        if (channel === 'CHANNEL_WEIXIN') {
-          return h(SvgIcon, {
-            class: 'text-4xl text-green-400',
-            icon: 'uiw:weixin',
-          });
-        }
-      },
-    };
+    const apiArr = await getApiList({});
+    const webArr = await getWebList({});
+    groups.value = [
+      { key: ChannelEnum.CHANNEL_API, value: apiArr as any[] },
+      { key: ChannelEnum.CHANNEL_WEB, value: webArr as any[] },
+      { key: ChannelEnum.CHANNEL_WEIXIN, value: [] as any[] },
+      { key: ChannelEnum.CHANNEL_DING, value: [] as any[] },
+    ];
   }
 
   function onDelete(channel: string, id: string) {
@@ -113,10 +65,6 @@
     });
   }
 
-  function getKey(apiKey: string) {
-    const key = apiKey;
-    return key.slice(0, 13) + key.slice(13, -4).replace(/./g, '*') + key.slice(-4);
-  }
   async function onCopy(key: string) {
     await copyToClip(key);
     ms.success('Api Key复制成功');
@@ -131,7 +79,7 @@
       </n-card>
     </div>
 
-    <n-spin :show="loading" class="mt-4 w-full mb-10 px-6">
+    <div class="mt-2 w-full mb-10 px-6 !h-auto">
       <div class="flex items-center gap-2 justify-start">
         <n-button dashed type="primary" @click="editRef.show()"> 新增应用 </n-button>
         <n-button tertiary type="primary" @click="fetchData">
@@ -145,6 +93,7 @@
             <component :is="renderIcon(items.key)" />
           </template>
         </n-alert>
+        <n-empty v-if="items.value.length === 0" class="mt-6" description="暂时没有配置" />
         <div class="grid gap-2 sm:grid-cols-3 lg:grid-cols-5">
           <n-card
             v-for="item in items.value"
@@ -204,7 +153,7 @@
           </n-card>
         </div>
       </div>
-    </n-spin>
+    </div>
 
     <Edit ref="editRef" @reload="fetchData" />
   </div>