From 411a9058cac1f79a71dbc0b7eaa7cdacabfdc3f8 Mon Sep 17 00:00:00 2001 From: Gsh <15170702455@163.com> Date: Sun, 28 Dec 2025 22:42:17 +0800 Subject: [PATCH 1/9] =?UTF-8?q?fix:=20=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=9E=B6=E6=9E=84=E9=87=8D=E6=9E=84=E5=88=9D=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yi.Ai.Vue3/.claude/settings.local.json | 3 +- .../components/ActivationCode.vue | 54 +- .../components/UsageStatistics.vue | 1 + .../components/UserManagement.vue | 39 +- Yi.Ai.Vue3/src/config/design.ts | 14 +- Yi.Ai.Vue3/src/hooks/useResponsive.ts | 72 ++ .../src/hooks/useWindowWidthObserver.ts | 5 +- .../src/layouts/LayoutDefault/index.vue | 35 + Yi.Ai.Vue3/src/layouts/LayoutMobile/index.vue | 288 +++++- .../src/layouts/LayoutVertical/index.vue | 56 +- .../src/layouts/components/Aside/index.vue | 392 -------- .../layouts/components/ChatAside/index.vue | 918 ++++++++++++++++++ .../components/Header/components/Avatar.vue | 72 +- .../Header/components/StartChatBtn.vue | 84 ++ .../components/Header/components/ThemeBtn.vue | 95 ++ .../src/layouts/components/Header/index.vue | 583 +++++++++-- .../src/layouts/components0/Aside/index.vue | 725 ++++++++++++++ .../components0/DesignConfig/index.vue | 8 + .../Header/components/AiTutorialBtn.vue | 88 ++ .../Header/components/AnnouncementBtn.vue | 112 +++ .../components0/Header/components/Avatar.vue | 499 ++++++++++ .../components0/Header/components/BuyBtn.vue | 68 ++ .../Header/components/Collapse.vue | 39 + .../Header/components/ConsoleBtn.vue | 91 ++ .../Header/components/CreateChat.vue | 45 + .../Header/components/LoginBtn.vue | 29 + .../Header/components/ModelLibraryBtn.vue | 88 ++ .../Header/components/StartChatBtn.vue | 84 ++ .../Header/components/ThemeBtn.vue | 95 ++ .../Header/components/TitleEditing.vue | 87 ++ .../Header/components/TutorialBtn.vue | 75 ++ .../src/layouts/components0/Header/index.vue | 122 +++ .../src/layouts/components0/Logo/index.vue | 8 + .../src/layouts/components0/Main/index.vue | 89 ++ Yi.Ai.Vue3/src/layouts/index.vue | 28 +- .../chat/components/ConversationList.vue | 226 +++++ .../src/pages/chat/conversation/index.vue | 44 + Yi.Ai.Vue3/src/pages/chat/image/index.vue | 26 + Yi.Ai.Vue3/src/pages/chat/index.vue | 305 +++++- .../pages/chat/layouts/chatDefaul/index.vue | 330 ++++--- .../pages/chat/layouts/chatWithId/index.vue | 4 +- Yi.Ai.Vue3/src/pages/chat/video/index.vue | 26 + Yi.Ai.Vue3/src/pages/console/index.vue | 313 ++++++ Yi.Ai.Vue3/src/pages/modelLibrary/index.vue | 51 +- Yi.Ai.Vue3/src/routers/index.ts | 34 +- .../src/routers/modules/staticRouter.ts | 183 +++- Yi.Ai.Vue3/src/stores/modules/design.ts | 56 +- Yi.Ai.Vue3/src/stores/modules/session.ts | 6 +- Yi.Ai.Vue3/src/stores/modules/user.ts | 2 +- Yi.Ai.Vue3/src/styles/index.scss | 2 +- Yi.Ai.Vue3/src/styles/var.scss | 238 ++++- Yi.Ai.Vue3/src/styles/yixin-markdown.scss | 3 +- Yi.Ai.Vue3/types/components.d.ts | 3 +- 53 files changed, 6098 insertions(+), 845 deletions(-) create mode 100644 Yi.Ai.Vue3/src/hooks/useResponsive.ts create mode 100644 Yi.Ai.Vue3/src/layouts/LayoutDefault/index.vue delete mode 100644 Yi.Ai.Vue3/src/layouts/components/Aside/index.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components/ChatAside/index.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components/Header/components/StartChatBtn.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components/Header/components/ThemeBtn.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Aside/index.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/DesignConfig/index.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/AiTutorialBtn.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/AnnouncementBtn.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/Avatar.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/BuyBtn.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/Collapse.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/ConsoleBtn.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/CreateChat.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/LoginBtn.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/ModelLibraryBtn.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/StartChatBtn.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/ThemeBtn.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/TitleEditing.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/components/TutorialBtn.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Header/index.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Logo/index.vue create mode 100644 Yi.Ai.Vue3/src/layouts/components0/Main/index.vue create mode 100644 Yi.Ai.Vue3/src/pages/chat/components/ConversationList.vue create mode 100644 Yi.Ai.Vue3/src/pages/chat/conversation/index.vue create mode 100644 Yi.Ai.Vue3/src/pages/chat/image/index.vue create mode 100644 Yi.Ai.Vue3/src/pages/chat/video/index.vue create mode 100644 Yi.Ai.Vue3/src/pages/console/index.vue diff --git a/Yi.Ai.Vue3/.claude/settings.local.json b/Yi.Ai.Vue3/.claude/settings.local.json index 131db92e..13e6d318 100644 --- a/Yi.Ai.Vue3/.claude/settings.local.json +++ b/Yi.Ai.Vue3/.claude/settings.local.json @@ -2,7 +2,8 @@ "permissions": { "allow": [ "Bash(npx vue-tsc --noEmit)", - "Bash(timeout 60 npx vue-tsc:*)" + "Bash(timeout 60 npx vue-tsc:*)", + "Bash(npm run dev:*)" ], "deny": [], "ask": [] diff --git a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/ActivationCode.vue b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/ActivationCode.vue index 88541897..48c2766d 100644 --- a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/ActivationCode.vue +++ b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/ActivationCode.vue @@ -31,33 +31,33 @@ class Particle { this.x = x; this.y = y; this.hue = hue; - + // Explosive physics const angle = Math.random() * Math.PI * 2; - const speed = Math.random() * 15 + 2; + const speed = Math.random() * 15 + 2; this.vx = Math.cos(angle) * speed; this.vy = Math.sin(angle) * speed; - + this.alpha = 1; this.decay = Math.random() * 0.015 + 0.005; this.gravity = 0.05; - this.friction = 0.96; - + this.friction = 0.96; + this.size = Math.random() * 3 + 1; this.brightness = 50; // Standard brightness for white bg visibility (0-100% HSL L value) - this.flicker = Math.random() > 0.5; + this.flicker = Math.random() > 0.5; } update() { this.vx *= this.friction; this.vy *= this.friction; this.vy += this.gravity; - + this.x += this.vx; this.y += this.vy; - + this.alpha -= this.decay; - this.hue += 0.5; + this.hue += 0.5; } draw(ctx: CanvasRenderingContext2D) { @@ -65,9 +65,9 @@ class Particle { // On white background: // We want high saturation (100%) and medium lightness (50%) to make colors pop against white. // If lightness is too high (like 80-100), it fades into white. - const lightness = this.flicker ? Math.random() * 20 + 40 : this.brightness; + const lightness = this.flicker ? Math.random() * 20 + 40 : this.brightness; ctx.fillStyle = `hsla(${this.hue}, 100%, ${lightness}%, ${this.alpha})`; - + ctx.beginPath(); ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2); ctx.fill(); @@ -93,7 +93,7 @@ class Shockwave { } update() { - this.radius += 15; + this.radius += 15; this.alpha -= 0.05; this.lineWidth -= 0.2; } @@ -132,10 +132,10 @@ function animate() { if (!ctx) return; // Clear with transparent fade for trails on white - // 'destination-out' erases content. + // 'destination-out' erases content. // To leave a trail on a white background (canvas is transparent over white gradient): // We need to gently erase what's there. - + ctx.globalCompositeOperation = 'destination-out'; ctx.fillStyle = 'rgba(255, 255, 255, 0.1)'; // Alpha controls trail length ctx.fillRect(0, 0, canvas.width, canvas.height); @@ -177,14 +177,14 @@ function triggerCelebration() { canvas.width = parent.clientWidth; canvas.height = parent.clientHeight; } - + const cx = canvas.width / 2; const cy = canvas.height / 2; // 1. Initial Mega Explosion triggerShake(); createExplosion(cx, cy, Math.random() * 360); - + // Start loop animate(); @@ -194,15 +194,15 @@ function triggerCelebration() { count++; const rx = cx + (Math.random() - 0.5) * canvas.width * 0.8; const ry = cy + (Math.random() - 0.5) * canvas.height * 0.8; - + createExplosion(rx, ry, Math.random() * 360); - - if (count % 3 === 0) triggerShake(); + + if (count % 3 === 0) triggerShake(); if (count > 25) { clearInterval(timer); } - }, 120); + }, 120); } async function handleRedeem() { @@ -221,7 +221,7 @@ async function handleRedeem() { duration: 3000, showClose: true, }); - activationCode.value = ''; + activationCode.value = ''; } catch (error: any) { // console.error(error); } finally { @@ -238,13 +238,13 @@ onUnmounted(() => {
- +
🎁
- +

激活码兑换

开启您的专属惊喜权益

@@ -258,9 +258,9 @@ onUnmounted(() => { clearable @keyup.enter="handleRedeem" /> - - @@ -321,7 +321,7 @@ onUnmounted(() => { .content-wrapper { position: relative; - z-index: 11; + z-index: 11; width: 100%; max-width: 480px; padding: 40px; diff --git a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/UsageStatistics.vue b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/UsageStatistics.vue index 8be7425f..e0baea70 100644 --- a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/UsageStatistics.vue +++ b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/UsageStatistics.vue @@ -549,6 +549,7 @@ onBeforeUnmount(() => { @@ -180,7 +187,9 @@ function bindWechat() { 昵称
-
{{ userNick }}
+
+ {{ userNick }} +
@@ -215,7 +224,9 @@ function bindWechat() {
- + + + 微信绑定
diff --git a/Yi.Ai.Vue3/src/config/design.ts b/Yi.Ai.Vue3/src/config/design.ts index 44995efd..6d597f54 100644 --- a/Yi.Ai.Vue3/src/config/design.ts +++ b/Yi.Ai.Vue3/src/config/design.ts @@ -1,4 +1,4 @@ -export type LayoutType = | 'vertical' | 'blankPage'; +export type LayoutType = 'default' | 'vertical' | 'blankPage' | 'blankPage'; // 仿豆包折叠逻辑 export type CollapseType @@ -25,7 +25,7 @@ export interface DesignConfigState { // 是否折叠菜单 isCollapse: boolean; // 安全区是否被悬停 - isSafeAreaHover: boolean; + isCollapseConversationList: boolean; // 跟踪是否首次激活悬停 hasActivatedHover: boolean; } @@ -65,15 +65,13 @@ const design: DesignConfigState = { // 需要自定义路由动画可以把 Main 组件样式代码注释放开,从新对话切换到带id的路由时,会执行这个动画样式 pageAnimateType: 'zoom-fade', // 布局模式 (纵向:vertical | ... | 自己定义) - layout: 'vertical', + layout: 'default', // 折叠类型 collapseType: 'followSystem', - // 是否折叠菜单 + // 是否折叠对话记录菜单 isCollapse: false, - // 安全区是否被悬停 - isSafeAreaHover: false, - // 跟踪是否首次激活悬停 - hasActivatedHover: false, + // 是否折叠对话记录菜单 + isCollapseConversationList: false, }; export default design; diff --git a/Yi.Ai.Vue3/src/hooks/useResponsive.ts b/Yi.Ai.Vue3/src/hooks/useResponsive.ts new file mode 100644 index 00000000..2c57ef32 --- /dev/null +++ b/Yi.Ai.Vue3/src/hooks/useResponsive.ts @@ -0,0 +1,72 @@ +import { useBreakpoints, useWindowSize } from '@vueuse/core'; +import { computed } from 'vue'; + +// 断点定义 +export const breakpoints = { + xs: 0, // 手机竖屏 < 640px + sm: 640, // 手机横屏 ≥ 640px + md: 768, // 平板 ≥ 768px + lg: 1024, // 小桌面 ≥ 1024px + xl: 1280, // 桌面 ≥ 1280px + xxl: 1536, // 大桌面 ≥ 1536px +}; + +export function useResponsive() { + const bp = useBreakpoints(breakpoints); + + // 设备类型判断 + const isMobile = bp.smaller('md'); // < 768px + const isTablet = bp.between('md', 'lg'); // 768px - 1024px + const isDesktop = bp.greaterOrEqual('lg'); // ≥ 1024px + + // 精确断点 + const isXs = bp.smaller('sm'); // < 640px + const isSm = bp.between('sm', 'md'); // 640px - 768px + const isMd = bp.between('md', 'lg'); // 768px - 1024px + const isLg = bp.between('lg', 'xl'); // 1024px - 1280px + const isXl = bp.between('xl', 'xxl'); // 1280px - 1536px + const isXxl = bp.greater('xxl'); // > 1536px + + // 监听窗口变化 + const { width, height } = useWindowSize(); + + // 方向检测 + const isPortrait = computed(() => height.value > width.value); + const isLandscape = computed(() => width.value > height.value); + + // 当前断点名称 + const currentBreakpoint = computed(() => { + if (isXs.value) return 'xs'; + if (isSm.value) return 'sm'; + if (isMd.value) return 'md'; + if (isLg.value) return 'lg'; + if (isXl.value) return 'xl'; + return 'xxl'; + }); + + return { + // 设备类型 + isMobile, + isTablet, + isDesktop, + + // 精确断点 + isXs, + isSm, + isMd, + isLg, + isXl, + isXxl, + + // 尺寸 + width, + height, + + // 方向 + isPortrait, + isLandscape, + + // 当前断点名称 + currentBreakpoint, + }; +} diff --git a/Yi.Ai.Vue3/src/hooks/useWindowWidthObserver.ts b/Yi.Ai.Vue3/src/hooks/useWindowWidthObserver.ts index a5c4bc52..5adf34b3 100644 --- a/Yi.Ai.Vue3/src/hooks/useWindowWidthObserver.ts +++ b/Yi.Ai.Vue3/src/hooks/useWindowWidthObserver.ts @@ -19,8 +19,9 @@ export function useWindowWidthObserver( const isAboveThreshold = ref(false); const thresholdRef = ref(threshold); let prevIsAbove = false; // 记录上一次状态,避免重复触发 - + // 待定 待梳理 1227 // 默认逻辑:修改全局折叠状态 + // eslint-disable-next-line unused-imports/no-unused-vars const updateCollapseState = (isAbove: boolean) => { // 判断当前的折叠状态 switch (designStore.collapseType) { @@ -70,7 +71,7 @@ export function useWindowWidthObserver( onChange(newIsAbove); } else { - updateCollapseState(newIsAbove); + // updateCollapseState(newIsAbove); } } }; diff --git a/Yi.Ai.Vue3/src/layouts/LayoutDefault/index.vue b/Yi.Ai.Vue3/src/layouts/LayoutDefault/index.vue new file mode 100644 index 00000000..cb358436 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/LayoutDefault/index.vue @@ -0,0 +1,35 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/LayoutMobile/index.vue b/Yi.Ai.Vue3/src/layouts/LayoutMobile/index.vue index 29fc25ab..60d7f8dd 100644 --- a/Yi.Ai.Vue3/src/layouts/LayoutMobile/index.vue +++ b/Yi.Ai.Vue3/src/layouts/LayoutMobile/index.vue @@ -1,8 +1,288 @@ - - + + - + diff --git a/Yi.Ai.Vue3/src/layouts/LayoutVertical/index.vue b/Yi.Ai.Vue3/src/layouts/LayoutVertical/index.vue index 32264f60..5d752ac4 100644 --- a/Yi.Ai.Vue3/src/layouts/LayoutVertical/index.vue +++ b/Yi.Ai.Vue3/src/layouts/LayoutVertical/index.vue @@ -2,8 +2,6 @@ - - - - diff --git a/Yi.Ai.Vue3/src/layouts/components/ChatAside/index.vue b/Yi.Ai.Vue3/src/layouts/components/ChatAside/index.vue new file mode 100644 index 00000000..c0e8710d --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components/ChatAside/index.vue @@ -0,0 +1,918 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue b/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue index 26675ad5..0b98e38e 100644 --- a/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue +++ b/Yi.Ai.Vue3/src/layouts/components/Header/components/Avatar.vue @@ -30,40 +30,40 @@ const popoverRef = ref(); // 弹出面板内容 const popoverList = ref([ - { - key: '5', - title: '控制台', - icon: 'settings-4-fill', - }, - { - key: '3', - divider: true, - }, - { - key: '7', - title: '公告', - icon: 'notification-fill', - }, - { - key: '8', - title: '模型库', - icon: 'apps-fill', - }, - { - key: '9', - title: '文档', - icon: 'book-fill', - }, - - { - key: '6', - title: '新手引导', - icon: 'dashboard-fill', - }, - { - key: '3', - divider: true, - }, + // { + // key: '5', + // title: '控制台', + // icon: 'settings-4-fill', + // }, + // { + // key: '3', + // divider: true, + // }, + // { + // key: '7', + // title: '公告', + // icon: 'notification-fill', + // }, + // { + // key: '8', + // title: '模型库', + // icon: 'apps-fill', + // }, + // { + // key: '9', + // title: '文档', + // icon: 'book-fill', + // }, + // + // { + // key: '6', + // title: '新手引导', + // icon: 'dashboard-fill', + // }, + // { + // key: '3', + // divider: true, + // }, { key: '4', title: '退出登录', @@ -130,7 +130,9 @@ function handleClick(item: any) { ElMessage.warning('暂未开放'); break; case '5': - openDialog(); + // 打开控制台 + popoverRef.value?.hide?.(); + router.push('/console'); break; case '6': handleStartTutorial(); diff --git a/Yi.Ai.Vue3/src/layouts/components/Header/components/StartChatBtn.vue b/Yi.Ai.Vue3/src/layouts/components/Header/components/StartChatBtn.vue new file mode 100644 index 00000000..970e1509 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components/Header/components/StartChatBtn.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components/Header/components/ThemeBtn.vue b/Yi.Ai.Vue3/src/layouts/components/Header/components/ThemeBtn.vue new file mode 100644 index 00000000..975fd521 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components/Header/components/ThemeBtn.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components/Header/index.vue b/Yi.Ai.Vue3/src/layouts/components/Header/index.vue index aaacdec3..1db0ae27 100644 --- a/Yi.Ai.Vue3/src/layouts/components/Header/index.vue +++ b/Yi.Ai.Vue3/src/layouts/components/Header/index.vue @@ -1,94 +1,50 @@ - + -
- - -
-
- - -
- -
-
+
+ <!– 左侧logo和品牌区域 –> +
+
+ + 意心AI
+
- -
- - - - - - - -
+ <!– 右侧功能按钮区域 –> +
+ + + + + + + + +
@@ -98,20 +54,483 @@ function handleOpenConsole() { .header-container { display: flex; flex-shrink: 0; - flex-direction: column; width: 100%; - height: fit-content; + height: var(--header-container-default-height, 60px); + .header-box { + display: flex; + align-items: center; + justify-content: space-between; width: 100%; - width: calc( - 100% - var(--sidebar-left-container-default-width, 0px) - var( - --sidebar-right-container-default-width, - 0px - ) - ); - height: var(--header-container-default-heigth); - margin: 0 var(--sidebar-right-container-default-width, 0) 0 - var(--sidebar-left-container-default-width, 0); + height: 100%; + padding: 0 16px; + background: var(--header-bg-color, #ffffff); + box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); + } + + // 左侧品牌区域 + .left-section { + display: flex; + align-items: center; + min-width: fit-content; + flex-shrink: 0; + + .brand-container { + display: flex; + align-items: center; + gap: 8px; + + .logo-img { + width: 36px; // 优化为更合适的大小 + height: 36px; + flex-shrink: 0; + transition: transform 0.2s ease; + + &:hover { + transform: scale(1.05); + } + } + + .brand-text { + font-size: 22px; // 减小字体大小 + font-weight: bold; + color: var(--brand-color, #000000); + white-space: nowrap; + letter-spacing: -0.5px; + transition: color 0.2s ease; + + &:hover { + //color: var(--brand-hover-color, #40a9ff); + } + } + } + } + + // 右侧功能区域 + .right-section { + display: flex; + align-items: center; + gap: 12px; // 优化按钮间距 + height: 100%; + flex-shrink: 0; + + // 统一按钮样式 + :deep(.menu-button) { + height: 36px; + display: flex; + align-items: center; + justify-content: center; + } + } +} + +--> + + + + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Aside/index.vue b/Yi.Ai.Vue3/src/layouts/components0/Aside/index.vue new file mode 100644 index 00000000..be93e273 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Aside/index.vue @@ -0,0 +1,725 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/DesignConfig/index.vue b/Yi.Ai.Vue3/src/layouts/components0/DesignConfig/index.vue new file mode 100644 index 00000000..f3409aa6 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/DesignConfig/index.vue @@ -0,0 +1,8 @@ + + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/AiTutorialBtn.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/AiTutorialBtn.vue new file mode 100644 index 00000000..bd7f2647 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/AiTutorialBtn.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/AnnouncementBtn.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/AnnouncementBtn.vue new file mode 100644 index 00000000..a6c6adda --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/AnnouncementBtn.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/Avatar.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/Avatar.vue new file mode 100644 index 00000000..7f1ed3c1 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/Avatar.vue @@ -0,0 +1,499 @@ + + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/BuyBtn.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/BuyBtn.vue new file mode 100644 index 00000000..9e5b512a --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/BuyBtn.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/Collapse.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/Collapse.vue new file mode 100644 index 00000000..9868df5d --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/Collapse.vue @@ -0,0 +1,39 @@ + + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/ConsoleBtn.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/ConsoleBtn.vue new file mode 100644 index 00000000..3091d22e --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/ConsoleBtn.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/CreateChat.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/CreateChat.vue new file mode 100644 index 00000000..5ec82222 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/CreateChat.vue @@ -0,0 +1,45 @@ + + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/LoginBtn.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/LoginBtn.vue new file mode 100644 index 00000000..64b43c4c --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/LoginBtn.vue @@ -0,0 +1,29 @@ + + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/ModelLibraryBtn.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/ModelLibraryBtn.vue new file mode 100644 index 00000000..73347ac9 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/ModelLibraryBtn.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/StartChatBtn.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/StartChatBtn.vue new file mode 100644 index 00000000..970e1509 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/StartChatBtn.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/ThemeBtn.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/ThemeBtn.vue new file mode 100644 index 00000000..975fd521 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/ThemeBtn.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/TitleEditing.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/TitleEditing.vue new file mode 100644 index 00000000..767e2d53 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/TitleEditing.vue @@ -0,0 +1,87 @@ + + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/TutorialBtn.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/TutorialBtn.vue new file mode 100644 index 00000000..524ae1cd --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/TutorialBtn.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/index.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/index.vue new file mode 100644 index 00000000..d8dc7806 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/index.vue @@ -0,0 +1,122 @@ + + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Logo/index.vue b/Yi.Ai.Vue3/src/layouts/components0/Logo/index.vue new file mode 100644 index 00000000..a84746fd --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Logo/index.vue @@ -0,0 +1,8 @@ + + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components0/Main/index.vue b/Yi.Ai.Vue3/src/layouts/components0/Main/index.vue new file mode 100644 index 00000000..59622a62 --- /dev/null +++ b/Yi.Ai.Vue3/src/layouts/components0/Main/index.vue @@ -0,0 +1,89 @@ + + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/index.vue b/Yi.Ai.Vue3/src/layouts/index.vue index ed682c5e..50a80f49 100644 --- a/Yi.Ai.Vue3/src/layouts/index.vue +++ b/Yi.Ai.Vue3/src/layouts/index.vue @@ -1,21 +1,41 @@ + + + + diff --git a/Yi.Ai.Vue3/src/pages/chat/conversation/index.vue b/Yi.Ai.Vue3/src/pages/chat/conversation/index.vue new file mode 100644 index 00000000..815896e9 --- /dev/null +++ b/Yi.Ai.Vue3/src/pages/chat/conversation/index.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/pages/chat/image/index.vue b/Yi.Ai.Vue3/src/pages/chat/image/index.vue new file mode 100644 index 00000000..b319c725 --- /dev/null +++ b/Yi.Ai.Vue3/src/pages/chat/image/index.vue @@ -0,0 +1,26 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/pages/chat/index.vue b/Yi.Ai.Vue3/src/pages/chat/index.vue index 933c9a65..82619c11 100644 --- a/Yi.Ai.Vue3/src/pages/chat/index.vue +++ b/Yi.Ai.Vue3/src/pages/chat/index.vue @@ -1,31 +1,304 @@ - diff --git a/Yi.Ai.Vue3/src/pages/chat/layouts/chatDefaul/index.vue b/Yi.Ai.Vue3/src/pages/chat/layouts/chatDefaul/index.vue index 44180051..2ec17b1c 100644 --- a/Yi.Ai.Vue3/src/pages/chat/layouts/chatDefaul/index.vue +++ b/Yi.Ai.Vue3/src/pages/chat/layouts/chatDefaul/index.vue @@ -7,162 +7,259 @@ import { ElMessage } from 'element-plus'; import { nextTick, ref, watch } from 'vue'; import ModelSelect from '@/components/ModelSelect/index.vue'; import WelecomeText from '@/components/WelecomeText/index.vue'; -import { useGuideTourStore, useUserStore } from '@/stores'; +import { useUserStore } from '@/stores'; import { useFilesStore } from '@/stores/modules/files'; - import { useSessionStore } from '@/stores/modules/session'; +// Store 实例 const userStore = useUserStore(); const sessionStore = useSessionStore(); const filesStore = useFilesStore(); -const guideTourStore = useGuideTourStore(); -const senderValue = ref(''); -const senderRef = ref(); +// 响应式数据 +const senderValue = ref(''); // 输入框内容 +const senderRef = ref(); // Sender 组件引用 const isSending = ref(false); // 发送状态标志 -// 防抖发送函数 -const debouncedSend = useDebounceFn(async () => { - if (!senderValue.value.trim()) { - ElMessage.warning('消息内容不能为空'); - return; - } +/** + * 防抖发送消息函数 + */ +const debouncedSend = useDebounceFn( + async () => { + // 1. 验证输入 + if (!senderValue.value.trim()) { + ElMessage.warning('消息内容不能为空'); + return; + } - if (isSending.value) { - ElMessage.warning('请等待上一条消息发送完成'); - return; - } + // 2. 检查是否正在发送 + if (isSending.value) { + ElMessage.warning('请等待上一条消息发送完成'); + return; + } - const content = senderValue.value; - isSending.value = true; + // 3. 准备发送数据 + const content = senderValue.value.trim(); + isSending.value = true; - try { - localStorage.setItem('chatContent', content); - await sessionStore.createSessionList({ - userId: userStore.userInfo?.userId as number, - sessionContent: content, - sessionTitle: content.slice(0, 10), - remark: content.slice(0, 10), - }); - senderValue.value = ''; // 清空输入框 - } - catch (error: any) { - console.error('发送消息失败:', error); - ElMessage.error(error); - } - finally { - isSending.value = false; - } -}, 800, { leading: true, trailing: false }); // 800ms防抖 + try { + // 4. 保存到本地存储(可选,用于页面刷新后恢复) + localStorage.setItem('chatContent', content); -// 处理发送事件 + // 5. 创建会话 + await sessionStore.createSessionList({ + userId: userStore.userInfo?.userId as number, + sessionContent: content, + sessionTitle: content.slice(0, 10), + remark: content.slice(0, 10), + }); + + // 6. 清空输入框 + senderValue.value = ''; + } + catch (error: any) { + console.error('发送消息失败:', error); + ElMessage.error(error.message || '发送消息失败'); + } + finally { + // 7. 重置发送状态 + isSending.value = false; + } + }, + 800, // 防抖延迟 + { leading: true, trailing: false }, // 立即执行第一次,忽略后续快速点击 +); + +/** + * 触发发送消息 + */ function handleSend() { debouncedSend(); } +/** + * 删除文件卡片 + * @param _item 文件项 + * @param index 文件索引 + */ function handleDeleteCard(_item: FilesCardProps, index: number) { filesStore.deleteFileByIndex(index); } +/** + * 监听文件列表变化,自动展开/收起 Sender 头部 + */ watch( () => filesStore.filesList.length, (val) => { - if (val > 0) { - nextTick(() => { + nextTick(() => { + if (val > 0) { senderRef.value?.openHeader(); - }); - } - else { - nextTick(() => { + } + else { senderRef.value?.closeHeader(); - }); - } + } + }); }, ); diff --git a/Yi.Ai.Vue3/src/pages/chat/layouts/chatWithId/index.vue b/Yi.Ai.Vue3/src/pages/chat/layouts/chatWithId/index.vue index 0ecb2ee1..fd6d0046 100644 --- a/Yi.Ai.Vue3/src/pages/chat/layouts/chatWithId/index.vue +++ b/Yi.Ai.Vue3/src/pages/chat/layouts/chatWithId/index.vue @@ -562,14 +562,16 @@ function handleImagePreview(url: string) { diff --git a/Yi.Ai.Vue3/src/pages/console/index.vue b/Yi.Ai.Vue3/src/pages/console/index.vue new file mode 100644 index 00000000..44aece8f --- /dev/null +++ b/Yi.Ai.Vue3/src/pages/console/index.vue @@ -0,0 +1,313 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/pages/modelLibrary/index.vue b/Yi.Ai.Vue3/src/pages/modelLibrary/index.vue index df8dc070..264aeb12 100644 --- a/Yi.Ai.Vue3/src/pages/modelLibrary/index.vue +++ b/Yi.Ai.Vue3/src/pages/modelLibrary/index.vue @@ -266,6 +266,7 @@ onMounted(() => {
{ diff --git a/Yi.Ai.Vue3/src/pages/console/index.vue b/Yi.Ai.Vue3/src/pages/console/index.vue index 44aece8f..15ae21dd 100644 --- a/Yi.Ai.Vue3/src/pages/console/index.vue +++ b/Yi.Ai.Vue3/src/pages/console/index.vue @@ -19,6 +19,7 @@ const navItems = [ { name: 'daily-task', label: '每日任务(限时)', icon: 'Trophy', path: '/console/daily-task' }, { name: 'invite', label: '每周邀请(限时)', icon: 'Present', path: '/console/invite' }, { name: 'activation', label: '激活码兑换', icon: 'MagicStick', path: '/console/activation' }, + { name: 'channel', label: '渠道商管理', icon: 'Setting', path: '/console/channel' }, ]; // 当前激活的菜单 diff --git a/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts b/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts index b94431ec..496bb214 100644 --- a/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts +++ b/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts @@ -207,6 +207,14 @@ export const layoutRouter: RouteRecordRaw[] = [ title: '激活码兑换', }, }, + { + path: 'channel', + name: 'consoleChannel', + component: () => import('@/pages/console/channel/index.vue'), + meta: { + title: '渠道商管理', + }, + }, ], }, ], diff --git a/Yi.Ai.Vue3/types/components.d.ts b/Yi.Ai.Vue3/types/components.d.ts index 9ef439fb..16d28441 100644 --- a/Yi.Ai.Vue3/types/components.d.ts +++ b/Yi.Ai.Vue3/types/components.d.ts @@ -25,6 +25,8 @@ declare module 'vue' { ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] ElContainer: typeof import('element-plus/es')['ElContainer'] ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] + ElDescriptions: typeof import('element-plus/es')['ElDescriptions'] + ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem'] ElDialog: typeof import('element-plus/es')['ElDialog'] ElDivider: typeof import('element-plus/es')['ElDivider'] ElDrawer: typeof import('element-plus/es')['ElDrawer'] diff --git a/Yi.Ai.Vue3/types/import_meta.d.ts b/Yi.Ai.Vue3/types/import_meta.d.ts index c98d612e..8f2a798b 100644 --- a/Yi.Ai.Vue3/types/import_meta.d.ts +++ b/Yi.Ai.Vue3/types/import_meta.d.ts @@ -7,7 +7,6 @@ interface ImportMetaEnv { readonly VITE_WEB_BASE_API: string; readonly VITE_API_URL: string; readonly VITE_FILE_UPLOAD_API: string; - readonly VITE_BUILD_COMPRESS: string; readonly VITE_SSO_SEVER_URL: string; readonly VITE_APP_VERSION: string; } From 0c31b978240fd3ead89a6f0802ddeddd4ebf3859 Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Wed, 31 Dec 2025 00:10:44 +0800 Subject: [PATCH 3/9] =?UTF-8?q?Revert=20"feat:=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=B0=8A=E4=BA=AB=E5=8C=85=E6=B8=A0=E9=81=93"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 70ae2fab44f8de01437aa060d404b072f8b157b9. --- .../Dtos/Channel/AiAppCreateInput.cs | 42 -- .../Dtos/Channel/AiAppDto.cs | 42 -- .../Dtos/Channel/AiAppGetListInput.cs | 14 - .../Dtos/Channel/AiAppUpdateInput.cs | 48 -- .../Dtos/Channel/AiModelCreateInput.cs | 96 --- .../Dtos/Channel/AiModelDto.cs | 84 --- .../Dtos/Channel/AiModelGetListInput.cs | 24 - .../Dtos/Channel/AiModelUpdateInput.cs | 102 ---- .../IServices/IChannelService.cs | 86 --- .../Services/Activities/DailyTaskService.cs | 8 +- .../Services/ChannelService.cs | 233 -------- .../Services/Chat/AiChatService.cs | 27 +- .../Services/Chat/AiImageService.cs | 3 - .../Services/Chat/ModelService.cs | 5 +- .../Services/Chat/TokenService.cs | 5 +- .../Services/OpenApiService.cs | 7 +- .../Services/UsageStatisticsService.cs | 7 +- .../Entities/Model/AiModelEntity.cs | 5 - .../Managers/AiGateWayManager.cs | 39 +- .../Managers/ChatManager.cs | 12 +- .../Managers/TokenManager.cs | 30 +- Yi.Ai.Vue3/src/api/channel/index.ts | 100 ---- Yi.Ai.Vue3/src/api/channel/types.ts | 121 ---- .../src/pages/console/channel/index.vue | 548 ------------------ Yi.Ai.Vue3/src/pages/console/index.vue | 1 - .../src/routers/modules/staticRouter.ts | 8 - Yi.Ai.Vue3/types/components.d.ts | 2 - Yi.Ai.Vue3/types/import_meta.d.ts | 1 + 28 files changed, 34 insertions(+), 1666 deletions(-) delete mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppCreateInput.cs delete mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppDto.cs delete mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppGetListInput.cs delete mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppUpdateInput.cs delete mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelCreateInput.cs delete mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelDto.cs delete mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelGetListInput.cs delete mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelUpdateInput.cs delete mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/IServices/IChannelService.cs delete mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ChannelService.cs delete mode 100644 Yi.Ai.Vue3/src/api/channel/index.ts delete mode 100644 Yi.Ai.Vue3/src/api/channel/types.ts delete mode 100644 Yi.Ai.Vue3/src/pages/console/channel/index.vue diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppCreateInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppCreateInput.cs deleted file mode 100644 index f3c8ee6f..00000000 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppCreateInput.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Channel; - -/// -/// 创建AI应用输入 -/// -public class AiAppCreateInput -{ - /// - /// 应用名称 - /// - [Required(ErrorMessage = "应用名称不能为空")] - [StringLength(100, ErrorMessage = "应用名称不能超过100个字符")] - public string Name { get; set; } - - /// - /// 应用终结点 - /// - [Required(ErrorMessage = "应用终结点不能为空")] - [StringLength(500, ErrorMessage = "应用终结点不能超过500个字符")] - public string Endpoint { get; set; } - - /// - /// 额外URL - /// - [StringLength(500, ErrorMessage = "额外URL不能超过500个字符")] - public string? ExtraUrl { get; set; } - - /// - /// 应用Key - /// - [Required(ErrorMessage = "应用Key不能为空")] - [StringLength(500, ErrorMessage = "应用Key不能超过500个字符")] - public string ApiKey { get; set; } - - /// - /// 排序 - /// - [Range(0, int.MaxValue, ErrorMessage = "排序必须大于等于0")] - public int OrderNum { get; set; } -} diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppDto.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppDto.cs deleted file mode 100644 index 95be653d..00000000 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppDto.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Channel; - -/// -/// AI应用DTO -/// -public class AiAppDto -{ - /// - /// 应用ID - /// - public Guid Id { get; set; } - - /// - /// 应用名称 - /// - public string Name { get; set; } - - /// - /// 应用终结点 - /// - public string Endpoint { get; set; } - - /// - /// 额外URL - /// - public string? ExtraUrl { get; set; } - - /// - /// 应用Key - /// - public string ApiKey { get; set; } - - /// - /// 排序 - /// - public int OrderNum { get; set; } - - /// - /// 创建时间 - /// - public DateTime CreationTime { get; set; } -} diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppGetListInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppGetListInput.cs deleted file mode 100644 index c1e98085..00000000 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppGetListInput.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Yi.Framework.Ddd.Application.Contracts; - -namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Channel; - -/// -/// 获取AI应用列表输入 -/// -public class AiAppGetListInput : PagedAllResultRequestDto -{ - /// - /// 搜索关键词(搜索应用名称) - /// - public string? SearchKey { get; set; } -} diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppUpdateInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppUpdateInput.cs deleted file mode 100644 index ee14667c..00000000 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiAppUpdateInput.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Channel; - -/// -/// 更新AI应用输入 -/// -public class AiAppUpdateInput -{ - /// - /// 应用ID - /// - [Required(ErrorMessage = "应用ID不能为空")] - public Guid Id { get; set; } - - /// - /// 应用名称 - /// - [Required(ErrorMessage = "应用名称不能为空")] - [StringLength(100, ErrorMessage = "应用名称不能超过100个字符")] - public string Name { get; set; } - - /// - /// 应用终结点 - /// - [Required(ErrorMessage = "应用终结点不能为空")] - [StringLength(500, ErrorMessage = "应用终结点不能超过500个字符")] - public string Endpoint { get; set; } - - /// - /// 额外URL - /// - [StringLength(500, ErrorMessage = "额外URL不能超过500个字符")] - public string? ExtraUrl { get; set; } - - /// - /// 应用Key - /// - [Required(ErrorMessage = "应用Key不能为空")] - [StringLength(500, ErrorMessage = "应用Key不能超过500个字符")] - public string ApiKey { get; set; } - - /// - /// 排序 - /// - [Range(0, int.MaxValue, ErrorMessage = "排序必须大于等于0")] - public int OrderNum { get; set; } -} diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelCreateInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelCreateInput.cs deleted file mode 100644 index 9e956c52..00000000 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelCreateInput.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Yi.Framework.AiHub.Domain.Shared.Enums; - -namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Channel; - -/// -/// 创建AI模型输入 -/// -public class AiModelCreateInput -{ - /// - /// 处理名 - /// - [Required(ErrorMessage = "处理名不能为空")] - [StringLength(100, ErrorMessage = "处理名不能超过100个字符")] - public string HandlerName { get; set; } - - /// - /// 模型ID - /// - [Required(ErrorMessage = "模型ID不能为空")] - [StringLength(200, ErrorMessage = "模型ID不能超过200个字符")] - public string ModelId { get; set; } - - /// - /// 模型名称 - /// - [Required(ErrorMessage = "模型名称不能为空")] - [StringLength(200, ErrorMessage = "模型名称不能超过200个字符")] - public string Name { get; set; } - - /// - /// 模型描述 - /// - [StringLength(1000, ErrorMessage = "模型描述不能超过1000个字符")] - public string? Description { get; set; } - - /// - /// 排序 - /// - [Range(0, int.MaxValue, ErrorMessage = "排序必须大于等于0")] - public int OrderNum { get; set; } - - /// - /// AI应用ID - /// - [Required(ErrorMessage = "AI应用ID不能为空")] - public Guid AiAppId { get; set; } - - /// - /// 额外信息 - /// - [StringLength(2000, ErrorMessage = "额外信息不能超过2000个字符")] - public string? ExtraInfo { get; set; } - - /// - /// 模型类型 - /// - [Required(ErrorMessage = "模型类型不能为空")] - public ModelTypeEnum ModelType { get; set; } - - /// - /// 模型API类型 - /// - [Required(ErrorMessage = "模型API类型不能为空")] - public ModelApiTypeEnum ModelApiType { get; set; } - - /// - /// 模型倍率 - /// - [Range(0.01, double.MaxValue, ErrorMessage = "模型倍率必须大于0")] - public decimal Multiplier { get; set; } = 1; - - /// - /// 模型显示倍率 - /// - [Range(0.01, double.MaxValue, ErrorMessage = "模型显示倍率必须大于0")] - public decimal MultiplierShow { get; set; } = 1; - - /// - /// 供应商分组名称 - /// - [StringLength(100, ErrorMessage = "供应商分组名称不能超过100个字符")] - public string? ProviderName { get; set; } - - /// - /// 模型图标URL - /// - [StringLength(500, ErrorMessage = "模型图标URL不能超过500个字符")] - public string? IconUrl { get; set; } - - /// - /// 是否为尊享模型 - /// - public bool IsPremium { get; set; } -} diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelDto.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelDto.cs deleted file mode 100644 index 3b93b680..00000000 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelDto.cs +++ /dev/null @@ -1,84 +0,0 @@ -using Yi.Framework.AiHub.Domain.Shared.Enums; - -namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Channel; - -/// -/// AI模型DTO -/// -public class AiModelDto -{ - /// - /// 模型ID - /// - public Guid Id { get; set; } - - /// - /// 处理名 - /// - public string HandlerName { get; set; } - - /// - /// 模型ID - /// - public string ModelId { get; set; } - - /// - /// 模型名称 - /// - public string Name { get; set; } - - /// - /// 模型描述 - /// - public string? Description { get; set; } - - /// - /// 排序 - /// - public int OrderNum { get; set; } - - /// - /// AI应用ID - /// - public Guid AiAppId { get; set; } - - /// - /// 额外信息 - /// - public string? ExtraInfo { get; set; } - - /// - /// 模型类型 - /// - public ModelTypeEnum ModelType { get; set; } - - /// - /// 模型API类型 - /// - public ModelApiTypeEnum ModelApiType { get; set; } - - /// - /// 模型倍率 - /// - public decimal Multiplier { get; set; } - - /// - /// 模型显示倍率 - /// - public decimal MultiplierShow { get; set; } - - /// - /// 供应商分组名称 - /// - public string? ProviderName { get; set; } - - /// - /// 模型图标URL - /// - public string? IconUrl { get; set; } - - /// - /// 是否为尊享模型 - /// - public bool IsPremium { get; set; } -} diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelGetListInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelGetListInput.cs deleted file mode 100644 index c71cfc9b..00000000 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelGetListInput.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Yi.Framework.Ddd.Application.Contracts; - -namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Channel; - -/// -/// 获取AI模型列表输入 -/// -public class AiModelGetListInput : PagedAllResultRequestDto -{ - /// - /// 搜索关键词(搜索模型名称、模型ID) - /// - public string? SearchKey { get; set; } - - /// - /// AI应用ID筛选 - /// - public Guid? AiAppId { get; set; } - - /// - /// 是否只显示尊享模型 - /// - public bool? IsPremiumOnly { get; set; } -} diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelUpdateInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelUpdateInput.cs deleted file mode 100644 index b35065d9..00000000 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Channel/AiModelUpdateInput.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Yi.Framework.AiHub.Domain.Shared.Enums; - -namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Channel; - -/// -/// 更新AI模型输入 -/// -public class AiModelUpdateInput -{ - /// - /// 模型ID - /// - [Required(ErrorMessage = "模型ID不能为空")] - public Guid Id { get; set; } - - /// - /// 处理名 - /// - [Required(ErrorMessage = "处理名不能为空")] - [StringLength(100, ErrorMessage = "处理名不能超过100个字符")] - public string HandlerName { get; set; } - - /// - /// 模型ID - /// - [Required(ErrorMessage = "模型ID不能为空")] - [StringLength(200, ErrorMessage = "模型ID不能超过200个字符")] - public string ModelId { get; set; } - - /// - /// 模型名称 - /// - [Required(ErrorMessage = "模型名称不能为空")] - [StringLength(200, ErrorMessage = "模型名称不能超过200个字符")] - public string Name { get; set; } - - /// - /// 模型描述 - /// - [StringLength(1000, ErrorMessage = "模型描述不能超过1000个字符")] - public string? Description { get; set; } - - /// - /// 排序 - /// - [Range(0, int.MaxValue, ErrorMessage = "排序必须大于等于0")] - public int OrderNum { get; set; } - - /// - /// AI应用ID - /// - [Required(ErrorMessage = "AI应用ID不能为空")] - public Guid AiAppId { get; set; } - - /// - /// 额外信息 - /// - [StringLength(2000, ErrorMessage = "额外信息不能超过2000个字符")] - public string? ExtraInfo { get; set; } - - /// - /// 模型类型 - /// - [Required(ErrorMessage = "模型类型不能为空")] - public ModelTypeEnum ModelType { get; set; } - - /// - /// 模型API类型 - /// - [Required(ErrorMessage = "模型API类型不能为空")] - public ModelApiTypeEnum ModelApiType { get; set; } - - /// - /// 模型倍率 - /// - [Range(0.01, double.MaxValue, ErrorMessage = "模型倍率必须大于0")] - public decimal Multiplier { get; set; } - - /// - /// 模型显示倍率 - /// - [Range(0.01, double.MaxValue, ErrorMessage = "模型显示倍率必须大于0")] - public decimal MultiplierShow { get; set; } - - /// - /// 供应商分组名称 - /// - [StringLength(100, ErrorMessage = "供应商分组名称不能超过100个字符")] - public string? ProviderName { get; set; } - - /// - /// 模型图标URL - /// - [StringLength(500, ErrorMessage = "模型图标URL不能超过500个字符")] - public string? IconUrl { get; set; } - - /// - /// 是否为尊享模型 - /// - public bool IsPremium { get; set; } -} diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/IServices/IChannelService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/IServices/IChannelService.cs deleted file mode 100644 index d45b542e..00000000 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/IServices/IChannelService.cs +++ /dev/null @@ -1,86 +0,0 @@ -using Volo.Abp.Application.Dtos; -using Yi.Framework.AiHub.Application.Contracts.Dtos.Channel; - -namespace Yi.Framework.AiHub.Application.Contracts.IServices; - -/// -/// 渠道商管理服务接口 -/// -public interface IChannelService -{ - #region AI应用管理 - - /// - /// 获取AI应用列表 - /// - /// 查询参数 - /// 分页应用列表 - Task> GetAppListAsync(AiAppGetListInput input); - - /// - /// 根据ID获取AI应用 - /// - /// 应用ID - /// 应用详情 - Task GetAppByIdAsync(Guid id); - - /// - /// 创建AI应用 - /// - /// 创建输入 - /// 创建的应用 - Task CreateAppAsync(AiAppCreateInput input); - - /// - /// 更新AI应用 - /// - /// 更新输入 - /// 更新后的应用 - Task UpdateAppAsync(AiAppUpdateInput input); - - /// - /// 删除AI应用 - /// - /// 应用ID - Task DeleteAppAsync(Guid id); - - #endregion - - #region AI模型管理 - - /// - /// 获取AI模型列表 - /// - /// 查询参数 - /// 分页模型列表 - Task> GetModelListAsync(AiModelGetListInput input); - - /// - /// 根据ID获取AI模型 - /// - /// 模型ID - /// 模型详情 - Task GetModelByIdAsync(Guid id); - - /// - /// 创建AI模型 - /// - /// 创建输入 - /// 创建的模型 - Task CreateModelAsync(AiModelCreateInput input); - - /// - /// 更新AI模型 - /// - /// 更新输入 - /// 更新后的模型 - Task UpdateModelAsync(AiModelUpdateInput input); - - /// - /// 删除AI模型(软删除) - /// - /// 模型ID - Task DeleteModelAsync(Guid id); - - #endregion -} diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Activities/DailyTaskService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Activities/DailyTaskService.cs index a7e65a0a..013a82f4 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Activities/DailyTaskService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Activities/DailyTaskService.cs @@ -179,16 +179,10 @@ public class DailyTaskService : ApplicationService var tomorrow = today.AddDays(1); // 查询今日所有使用尊享包模型的消息(role=system 表示消耗) - // 先获取所有尊享模型的ModelId列表 - var premiumModelIds = await _aiModelRepository._DbQueryable - .Where(x => x.IsPremium) - .Select(x => x.ModelId) - .ToListAsync(); - var totalTokens = await _messageRepository._DbQueryable .Where(x => x.UserId == userId) .Where(x => x.Role == "system") // system角色表示实际消耗 - .Where(x => premiumModelIds.Contains(x.ModelId)) // 尊享包模型 + .Where(x => PremiumPackageConst.ModeIds.Contains(x.ModelId)) // 尊享包模型 .Where(x => x.CreationTime >= today && x.CreationTime < tomorrow) .SumAsync(x => x.TokenUsage.TotalTokenCount); diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ChannelService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ChannelService.cs deleted file mode 100644 index 7e7a2f9b..00000000 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ChannelService.cs +++ /dev/null @@ -1,233 +0,0 @@ -using Mapster; -using Microsoft.AspNetCore.Authorization; -using SqlSugar; -using Volo.Abp.Application.Dtos; -using Volo.Abp.Application.Services; -using Yi.Framework.AiHub.Application.Contracts.Dtos.Channel; -using Yi.Framework.AiHub.Application.Contracts.IServices; -using Yi.Framework.AiHub.Domain.Entities.Model; -using Yi.Framework.SqlSugarCore.Abstractions; - -namespace Yi.Framework.AiHub.Application.Services; - -/// -/// 渠道商管理服务实现 -/// -[Authorize] -public class ChannelService : ApplicationService, IChannelService -{ - private readonly ISqlSugarRepository _appRepository; - private readonly ISqlSugarRepository _modelRepository; - - public ChannelService( - ISqlSugarRepository appRepository, - ISqlSugarRepository modelRepository) - { - _appRepository = appRepository; - _modelRepository = modelRepository; - } - - #region AI应用管理 - - /// - /// 获取AI应用列表 - /// - public async Task> GetAppListAsync(AiAppGetListInput input) - { - RefAsync total = 0; - - var entities = await _appRepository._DbQueryable - .WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), x => x.Name.Contains(input.SearchKey)) - .OrderBy(x => x.OrderNum) - .OrderByDescending(x => x.CreationTime) - .ToPageListAsync(input.SkipCount, input.MaxResultCount, total); - - var output = entities.Adapt>(); - return new PagedResultDto(total, output); - } - - /// - /// 根据ID获取AI应用 - /// - public async Task GetAppByIdAsync(Guid id) - { - var entity = await _appRepository.GetByIdAsync(id); - return entity.Adapt(); - } - - /// - /// 创建AI应用 - /// - public async Task CreateAppAsync(AiAppCreateInput input) - { - var entity = new AiAppAggregateRoot - { - Name = input.Name, - Endpoint = input.Endpoint, - ExtraUrl = input.ExtraUrl, - ApiKey = input.ApiKey, - OrderNum = input.OrderNum - }; - - await _appRepository.InsertAsync(entity); - return entity.Adapt(); - } - - /// - /// 更新AI应用 - /// - public async Task UpdateAppAsync(AiAppUpdateInput input) - { - var entity = await _appRepository.GetByIdAsync(input.Id); - - entity.Name = input.Name; - entity.Endpoint = input.Endpoint; - entity.ExtraUrl = input.ExtraUrl; - entity.ApiKey = input.ApiKey; - entity.OrderNum = input.OrderNum; - - await _appRepository.UpdateAsync(entity); - return entity.Adapt(); - } - - /// - /// 删除AI应用 - /// - public async Task DeleteAppAsync(Guid id) - { - // 检查是否有关联的模型 - var hasModels = await _modelRepository._DbQueryable - .Where(x => x.AiAppId == id && !x.IsDeleted) - .AnyAsync(); - - if (hasModels) - { - throw new Volo.Abp.UserFriendlyException("该应用下存在模型,无法删除"); - } - - await _appRepository.DeleteAsync(id); - } - - #endregion - - #region AI模型管理 - - /// - /// 获取AI模型列表 - /// - public async Task> GetModelListAsync(AiModelGetListInput input) - { - RefAsync total = 0; - - var query = _modelRepository._DbQueryable - .Where(x => !x.IsDeleted) - .WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), x => - x.Name.Contains(input.SearchKey) || x.ModelId.Contains(input.SearchKey)) - .WhereIF(input.AiAppId.HasValue, x => x.AiAppId == input.AiAppId.Value) - .WhereIF(input.IsPremiumOnly == true, x => x.IsPremium); - - var entities = await query - .OrderBy(x => x.OrderNum) - .OrderByDescending(x => x.Id) - .ToPageListAsync(input.SkipCount, input.MaxResultCount, total); - - var output = entities.Adapt>(); - return new PagedResultDto(total, output); - } - - /// - /// 根据ID获取AI模型 - /// - public async Task GetModelByIdAsync(Guid id) - { - var entity = await _modelRepository.GetByIdAsync(id); - return entity.Adapt(); - } - - /// - /// 创建AI模型 - /// - public async Task CreateModelAsync(AiModelCreateInput input) - { - // 验证应用是否存在 - var appExists = await _appRepository._DbQueryable - .Where(x => x.Id == input.AiAppId) - .AnyAsync(); - - if (!appExists) - { - throw new Volo.Abp.UserFriendlyException("指定的AI应用不存在"); - } - - var entity = new AiModelEntity - { - HandlerName = input.HandlerName, - ModelId = input.ModelId, - Name = input.Name, - Description = input.Description, - OrderNum = input.OrderNum, - AiAppId = input.AiAppId, - ExtraInfo = input.ExtraInfo, - ModelType = input.ModelType, - ModelApiType = input.ModelApiType, - Multiplier = input.Multiplier, - MultiplierShow = input.MultiplierShow, - ProviderName = input.ProviderName, - IconUrl = input.IconUrl, - IsPremium = input.IsPremium, - IsDeleted = false - }; - - await _modelRepository.InsertAsync(entity); - return entity.Adapt(); - } - - /// - /// 更新AI模型 - /// - public async Task UpdateModelAsync(AiModelUpdateInput input) - { - var entity = await _modelRepository.GetByIdAsync(input.Id); - - // 验证应用是否存在 - if (entity.AiAppId != input.AiAppId) - { - var appExists = await _appRepository._DbQueryable - .Where(x => x.Id == input.AiAppId) - .AnyAsync(); - - if (!appExists) - { - throw new Volo.Abp.UserFriendlyException("指定的AI应用不存在"); - } - } - - entity.HandlerName = input.HandlerName; - entity.ModelId = input.ModelId; - entity.Name = input.Name; - entity.Description = input.Description; - entity.OrderNum = input.OrderNum; - entity.AiAppId = input.AiAppId; - entity.ExtraInfo = input.ExtraInfo; - entity.ModelType = input.ModelType; - entity.ModelApiType = input.ModelApiType; - entity.Multiplier = input.Multiplier; - entity.MultiplierShow = input.MultiplierShow; - entity.ProviderName = input.ProviderName; - entity.IconUrl = input.IconUrl; - entity.IsPremium = input.IsPremium; - - await _modelRepository.UpdateAsync(entity); - return entity.Adapt(); - } - - /// - /// 删除AI模型(软删除) - /// - public async Task DeleteModelAsync(Guid id) - { - await _modelRepository.DeleteByIdAsync(id); - } - - #endregion -} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiChatService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiChatService.cs index 42f0b1a5..341638ce 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiChatService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiChatService.cs @@ -109,7 +109,7 @@ public class AiChatService : ApplicationService ApiHost = null, ApiKey = null, Remark = x.Description, - IsPremiumPackage = x.IsPremium + IsPremiumPackage = PremiumPackageConst.ModeIds.Contains(x.ModelId) }).ToListAsync(); return output; } @@ -144,21 +144,13 @@ public class AiChatService : ApplicationService } //如果是尊享包服务,需要校验是是否尊享包足够 - if (CurrentUser.IsAuthenticated) + if (CurrentUser.IsAuthenticated && PremiumPackageConst.ModeIds.Contains(input.Model)) { - var isPremium = await _aiModelRepository._DbQueryable - .Where(x => x.ModelId == input.Model) - .Select(x => x.IsPremium) - .FirstAsync(); - - if (isPremium) + // 检查尊享token包用量 + var availableTokens = await _premiumPackageManager.GetAvailableTokensAsync(CurrentUser.GetId()); + if (availableTokens <= 0) { - // 检查尊享token包用量 - var availableTokens = await _premiumPackageManager.GetAvailableTokensAsync(CurrentUser.GetId()); - if (availableTokens <= 0) - { - throw new UserFriendlyException("尊享token包用量不足,请先购买尊享token包"); - } + throw new UserFriendlyException("尊享token包用量不足,请先购买尊享token包"); } } @@ -227,12 +219,7 @@ public class AiChatService : ApplicationService } //如果是尊享包服务,需要校验是是否尊享包足够 - var isPremium = await _aiModelRepository._DbQueryable - .Where(x => x.ModelId == input.ModelId) - .Select(x => x.IsPremium) - .FirstAsync(); - - if (isPremium) + if (PremiumPackageConst.ModeIds.Contains(input.ModelId)) { // 检查尊享token包用量 var availableTokens = await _premiumPackageManager.GetAvailableTokensAsync(tokenValidation.UserId); diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiImageService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiImageService.cs index caa7313d..5bffa03d 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiImageService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiImageService.cs @@ -69,9 +69,6 @@ public class AiImageService : ApplicationService } // 尊享包校验 - // 注意: AiImageService目前没有注入AiModelEntity仓储 - // 由于图片生成功能使用频率较低,且当前所有图片模型都不是尊享模型 - // 暂时保留原逻辑,等待后续重构时再注入仓储 if (PremiumPackageConst.ModeIds.Contains(input.ModelId)) { var availableTokens = await _premiumPackageManager.GetAvailableTokensAsync(userId); diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/ModelService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/ModelService.cs index 0eee3438..98faf61c 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/ModelService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/ModelService.cs @@ -41,7 +41,8 @@ public class ModelService : ApplicationService, IModelService input.ModelTypes.Contains(x.ModelType)) .WhereIF(input.ModelApiTypes is not null, x => input.ModelApiTypes.Contains(x.ModelApiType)) - .WhereIF(input.IsPremiumOnly == true, x => x.IsPremium) + .WhereIF(input.IsPremiumOnly == true, x => + PremiumPackageConst.ModeIds.Contains(x.ModelId)) .GroupBy(x => x.ModelId) .Select(x => x.ModelId) .ToPageListAsync(input.SkipCount, input.MaxResultCount, total)); @@ -60,7 +61,7 @@ public class ModelService : ApplicationService, IModelService MultiplierShow = x.First().MultiplierShow, ProviderName = x.First().ProviderName, IconUrl = x.First().IconUrl, - IsPremium = x.First().IsPremium, + IsPremium = PremiumPackageConst.ModeIds.Contains(x.First().ModelId), OrderNum = x.First().OrderNum }).ToList(); diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/TokenService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/TokenService.cs index d18de550..23e7e666 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/TokenService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/TokenService.cs @@ -52,10 +52,7 @@ public class TokenService : ApplicationService } // 获取尊享包模型ID列表 - var premiumModelIds = await _aiModelRepository._DbQueryable - .Where(x => x.IsPremium) - .Select(x => x.ModelId) - .ToListAsync(); + var premiumModelIds = PremiumPackageConst.ModeIds; // 批量查询所有Token的尊享包已使用额度 var tokenIds = tokens.Select(t => t.Id).ToList(); diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs index eef91f3b..ccb05089 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs @@ -65,12 +65,7 @@ public class OpenApiService : ApplicationService await _aiBlacklistManager.VerifiyAiBlacklist(userId); //如果是尊享包服务,需要校验是是否尊享包足够 - var isPremium = await _aiModelRepository._DbQueryable - .Where(x => x.ModelId == input.Model) - .Select(x => x.IsPremium) - .FirstAsync(); - - if (isPremium) + if (PremiumPackageConst.ModeIds.Contains(input.Model)) { // 检查尊享token包用量 var availableTokens = await _premiumPackageManager.GetAvailableTokensAsync(userId); diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs index f8c0b3a4..bffce1e6 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs @@ -181,12 +181,7 @@ public class UsageStatisticsService : ApplicationService, IUsageStatisticsServic public async Task> GetPremiumTokenUsageByTokenAsync() { var userId = CurrentUser.GetId(); - - // 先获取所有尊享模型的ModelId列表 - var premiumModelIds = await _aiModelRepository._DbQueryable - .Where(x => x.IsPremium) - .Select(x => x.ModelId) - .ToListAsync(); + var premiumModelIds = PremiumPackageConst.ModeIds; // 从UsageStatistics表获取尊享模型的token消耗统计(按TokenId聚合) var tokenUsages = await _usageStatisticsRepository._DbQueryable diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Model/AiModelEntity.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Model/AiModelEntity.cs index ef0f1ebd..991d0ff2 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Model/AiModelEntity.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Model/AiModelEntity.cs @@ -80,9 +80,4 @@ public class AiModelEntity : Entity, IOrderNum, ISoftDelete /// 模型图标URL /// public string? IconUrl { get; set; } - - /// - /// 是否为尊享模型 - /// - public bool IsPremium { get; set; } } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs index 34cf3486..971fef75 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs @@ -150,12 +150,7 @@ public class AiGateWayManager : DomainService await _usageStatisticsManager.SetUsageAsync(userId.Value, request.Model, data.Usage, tokenId); // 扣减尊享token包用量 - var isPremium = await _aiModelRepository._DbQueryable - .Where(x => x.ModelId == request.Model) - .Select(x => x.IsPremium) - .FirstAsync(); - - if (isPremium) + if (PremiumPackageConst.ModeIds.Contains(request.Model)) { var totalTokens = data.Usage?.TotalTokens ?? 0; if (totalTokens > 0) @@ -305,20 +300,12 @@ public class AiGateWayManager : DomainService await _usageStatisticsManager.SetUsageAsync(userId, request.Model, tokenUsage, tokenId); // 扣减尊享token包用量 - if (userId is not null) + if (userId is not null && PremiumPackageConst.ModeIds.Contains(request.Model)) { - var isPremium = await _aiModelRepository._DbQueryable - .Where(x => x.ModelId == request.Model) - .Select(x => x.IsPremium) - .FirstAsync(); - - if (isPremium) + var totalTokens = tokenUsage.TotalTokens ?? 0; + if (totalTokens > 0) { - var totalTokens = tokenUsage.TotalTokens ?? 0; - if (totalTokens > 0) - { - await PremiumPackageManager.TryConsumeTokensAsync(userId.Value, totalTokens); - } + await PremiumPackageManager.TryConsumeTokensAsync(userId.Value, totalTokens); } } } @@ -376,20 +363,12 @@ public class AiGateWayManager : DomainService await _usageStatisticsManager.SetUsageAsync(userId, model, response.Usage, tokenId); // 扣减尊享token包用量 - if (userId is not null) + if (userId is not null && PremiumPackageConst.ModeIds.Contains(request.Model)) { - var isPremium = await _aiModelRepository._DbQueryable - .Where(x => x.ModelId == request.Model) - .Select(x => x.IsPremium) - .FirstAsync(); - - if (isPremium) + var totalTokens = response.Usage.TotalTokens ?? 0; + if (totalTokens > 0) { - var totalTokens = response.Usage.TotalTokens ?? 0; - if (totalTokens > 0) - { - await PremiumPackageManager.TryConsumeTokensAsync(userId.Value, totalTokens); - } + await PremiumPackageManager.TryConsumeTokensAsync(userId.Value, totalTokens); } } } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/ChatManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/ChatManager.cs index 5e411fbb..b4d9110c 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/ChatManager.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/ChatManager.cs @@ -15,7 +15,6 @@ using Volo.Abp.Domain.Services; using Yi.Framework.AiHub.Application.Contracts.Dtos.Chat; using Yi.Framework.AiHub.Domain.AiGateWay; using Yi.Framework.AiHub.Domain.Entities.Chat; -using Yi.Framework.AiHub.Domain.Entities.Model; using Yi.Framework.AiHub.Domain.Entities.OpenApi; using Yi.Framework.AiHub.Domain.Shared.Attributes; using Yi.Framework.AiHub.Domain.Shared.Consts; @@ -35,13 +34,12 @@ public class ChatManager : DomainService private readonly UsageStatisticsManager _usageStatisticsManager; private readonly PremiumPackageManager _premiumPackageManager; private readonly AiGateWayManager _aiGateWayManager; - private readonly ISqlSugarRepository _aiModelRepository; public ChatManager(ILoggerFactory loggerFactory, ISqlSugarRepository messageRepository, ISqlSugarRepository agentStoreRepository, AiMessageManager aiMessageManager, UsageStatisticsManager usageStatisticsManager, PremiumPackageManager premiumPackageManager, - AiGateWayManager aiGateWayManager, ISqlSugarRepository aiModelRepository) + AiGateWayManager aiGateWayManager) { _loggerFactory = loggerFactory; _messageRepository = messageRepository; @@ -50,7 +48,6 @@ public class ChatManager : DomainService _usageStatisticsManager = usageStatisticsManager; _premiumPackageManager = premiumPackageManager; _aiGateWayManager = aiGateWayManager; - _aiModelRepository = aiModelRepository; } /// @@ -210,12 +207,7 @@ public class ChatManager : DomainService await _usageStatisticsManager.SetUsageAsync(userId, modelId, usage, tokenId); //扣减尊享token包用量 - var isPremium = await _aiModelRepository._DbQueryable - .Where(x => x.ModelId == modelId) - .Select(x => x.IsPremium) - .FirstAsync(); - - if (isPremium) + if (PremiumPackageConst.ModeIds.Contains(modelId)) { var totalTokens = usage?.TotalTokens ?? 0; if (totalTokens > 0) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/TokenManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/TokenManager.cs index 28595a48..dd2ae774 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/TokenManager.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/TokenManager.cs @@ -1,7 +1,6 @@ using SqlSugar; using Volo.Abp.Domain.Services; using Yi.Framework.AiHub.Domain.Entities; -using Yi.Framework.AiHub.Domain.Entities.Model; using Yi.Framework.AiHub.Domain.Entities.OpenApi; using Yi.Framework.AiHub.Domain.Shared.Consts; using Yi.Framework.SqlSugarCore.Abstractions; @@ -28,16 +27,13 @@ public class TokenManager : DomainService { private readonly ISqlSugarRepository _tokenRepository; private readonly ISqlSugarRepository _usageStatisticsRepository; - private readonly ISqlSugarRepository _aiModelRepository; public TokenManager( ISqlSugarRepository tokenRepository, - ISqlSugarRepository usageStatisticsRepository, - ISqlSugarRepository aiModelRepository) + ISqlSugarRepository usageStatisticsRepository) { _tokenRepository = tokenRepository; _usageStatisticsRepository = usageStatisticsRepository; - _aiModelRepository = aiModelRepository; } /// @@ -80,20 +76,14 @@ public class TokenManager : DomainService } // 如果是尊享模型且Token设置了额度限制,检查是否超限 - if (!string.IsNullOrEmpty(modelId) && entity.PremiumQuotaLimit.HasValue) + if (!string.IsNullOrEmpty(modelId) && + PremiumPackageConst.ModeIds.Contains(modelId) && + entity.PremiumQuotaLimit.HasValue) { - var isPremium = await _aiModelRepository._DbQueryable - .Where(x => x.ModelId == modelId) - .Select(x => x.IsPremium) - .FirstAsync(); - - if (isPremium) + var usedQuota = await GetTokenPremiumUsedQuotaAsync(entity.UserId, entity.Id); + if (usedQuota >= entity.PremiumQuotaLimit.Value) { - var usedQuota = await GetTokenPremiumUsedQuotaAsync(entity.UserId, entity.Id); - if (usedQuota >= entity.PremiumQuotaLimit.Value) - { - throw new UserFriendlyException($"当前Token的尊享包额度已用完(已使用:{usedQuota},限制:{entity.PremiumQuotaLimit.Value}),请调整额度限制或使用其他Token", "403"); - } + throw new UserFriendlyException($"当前Token的尊享包额度已用完(已使用:{usedQuota},限制:{entity.PremiumQuotaLimit.Value}),请调整额度限制或使用其他Token", "403"); } } @@ -109,11 +99,7 @@ public class TokenManager : DomainService /// private async Task GetTokenPremiumUsedQuotaAsync(Guid userId, Guid tokenId) { - // 先获取所有尊享模型的ModelId列表 - var premiumModelIds = await _aiModelRepository._DbQueryable - .Where(x => x.IsPremium) - .Select(x => x.ModelId) - .ToListAsync(); + var premiumModelIds = PremiumPackageConst.ModeIds; var usedQuota = await _usageStatisticsRepository._DbQueryable .Where(x => x.UserId == userId && x.TokenId == tokenId && premiumModelIds.Contains(x.ModelId)) diff --git a/Yi.Ai.Vue3/src/api/channel/index.ts b/Yi.Ai.Vue3/src/api/channel/index.ts deleted file mode 100644 index cd31154f..00000000 --- a/Yi.Ai.Vue3/src/api/channel/index.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { del, get, post, put } from '@/utils/request'; -import type { - AiAppDto, - AiAppCreateInput, - AiAppUpdateInput, - AiAppGetListInput, - AiModelDto, - AiModelCreateInput, - AiModelUpdateInput, - AiModelGetListInput, - PagedResultDto, -} from './types'; - -// ==================== AI应用管理 ==================== - -// 获取AI应用列表 -export function getAppList(params?: AiAppGetListInput) { - const queryParams = new URLSearchParams(); - if (params?.searchKey) { - queryParams.append('SearchKey', params.searchKey); - } - if (params?.skipCount !== undefined) { - queryParams.append('SkipCount', params.skipCount.toString()); - } - if (params?.maxResultCount !== undefined) { - queryParams.append('MaxResultCount', params.maxResultCount.toString()); - } - - const queryString = queryParams.toString(); - const url = queryString ? `/channel/app?${queryString}` : '/channel/app'; - - return get>(url).json(); -} - -// 根据ID获取AI应用 -export function getAppById(id: string) { - return get(`/channel/app/${id}`).json(); -} - -// 创建AI应用 -export function createApp(data: AiAppCreateInput) { - return post('/channel/app', data).json(); -} - -// 更新AI应用 -export function updateApp(data: AiAppUpdateInput) { - return put('/channel/app', data).json(); -} - -// 删除AI应用 -export function deleteApp(id: string) { - return del(`/channel/app/${id}`).json(); -} - -// ==================== AI模型管理 ==================== - -// 获取AI模型列表 -export function getModelList(params?: AiModelGetListInput) { - const queryParams = new URLSearchParams(); - if (params?.searchKey) { - queryParams.append('SearchKey', params.searchKey); - } - if (params?.aiAppId) { - queryParams.append('AiAppId', params.aiAppId); - } - if (params?.isPremiumOnly !== undefined) { - queryParams.append('IsPremiumOnly', params.isPremiumOnly.toString()); - } - if (params?.skipCount !== undefined) { - queryParams.append('SkipCount', params.skipCount.toString()); - } - if (params?.maxResultCount !== undefined) { - queryParams.append('MaxResultCount', params.maxResultCount.toString()); - } - - const queryString = queryParams.toString(); - const url = queryString ? `/channel/model?${queryString}` : '/channel/model'; - - return get>(url).json(); -} - -// 根据ID获取AI模型 -export function getModelById(id: string) { - return get(`/channel/model/${id}`).json(); -} - -// 创建AI模型 -export function createModel(data: AiModelCreateInput) { - return post('/channel/model', data).json(); -} - -// 更新AI模型 -export function updateModel(data: AiModelUpdateInput) { - return put('/channel/model', data).json(); -} - -// 删除AI模型 -export function deleteModel(id: string) { - return del(`/channel/model/${id}`).json(); -} diff --git a/Yi.Ai.Vue3/src/api/channel/types.ts b/Yi.Ai.Vue3/src/api/channel/types.ts deleted file mode 100644 index 76a6306a..00000000 --- a/Yi.Ai.Vue3/src/api/channel/types.ts +++ /dev/null @@ -1,121 +0,0 @@ -// 模型类型枚举 -export enum ModelTypeEnum { - Chat = 0, - Image = 1, - Embedding = 2, - PremiumChat = 3, -} - -// 模型API类型枚举 -export enum ModelApiTypeEnum { - OpenAi = 0, - Claude = 1, -} - -// AI应用DTO -export interface AiAppDto { - id: string; - name: string; - endpoint: string; - extraUrl?: string; - apiKey: string; - orderNum: number; - creationTime: string; -} - -// 创建AI应用输入 -export interface AiAppCreateInput { - name: string; - endpoint: string; - extraUrl?: string; - apiKey: string; - orderNum: number; -} - -// 更新AI应用输入 -export interface AiAppUpdateInput { - id: string; - name: string; - endpoint: string; - extraUrl?: string; - apiKey: string; - orderNum: number; -} - -// 获取AI应用列表输入 -export interface AiAppGetListInput { - searchKey?: string; - skipCount?: number; - maxResultCount?: number; -} - -// AI模型DTO -export interface AiModelDto { - id: string; - handlerName: string; - modelId: string; - name: string; - description?: string; - orderNum: number; - aiAppId: string; - extraInfo?: string; - modelType: ModelTypeEnum; - modelApiType: ModelApiTypeEnum; - multiplier: number; - multiplierShow: number; - providerName?: string; - iconUrl?: string; - isPremium: boolean; -} - -// 创建AI模型输入 -export interface AiModelCreateInput { - handlerName: string; - modelId: string; - name: string; - description?: string; - orderNum: number; - aiAppId: string; - extraInfo?: string; - modelType: ModelTypeEnum; - modelApiType: ModelApiTypeEnum; - multiplier: number; - multiplierShow: number; - providerName?: string; - iconUrl?: string; - isPremium: boolean; -} - -// 更新AI模型输入 -export interface AiModelUpdateInput { - id: string; - handlerName: string; - modelId: string; - name: string; - description?: string; - orderNum: number; - aiAppId: string; - extraInfo?: string; - modelType: ModelTypeEnum; - modelApiType: ModelApiTypeEnum; - multiplier: number; - multiplierShow: number; - providerName?: string; - iconUrl?: string; - isPremium: boolean; -} - -// 获取AI模型列表输入 -export interface AiModelGetListInput { - searchKey?: string; - aiAppId?: string; - isPremiumOnly?: boolean; - skipCount?: number; - maxResultCount?: number; -} - -// 分页结果 -export interface PagedResultDto { - items: T[]; - totalCount: number; -} diff --git a/Yi.Ai.Vue3/src/pages/console/channel/index.vue b/Yi.Ai.Vue3/src/pages/console/channel/index.vue deleted file mode 100644 index c780fe70..00000000 --- a/Yi.Ai.Vue3/src/pages/console/channel/index.vue +++ /dev/null @@ -1,548 +0,0 @@ - - - - - diff --git a/Yi.Ai.Vue3/src/pages/console/index.vue b/Yi.Ai.Vue3/src/pages/console/index.vue index 15ae21dd..44aece8f 100644 --- a/Yi.Ai.Vue3/src/pages/console/index.vue +++ b/Yi.Ai.Vue3/src/pages/console/index.vue @@ -19,7 +19,6 @@ const navItems = [ { name: 'daily-task', label: '每日任务(限时)', icon: 'Trophy', path: '/console/daily-task' }, { name: 'invite', label: '每周邀请(限时)', icon: 'Present', path: '/console/invite' }, { name: 'activation', label: '激活码兑换', icon: 'MagicStick', path: '/console/activation' }, - { name: 'channel', label: '渠道商管理', icon: 'Setting', path: '/console/channel' }, ]; // 当前激活的菜单 diff --git a/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts b/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts index 496bb214..b94431ec 100644 --- a/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts +++ b/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts @@ -207,14 +207,6 @@ export const layoutRouter: RouteRecordRaw[] = [ title: '激活码兑换', }, }, - { - path: 'channel', - name: 'consoleChannel', - component: () => import('@/pages/console/channel/index.vue'), - meta: { - title: '渠道商管理', - }, - }, ], }, ], diff --git a/Yi.Ai.Vue3/types/components.d.ts b/Yi.Ai.Vue3/types/components.d.ts index 16d28441..9ef439fb 100644 --- a/Yi.Ai.Vue3/types/components.d.ts +++ b/Yi.Ai.Vue3/types/components.d.ts @@ -25,8 +25,6 @@ declare module 'vue' { ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] ElContainer: typeof import('element-plus/es')['ElContainer'] ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] - ElDescriptions: typeof import('element-plus/es')['ElDescriptions'] - ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem'] ElDialog: typeof import('element-plus/es')['ElDialog'] ElDivider: typeof import('element-plus/es')['ElDivider'] ElDrawer: typeof import('element-plus/es')['ElDrawer'] diff --git a/Yi.Ai.Vue3/types/import_meta.d.ts b/Yi.Ai.Vue3/types/import_meta.d.ts index 8f2a798b..c98d612e 100644 --- a/Yi.Ai.Vue3/types/import_meta.d.ts +++ b/Yi.Ai.Vue3/types/import_meta.d.ts @@ -7,6 +7,7 @@ interface ImportMetaEnv { readonly VITE_WEB_BASE_API: string; readonly VITE_API_URL: string; readonly VITE_FILE_UPLOAD_API: string; + readonly VITE_BUILD_COMPRESS: string; readonly VITE_SSO_SEVER_URL: string; readonly VITE_APP_VERSION: string; } From 77a9a64a410fa7b4f904c98c992edf3ec311a5bf Mon Sep 17 00:00:00 2001 From: Gsh <15170702455@163.com> Date: Wed, 31 Dec 2025 00:59:06 +0800 Subject: [PATCH 4/9] =?UTF-8?q?fix:=20=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=9E=B6=E6=9E=84=E9=87=8D=E6=9E=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layouts/components/ChatAside/index.vue | 138 +----------------- .../Header/components/Collapse.vue | 38 ++--- .../Header/components/CreateChat.vue | 2 + .../pages/chat/layouts/chatDefaul/index.vue | 54 ++++++- .../pages/chat/layouts/chatWithId/index.vue | 62 ++++++-- Yi.Ai.Vue3/src/stores/modules/session.ts | 2 +- 6 files changed, 125 insertions(+), 171 deletions(-) diff --git a/Yi.Ai.Vue3/src/layouts/components/ChatAside/index.vue b/Yi.Ai.Vue3/src/layouts/components/ChatAside/index.vue index c0e8710d..90bc5731 100644 --- a/Yi.Ai.Vue3/src/layouts/components/ChatAside/index.vue +++ b/Yi.Ai.Vue3/src/layouts/components/ChatAside/index.vue @@ -124,141 +124,7 @@ function handleMenuCommand(command: string, item: ConversationItem) { - event.preventDefault(); - // 在折叠状态下触发删除确认 - ElMessageBox.confirm('删除后,聊天记录将不可恢复。', '确定删除对话?', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', - confirmButtonClass: 'el-button--danger', - cancelButtonClass: 'el-button--info', - roundButton: true, - autofocus: false, - }) - .then(() => { - sessionStore.deleteSessions([item.id!]); - nextTick(() => { - if (item.id === active.value) { - sessionStore.createSessionBtn(); - } - }); - }) - .catch(() => { - // 取消删除 - }); -} - -// 折叠状态下点击更多按钮 -function handleCollapsedMenuClick(event: MouseEvent, item: ConversationItem) { - event.stopPropagation(); - - // 创建一个简单的菜单 - ElMessageBox({ - title: '对话操作', - message: ` -
- - -
- `, - showConfirmButton: false, - showCancelButton: false, - dangerouslyUseHTMLString: true, - customClass: 'collapsed-menu-dialog', - closeOnClickModal: true, - closeOnPressEscape: true, - }).then(() => { - // 对话框关闭 - }).catch(() => { - // 对话框关闭 - }); - - // 添加菜单项点击事件 - nextTick(() => { - const menuItems = document.querySelectorAll('.menu-item'); - menuItems.forEach((itemEl) => { - itemEl.addEventListener('click', (e) => { - const action = (e.currentTarget as HTMLElement).dataset.action; - if (action === 'delete') { - ElMessageBox.confirm('删除后,聊天记录将不可恢复。', '确定删除对话?', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', - confirmButtonClass: 'el-button--danger', - cancelButtonClass: 'el-button--info', - roundButton: true, - autofocus: false, - }) - .then(() => { - sessionStore.deleteSessions([item.id!]); - nextTick(() => { - if (item.id === active.value) { - sessionStore.createSessionBtn(); - } - }); - }) - .catch(() => { - // 取消删除 - }); - } - else if (action === 'rename') { - ElMessageBox.prompt('', '编辑对话名称', { - confirmButtonText: '确定', - cancelButtonText: '取消', - inputErrorMessage: '请输入对话名称', - confirmButtonClass: 'el-button--primary', - cancelButtonClass: 'el-button--info', - roundButton: true, - inputValue: item.sessionTitle, - autofocus: false, - inputValidator: (value) => { - return !!value; - }, - }).then(({ value }) => { - sessionStore - .updateSession({ - id: item.id!, - sessionTitle: value, - sessionContent: item.sessionContent, - }) - .then(() => { - ElMessage({ - type: 'success', - message: '修改成功', - }); - nextTick(() => { - if (sessionStore.currentSession?.id === item.id) { - sessionStore.setCurrentSession({ - ...item, - sessionTitle: value, - }); - } - }); - }); - }); - } - - // 关闭菜单对话框 - document.querySelector('.collapsed-menu-dialog .el-message-box__headerbtn')?.dispatchEvent(new Event('click')); - }); - }); - }); + designStore.setIsCollapseConversationList(!designStore.isCollapseConversationList); } @@ -446,7 +312,7 @@ function handleCollapsedMenuClick(event: MouseEvent, item: ConversationItem diff --git a/Yi.Ai.Vue3/src/layouts/components0/Header/components/CreateChat.vue b/Yi.Ai.Vue3/src/layouts/components0/Header/components/CreateChat.vue index 5ec82222..9553e1bf 100644 --- a/Yi.Ai.Vue3/src/layouts/components0/Header/components/CreateChat.vue +++ b/Yi.Ai.Vue3/src/layouts/components0/Header/components/CreateChat.vue @@ -1,5 +1,7 @@ + + + + diff --git a/Yi.Ai.Vue3/src/pages/console/index.vue b/Yi.Ai.Vue3/src/pages/console/index.vue index 44aece8f..15ae21dd 100644 --- a/Yi.Ai.Vue3/src/pages/console/index.vue +++ b/Yi.Ai.Vue3/src/pages/console/index.vue @@ -19,6 +19,7 @@ const navItems = [ { name: 'daily-task', label: '每日任务(限时)', icon: 'Trophy', path: '/console/daily-task' }, { name: 'invite', label: '每周邀请(限时)', icon: 'Present', path: '/console/invite' }, { name: 'activation', label: '激活码兑换', icon: 'MagicStick', path: '/console/activation' }, + { name: 'channel', label: '渠道商管理', icon: 'Setting', path: '/console/channel' }, ]; // 当前激活的菜单 diff --git a/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts b/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts index b94431ec..496bb214 100644 --- a/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts +++ b/Yi.Ai.Vue3/src/routers/modules/staticRouter.ts @@ -207,6 +207,14 @@ export const layoutRouter: RouteRecordRaw[] = [ title: '激活码兑换', }, }, + { + path: 'channel', + name: 'consoleChannel', + component: () => import('@/pages/console/channel/index.vue'), + meta: { + title: '渠道商管理', + }, + }, ], }, ], diff --git a/Yi.Ai.Vue3/types/components.d.ts b/Yi.Ai.Vue3/types/components.d.ts index 9ef439fb..16d28441 100644 --- a/Yi.Ai.Vue3/types/components.d.ts +++ b/Yi.Ai.Vue3/types/components.d.ts @@ -25,6 +25,8 @@ declare module 'vue' { ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] ElContainer: typeof import('element-plus/es')['ElContainer'] ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] + ElDescriptions: typeof import('element-plus/es')['ElDescriptions'] + ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem'] ElDialog: typeof import('element-plus/es')['ElDialog'] ElDivider: typeof import('element-plus/es')['ElDivider'] ElDrawer: typeof import('element-plus/es')['ElDrawer'] diff --git a/Yi.Ai.Vue3/types/import_meta.d.ts b/Yi.Ai.Vue3/types/import_meta.d.ts index c98d612e..8f2a798b 100644 --- a/Yi.Ai.Vue3/types/import_meta.d.ts +++ b/Yi.Ai.Vue3/types/import_meta.d.ts @@ -7,7 +7,6 @@ interface ImportMetaEnv { readonly VITE_WEB_BASE_API: string; readonly VITE_API_URL: string; readonly VITE_FILE_UPLOAD_API: string; - readonly VITE_BUILD_COMPRESS: string; readonly VITE_SSO_SEVER_URL: string; readonly VITE_APP_VERSION: string; } From 953fbc043b4a6e1e25b2a0bae5a448cff22047a6 Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Thu, 1 Jan 2026 18:25:43 +0800 Subject: [PATCH 7/9] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E6=B8=A0?= =?UTF-8?q?=E9=81=93=E5=95=86=E7=AE=A1=E7=90=86=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/{ => Activities}/ActivationCodeService.cs | 0 Yi.Ai.Vue3/src/pages/console/channel/index.vue | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/{ => Activities}/ActivationCodeService.cs (100%) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ActivationCodeService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Activities/ActivationCodeService.cs similarity index 100% rename from Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ActivationCodeService.cs rename to Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Activities/ActivationCodeService.cs diff --git a/Yi.Ai.Vue3/src/pages/console/channel/index.vue b/Yi.Ai.Vue3/src/pages/console/channel/index.vue index c780fe70..b177512a 100644 --- a/Yi.Ai.Vue3/src/pages/console/channel/index.vue +++ b/Yi.Ai.Vue3/src/pages/console/channel/index.vue @@ -338,6 +338,7 @@ onMounted(() => { + @@ -450,8 +451,7 @@ onMounted(() => {