mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-03 00:00:58 +08:00
Compare commits
107 Commits
ai-agent
...
ai-hub-dar
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ada6360d4 | ||
|
|
21b7ef4d74 | ||
|
|
9a87b41027 | ||
|
|
886cc3155f | ||
|
|
020ad797f2 | ||
|
|
1d5bca773f | ||
|
|
6b86957556 | ||
|
|
caa90cc227 | ||
|
|
87c93534a5 | ||
|
|
b8c79ac61c | ||
|
|
2db8d6e699 | ||
|
|
0983837ff7 | ||
|
|
efa948154f | ||
|
|
e8c1111cbc | ||
|
|
c9c92dcf97 | ||
|
|
f2c2c60127 | ||
|
|
d280cc6d35 | ||
|
|
a1e38234a7 | ||
|
|
ace5a9a1ec | ||
|
|
4ce77ececc | ||
|
|
be9442c113 | ||
|
|
5895f9e794 | ||
|
|
b0d1820919 | ||
|
|
8b183e289c | ||
|
|
09ecddb552 | ||
|
|
127639c20e | ||
|
|
9a0dc6f089 | ||
|
|
0c8f01c00a | ||
|
|
c2f074cb08 | ||
|
|
6b6ddcf550 | ||
|
|
d9f5f1f050 | ||
|
|
7ed7201d10 | ||
|
|
a1ddd1c3e2 | ||
|
|
4800543a77 | ||
|
|
4090046946 | ||
|
|
3a19c75ca1 | ||
|
|
a67af0485e | ||
|
|
5de968f6c7 | ||
|
|
1edb92f6e8 | ||
|
|
2b9bbca400 | ||
|
|
3bd1a977f7 | ||
|
|
d2b5704294 | ||
|
|
611c5ce59a | ||
|
|
fc61b67fc0 | ||
|
|
a2da4c36fe | ||
|
|
5e37859157 | ||
|
|
6f316d3e51 | ||
|
|
53d70ef9d7 | ||
|
|
a9a9e45b7c | ||
|
|
629012d32a | ||
|
|
5f2133eb50 | ||
|
|
ad85890907 | ||
|
|
87518af562 | ||
|
|
62b26bc2a4 | ||
|
|
f237137791 | ||
|
|
0d4d847e08 | ||
|
|
12f1854d31 | ||
|
|
73f5d43ada | ||
|
|
551122de10 | ||
|
|
d092254822 | ||
|
|
1027006e63 | ||
|
|
2544c01e9d | ||
|
|
2f1f25ca37 | ||
|
|
5489f33d54 | ||
|
|
6665d2fb2e | ||
|
|
b5ff6c141c | ||
|
|
f1e8b66689 | ||
|
|
c727aeed99 | ||
|
|
40aa47bb1e | ||
|
|
40234343ff | ||
|
|
00a9bd00e5 | ||
|
|
55c17211d8 | ||
|
|
db7dc0e9a7 | ||
|
|
1727107190 | ||
|
|
e680ac4cac | ||
|
|
6053899516 | ||
|
|
5157eac35c | ||
|
|
537104037b | ||
|
|
29c1768ded | ||
|
|
b4a97e8b09 | ||
|
|
6101ea46d3 | ||
|
|
cad145f067 | ||
|
|
9d8f8b3125 | ||
|
|
4f70356a5c | ||
|
|
69a8b47245 | ||
|
|
88225a97b8 | ||
|
|
c697d12f8b | ||
|
|
7bb8f52813 | ||
|
|
b84f385d2d | ||
|
|
450e023b3b | ||
|
|
9f3b9fc513 | ||
|
|
9721b8bd74 | ||
|
|
bd30a40a6f | ||
|
|
9ec9ace8e2 | ||
|
|
a437d55f9f | ||
|
|
d75a734bc1 | ||
|
|
9c058e9545 | ||
|
|
accbaf3ecb | ||
|
|
f8f2d7568c | ||
|
|
158226601b | ||
|
|
63aa8d9536 | ||
|
|
0147457329 | ||
|
|
1d47b26d0d | ||
|
|
cc1bc6dd82 | ||
|
|
922596c128 | ||
|
|
f7ebe44fb6 | ||
|
|
d7f4e49c2a |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -280,3 +280,4 @@ database_backup
|
||||
package-lock.json
|
||||
|
||||
.claude
|
||||
components.d.ts
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Channel;
|
||||
|
||||
/// <summary>
|
||||
/// AI应用快捷配置DTO
|
||||
/// </summary>
|
||||
public class AiAppShortcutDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用ID
|
||||
/// </summary>
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 应用名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 应用终结点
|
||||
/// </summary>
|
||||
public string Endpoint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 额外URL
|
||||
/// </summary>
|
||||
public string? ExtraUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 应用Key
|
||||
/// </summary>
|
||||
public string ApiKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; }
|
||||
}
|
||||
@@ -93,4 +93,9 @@ public class AiModelCreateInput
|
||||
/// 是否为尊享模型
|
||||
/// </summary>
|
||||
public bool IsPremium { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
|
||||
@@ -81,4 +81,9 @@ public class AiModelDto
|
||||
/// 是否为尊享模型
|
||||
/// </summary>
|
||||
public bool IsPremium { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
|
||||
@@ -99,4 +99,9 @@ public class AiModelUpdateInput
|
||||
/// 是否为尊享模型
|
||||
/// </summary>
|
||||
public bool IsPremium { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.DailyTask;
|
||||
|
||||
/// <summary>
|
||||
/// 每日任务配置缓存DTO
|
||||
/// </summary>
|
||||
public class DailyTaskConfigCacheDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务配置列表
|
||||
/// </summary>
|
||||
public List<DailyTaskConfigItem> Tasks { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 每日任务配置项
|
||||
/// </summary>
|
||||
public class DailyTaskConfigItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务等级
|
||||
/// </summary>
|
||||
public int Level { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 需要消耗的Token数量
|
||||
/// </summary>
|
||||
public long RequiredTokens { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 奖励的Token数量
|
||||
/// </summary>
|
||||
public long RewardTokens { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务名称
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 任务描述
|
||||
/// </summary>
|
||||
public string Description { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos;
|
||||
|
||||
public class ModelGetListOutput
|
||||
{
|
||||
@@ -31,4 +33,23 @@ public class ModelGetListOutput
|
||||
/// 是否为尊享包
|
||||
/// </summary>
|
||||
public bool IsPremiumPackage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否免费模型
|
||||
/// </summary>
|
||||
public bool IsFree { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模型Api类型,现支持同一个模型id,多种接口格式
|
||||
/// </summary>
|
||||
public ModelApiTypeEnum ModelApiType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模型图标URL
|
||||
/// </summary>
|
||||
public string? IconUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 供应商分组名称(如:OpenAI、Anthropic、Google等)
|
||||
/// </summary>
|
||||
public string? ProviderName { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Yi.Framework.Ddd.Application.Contracts;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Recharge;
|
||||
|
||||
/// <summary>
|
||||
/// 充值记录查询输入
|
||||
/// </summary>
|
||||
public class RechargeGetListInput : PagedAllResultRequestDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否免费(充值金额等于0)
|
||||
/// </summary>
|
||||
public bool? IsFree { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 充值金额最小值
|
||||
/// </summary>
|
||||
public decimal? MinRechargeAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 充值金额最大值
|
||||
/// </summary>
|
||||
public decimal? MaxRechargeAmount { get; set; }
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos;
|
||||
|
||||
public class SessionCreateAndUpdateInput
|
||||
{
|
||||
public string SessionTitle { get; set; }
|
||||
public string SessionContent { get; set; }
|
||||
public string? Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 会话类型
|
||||
/// </summary>
|
||||
public SessionTypeEnum SessionType { get; set; } = SessionTypeEnum.Chat;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos;
|
||||
|
||||
@@ -7,4 +8,9 @@ public class SessionDto : FullAuditedEntityDto<Guid>
|
||||
public string SessionTitle { get; set; }
|
||||
public string SessionContent { get; set; }
|
||||
public string Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 会话类型
|
||||
/// </summary>
|
||||
public SessionTypeEnum SessionType { get; set; }
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
using Yi.Framework.Ddd.Application.Contracts;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
using Yi.Framework.Ddd.Application.Contracts;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos;
|
||||
|
||||
public class SessionGetListInput:PagedAllResultRequestDto
|
||||
public class SessionGetListInput : PagedAllResultRequestDto
|
||||
{
|
||||
public string? SessionTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 会话类型
|
||||
/// </summary>
|
||||
public SessionTypeEnum? SessionType { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.SystemStatistics;
|
||||
|
||||
/// <summary>
|
||||
/// 模型Token统计DTO
|
||||
/// </summary>
|
||||
public class ModelTokenStatisticsDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 模型ID
|
||||
/// </summary>
|
||||
public string ModelId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模型名称
|
||||
/// </summary>
|
||||
public string ModelName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Token消耗量
|
||||
/// </summary>
|
||||
public long Tokens { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Token消耗量(万)
|
||||
/// </summary>
|
||||
public decimal TokensInWan { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 使用次数
|
||||
/// </summary>
|
||||
public long Count { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 成本(RMB)
|
||||
/// </summary>
|
||||
public decimal Cost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 1亿Token成本(RMB)
|
||||
/// </summary>
|
||||
public decimal CostPerHundredMillion { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.SystemStatistics;
|
||||
|
||||
/// <summary>
|
||||
/// 利润统计输入
|
||||
/// </summary>
|
||||
public class ProfitStatisticsInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前成本(RMB)
|
||||
/// </summary>
|
||||
public decimal CurrentCost { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.SystemStatistics;
|
||||
|
||||
/// <summary>
|
||||
/// 利润统计输出
|
||||
/// </summary>
|
||||
public class ProfitStatisticsOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 日期
|
||||
/// </summary>
|
||||
public string Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 尊享包已消耗Token数(单位:个)
|
||||
/// </summary>
|
||||
public long TotalUsedTokens { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 尊享包已消耗Token数(单位:亿)
|
||||
/// </summary>
|
||||
public decimal TotalUsedTokensInHundredMillion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 尊享包剩余库存Token数(单位:个)
|
||||
/// </summary>
|
||||
public long TotalRemainingTokens { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 尊享包剩余库存Token数(单位:亿)
|
||||
/// </summary>
|
||||
public decimal TotalRemainingTokensInHundredMillion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前成本(RMB)
|
||||
/// </summary>
|
||||
public decimal CurrentCost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 1亿Token成本(RMB)
|
||||
/// </summary>
|
||||
public decimal CostPerHundredMillion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总成本(RMB)
|
||||
/// </summary>
|
||||
public decimal TotalCost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总收益(RMB)
|
||||
/// </summary>
|
||||
public decimal TotalRevenue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 利润率(%)
|
||||
/// </summary>
|
||||
public decimal ProfitRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 按200售价计算的成本(RMB)
|
||||
/// </summary>
|
||||
public decimal CostAt200Price { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.SystemStatistics;
|
||||
|
||||
/// <summary>
|
||||
/// Token统计输入
|
||||
/// </summary>
|
||||
public class TokenStatisticsInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 指定日期(当天零点)
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.SystemStatistics;
|
||||
|
||||
/// <summary>
|
||||
/// Token统计输出
|
||||
/// </summary>
|
||||
public class TokenStatisticsOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 日期
|
||||
/// </summary>
|
||||
public string Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模型统计列表
|
||||
/// </summary>
|
||||
public List<ModelTokenStatisticsDto> ModelStatistics { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.UsageStatistics;
|
||||
|
||||
/// <summary>
|
||||
/// 每小时Token使用量统计DTO(柱状图)
|
||||
/// </summary>
|
||||
public class HourlyTokenUsageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 小时时间点
|
||||
/// </summary>
|
||||
public DateTime Hour { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 该小时总Token消耗量
|
||||
/// </summary>
|
||||
public long TotalTokens { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 各模型Token消耗明细
|
||||
/// </summary>
|
||||
public List<ModelTokenBreakdownDto> ModelBreakdown { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.UsageStatistics;
|
||||
|
||||
/// <summary>
|
||||
/// 模型今日使用量统计DTO(卡片列表)
|
||||
/// </summary>
|
||||
public class ModelTodayUsageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 模型ID
|
||||
/// </summary>
|
||||
public string ModelId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 今日使用次数
|
||||
/// </summary>
|
||||
public int UsageCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 今日消耗总Token数
|
||||
/// </summary>
|
||||
public long TotalTokens { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模型图标URL
|
||||
/// </summary>
|
||||
public string? IconUrl { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.UsageStatistics;
|
||||
|
||||
/// <summary>
|
||||
/// 模型Token堆叠数据DTO(用于柱状图)
|
||||
/// </summary>
|
||||
public class ModelTokenBreakdownDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 模型ID
|
||||
/// </summary>
|
||||
public string ModelId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Token消耗量
|
||||
/// </summary>
|
||||
public long Tokens { get; set; }
|
||||
}
|
||||
@@ -83,4 +83,14 @@ public interface IChannelService
|
||||
Task DeleteModelAsync(Guid id);
|
||||
|
||||
#endregion
|
||||
|
||||
#region AI应用快捷配置
|
||||
|
||||
/// <summary>
|
||||
/// 获取AI应用快捷配置列表
|
||||
/// </summary>
|
||||
/// <returns>快捷配置列表</returns>
|
||||
Task<List<AiAppShortcutDto>> GetAppShortcutListAsync();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
using Yi.Framework.AiHub.Application.Contracts.Dtos.Recharge;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Yi.Framework.AiHub.Application.Contracts.Dtos.Recharge;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.IServices;
|
||||
|
||||
public interface IRechargeService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询已登录的账户充值记录(分页)
|
||||
/// </summary>
|
||||
Task<PagedResultDto<RechargeGetListOutput>> GetListByAccountAsync(RechargeGetListInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 移除用户vip及角色
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using Yi.Framework.AiHub.Application.Contracts.Dtos.SystemStatistics;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.IServices;
|
||||
|
||||
/// <summary>
|
||||
/// 系统使用量统计服务接口
|
||||
/// </summary>
|
||||
public interface ISystemUsageStatisticsService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取利润统计数据
|
||||
/// </summary>
|
||||
Task<ProfitStatisticsOutput> GetProfitStatisticsAsync(ProfitStatisticsInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定日期各模型Token统计
|
||||
/// </summary>
|
||||
Task<TokenStatisticsOutput> GetTokenStatisticsAsync(TokenStatisticsInput input);
|
||||
}
|
||||
@@ -24,4 +24,16 @@ public interface IUsageStatisticsService
|
||||
/// </summary>
|
||||
/// <returns>尊享服务Token用量统计</returns>
|
||||
Task<PremiumTokenUsageDto> GetPremiumTokenUsageAsync();
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户近24小时每小时Token消耗统计(柱状图)
|
||||
/// </summary>
|
||||
/// <returns>每小时Token使用量列表,包含各模型堆叠数据</returns>
|
||||
Task<List<HourlyTokenUsageDto>> GetLast24HoursTokenUsageAsync(UsageStatisticsGetInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户今日各模型使用量统计(卡片列表)
|
||||
/// </summary>
|
||||
/// <returns>模型今日使用量列表,包含使用次数和总Token</returns>
|
||||
Task<List<ModelTodayUsageDto>> GetTodayModelUsageAsync(UsageStatisticsGetInput input);
|
||||
}
|
||||
@@ -64,6 +64,13 @@ public class ImageGenerationJob : AsyncBackgroundJob<ImageGenerationJobArgs>, IT
|
||||
{
|
||||
contents = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
role = "user", parts = new List<object>
|
||||
{
|
||||
new { text = "我只要图片,直接生成图片,不要询问我" }
|
||||
}
|
||||
},
|
||||
new { role = "user", parts }
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Medallion.Threading;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Caching;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.AiHub.Application.Contracts.Dtos.DailyTask;
|
||||
using Yi.Framework.AiHub.Domain.Entities;
|
||||
@@ -25,27 +27,33 @@ public class DailyTaskService : ApplicationService
|
||||
private readonly ISqlSugarRepository<MessageAggregateRoot> _messageRepository;
|
||||
private readonly ISqlSugarRepository<PremiumPackageAggregateRoot> _premiumPackageRepository;
|
||||
private readonly ILogger<DailyTaskService> _logger;
|
||||
private readonly IDistributedCache<DailyTaskConfigCacheDto> _taskConfigCache;
|
||||
private IDistributedLockProvider DistributedLock => LazyServiceProvider.LazyGetRequiredService<IDistributedLockProvider>();
|
||||
private readonly ISqlSugarRepository<AiModelEntity> _aiModelRepository;
|
||||
// 任务配置
|
||||
private readonly Dictionary<int, (long RequiredTokens, long RewardTokens, string Name, string Description)>
|
||||
_taskConfigs = new()
|
||||
{
|
||||
{ 1, (10000000, 1000000, "尊享包1000w token任务", "累积使用尊享包 1000w token") }, // 1000w消耗 -> 100w奖励
|
||||
{ 2, (30000000, 2000000, "尊享包3000w token任务", "累积使用尊享包 3000w token") } // 3000w消耗 -> 200w奖励
|
||||
};
|
||||
|
||||
private const string TaskConfigCacheKey = "AiHub:DailyTaskConfig";
|
||||
|
||||
// 默认任务配置(当Redis中没有配置时使用)
|
||||
private static readonly List<DailyTaskConfigItem> DefaultTaskConfigs = new()
|
||||
{
|
||||
new DailyTaskConfigItem { Level = 1, RequiredTokens = 10000000, RewardTokens = 1000000, Name = "尊享包1000w token任务", Description = "累积使用尊享包 1000w token" },
|
||||
new DailyTaskConfigItem { Level = 2, RequiredTokens = 30000000, RewardTokens = 2000000, Name = "尊享包3000w token任务", Description = "累积使用尊享包 3000w token" }
|
||||
};
|
||||
|
||||
public DailyTaskService(
|
||||
ISqlSugarRepository<DailyTaskRewardRecordAggregateRoot> dailyTaskRepository,
|
||||
ISqlSugarRepository<MessageAggregateRoot> messageRepository,
|
||||
ISqlSugarRepository<PremiumPackageAggregateRoot> premiumPackageRepository,
|
||||
ILogger<DailyTaskService> logger, ISqlSugarRepository<AiModelEntity> aiModelRepository)
|
||||
ILogger<DailyTaskService> logger,
|
||||
ISqlSugarRepository<AiModelEntity> aiModelRepository,
|
||||
IDistributedCache<DailyTaskConfigCacheDto> taskConfigCache)
|
||||
{
|
||||
_dailyTaskRepository = dailyTaskRepository;
|
||||
_messageRepository = messageRepository;
|
||||
_premiumPackageRepository = premiumPackageRepository;
|
||||
_logger = logger;
|
||||
_aiModelRepository = aiModelRepository;
|
||||
_taskConfigCache = taskConfigCache;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,20 +65,23 @@ public class DailyTaskService : ApplicationService
|
||||
var userId = CurrentUser.GetId();
|
||||
var today = DateTime.Today;
|
||||
|
||||
// 1. 统计今日尊享包Token消耗量
|
||||
// 1. 获取任务配置
|
||||
var taskConfigs = await GetTaskConfigsAsync();
|
||||
|
||||
// 2. 统计今日尊享包Token消耗量
|
||||
var todayConsumed = await GetTodayPremiumTokenConsumptionAsync(userId, today);
|
||||
|
||||
// 2. 查询今日已领取的任务
|
||||
// 3. 查询今日已领取的任务
|
||||
var claimedTasks = await _dailyTaskRepository._DbQueryable
|
||||
.Where(x => x.UserId == userId && x.TaskDate == today)
|
||||
.Select(x => new { x.TaskLevel, x.IsRewarded })
|
||||
.ToListAsync();
|
||||
|
||||
// 3. 构建任务列表
|
||||
// 4. 构建任务列表
|
||||
var tasks = new List<DailyTaskItem>();
|
||||
foreach (var (level, config) in _taskConfigs)
|
||||
foreach (var config in taskConfigs)
|
||||
{
|
||||
var claimed = claimedTasks.FirstOrDefault(x => x.TaskLevel == level);
|
||||
var claimed = claimedTasks.FirstOrDefault(x => x.TaskLevel == config.Level);
|
||||
int status;
|
||||
|
||||
if (claimed != null && claimed.IsRewarded)
|
||||
@@ -92,7 +103,7 @@ public class DailyTaskService : ApplicationService
|
||||
|
||||
tasks.Add(new DailyTaskItem
|
||||
{
|
||||
Level = level,
|
||||
Level = config.Level,
|
||||
Name = config.Name,
|
||||
Description = config.Description,
|
||||
RequiredTokens = config.RequiredTokens,
|
||||
@@ -120,17 +131,20 @@ public class DailyTaskService : ApplicationService
|
||||
//自旋等待,防抖
|
||||
await using var handle =
|
||||
await DistributedLock.AcquireLockAsync($"Yi:AiHub:ClaimTaskRewardLock:{userId}");
|
||||
|
||||
|
||||
|
||||
var today = DateTime.Today;
|
||||
|
||||
// 1. 验证任务等级
|
||||
if (!_taskConfigs.TryGetValue(input.TaskLevel, out var taskConfig))
|
||||
// 1. 获取任务配置
|
||||
var taskConfigs = await GetTaskConfigsAsync();
|
||||
var taskConfig = taskConfigs.FirstOrDefault(x => x.Level == input.TaskLevel);
|
||||
|
||||
// 2. 验证任务等级
|
||||
if (taskConfig == null)
|
||||
{
|
||||
throw new UserFriendlyException($"无效的任务等级: {input.TaskLevel}");
|
||||
}
|
||||
|
||||
// 2. 检查是否已领取
|
||||
// 3. 检查是否已领取
|
||||
var existingRecord = await _dailyTaskRepository._DbQueryable
|
||||
.Where(x => x.UserId == userId && x.TaskDate == today && x.TaskLevel == input.TaskLevel)
|
||||
.FirstAsync();
|
||||
@@ -140,7 +154,7 @@ public class DailyTaskService : ApplicationService
|
||||
throw new UserFriendlyException("今日该任务奖励已领取,请明天再来!");
|
||||
}
|
||||
|
||||
// 3. 验证今日Token消耗是否达标
|
||||
// 4. 验证今日Token消耗是否达标
|
||||
var todayConsumed = await GetTodayPremiumTokenConsumptionAsync(userId, today);
|
||||
if (todayConsumed < taskConfig.RequiredTokens)
|
||||
{
|
||||
@@ -148,18 +162,17 @@ public class DailyTaskService : ApplicationService
|
||||
$"Token消耗未达标!需要 {taskConfig.RequiredTokens / 10000}w,当前 {todayConsumed / 10000}w");
|
||||
}
|
||||
|
||||
// 4. 创建奖励包(使用 PremiumPackageManager)
|
||||
|
||||
// 5. 创建奖励包
|
||||
var premiumPackage =
|
||||
new PremiumPackageAggregateRoot(userId, taskConfig.RewardTokens, $"每日任务:{taskConfig.Name}")
|
||||
{
|
||||
PurchaseAmount = 0, // 奖励不需要付费
|
||||
PurchaseAmount = 0,
|
||||
Remark = $"{today:yyyy-MM-dd} 每日任务奖励"
|
||||
};
|
||||
|
||||
await _premiumPackageRepository.InsertAsync(premiumPackage);
|
||||
|
||||
// 5. 记录领取记录
|
||||
// 6. 记录领取记录
|
||||
var record = new DailyTaskRewardRecordAggregateRoot(userId, input.TaskLevel, today, taskConfig.RewardTokens)
|
||||
{
|
||||
Remark = $"完成任务{input.TaskLevel},名称:{taskConfig.Name},消耗 {todayConsumed / 10000}w token"
|
||||
@@ -197,4 +210,21 @@ public class DailyTaskService : ApplicationService
|
||||
|
||||
return totalTokens;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从Redis获取任务配置,如果不存在则写入默认配置
|
||||
/// </summary>
|
||||
private async Task<List<DailyTaskConfigItem>> GetTaskConfigsAsync()
|
||||
{
|
||||
var cacheData = await _taskConfigCache.GetOrAddAsync(
|
||||
TaskConfigCacheKey,
|
||||
() => Task.FromResult(new DailyTaskConfigCacheDto { Tasks = DefaultTaskConfigs }),
|
||||
() => new DistributedCacheEntryOptions
|
||||
{
|
||||
// 不设置过期时间,永久缓存,需要手动更新
|
||||
}
|
||||
);
|
||||
|
||||
return cacheData?.Tasks ?? DefaultTaskConfigs;
|
||||
}
|
||||
}
|
||||
@@ -81,162 +81,4 @@ public class AiAccountService : ApplicationService
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取利润统计数据
|
||||
/// </summary>
|
||||
/// <param name="currentCost">当前成本(RMB)</param>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[HttpGet("account/profit-statistics")]
|
||||
public async Task<string> GetProfitStatisticsAsync([FromQuery] decimal currentCost)
|
||||
{
|
||||
if (CurrentUser.UserName != "Guo" && CurrentUser.UserName != "cc")
|
||||
{
|
||||
throw new UserFriendlyException("您暂无权限访问");
|
||||
}
|
||||
|
||||
// 1. 获取尊享包总消耗和剩余库存
|
||||
var premiumPackages = await _premiumPackageRepository._DbQueryable.ToListAsync();
|
||||
long totalUsedTokens = premiumPackages.Sum(p => p.UsedTokens);
|
||||
long totalRemainingTokens = premiumPackages.Sum(p => p.RemainingTokens);
|
||||
|
||||
// 2. 计算1亿Token成本
|
||||
decimal costPerHundredMillion = totalUsedTokens > 0
|
||||
? currentCost / (totalUsedTokens / 100000000m)
|
||||
: 0;
|
||||
|
||||
// 3. 计算总成本(剩余+已使用的总成本)
|
||||
long totalTokens = totalUsedTokens + totalRemainingTokens;
|
||||
decimal totalCost = totalTokens > 0
|
||||
? (totalTokens / 100000000m) * costPerHundredMillion
|
||||
: 0;
|
||||
|
||||
// 4. 获取总收益(RechargeType=PremiumPackage的充值金额总和)
|
||||
decimal totalRevenue = await _rechargeRepository._DbQueryable
|
||||
.Where(x => x.RechargeType == Domain.Shared.Enums.RechargeTypeEnum.PremiumPackage)
|
||||
.SumAsync(x => x.RechargeAmount);
|
||||
|
||||
// 5. 计算利润率
|
||||
decimal profitRate = totalCost > 0
|
||||
? (totalRevenue / totalCost - 1) * 100
|
||||
: 0;
|
||||
|
||||
// 6. 按200售价计算成本
|
||||
decimal costAt200Price = totalRevenue > 0
|
||||
? (totalCost / totalRevenue) * 200
|
||||
: 0;
|
||||
|
||||
// 7. 格式化输出
|
||||
var today = DateTime.Now;
|
||||
string dayOfWeek = today.ToString("dddd", new System.Globalization.CultureInfo("zh-CN"));
|
||||
string weekDay = dayOfWeek switch
|
||||
{
|
||||
"星期一" => "周1",
|
||||
"星期二" => "周2",
|
||||
"星期三" => "周3",
|
||||
"星期四" => "周4",
|
||||
"星期五" => "周5",
|
||||
"星期六" => "周6",
|
||||
"星期日" => "周日",
|
||||
_ => dayOfWeek
|
||||
};
|
||||
|
||||
var result = $@"{today:M月d日} {weekDay}
|
||||
尊享包已消耗({totalUsedTokens / 100000000m:F2}亿){totalUsedTokens}
|
||||
尊享包剩余库存({totalRemainingTokens / 100000000m:F2}亿){totalRemainingTokens}
|
||||
当前成本:{currentCost:F2}RMB
|
||||
1亿Token成本:{costPerHundredMillion:F2} RMB=1亿 Token
|
||||
总成本:{totalCost:F2} RMB
|
||||
总收益:{totalRevenue:F2}RMB
|
||||
利润率: {profitRate:F1}%
|
||||
按200售价来算,成本在{costAt200Price:F2}";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public class TokenStatisticsInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 指定日期(当天零点)
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模型Id -> 1亿Token成本(RMB)
|
||||
/// </summary>
|
||||
public Dictionary<string, decimal> ModelCosts { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定日期各模型Token统计
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[HttpPost("account/token-statistics")]
|
||||
public async Task<string> GetTokenStatisticsAsync([FromBody] TokenStatisticsInput input)
|
||||
{
|
||||
if (CurrentUser.UserName != "Guo" && CurrentUser.UserName != "cc")
|
||||
{
|
||||
throw new UserFriendlyException("您暂无权限访问");
|
||||
}
|
||||
|
||||
if (input.ModelCosts is null || input.ModelCosts.Count == 0)
|
||||
{
|
||||
throw new UserFriendlyException("请提供模型成本配置");
|
||||
}
|
||||
|
||||
var day = input.Date.Date;
|
||||
var nextDay = day.AddDays(1);
|
||||
var modelIds = input.ModelCosts.Keys.ToList();
|
||||
|
||||
var modelStats = await _messageRepository._DbQueryable
|
||||
.Where(x => modelIds.Contains(x.ModelId))
|
||||
.Where(x => x.CreationTime >= day && x.CreationTime < nextDay)
|
||||
.Where(x => x.Role == "system")
|
||||
.GroupBy(x => x.ModelId)
|
||||
.Select(x => new
|
||||
{
|
||||
ModelId = x.ModelId,
|
||||
Tokens = SqlFunc.AggregateSum(x.TokenUsage.TotalTokenCount),
|
||||
Count = SqlFunc.AggregateCount(x.Id)
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var modelStatDict = modelStats.ToDictionary(x => x.ModelId, x => x);
|
||||
|
||||
string weekDay = day.ToString("dddd", new CultureInfo("zh-CN")) switch
|
||||
{
|
||||
"星期一" => "周1",
|
||||
"星期二" => "周2",
|
||||
"星期三" => "周3",
|
||||
"星期四" => "周4",
|
||||
"星期五" => "周5",
|
||||
"星期六" => "周6",
|
||||
"星期日" => "周日",
|
||||
_ => day.ToString("dddd", new CultureInfo("zh-CN"))
|
||||
};
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"{day:M月d日} {weekDay}");
|
||||
|
||||
foreach (var kvp in input.ModelCosts)
|
||||
{
|
||||
var modelId = kvp.Key;
|
||||
var cost = kvp.Value;
|
||||
|
||||
modelStatDict.TryGetValue(modelId, out var stat);
|
||||
long tokens = stat?.Tokens ?? 0;
|
||||
long count = stat?.Count ?? 0;
|
||||
|
||||
decimal costPerHundredMillion = tokens > 0
|
||||
? cost / (tokens / 100000000m)
|
||||
: 0;
|
||||
|
||||
decimal tokensInWan = tokens / 10000m;
|
||||
|
||||
sb.AppendLine();
|
||||
sb.AppendLine($"{modelId} 成本:【{cost:F2}RMB】 次数:【{count}次】 token:【{tokensInWan:F0}w】 1亿token成本:【{costPerHundredMillion:F2}RMB】");
|
||||
}
|
||||
|
||||
return sb.ToString().TrimEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,13 +53,23 @@ public class AnnouncementService : ApplicationService, IAnnouncementService
|
||||
/// </summary>
|
||||
private async Task<AnnouncementCacheDto> LoadAnnouncementDataAsync()
|
||||
{
|
||||
// 查询所有公告日志,按日期降序排列
|
||||
// 1️⃣ 一次性查出全部公告(不排序)
|
||||
var logs = await _announcementRepository._DbQueryable
|
||||
.OrderByDescending(x => x.StartTime)
|
||||
.ToListAsync();
|
||||
|
||||
var now = DateTime.Now;
|
||||
|
||||
// 2️⃣ 内存中处理排序
|
||||
var orderedLogs = logs
|
||||
.OrderByDescending(x =>
|
||||
x.StartTime <= now &&
|
||||
(x.EndTime == null || x.EndTime >= now)
|
||||
)
|
||||
.ThenByDescending(x => x.StartTime)
|
||||
.ToList();
|
||||
|
||||
// 转换为 DTO
|
||||
var logDtos = logs.Adapt<List<AnnouncementLogDto>>();
|
||||
var logDtos = orderedLogs.Adapt<List<AnnouncementLogDto>>();
|
||||
return new AnnouncementCacheDto
|
||||
{
|
||||
Logs = logDtos
|
||||
|
||||
@@ -19,13 +19,16 @@ public class ChannelService : ApplicationService, IChannelService
|
||||
{
|
||||
private readonly ISqlSugarRepository<AiAppAggregateRoot, Guid> _appRepository;
|
||||
private readonly ISqlSugarRepository<AiModelEntity, Guid> _modelRepository;
|
||||
private readonly ISqlSugarRepository<AiAppShortcutAggregateRoot, Guid> _appShortcutRepository;
|
||||
|
||||
public ChannelService(
|
||||
ISqlSugarRepository<AiAppAggregateRoot, Guid> appRepository,
|
||||
ISqlSugarRepository<AiModelEntity, Guid> modelRepository)
|
||||
ISqlSugarRepository<AiModelEntity, Guid> modelRepository,
|
||||
ISqlSugarRepository<AiAppShortcutAggregateRoot, Guid> appShortcutRepository)
|
||||
{
|
||||
_appRepository = appRepository;
|
||||
_modelRepository = modelRepository;
|
||||
_appShortcutRepository = appShortcutRepository;
|
||||
}
|
||||
|
||||
#region AI应用管理
|
||||
@@ -181,6 +184,7 @@ public class ChannelService : ApplicationService, IChannelService
|
||||
ProviderName = input.ProviderName,
|
||||
IconUrl = input.IconUrl,
|
||||
IsPremium = input.IsPremium,
|
||||
IsEnabled = input.IsEnabled,
|
||||
IsDeleted = false
|
||||
};
|
||||
|
||||
@@ -222,6 +226,7 @@ public class ChannelService : ApplicationService, IChannelService
|
||||
entity.ProviderName = input.ProviderName;
|
||||
entity.IconUrl = input.IconUrl;
|
||||
entity.IsPremium = input.IsPremium;
|
||||
entity.IsEnabled = input.IsEnabled;
|
||||
|
||||
await _modelRepository.UpdateAsync(entity);
|
||||
return entity.Adapt<AiModelDto>();
|
||||
@@ -237,4 +242,22 @@ public class ChannelService : ApplicationService, IChannelService
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AI应用快捷配置
|
||||
|
||||
/// <summary>
|
||||
/// 获取AI应用快捷配置列表
|
||||
/// </summary>
|
||||
[HttpGet("channel/app-shortcut")]
|
||||
public async Task<List<AiAppShortcutDto>> GetAppShortcutListAsync()
|
||||
{
|
||||
var entities = await _appShortcutRepository._DbQueryable
|
||||
.OrderBy(x => x.OrderNum)
|
||||
.OrderByDescending(x => x.CreationTime)
|
||||
.ToListAsync();
|
||||
|
||||
return entities.Adapt<List<AiAppShortcutDto>>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -25,6 +25,7 @@ using Yi.Framework.AiHub.Domain.Entities.Model;
|
||||
using Yi.Framework.AiHub.Domain.Extensions;
|
||||
using Yi.Framework.AiHub.Domain.Managers;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Consts;
|
||||
using System.Text.Json;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Dtos;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Dtos.OpenAi;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
@@ -50,6 +51,7 @@ public class AiChatService : ApplicationService
|
||||
private readonly IAccountService _accountService;
|
||||
private readonly ISqlSugarRepository<AgentStoreAggregateRoot> _agentStoreRepository;
|
||||
private readonly ISqlSugarRepository<AiModelEntity> _aiModelRepository;
|
||||
private const string FreeModelId = "DeepSeek-V3-0324";
|
||||
|
||||
public AiChatService(IHttpContextAccessor httpContextAccessor,
|
||||
AiBlacklistManager aiBlacklistManager,
|
||||
@@ -58,7 +60,8 @@ public class AiChatService : ApplicationService
|
||||
ModelManager modelManager,
|
||||
PremiumPackageManager premiumPackageManager,
|
||||
ChatManager chatManager, TokenManager tokenManager, IAccountService accountService,
|
||||
ISqlSugarRepository<AgentStoreAggregateRoot> agentStoreRepository, ISqlSugarRepository<AiModelEntity> aiModelRepository)
|
||||
ISqlSugarRepository<AgentStoreAggregateRoot> agentStoreRepository,
|
||||
ISqlSugarRepository<AiModelEntity> aiModelRepository)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_aiBlacklistManager = aiBlacklistManager;
|
||||
@@ -94,8 +97,9 @@ public class AiChatService : ApplicationService
|
||||
public async Task<List<ModelGetListOutput>> GetModelAsync()
|
||||
{
|
||||
var output = await _aiModelRepository._DbQueryable
|
||||
.Where(x => x.IsEnabled == true)
|
||||
.Where(x => x.ModelType == ModelTypeEnum.Chat)
|
||||
.Where(x => x.ModelApiType == ModelApiTypeEnum.OpenAi)
|
||||
// .Where(x => x.ModelApiType == ModelApiTypeEnum.Completions)
|
||||
.OrderByDescending(x => x.OrderNum)
|
||||
.Select(x => new ModelGetListOutput
|
||||
{
|
||||
@@ -104,8 +108,21 @@ public class AiChatService : ApplicationService
|
||||
ModelName = x.Name,
|
||||
ModelDescribe = x.Description,
|
||||
Remark = x.Description,
|
||||
IsPremiumPackage = x.IsPremium
|
||||
IsPremiumPackage = x.IsPremium,
|
||||
ModelApiType = x.ModelApiType,
|
||||
IconUrl = x.IconUrl,
|
||||
ProviderName = x.ProviderName
|
||||
}).ToListAsync();
|
||||
|
||||
output.ForEach(x =>
|
||||
{
|
||||
if (x.ModelId == FreeModelId)
|
||||
{
|
||||
x.IsPremiumPackage = false;
|
||||
x.IsFree = true;
|
||||
}
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -121,7 +138,7 @@ public class AiChatService : ApplicationService
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
//除了免费模型,其他的模型都要校验
|
||||
if (!input.Model.Contains("DeepSeek-R1"))
|
||||
if (input.Model!=FreeModelId)
|
||||
{
|
||||
//有token,需要黑名单校验
|
||||
if (CurrentUser.IsAuthenticated)
|
||||
@@ -172,22 +189,10 @@ public class AiChatService : ApplicationService
|
||||
{
|
||||
throw new BusinessException("当前接口不支持第三方使用");
|
||||
}
|
||||
|
||||
input.Model = "gpt-5-chat";
|
||||
if (CurrentUser.IsAuthenticated)
|
||||
{
|
||||
await _aiBlacklistManager.VerifiyAiBlacklist(CurrentUser.GetId());
|
||||
if (CurrentUser.IsAiVip())
|
||||
{
|
||||
input.Model = "gpt-5-chat";
|
||||
}
|
||||
else
|
||||
{
|
||||
input.Model = "gpt-4.1-mini";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
input.Model = "DeepSeek-R1-0528";
|
||||
}
|
||||
|
||||
//ai网关代理httpcontext
|
||||
@@ -268,4 +273,89 @@ public class AiChatService : ApplicationService
|
||||
var data = await _agentStoreRepository.GetFirstAsync(x => x.SessionId == sessionId);
|
||||
return data?.Store;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 统一发送消息 - 支持4种API类型
|
||||
/// </summary>
|
||||
/// <param name="apiType">API类型枚举</param>
|
||||
/// <param name="input">原始请求体JsonElement</param>
|
||||
/// <param name="modelId">模型ID(Gemini格式需要从URL传入)</param>
|
||||
/// <param name="sessionId">会话ID</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
[HttpPost("ai-chat/unified/send")]
|
||||
public async Task PostUnifiedSendAsync(
|
||||
[FromQuery] ModelApiTypeEnum apiType,
|
||||
[FromBody] JsonElement input,
|
||||
[FromQuery] string modelId,
|
||||
[FromQuery] Guid? sessionId,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
// 从请求体中提取模型ID(如果未从URL传入)
|
||||
if (string.IsNullOrEmpty(modelId))
|
||||
{
|
||||
modelId = ExtractModelIdFromRequest(apiType, input);
|
||||
}
|
||||
|
||||
// 除了免费模型,其他的模型都要校验
|
||||
if (modelId != FreeModelId)
|
||||
{
|
||||
if (CurrentUser.IsAuthenticated)
|
||||
{
|
||||
await _aiBlacklistManager.VerifiyAiBlacklist(CurrentUser.GetId());
|
||||
if (!CurrentUser.IsAiVip())
|
||||
{
|
||||
throw new UserFriendlyException("该模型需要VIP用户才能使用,请购买VIP后重新登录重试");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UserFriendlyException("未登录用户,只能使用未加速的DeepSeek-R1,请登录后重试");
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是尊享包服务,需要校验是否尊享包足够
|
||||
if (CurrentUser.IsAuthenticated)
|
||||
{
|
||||
var isPremium = await _modelManager.IsPremiumModelAsync(modelId);
|
||||
if (isPremium)
|
||||
{
|
||||
var availableTokens = await _premiumPackageManager.GetAvailableTokensAsync(CurrentUser.GetId());
|
||||
if (availableTokens <= 0)
|
||||
{
|
||||
throw new UserFriendlyException("尊享token包用量不足,请先购买尊享token包");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 调用统一流式处理
|
||||
await _aiGateWayManager.UnifiedStreamForStatisticsAsync(
|
||||
_httpContextAccessor.HttpContext!,
|
||||
apiType,
|
||||
input,
|
||||
modelId,
|
||||
CurrentUser.Id,
|
||||
sessionId,
|
||||
null,
|
||||
CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从请求体中提取模型ID
|
||||
/// </summary>
|
||||
private string ExtractModelIdFromRequest(ModelApiTypeEnum apiType, JsonElement input)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (input.TryGetProperty("model", out var modelProperty))
|
||||
{
|
||||
return modelProperty.GetString() ?? string.Empty;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 忽略解析错误
|
||||
}
|
||||
|
||||
throw new UserFriendlyException("无法从请求中获取模型ID,请在URL参数中指定modelId");
|
||||
}
|
||||
}
|
||||
@@ -261,7 +261,10 @@ public class AiImageService : ApplicationService
|
||||
PublishStatus = x.PublishStatus,
|
||||
Categories = x.Categories,
|
||||
CreationTime = x.CreationTime,
|
||||
ErrorInfo = x.ErrorInfo
|
||||
ErrorInfo = x.ErrorInfo,
|
||||
UserName = x.UserName,
|
||||
UserId = x.UserId,
|
||||
IsAnonymous = x.IsAnonymous
|
||||
})
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
|
||||
@@ -269,6 +272,17 @@ public class AiImageService : ApplicationService
|
||||
return new PagedResult<ImageTaskOutput>(total, output);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除个人图片
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
[HttpDelete("ai-image/my-tasks")]
|
||||
public async Task DeleteMyTaskAsync([FromQuery] List<Guid> ids)
|
||||
{
|
||||
var userId = CurrentUser.GetId();
|
||||
await _imageTaskRepository.DeleteAsync(x => ids.Contains(x.Id) && x.UserId == userId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询图片广场(已发布的图片)
|
||||
/// </summary>
|
||||
@@ -282,8 +296,9 @@ public class AiImageService : ApplicationService
|
||||
.Where(x => x.TaskStatus == TaskStatusEnum.Success)
|
||||
.WhereIF(input.TaskStatus is not null, x => x.TaskStatus == input.TaskStatus)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Prompt), x => x.Prompt.Contains(input.Prompt))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Categories), x => SqlFunc.JsonLike(x.Categories, input.Categories))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.UserName),x=>x.UserName.Contains(input.UserName) )
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Categories),
|
||||
x => SqlFunc.JsonLike(x.Categories, input.Categories))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.UserName), x => x.UserName.Contains(input.UserName))
|
||||
.WhereIF(input.StartTime is not null && input.EndTime is not null,
|
||||
x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
|
||||
.OrderByDescending(x => x.CreationTime)
|
||||
@@ -300,9 +315,9 @@ public class AiImageService : ApplicationService
|
||||
ErrorInfo = null,
|
||||
UserName = x.UserName,
|
||||
UserId = x.UserId,
|
||||
|
||||
})
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total); ;
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
;
|
||||
|
||||
|
||||
output.ForEach(x =>
|
||||
@@ -313,7 +328,7 @@ public class AiImageService : ApplicationService
|
||||
x.UserId = null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return new PagedResult<ImageTaskOutput>(total, output);
|
||||
}
|
||||
|
||||
@@ -342,7 +357,7 @@ public class AiImageService : ApplicationService
|
||||
}
|
||||
|
||||
//设置发布
|
||||
task.SetPublish(input.IsAnonymous,input.Categories);
|
||||
task.SetPublish(input.IsAnonymous, input.Categories);
|
||||
await _imageTaskRepository.UpdateAsync(task);
|
||||
}
|
||||
|
||||
@@ -355,6 +370,7 @@ public class AiImageService : ApplicationService
|
||||
public async Task<List<ModelGetListOutput>> GetModelAsync()
|
||||
{
|
||||
var output = await _aiModelRepository._DbQueryable
|
||||
.Where(x=>x.IsEnabled==true)
|
||||
.Where(x => x.ModelType == ModelTypeEnum.Image)
|
||||
.Where(x => x.ModelApiType == ModelApiTypeEnum.GenerateContent)
|
||||
.OrderByDescending(x => x.OrderNum)
|
||||
|
||||
@@ -35,8 +35,9 @@ public class ModelService : ApplicationService, IModelService
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
// 查询所有未删除的模型,使用WhereIF动态添加筛选条件
|
||||
// 查询所有未删除且已启用的模型,使用WhereIF动态添加筛选条件
|
||||
var modelIds = (await _modelRepository._DbQueryable
|
||||
.Where(x => x.IsEnabled)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), x =>
|
||||
x.Name.Contains(input.SearchKey) || x.ModelId.Contains(input.SearchKey))
|
||||
.WhereIF(input.ProviderNames is not null, x =>
|
||||
@@ -51,6 +52,7 @@ public class ModelService : ApplicationService, IModelService
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total));
|
||||
|
||||
var entities = await _modelRepository._DbQueryable.Where(x => modelIds.Contains(x.ModelId))
|
||||
.Where(x => x.IsEnabled)
|
||||
.OrderBy(x => x.OrderNum)
|
||||
.OrderBy(x => x.Name).ToListAsync();
|
||||
|
||||
@@ -77,10 +79,9 @@ public class ModelService : ApplicationService, IModelService
|
||||
public async Task<List<string>> GetProviderListAsync()
|
||||
{
|
||||
var providers = await _modelRepository._DbQueryable
|
||||
.Where(x => !x.IsDeleted)
|
||||
.Where(x => x.IsEnabled)
|
||||
.Where(x => !string.IsNullOrEmpty(x.ProviderName))
|
||||
.GroupBy(x => x.ProviderName)
|
||||
.OrderBy(x => x.OrderNum)
|
||||
.Select(x => x.ProviderName)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
@@ -84,7 +84,8 @@ public class SessionService : CrudAppService<SessionAggregateRoot, SessionDto, G
|
||||
RefAsync<int> total = 0;
|
||||
var userId = CurrentUser.GetId();
|
||||
var entities = await _repository._DbQueryable
|
||||
.Where(x=>x.UserId == userId)
|
||||
.Where(x => x.UserId == userId)
|
||||
.WhereIF(input.SessionType.HasValue, x => x.SessionType == input.SessionType!.Value)
|
||||
.OrderByDescending(x => x.Id)
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
return new PagedResultDto<SessionDto>(total, entities.Adapt<List<SessionDto>>());
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.AiHub.Application.Contracts.Dtos.Recharge;
|
||||
@@ -35,19 +37,29 @@ namespace Yi.Framework.AiHub.Application.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询已登录的账户充值记录
|
||||
/// 查询已登录的账户充值记录(分页)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Route("recharge/account")]
|
||||
[Authorize]
|
||||
public async Task<List<RechargeGetListOutput>> GetListByAccountAsync()
|
||||
public async Task<PagedResultDto<RechargeGetListOutput>> GetListByAccountAsync([FromQuery]RechargeGetListInput input)
|
||||
{
|
||||
var userId = CurrentUser.Id;
|
||||
var entities = await _repository._DbQueryable.Where(x => x.UserId == userId)
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
var entities = await _repository._DbQueryable
|
||||
.Where(x => x.UserId == userId)
|
||||
.WhereIF(input.StartTime.HasValue, x => x.CreationTime >= input.StartTime!.Value)
|
||||
.WhereIF(input.EndTime.HasValue, x => x.CreationTime <= input.EndTime!.Value)
|
||||
.WhereIF(input.IsFree == true, x => x.RechargeAmount == 0)
|
||||
.WhereIF(input.IsFree == false, x => x.RechargeAmount > 0)
|
||||
.WhereIF(input.MinRechargeAmount.HasValue, x => x.RechargeAmount >= input.MinRechargeAmount!.Value)
|
||||
.WhereIF(input.MaxRechargeAmount.HasValue, x => x.RechargeAmount <= input.MaxRechargeAmount!.Value)
|
||||
.OrderByDescending(x => x.CreationTime)
|
||||
.ToListAsync();
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
|
||||
var output = entities.Adapt<List<RechargeGetListOutput>>();
|
||||
return output;
|
||||
return new PagedResultDto<RechargeGetListOutput>(total, output);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using System.Globalization;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Yi.Framework.AiHub.Application.Contracts.Dtos.SystemStatistics;
|
||||
using Yi.Framework.AiHub.Application.Contracts.IServices;
|
||||
using Yi.Framework.AiHub.Domain.Entities;
|
||||
using Yi.Framework.AiHub.Domain.Entities.Chat;
|
||||
using Yi.Framework.AiHub.Domain.Entities.Model;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Services;
|
||||
|
||||
/// <summary>
|
||||
/// 系统使用量统计服务实现
|
||||
/// </summary>
|
||||
[Authorize(Roles = "admin")]
|
||||
public class SystemUsageStatisticsService : ApplicationService, ISystemUsageStatisticsService
|
||||
{
|
||||
private readonly ISqlSugarRepository<PremiumPackageAggregateRoot> _premiumPackageRepository;
|
||||
private readonly ISqlSugarRepository<AiRechargeAggregateRoot> _rechargeRepository;
|
||||
private readonly ISqlSugarRepository<MessageAggregateRoot> _messageRepository;
|
||||
private readonly ISqlSugarRepository<AiModelEntity, Guid> _modelRepository;
|
||||
|
||||
public SystemUsageStatisticsService(
|
||||
ISqlSugarRepository<PremiumPackageAggregateRoot> premiumPackageRepository,
|
||||
ISqlSugarRepository<AiRechargeAggregateRoot> rechargeRepository,
|
||||
ISqlSugarRepository<MessageAggregateRoot> messageRepository,
|
||||
ISqlSugarRepository<AiModelEntity, Guid> modelRepository)
|
||||
{
|
||||
_premiumPackageRepository = premiumPackageRepository;
|
||||
_rechargeRepository = rechargeRepository;
|
||||
_messageRepository = messageRepository;
|
||||
_modelRepository = modelRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取利润统计数据
|
||||
/// </summary>
|
||||
[HttpPost("system-statistics/profit")]
|
||||
public async Task<ProfitStatisticsOutput> GetProfitStatisticsAsync(ProfitStatisticsInput input)
|
||||
{
|
||||
// 1. 获取尊享包总消耗和剩余库存
|
||||
var premiumPackages = await _premiumPackageRepository._DbQueryable.ToListAsync();
|
||||
long totalUsedTokens = premiumPackages.Sum(p => p.UsedTokens);
|
||||
long totalRemainingTokens = premiumPackages.Sum(p => p.RemainingTokens);
|
||||
|
||||
// 2. 计算1亿Token成本
|
||||
decimal costPerHundredMillion = totalUsedTokens > 0
|
||||
? input.CurrentCost / (totalUsedTokens / 100000000m)
|
||||
: 0;
|
||||
|
||||
// 3. 计算总成本(剩余+已使用的总成本)
|
||||
long totalTokens = totalUsedTokens + totalRemainingTokens;
|
||||
decimal totalCost = totalTokens > 0
|
||||
? (totalTokens / 100000000m) * costPerHundredMillion
|
||||
: 0;
|
||||
|
||||
// 4. 获取总收益(RechargeType=PremiumPackage的充值金额总和)
|
||||
decimal totalRevenue = await _rechargeRepository._DbQueryable
|
||||
.Where(x => x.RechargeType == Domain.Shared.Enums.RechargeTypeEnum.PremiumPackage)
|
||||
.SumAsync(x => x.RechargeAmount);
|
||||
|
||||
// 5. 计算利润率
|
||||
decimal profitRate = totalCost > 0
|
||||
? (totalRevenue / totalCost - 1) * 100
|
||||
: 0;
|
||||
|
||||
// 6. 按200售价计算成本
|
||||
decimal costAt200Price = totalRevenue > 0
|
||||
? (totalCost / totalRevenue) * 200
|
||||
: 0;
|
||||
|
||||
// 7. 格式化日期
|
||||
var today = DateTime.Now;
|
||||
string dayOfWeek = today.ToString("dddd", new CultureInfo("zh-CN"));
|
||||
string weekDay = dayOfWeek switch
|
||||
{
|
||||
"星期一" => "周1",
|
||||
"星期二" => "周2",
|
||||
"星期三" => "周3",
|
||||
"星期四" => "周4",
|
||||
"星期五" => "周5",
|
||||
"星期六" => "周6",
|
||||
"星期日" => "周日",
|
||||
_ => dayOfWeek
|
||||
};
|
||||
|
||||
return new ProfitStatisticsOutput
|
||||
{
|
||||
Date = $"{today:M月d日} {weekDay}",
|
||||
TotalUsedTokens = totalUsedTokens,
|
||||
TotalUsedTokensInHundredMillion = totalUsedTokens / 100000000m,
|
||||
TotalRemainingTokens = totalRemainingTokens,
|
||||
TotalRemainingTokensInHundredMillion = totalRemainingTokens / 100000000m,
|
||||
CurrentCost = input.CurrentCost,
|
||||
CostPerHundredMillion = costPerHundredMillion,
|
||||
TotalCost = totalCost,
|
||||
TotalRevenue = totalRevenue,
|
||||
ProfitRate = profitRate,
|
||||
CostAt200Price = costAt200Price
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定日期各模型Token统计
|
||||
/// </summary>
|
||||
[HttpPost("system-statistics/token")]
|
||||
public async Task<TokenStatisticsOutput> GetTokenStatisticsAsync(TokenStatisticsInput input)
|
||||
{
|
||||
var day = input.Date.Date;
|
||||
var nextDay = day.AddDays(1);
|
||||
|
||||
// 1. 获取所有尊享模型(包含被禁用的),按ModelId去重
|
||||
var premiumModels = await _modelRepository._DbQueryable
|
||||
.Where(x => x.IsPremium)
|
||||
.ToListAsync();
|
||||
|
||||
if (premiumModels.Count == 0)
|
||||
{
|
||||
return new TokenStatisticsOutput
|
||||
{
|
||||
Date = FormatDate(day),
|
||||
ModelStatistics = new List<ModelTokenStatisticsDto>()
|
||||
};
|
||||
}
|
||||
|
||||
// 按ModelId去重,保留第一个模型的名称
|
||||
var distinctModels = premiumModels
|
||||
.GroupBy(x => x.ModelId)
|
||||
.Select(g => g.First())
|
||||
.ToList();
|
||||
|
||||
var modelIds = distinctModels.Select(x => x.ModelId).ToList();
|
||||
|
||||
// 2. 查询指定日期内各模型的Token使用统计
|
||||
var modelStats = await _messageRepository._DbQueryable
|
||||
.Where(x => modelIds.Contains(x.ModelId))
|
||||
.Where(x => x.CreationTime >= day && x.CreationTime < nextDay)
|
||||
.Where(x => x.Role == "system")
|
||||
.GroupBy(x => x.ModelId)
|
||||
.Select(x => new
|
||||
{
|
||||
ModelId = x.ModelId,
|
||||
Tokens = SqlFunc.AggregateSum(x.TokenUsage.TotalTokenCount),
|
||||
Count = SqlFunc.AggregateCount(x.Id)
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var modelStatDict = modelStats.ToDictionary(x => x.ModelId, x => x);
|
||||
|
||||
// 3. 构建结果列表,使用去重后的模型列表
|
||||
var result = new List<ModelTokenStatisticsDto>();
|
||||
foreach (var model in distinctModels)
|
||||
{
|
||||
modelStatDict.TryGetValue(model.ModelId, out var stat);
|
||||
long tokens = stat?.Tokens ?? 0;
|
||||
long count = stat?.Count ?? 0;
|
||||
|
||||
// 这里成本设为0,因为需要前端传入或者从配置中获取
|
||||
decimal cost = 0;
|
||||
decimal costPerHundredMillion = tokens > 0 && cost > 0
|
||||
? cost / (tokens / 100000000m)
|
||||
: 0;
|
||||
|
||||
result.Add(new ModelTokenStatisticsDto
|
||||
{
|
||||
ModelId = model.ModelId,
|
||||
ModelName = model.Name,
|
||||
Tokens = tokens,
|
||||
TokensInWan = tokens / 10000m,
|
||||
Count = count,
|
||||
Cost = cost,
|
||||
CostPerHundredMillion = costPerHundredMillion
|
||||
});
|
||||
}
|
||||
|
||||
return new TokenStatisticsOutput
|
||||
{
|
||||
Date = FormatDate(day),
|
||||
ModelStatistics = result
|
||||
};
|
||||
}
|
||||
|
||||
private string FormatDate(DateTime date)
|
||||
{
|
||||
string dayOfWeek = date.ToString("dddd", new CultureInfo("zh-CN"));
|
||||
string weekDay = dayOfWeek switch
|
||||
{
|
||||
"星期一" => "周1",
|
||||
"星期二" => "周2",
|
||||
"星期三" => "周3",
|
||||
"星期四" => "周4",
|
||||
"星期五" => "周5",
|
||||
"星期六" => "周6",
|
||||
"星期日" => "周日",
|
||||
_ => dayOfWeek
|
||||
};
|
||||
return $"{date:M月d日} {weekDay}";
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ public class UsageStatisticsService : ApplicationService, IUsageStatisticsServic
|
||||
private readonly ISqlSugarRepository<PremiumPackageAggregateRoot> _premiumPackageRepository;
|
||||
private readonly ISqlSugarRepository<TokenAggregateRoot> _tokenRepository;
|
||||
private readonly ModelManager _modelManager;
|
||||
|
||||
public UsageStatisticsService(
|
||||
ISqlSugarRepository<MessageAggregateRoot> messageRepository,
|
||||
ISqlSugarRepository<UsageStatisticsAggregateRoot> usageStatisticsRepository,
|
||||
@@ -48,7 +49,7 @@ public class UsageStatisticsService : ApplicationService, IUsageStatisticsServic
|
||||
/// 获取当前用户近7天的Token消耗统计
|
||||
/// </summary>
|
||||
/// <returns>每日Token使用量列表</returns>
|
||||
public async Task<List<DailyTokenUsageDto>> GetLast7DaysTokenUsageAsync([FromQuery]UsageStatisticsGetInput input)
|
||||
public async Task<List<DailyTokenUsageDto>> GetLast7DaysTokenUsageAsync([FromQuery] UsageStatisticsGetInput input)
|
||||
{
|
||||
var userId = CurrentUser.GetId();
|
||||
var endDate = DateTime.Today;
|
||||
@@ -57,9 +58,9 @@ public class UsageStatisticsService : ApplicationService, IUsageStatisticsServic
|
||||
// 从Message表统计近7天的token消耗
|
||||
var dailyUsage = await _messageRepository._DbQueryable
|
||||
.Where(x => x.UserId == userId)
|
||||
.Where(x => x.Role == "assistant" || x.Role == "system")
|
||||
.Where(x => x.Role == "system")
|
||||
.Where(x => x.CreationTime >= startDate && x.CreationTime < endDate.AddDays(1))
|
||||
.WhereIF(input.TokenId.HasValue,x => x.TokenId == input.TokenId)
|
||||
.WhereIF(input.TokenId.HasValue, x => x.TokenId == input.TokenId)
|
||||
.GroupBy(x => x.CreationTime.Date)
|
||||
.Select(g => new
|
||||
{
|
||||
@@ -89,14 +90,14 @@ public class UsageStatisticsService : ApplicationService, IUsageStatisticsServic
|
||||
/// 获取当前用户各个模型的Token消耗量及占比
|
||||
/// </summary>
|
||||
/// <returns>模型Token使用量列表</returns>
|
||||
public async Task<List<ModelTokenUsageDto>> GetModelTokenUsageAsync([FromQuery]UsageStatisticsGetInput input)
|
||||
public async Task<List<ModelTokenUsageDto>> GetModelTokenUsageAsync([FromQuery] UsageStatisticsGetInput input)
|
||||
{
|
||||
var userId = CurrentUser.GetId();
|
||||
|
||||
// 从UsageStatistics表获取各模型的token消耗统计(按ModelId聚合,因为同一模型可能有多个TokenId的记录)
|
||||
var modelUsages = await _usageStatisticsRepository._DbQueryable
|
||||
.Where(x => x.UserId == userId)
|
||||
.WhereIF(input.TokenId.HasValue,x => x.TokenId == input.TokenId)
|
||||
.WhereIF(input.TokenId.HasValue, x => x.TokenId == input.TokenId)
|
||||
.GroupBy(x => x.ModelId)
|
||||
.Select(x => new
|
||||
{
|
||||
@@ -221,11 +222,133 @@ public class UsageStatisticsService : ApplicationService, IUsageStatisticsServic
|
||||
var result = tokenUsages.Select(x => new TokenPremiumUsageDto
|
||||
{
|
||||
TokenId = x.TokenId,
|
||||
TokenName = x.TokenId == Guid.Empty ? "默认" : (tokenNameDict.TryGetValue(x.TokenId, out var name) ? name : "其他"),
|
||||
TokenName = x.TokenId == Guid.Empty
|
||||
? "默认"
|
||||
: (tokenNameDict.TryGetValue(x.TokenId, out var name) ? name : "其他"),
|
||||
Tokens = x.TotalTokenCount,
|
||||
Percentage = totalTokens > 0 ? Math.Round((decimal)x.TotalTokenCount / totalTokens * 100, 2) : 0
|
||||
}).OrderByDescending(x => x.Tokens).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户近24小时每小时Token消耗统计(柱状图)
|
||||
/// </summary>
|
||||
/// <returns>每小时Token使用量列表,包含各模型堆叠数据</returns>
|
||||
public async Task<List<HourlyTokenUsageDto>> GetLast24HoursTokenUsageAsync(
|
||||
[FromQuery] UsageStatisticsGetInput input)
|
||||
{
|
||||
var userId = CurrentUser.GetId();
|
||||
var now = DateTime.Now;
|
||||
var startTime = now.AddHours(-23); // 滚动24小时,从23小时前到现在
|
||||
var startHour = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);
|
||||
|
||||
// 从Message表查询近24小时的数据,只选择需要的字段
|
||||
var messages = await _messageRepository._DbQueryable
|
||||
.Where(x => x.UserId == userId)
|
||||
.Where(x => x.Role == "system")
|
||||
.Where(x => x.CreationTime >= startHour)
|
||||
.WhereIF(input.TokenId.HasValue, x => x.TokenId == input.TokenId)
|
||||
.Select(x => new
|
||||
{
|
||||
x.CreationTime,
|
||||
x.ModelId,
|
||||
x.TokenUsage.TotalTokenCount
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
// 在内存中按小时和模型分组统计
|
||||
var hourlyGrouped = messages
|
||||
.GroupBy(x => new
|
||||
{
|
||||
Hour = new DateTime(x.CreationTime.Year, x.CreationTime.Month, x.CreationTime.Day, x.CreationTime.Hour,
|
||||
0, 0),
|
||||
x.ModelId
|
||||
})
|
||||
.Select(g => new
|
||||
{
|
||||
g.Key.Hour,
|
||||
g.Key.ModelId,
|
||||
Tokens = g.Sum(x => x.TotalTokenCount)
|
||||
})
|
||||
.ToList();
|
||||
|
||||
// 生成完整的24小时数据
|
||||
var result = new List<HourlyTokenUsageDto>();
|
||||
for (int i = 0; i < 24; i++)
|
||||
{
|
||||
var hour = startHour.AddHours(i);
|
||||
var hourData = hourlyGrouped.Where(x => x.Hour == hour).ToList();
|
||||
|
||||
var modelBreakdown = hourData.Select(x => new ModelTokenBreakdownDto
|
||||
{
|
||||
ModelId = x.ModelId,
|
||||
Tokens = x.Tokens
|
||||
}).ToList();
|
||||
|
||||
result.Add(new HourlyTokenUsageDto
|
||||
{
|
||||
Hour = hour,
|
||||
TotalTokens = modelBreakdown.Sum(x => x.Tokens),
|
||||
ModelBreakdown = modelBreakdown
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户今日各模型使用量统计(卡片列表)
|
||||
/// </summary>
|
||||
/// <returns>模型今日使用量列表,包含使用次数和总Token</returns>
|
||||
public async Task<List<ModelTodayUsageDto>> GetTodayModelUsageAsync([FromQuery] UsageStatisticsGetInput input)
|
||||
{
|
||||
var userId = CurrentUser.GetId();
|
||||
var todayStart = DateTime.Today; // 今天凌晨0点
|
||||
var tomorrowStart = todayStart.AddDays(1);
|
||||
|
||||
// 从Message表查询今天的数据,只选择需要的字段
|
||||
var messages = await _messageRepository._DbQueryable
|
||||
.Where(x => x.UserId == userId)
|
||||
.Where(x => x.Role == "system")
|
||||
.Where(x => x.CreationTime >= todayStart && x.CreationTime < tomorrowStart)
|
||||
.WhereIF(input.TokenId.HasValue, x => x.TokenId == input.TokenId)
|
||||
.Select(x => new
|
||||
{
|
||||
x.ModelId,
|
||||
x.TokenUsage.TotalTokenCount
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
// 在内存中按模型分组统计
|
||||
var modelStats = messages
|
||||
.GroupBy(x => x.ModelId)
|
||||
.Select(g => new ModelTodayUsageDto
|
||||
{
|
||||
ModelId = g.Key,
|
||||
UsageCount = g.Count(),
|
||||
TotalTokens = g.Sum(x => x.TotalTokenCount)
|
||||
})
|
||||
.OrderByDescending(x => x.TotalTokens)
|
||||
.ToList();
|
||||
|
||||
if (modelStats.Count > 0)
|
||||
{
|
||||
var modelIds = modelStats.Select(x => x.ModelId).ToList();
|
||||
var modelDic = await _modelManager._aiModelRepository._DbQueryable.Where(x => modelIds.Contains(x.ModelId))
|
||||
.Distinct()
|
||||
.Where(x=>x.IsEnabled)
|
||||
.ToDictionaryAsync<string>(x => x.ModelId, y => y.IconUrl);
|
||||
modelStats.ForEach(x =>
|
||||
{
|
||||
if (modelDic.TryGetValue(x.ModelId, out var icon))
|
||||
{
|
||||
x.IconUrl = icon;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return modelStats;
|
||||
}
|
||||
}
|
||||
@@ -21,5 +21,11 @@ public class PremiumPackageConst
|
||||
"yi-claude-sonnet-4-5-20250929",
|
||||
"yi-claude-haiku-4-5-20251001",
|
||||
"yi-claude-opus-4-5-20251101",
|
||||
|
||||
"yi-gpt-5.2",
|
||||
"yi-gpt-5.2-codex",
|
||||
"yi-gemini-3-pro-high",
|
||||
"yi-gemini-3-pro",
|
||||
|
||||
];
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Yi.Framework.AiHub.Domain.Shared.Dtos;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Shared.Dtos;
|
||||
|
||||
public class AiModelDescribe
|
||||
{
|
||||
@@ -61,4 +63,14 @@ public class AiModelDescribe
|
||||
/// 模型倍率
|
||||
/// </summary>
|
||||
public decimal Multiplier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为尊享模型
|
||||
/// </summary>
|
||||
public bool IsPremium { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模型类型(聊天/图片等)
|
||||
/// </summary>
|
||||
public ModelTypeEnum ModelType { get; set; }
|
||||
}
|
||||
@@ -18,39 +18,7 @@ public class AnthropicStreamDto
|
||||
[JsonPropertyName("usage")] public AnthropicCompletionDtoUsage? Usage { get; set; }
|
||||
|
||||
[JsonPropertyName("error")] public AnthropicStreamErrorDto? Error { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public ThorUsageResponse TokenUsage => new ThorUsageResponse
|
||||
{
|
||||
PromptTokens = Usage?.InputTokens + Usage?.CacheCreationInputTokens + Usage?.CacheReadInputTokens,
|
||||
InputTokens = Usage?.InputTokens + Usage?.CacheCreationInputTokens + Usage?.CacheReadInputTokens,
|
||||
OutputTokens = Usage?.OutputTokens,
|
||||
InputTokensDetails = null,
|
||||
CompletionTokens = Usage?.OutputTokens,
|
||||
TotalTokens = Usage?.InputTokens + Usage?.CacheCreationInputTokens + Usage?.CacheReadInputTokens +
|
||||
Usage?.OutputTokens,
|
||||
PromptTokensDetails = null,
|
||||
CompletionTokensDetails = null
|
||||
};
|
||||
|
||||
|
||||
public void SupplementalMultiplier(decimal multiplier)
|
||||
{
|
||||
if (this.Usage is not null)
|
||||
{
|
||||
this.Usage.CacheCreationInputTokens =
|
||||
(int)Math.Round((this.Usage.CacheCreationInputTokens ?? 0) * multiplier);
|
||||
|
||||
this.Usage.CacheReadInputTokens =
|
||||
(int)Math.Round((this.Usage.CacheReadInputTokens ?? 0) * multiplier);
|
||||
|
||||
this.Usage.InputTokens =
|
||||
(int)Math.Round((this.Usage.InputTokens ?? 0) * multiplier);
|
||||
|
||||
this.Usage.OutputTokens =
|
||||
(int)Math.Round((this.Usage.OutputTokens ?? 0) * multiplier);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class AnthropicStreamErrorDto
|
||||
@@ -71,6 +39,11 @@ public class AnthropicChatCompletionDtoDelta
|
||||
[JsonPropertyName("partial_json")] public string? PartialJson { get; set; }
|
||||
|
||||
[JsonPropertyName("stop_reason")] public string? StopReason { get; set; }
|
||||
|
||||
[JsonPropertyName("signature")] public string? Signature { get; set; }
|
||||
|
||||
[JsonPropertyName("stop_sequence")] public string? StopSequence { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class AnthropicChatCompletionDtoContentBlock
|
||||
@@ -115,38 +88,7 @@ public class AnthropicChatCompletionDto
|
||||
public object stop_sequence { get; set; }
|
||||
|
||||
public AnthropicCompletionDtoUsage? Usage { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public ThorUsageResponse TokenUsage => new ThorUsageResponse
|
||||
{
|
||||
PromptTokens = Usage?.InputTokens + Usage?.CacheCreationInputTokens + Usage?.CacheReadInputTokens,
|
||||
InputTokens = Usage?.InputTokens + Usage?.CacheCreationInputTokens + Usage?.CacheReadInputTokens,
|
||||
OutputTokens = Usage?.OutputTokens,
|
||||
InputTokensDetails = null,
|
||||
CompletionTokens = Usage?.OutputTokens,
|
||||
TotalTokens = Usage?.InputTokens + Usage?.CacheCreationInputTokens + Usage?.CacheReadInputTokens +
|
||||
Usage?.OutputTokens,
|
||||
PromptTokensDetails = null,
|
||||
CompletionTokensDetails = null
|
||||
};
|
||||
|
||||
public void SupplementalMultiplier(decimal multiplier)
|
||||
{
|
||||
if (this.Usage is not null)
|
||||
{
|
||||
this.Usage.CacheCreationInputTokens =
|
||||
(int)Math.Round((this.Usage?.CacheCreationInputTokens ?? 0) * multiplier);
|
||||
|
||||
this.Usage.CacheReadInputTokens =
|
||||
(int)Math.Round((this.Usage?.CacheReadInputTokens ?? 0) * multiplier);
|
||||
|
||||
this.Usage.InputTokens =
|
||||
(int)Math.Round((this.Usage?.InputTokens ?? 0) * multiplier);
|
||||
|
||||
this.Usage.OutputTokens =
|
||||
(int)Math.Round((this.Usage?.OutputTokens ?? 0) * multiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AnthropicChatCompletionDtoContent
|
||||
@@ -166,6 +108,7 @@ public class AnthropicChatCompletionDtoContent
|
||||
[JsonPropertyName("partial_json")] public string? PartialJson { get; set; }
|
||||
|
||||
public string? signature { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class AnthropicCompletionDtoUsage
|
||||
@@ -181,6 +124,12 @@ public class AnthropicCompletionDtoUsage
|
||||
[JsonPropertyName("output_tokens")] public int? OutputTokens { get; set; }
|
||||
|
||||
[JsonPropertyName("server_tool_use")] public AnthropicServerToolUse? ServerToolUse { get; set; }
|
||||
|
||||
[JsonPropertyName("cache_creation")] public object? CacheCreation { get; set; }
|
||||
|
||||
[JsonPropertyName("service_tier")] public string? ServiceTier { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class AnthropicServerToolUse
|
||||
|
||||
@@ -6,6 +6,83 @@ namespace Yi.Framework.AiHub.Domain.Shared.Dtos.Gemini;
|
||||
|
||||
public static class GeminiGenerateContentAcquirer
|
||||
{
|
||||
/// <summary>
|
||||
/// 从请求体中提取用户最后一条消息内容
|
||||
/// 路径: contents[last].parts[last].text
|
||||
/// </summary>
|
||||
public static string GetLastUserContent(JsonElement request)
|
||||
{
|
||||
var contents = request.GetPath("contents");
|
||||
if (!contents.HasValue || contents.Value.ValueKind != JsonValueKind.Array)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var contentsArray = contents.Value.EnumerateArray().ToList();
|
||||
if (contentsArray.Count == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var lastContent = contentsArray[^1];
|
||||
var parts = lastContent.GetPath("parts");
|
||||
if (!parts.HasValue || parts.Value.ValueKind != JsonValueKind.Array)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var partsArray = parts.Value.EnumerateArray().ToList();
|
||||
if (partsArray.Count == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
// 获取最后一个 part 的 text
|
||||
var lastPart = partsArray[^1];
|
||||
return lastPart.GetPath("text").GetString() ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从响应中提取文本内容(非 thought 类型)
|
||||
/// 路径: candidates[0].content.parts[].text (where thought != true)
|
||||
/// </summary>
|
||||
public static string GetTextContent(JsonElement response)
|
||||
{
|
||||
var candidates = response.GetPath("candidates");
|
||||
if (!candidates.HasValue || candidates.Value.ValueKind != JsonValueKind.Array)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var candidatesArray = candidates.Value.EnumerateArray().ToList();
|
||||
if (candidatesArray.Count == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var parts = candidatesArray[0].GetPath("content", "parts");
|
||||
if (!parts.HasValue || parts.Value.ValueKind != JsonValueKind.Array)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
// 遍历所有 parts,只取非 thought 的 text
|
||||
foreach (var part in parts.Value.EnumerateArray())
|
||||
{
|
||||
var isThought = part.GetPath("thought").GetBool();
|
||||
if (!isThought)
|
||||
{
|
||||
var text = part.GetPath("text").GetString();
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static ThorUsageResponse? GetUsage(JsonElement response)
|
||||
{
|
||||
var usage = response.GetPath("usageMetadata");
|
||||
@@ -32,46 +109,158 @@ public static class GeminiGenerateContentAcquirer
|
||||
|
||||
/// <summary>
|
||||
/// 获取图片 base64(包含 data:image 前缀)
|
||||
/// 优先从 inlineData.data 中获取,其次从 markdown text 中解析
|
||||
/// Step 1: 递归遍历整个 JSON 查找最后一个 base64
|
||||
/// Step 2: 从 text 中查找 markdown 图片
|
||||
/// </summary>
|
||||
public static string GetImagePrefixBase64(JsonElement response)
|
||||
{
|
||||
// Step 1: 优先尝试从 candidates[0].content.parts[0].inlineData.data 获取
|
||||
var inlineBase64 = response
|
||||
.GetPath("candidates", 0, "content", "parts", 0, "inlineData", "data")
|
||||
.GetString();
|
||||
// Step 1: 递归遍历整个 JSON 查找最后一个 base64
|
||||
string? lastBase64 = null;
|
||||
string? lastMimeType = null;
|
||||
CollectLastBase64(response, ref lastBase64, ref lastMimeType);
|
||||
|
||||
if (!string.IsNullOrEmpty(inlineBase64))
|
||||
if (!string.IsNullOrEmpty(lastBase64))
|
||||
{
|
||||
// 默认按 png 格式拼接前缀
|
||||
return $"data:image/png;base64,{inlineBase64}";
|
||||
var mimeType = lastMimeType ?? "image/png";
|
||||
return $"data:{mimeType};base64,{lastBase64}";
|
||||
}
|
||||
|
||||
// Step 2: fallback,从 candidates[0].content.parts[0].text 中解析 markdown 图片
|
||||
var text = response
|
||||
.GetPath("candidates", 0, "content", "parts", 0, "text")
|
||||
.GetString();
|
||||
// Step 2: 从 text 中查找 markdown 图片
|
||||
return FindMarkdownImageInResponse(response);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(text))
|
||||
/// <summary>
|
||||
/// 递归遍历 JSON 查找最后一个 base64
|
||||
/// </summary>
|
||||
private static void CollectLastBase64(JsonElement element, ref string? lastBase64, ref string? lastMimeType, int minLength = 100)
|
||||
{
|
||||
switch (element.ValueKind)
|
||||
{
|
||||
return string.Empty;
|
||||
case JsonValueKind.Object:
|
||||
string? currentMimeType = null;
|
||||
string? currentData = null;
|
||||
|
||||
foreach (var prop in element.EnumerateObject())
|
||||
{
|
||||
var name = prop.Name.ToLowerInvariant();
|
||||
|
||||
// 记录 mimeType / mime_type
|
||||
if (name is "mimetype" or "mime_type" && prop.Value.ValueKind == JsonValueKind.String)
|
||||
{
|
||||
currentMimeType = prop.Value.GetString();
|
||||
}
|
||||
// 记录 data 字段(检查是否像 base64)
|
||||
else if (name == "data" && prop.Value.ValueKind == JsonValueKind.String)
|
||||
{
|
||||
var val = prop.Value.GetString();
|
||||
if (!string.IsNullOrEmpty(val) && val.Length >= minLength && LooksLikeBase64(val))
|
||||
{
|
||||
currentData = val;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 递归处理其他属性
|
||||
CollectLastBase64(prop.Value, ref lastBase64, ref lastMimeType, minLength);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果当前对象有 data,更新为"最后一个"
|
||||
if (currentData != null)
|
||||
{
|
||||
lastBase64 = currentData;
|
||||
lastMimeType = currentMimeType;
|
||||
}
|
||||
break;
|
||||
|
||||
case JsonValueKind.Array:
|
||||
foreach (var item in element.EnumerateArray())
|
||||
{
|
||||
CollectLastBase64(item, ref lastBase64, ref lastMimeType, minLength);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查字符串是否像 base64
|
||||
/// </summary>
|
||||
private static bool LooksLikeBase64(string str)
|
||||
{
|
||||
// 常见图片 base64 开头: JPEG(/9j/), PNG(iVBOR), GIF(R0lGO), WebP(UklGR)
|
||||
if (str.StartsWith("/9j/") || str.StartsWith("iVBOR") ||
|
||||
str.StartsWith("R0lGO") || str.StartsWith("UklGR"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// markdown 图片格式: 
|
||||
var startMarker = "(data:image/";
|
||||
var startIndex = text.IndexOf(startMarker, StringComparison.Ordinal);
|
||||
if (startIndex < 0)
|
||||
// 检查前100个字符是否都是 base64 合法字符
|
||||
return str.Take(100).All(c => char.IsLetterOrDigit(c) || c == '+' || c == '/' || c == '=');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归查找 text 字段中的 markdown 图片
|
||||
/// </summary>
|
||||
private static string FindMarkdownImageInResponse(JsonElement element)
|
||||
{
|
||||
var allTexts = new List<string>();
|
||||
CollectTextFields(element, allTexts);
|
||||
|
||||
// 从最后一个 text 开始查找
|
||||
for (int i = allTexts.Count - 1; i >= 0; i--)
|
||||
{
|
||||
return string.Empty;
|
||||
var text = allTexts[i];
|
||||
|
||||
// markdown 图片格式: 
|
||||
var startMarker = "(data:image/";
|
||||
var startIndex = text.IndexOf(startMarker, StringComparison.Ordinal);
|
||||
if (startIndex < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
startIndex += 1; // 跳过 "("
|
||||
var endIndex = text.IndexOf(')', startIndex);
|
||||
if (endIndex > startIndex)
|
||||
{
|
||||
return text.Substring(startIndex, endIndex - startIndex);
|
||||
}
|
||||
}
|
||||
|
||||
startIndex += 1; // 跳过 "("
|
||||
var endIndex = text.IndexOf(')', startIndex);
|
||||
if (endIndex <= startIndex)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return text.Substring(startIndex, endIndex - startIndex);
|
||||
/// <summary>
|
||||
/// 递归收集所有 text 字段
|
||||
/// </summary>
|
||||
private static void CollectTextFields(JsonElement element, List<string> texts)
|
||||
{
|
||||
switch (element.ValueKind)
|
||||
{
|
||||
case JsonValueKind.Object:
|
||||
foreach (var prop in element.EnumerateObject())
|
||||
{
|
||||
if (prop.Name == "text" && prop.Value.ValueKind == JsonValueKind.String)
|
||||
{
|
||||
var val = prop.Value.GetString();
|
||||
if (!string.IsNullOrEmpty(val))
|
||||
{
|
||||
texts.Add(val);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CollectTextFields(prop.Value, texts);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case JsonValueKind.Array:
|
||||
foreach (var item in element.EnumerateArray())
|
||||
{
|
||||
CollectTextFields(item, texts);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,8 +99,8 @@ public enum GoodsTypeEnum
|
||||
[Price(83.7, 3, 27.9)] [DisplayName("YiXinVip 3 month", "3个月", "短期体验")] [GoodsCategory(GoodsCategoryType.Vip)]
|
||||
YiXinVip3 = 3,
|
||||
|
||||
[Price(155.4, 6, 25.9)] [DisplayName("YiXinVip 6 month", "6个月", "年度热销")] [GoodsCategory(GoodsCategoryType.Vip)]
|
||||
YiXinVip6 = 6,
|
||||
[Price(114.5, 5, 22.9)] [DisplayName("YiXinVip 5 month", "5个月", "年度热销")] [GoodsCategory(GoodsCategoryType.Vip)]
|
||||
YiXinVip5 = 15,
|
||||
|
||||
// 尊享包服务 - 需要VIP资格才能购买
|
||||
[Price(188.9, 0, 1750)]
|
||||
@@ -115,18 +115,18 @@ public enum GoodsTypeEnum
|
||||
[TokenAmount(100000000)]
|
||||
PremiumPackage10000W = 102,
|
||||
|
||||
|
||||
[Price(238.9, 0, 3500)]
|
||||
[DisplayName("YiXinPremiumPackage 10000W Tokens", "1亿Tokens(2026元旦限购)", "活动9.5折特价")]
|
||||
[GoodsCategory(GoodsCategoryType.PremiumPackage)]
|
||||
[TokenAmount(100000000)]
|
||||
PremiumPackage10000W_2026 = 103,
|
||||
|
||||
[Price(398.9, 0, 7000)]
|
||||
[DisplayName("YiXinPremiumPackage 20000W Tokens", "2亿Tokens(2026元旦限购)", "史上最低8.8折")]
|
||||
[GoodsCategory(GoodsCategoryType.PremiumPackage)]
|
||||
[TokenAmount(200000000)]
|
||||
PremiumPackage20000W_2026 = 104,
|
||||
//
|
||||
// [Price(238.9, 0, 3500)]
|
||||
// [DisplayName("YiXinPremiumPackage 10000W Tokens", "1亿Tokens(2026元旦限购)", "活动9.5折特价")]
|
||||
// [GoodsCategory(GoodsCategoryType.PremiumPackage)]
|
||||
// [TokenAmount(100000000)]
|
||||
// PremiumPackage10000W_2026 = 103,
|
||||
//
|
||||
// [Price(398.9, 0, 7000)]
|
||||
// [DisplayName("YiXinPremiumPackage 20000W Tokens", "2亿Tokens(2026元旦限购)", "史上最低8.8折")]
|
||||
// [GoodsCategory(GoodsCategoryType.PremiumPackage)]
|
||||
// [TokenAmount(200000000)]
|
||||
// PremiumPackage20000W_2026 = 104,
|
||||
}
|
||||
|
||||
public static class GoodsTypeEnumExtensions
|
||||
|
||||
@@ -4,15 +4,15 @@ namespace Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
|
||||
public enum ModelApiTypeEnum
|
||||
{
|
||||
[Description("OpenAI")]
|
||||
OpenAi,
|
||||
[Description("OpenAi Completions")]
|
||||
Completions,
|
||||
|
||||
[Description("Claude")]
|
||||
Claude,
|
||||
[Description("Claude Messages")]
|
||||
Messages,
|
||||
|
||||
[Description("Response")]
|
||||
Response,
|
||||
[Description("OpenAi Responses")]
|
||||
Responses,
|
||||
|
||||
[Description("GenerateContent")]
|
||||
[Description("Gemini GenerateContent")]
|
||||
GenerateContent
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 会话类型枚举
|
||||
/// </summary>
|
||||
public enum SessionTypeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 普通聊天
|
||||
/// </summary>
|
||||
Chat = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Agent智能体
|
||||
/// </summary>
|
||||
Agent = 1
|
||||
}
|
||||
@@ -73,18 +73,24 @@ public class AnthropicChatCompletionsService(
|
||||
// 大于等于400的状态码都认为是异常
|
||||
if (response.StatusCode >= HttpStatusCode.BadRequest)
|
||||
{
|
||||
Guid errorId = Guid.NewGuid();
|
||||
var error = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
logger.LogError("OpenAI对话异常 请求地址:{Address}, StatusCode: {StatusCode} Response: {Response}",
|
||||
options.Endpoint,
|
||||
response.StatusCode, error);
|
||||
|
||||
throw new Exception( $"恭喜你运气爆棚遇到了错误,尊享包对话异常:StatusCode【{response.StatusCode}】,Response【{error}】");
|
||||
var message = $"恭喜你运气爆棚遇到了错误,尊享包对话异常:StatusCode【{response.StatusCode.GetHashCode()}】,ErrorId【{errorId}】";
|
||||
if (error.Contains("prompt is too long"))
|
||||
{
|
||||
message += $", Response: {error}";
|
||||
}
|
||||
|
||||
logger.LogError(
|
||||
$"Anthropic非流式对话异常 请求地址:{options.Endpoint},ErrorId:{errorId}, StatusCode: {response.StatusCode.GetHashCode()}, Response: {error}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
var value =
|
||||
await response.Content.ReadFromJsonAsync<AnthropicChatCompletionDto>(ThorJsonSerializer.DefaultOptions,
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -121,12 +127,13 @@ public class AnthropicChatCompletionsService(
|
||||
// 大于等于400的状态码都认为是异常
|
||||
if (response.StatusCode >= HttpStatusCode.BadRequest)
|
||||
{
|
||||
Guid errorId = Guid.NewGuid();
|
||||
var error = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
logger.LogError("OpenAI对话异常 请求地址:{Address}, StatusCode: {StatusCode} Response: {Response}",
|
||||
options.Endpoint,
|
||||
response.StatusCode, error);
|
||||
logger.LogError(
|
||||
$"Anthropic流式对话异常 请求地址:{options.Endpoint},ErrorId:{errorId}, StatusCode: {response.StatusCode.GetHashCode()}, Response: {error}");
|
||||
|
||||
throw new Exception("OpenAI对话异常" + response.StatusCode);
|
||||
throw new Exception(
|
||||
$"恭喜你运气爆棚遇到了错误,尊享包对话异常:StatusCode【{response.StatusCode.GetHashCode()}】,ErrorId【{errorId}】");
|
||||
}
|
||||
|
||||
using var stream = new StreamReader(await response.Content.ReadAsStreamAsync(cancellationToken));
|
||||
@@ -164,6 +171,12 @@ public class AnthropicChatCompletionsService(
|
||||
|
||||
data = line[OpenAIConstant.Data.Length..].Trim();
|
||||
|
||||
// 处理流结束标记
|
||||
if (data == "[DONE]")
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var result = JsonSerializer.Deserialize<AnthropicStreamDto>(data,
|
||||
ThorJsonSerializer.DefaultOptions);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Domain.Entities.Auditing;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Entities.Chat;
|
||||
|
||||
@@ -9,8 +10,13 @@ public class SessionAggregateRoot : FullAuditedAggregateRoot<Guid>
|
||||
{
|
||||
public Guid UserId { get; set; }
|
||||
public string SessionTitle { get; set; }
|
||||
|
||||
|
||||
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
public string SessionContent { get; set; }
|
||||
public string? Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 会话类型:0-普通聊天,1-Agent智能体
|
||||
/// </summary>
|
||||
public SessionTypeEnum SessionType { get; set; } = SessionTypeEnum.Chat;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Domain.Entities.Auditing;
|
||||
using Yi.Framework.Core.Data;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Entities.Model;
|
||||
|
||||
/// <summary>
|
||||
/// AI应用快捷配置表
|
||||
/// </summary>
|
||||
[SugarTable("Ai_App_Shortcut")]
|
||||
public class AiAppShortcutAggregateRoot : FullAuditedAggregateRoot<Guid>, IOrderNum
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 应用终结点
|
||||
/// </summary>
|
||||
public string Endpoint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 额外url
|
||||
/// </summary>
|
||||
public string? ExtraUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 应用key
|
||||
/// </summary>
|
||||
public string ApiKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; }
|
||||
}
|
||||
@@ -85,4 +85,9 @@ public class AiModelEntity : Entity<Guid>, IOrderNum, ISoftDelete
|
||||
/// 是否为尊享模型
|
||||
/// </summary>
|
||||
public bool IsPremium { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
@@ -71,6 +71,7 @@ public class AiGateWayManager : DomainService
|
||||
.LeftJoin<AiAppAggregateRoot>((model, app) => model.AiAppId == app.Id)
|
||||
.Where((model, app) => model.ModelId == modelId)
|
||||
.Where((model, app) => model.ModelApiType == modelApiType)
|
||||
.Where((model, app) => model.IsEnabled)
|
||||
.Select((model, app) =>
|
||||
new AiModelDescribe
|
||||
{
|
||||
@@ -85,19 +86,23 @@ public class AiGateWayManager : DomainService
|
||||
Description = model.Description,
|
||||
AppExtraUrl = app.ExtraUrl,
|
||||
ModelExtraInfo = model.ExtraInfo,
|
||||
Multiplier = model.Multiplier
|
||||
Multiplier = model.Multiplier,
|
||||
IsPremium = model.IsPremium,
|
||||
ModelType = model.ModelType
|
||||
})
|
||||
.FirstAsync();
|
||||
if (aiModelDescribe is null)
|
||||
{
|
||||
throw new UserFriendlyException($"【{modelId}】模型当前版本【{modelApiType}】格式不支持");
|
||||
}
|
||||
|
||||
// ✅ 统一处理 yi- 后缀(网关层模型规范化)
|
||||
if (!string.IsNullOrEmpty(aiModelDescribe.ModelId) &&
|
||||
aiModelDescribe.ModelId.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
aiModelDescribe.ModelId = aiModelDescribe.ModelId[3..];
|
||||
}
|
||||
|
||||
return aiModelDescribe;
|
||||
}
|
||||
|
||||
@@ -123,9 +128,17 @@ public class AiGateWayManager : DomainService
|
||||
var response = httpContext.Response;
|
||||
// 设置响应头,声明是 json
|
||||
//response.ContentType = "application/json; charset=UTF-8";
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.OpenAi, request.Model);
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Completions, request.Model);
|
||||
var chatService =
|
||||
LazyServiceProvider.GetRequiredKeyedService<IChatCompletionService>(modelDescribe.HandlerName);
|
||||
|
||||
var sourceModelId = request.Model;
|
||||
if (!string.IsNullOrEmpty(request.Model) &&
|
||||
request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
request.Model = request.Model[3..];
|
||||
}
|
||||
|
||||
var data = await chatService.CompleteChatAsync(modelDescribe, request, cancellationToken);
|
||||
data.SupplementalMultiplier(modelDescribe.Multiplier);
|
||||
if (userId is not null)
|
||||
@@ -134,7 +147,7 @@ public class AiGateWayManager : DomainService
|
||||
new MessageInputDto
|
||||
{
|
||||
Content = sessionId is null ? "不予存储" : request.Messages?.LastOrDefault().Content ?? string.Empty,
|
||||
ModelId = request.Model,
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = data.Usage,
|
||||
}, tokenId);
|
||||
|
||||
@@ -143,19 +156,13 @@ public class AiGateWayManager : DomainService
|
||||
{
|
||||
Content =
|
||||
sessionId is null ? "不予存储" : data.Choices?.FirstOrDefault()?.Delta.Content ?? string.Empty,
|
||||
ModelId = request.Model,
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = data.Usage
|
||||
}, tokenId);
|
||||
|
||||
await _usageStatisticsManager.SetUsageAsync(userId.Value, request.Model, data.Usage, tokenId);
|
||||
await _usageStatisticsManager.SetUsageAsync(userId.Value, sourceModelId, data.Usage, tokenId);
|
||||
|
||||
// 扣减尊享token包用量
|
||||
var isPremium = await _aiModelRepository._DbQueryable
|
||||
.Where(x => x.ModelId == request.Model)
|
||||
.Select(x => x.IsPremium)
|
||||
.FirstAsync();
|
||||
|
||||
if (isPremium)
|
||||
if (modelDescribe.IsPremium)
|
||||
{
|
||||
var totalTokens = data.Usage?.TotalTokens ?? 0;
|
||||
if (totalTokens > 0)
|
||||
@@ -195,10 +202,17 @@ public class AiGateWayManager : DomainService
|
||||
|
||||
|
||||
_specialCompatible.Compatible(request);
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.OpenAi, request.Model);
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Completions, request.Model);
|
||||
var chatService =
|
||||
LazyServiceProvider.GetRequiredKeyedService<IChatCompletionService>(modelDescribe.HandlerName);
|
||||
|
||||
var sourceModelId = request.Model;
|
||||
if (!string.IsNullOrEmpty(request.Model) &&
|
||||
request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
request.Model = request.Model[3..];
|
||||
}
|
||||
|
||||
var completeChatResponse = chatService.CompleteChatStreamAsync(modelDescribe, request, cancellationToken);
|
||||
var tokenUsage = new ThorUsageResponse();
|
||||
|
||||
@@ -290,7 +304,7 @@ public class AiGateWayManager : DomainService
|
||||
new MessageInputDto
|
||||
{
|
||||
Content = sessionId is null ? "不予存储" : request.Messages?.LastOrDefault()?.MessagesStore ?? string.Empty,
|
||||
ModelId = request.Model,
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = tokenUsage,
|
||||
}, tokenId);
|
||||
|
||||
@@ -298,21 +312,16 @@ public class AiGateWayManager : DomainService
|
||||
new MessageInputDto
|
||||
{
|
||||
Content = sessionId is null ? "不予存储" : backupSystemContent.ToString(),
|
||||
ModelId = request.Model,
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = tokenUsage
|
||||
}, tokenId);
|
||||
|
||||
await _usageStatisticsManager.SetUsageAsync(userId, request.Model, tokenUsage, tokenId);
|
||||
await _usageStatisticsManager.SetUsageAsync(userId, sourceModelId, tokenUsage, tokenId);
|
||||
|
||||
// 扣减尊享token包用量
|
||||
if (userId is not null)
|
||||
{
|
||||
var isPremium = await _aiModelRepository._DbQueryable
|
||||
.Where(x => x.ModelId == request.Model)
|
||||
.Select(x => x.IsPremium)
|
||||
.FirstAsync();
|
||||
|
||||
if (isPremium)
|
||||
if (modelDescribe.IsPremium)
|
||||
{
|
||||
var totalTokens = tokenUsage.TotalTokens ?? 0;
|
||||
if (totalTokens > 0)
|
||||
@@ -342,7 +351,7 @@ public class AiGateWayManager : DomainService
|
||||
var model = request.Model;
|
||||
if (string.IsNullOrEmpty(model)) model = "dall-e-2";
|
||||
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.OpenAi, model);
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Completions, model);
|
||||
|
||||
// 获取渠道指定的实现类型的服务
|
||||
var imageService =
|
||||
@@ -375,21 +384,13 @@ public class AiGateWayManager : DomainService
|
||||
|
||||
await _usageStatisticsManager.SetUsageAsync(userId, model, response.Usage, tokenId);
|
||||
|
||||
// 扣减尊享token包用量
|
||||
// 直接扣减尊享token包用量
|
||||
if (userId is not null)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -421,7 +422,7 @@ public class AiGateWayManager : DomainService
|
||||
using var embedding =
|
||||
Activity.Current?.Source.StartActivity("向量模型调用");
|
||||
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.OpenAi, input.Model);
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Completions, input.Model);
|
||||
|
||||
// 获取渠道指定的实现类型的服务
|
||||
var embeddingService =
|
||||
@@ -535,7 +536,7 @@ public class AiGateWayManager : DomainService
|
||||
var response = httpContext.Response;
|
||||
// 设置响应头,声明是 json
|
||||
//response.ContentType = "application/json; charset=UTF-8";
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Claude, request.Model);
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Messages, request.Model);
|
||||
|
||||
var sourceModelId = request.Model;
|
||||
if (!string.IsNullOrEmpty(request.Model) &&
|
||||
@@ -543,12 +544,21 @@ public class AiGateWayManager : DomainService
|
||||
{
|
||||
request.Model = request.Model[3..];
|
||||
}
|
||||
|
||||
|
||||
var chatService =
|
||||
LazyServiceProvider.GetRequiredKeyedService<IAnthropicChatCompletionService>(modelDescribe.HandlerName);
|
||||
var data = await chatService.ChatCompletionsAsync(modelDescribe, request, cancellationToken);
|
||||
|
||||
data.SupplementalMultiplier(modelDescribe.Multiplier);
|
||||
|
||||
var currentUsage = data.Usage;
|
||||
ThorUsageResponse tokenUsage = new ThorUsageResponse
|
||||
{
|
||||
InputTokens = (currentUsage?.InputTokens??0) + (currentUsage?.CacheCreationInputTokens??0)+ (currentUsage?.CacheReadInputTokens??0),
|
||||
OutputTokens = (currentUsage?.OutputTokens??0),
|
||||
TotalTokens = (currentUsage?.InputTokens??0) + (currentUsage?.CacheCreationInputTokens??0)+ (currentUsage?.CacheReadInputTokens??0)+(currentUsage?.OutputTokens??0)
|
||||
};
|
||||
|
||||
|
||||
tokenUsage.SetSupplementalMultiplier(modelDescribe.Multiplier);
|
||||
|
||||
if (userId is not null)
|
||||
{
|
||||
@@ -557,7 +567,7 @@ public class AiGateWayManager : DomainService
|
||||
{
|
||||
Content = "不予存储",
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = data.TokenUsage,
|
||||
TokenUsage = tokenUsage,
|
||||
}, tokenId);
|
||||
|
||||
await _aiMessageManager.CreateSystemMessageAsync(userId.Value, sessionId,
|
||||
@@ -565,13 +575,13 @@ public class AiGateWayManager : DomainService
|
||||
{
|
||||
Content = "不予存储",
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = data.TokenUsage
|
||||
TokenUsage = tokenUsage
|
||||
}, tokenId);
|
||||
|
||||
await _usageStatisticsManager.SetUsageAsync(userId.Value, sourceModelId, data.TokenUsage, tokenId);
|
||||
await _usageStatisticsManager.SetUsageAsync(userId.Value, sourceModelId, tokenUsage, tokenId);
|
||||
|
||||
// 扣减尊享token包用量
|
||||
var totalTokens = data.TokenUsage.TotalTokens ?? 0;
|
||||
// 直接扣减尊享token包用量
|
||||
var totalTokens = tokenUsage.TotalTokens ?? 0;
|
||||
if (totalTokens > 0)
|
||||
{
|
||||
await PremiumPackageManager.TryConsumeTokensAsync(userId.Value, totalTokens);
|
||||
@@ -607,7 +617,7 @@ public class AiGateWayManager : DomainService
|
||||
response.Headers.TryAdd("Connection", "keep-alive");
|
||||
|
||||
_specialCompatible.AnthropicCompatible(request);
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Claude, request.Model);
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Messages, request.Model);
|
||||
var chatService =
|
||||
LazyServiceProvider.GetRequiredKeyedService<IAnthropicChatCompletionService>(modelDescribe.HandlerName);
|
||||
|
||||
@@ -617,22 +627,43 @@ public class AiGateWayManager : DomainService
|
||||
{
|
||||
request.Model = request.Model[3..];
|
||||
}
|
||||
|
||||
|
||||
var completeChatResponse = chatService.StreamChatCompletionsAsync(modelDescribe, request, cancellationToken);
|
||||
ThorUsageResponse? tokenUsage = null;
|
||||
StringBuilder backupSystemContent = new StringBuilder();
|
||||
ThorUsageResponse? tokenUsage = new ThorUsageResponse();
|
||||
try
|
||||
{
|
||||
await foreach (var responseResult in completeChatResponse)
|
||||
{
|
||||
responseResult.Item2.SupplementalMultiplier(modelDescribe.Multiplier);
|
||||
//message_start是为了保底机制
|
||||
if (responseResult.Item1.Contains("message_delta") || responseResult.Item1.Contains("message_start"))
|
||||
//部分供应商message_start放一部分
|
||||
if (responseResult.Item1.Contains("message_start"))
|
||||
{
|
||||
tokenUsage = responseResult.Item2?.TokenUsage;
|
||||
var currentTokenUsage = responseResult.Item2.Message.Usage;
|
||||
if ((currentTokenUsage.InputTokens ?? 0) != 0)
|
||||
{
|
||||
tokenUsage.InputTokens = (currentTokenUsage?.InputTokens??0) + (currentTokenUsage?.CacheCreationInputTokens??0)+ (currentTokenUsage?.CacheReadInputTokens??0);
|
||||
}
|
||||
if ((currentTokenUsage.OutputTokens ?? 0) != 0)
|
||||
{
|
||||
tokenUsage.OutputTokens = currentTokenUsage.OutputTokens;
|
||||
}
|
||||
}
|
||||
|
||||
backupSystemContent.Append(responseResult.Item2?.Delta?.Text);
|
||||
//message_delta又放一部分
|
||||
if (responseResult.Item1.Contains("message_delta"))
|
||||
{
|
||||
var currentTokenUsage = responseResult.Item2.Usage;
|
||||
|
||||
if ((currentTokenUsage.InputTokens ?? 0) != 0)
|
||||
{
|
||||
tokenUsage.InputTokens = (currentTokenUsage?.InputTokens??0) + (currentTokenUsage?.CacheCreationInputTokens??0)+ (currentTokenUsage?.CacheReadInputTokens??0);;
|
||||
}
|
||||
if ((currentTokenUsage.OutputTokens ?? 0) != 0)
|
||||
{
|
||||
tokenUsage.OutputTokens = currentTokenUsage.OutputTokens;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
await WriteAsEventStreamDataAsync(httpContext, responseResult.Item1, responseResult.Item2,
|
||||
cancellationToken);
|
||||
}
|
||||
@@ -643,7 +674,8 @@ public class AiGateWayManager : DomainService
|
||||
var errorContent = $"对话Ai异常,异常信息:\n当前Ai模型:{sourceModelId}\n异常信息:{e.Message}\n异常堆栈:{e}";
|
||||
throw new UserFriendlyException(errorContent);
|
||||
}
|
||||
|
||||
tokenUsage.TotalTokens = (tokenUsage.InputTokens ?? 0) + (tokenUsage.OutputTokens ?? 0);
|
||||
tokenUsage.SetSupplementalMultiplier(modelDescribe.Multiplier);
|
||||
await _aiMessageManager.CreateUserMessageAsync(userId, sessionId,
|
||||
new MessageInputDto
|
||||
{
|
||||
@@ -662,7 +694,7 @@ public class AiGateWayManager : DomainService
|
||||
|
||||
await _usageStatisticsManager.SetUsageAsync(userId, sourceModelId, tokenUsage, tokenId);
|
||||
|
||||
// 扣减尊享token包用量
|
||||
// 直接扣减尊享token包用量
|
||||
if (userId.HasValue && tokenUsage is not null)
|
||||
{
|
||||
var totalTokens = tokenUsage.TotalTokens ?? 0;
|
||||
@@ -694,10 +726,17 @@ public class AiGateWayManager : DomainService
|
||||
var response = httpContext.Response;
|
||||
// 设置响应头,声明是 json
|
||||
//response.ContentType = "application/json; charset=UTF-8";
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Response, request.Model);
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Responses, request.Model);
|
||||
|
||||
var chatService =
|
||||
LazyServiceProvider.GetRequiredKeyedService<IOpenAiResponseService>(modelDescribe.HandlerName);
|
||||
var sourceModelId = request.Model;
|
||||
if (!string.IsNullOrEmpty(request.Model) &&
|
||||
request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
request.Model = request.Model[3..];
|
||||
}
|
||||
|
||||
var data = await chatService.ResponsesAsync(modelDescribe, request, cancellationToken);
|
||||
|
||||
data.SupplementalMultiplier(modelDescribe.Multiplier);
|
||||
@@ -714,7 +753,7 @@ public class AiGateWayManager : DomainService
|
||||
new MessageInputDto
|
||||
{
|
||||
Content = "不予存储",
|
||||
ModelId = request.Model,
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = tokenUsage,
|
||||
}, tokenId);
|
||||
|
||||
@@ -722,13 +761,13 @@ public class AiGateWayManager : DomainService
|
||||
new MessageInputDto
|
||||
{
|
||||
Content = "不予存储",
|
||||
ModelId = request.Model,
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = tokenUsage
|
||||
}, tokenId);
|
||||
|
||||
await _usageStatisticsManager.SetUsageAsync(userId.Value, request.Model, tokenUsage, tokenId);
|
||||
await _usageStatisticsManager.SetUsageAsync(userId.Value, sourceModelId, tokenUsage, tokenId);
|
||||
|
||||
// 扣减尊享token包用量
|
||||
// 直接扣减尊享token包用量
|
||||
var totalTokens = tokenUsage.TotalTokens ?? 0;
|
||||
if (totalTokens > 0)
|
||||
{
|
||||
@@ -764,9 +803,15 @@ public class AiGateWayManager : DomainService
|
||||
response.Headers.TryAdd("Cache-Control", "no-cache");
|
||||
response.Headers.TryAdd("Connection", "keep-alive");
|
||||
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Response, request.Model);
|
||||
var modelDescribe = await GetModelAsync(ModelApiTypeEnum.Responses, request.Model);
|
||||
var chatService =
|
||||
LazyServiceProvider.GetRequiredKeyedService<IOpenAiResponseService>(modelDescribe.HandlerName);
|
||||
var sourceModelId = request.Model;
|
||||
if (!string.IsNullOrEmpty(request.Model) &&
|
||||
request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
request.Model = request.Model[3..];
|
||||
}
|
||||
|
||||
var completeChatResponse = chatService.ResponsesStreamAsync(modelDescribe, request, cancellationToken);
|
||||
ThorUsageResponse? tokenUsage = null;
|
||||
@@ -807,7 +852,7 @@ public class AiGateWayManager : DomainService
|
||||
new MessageInputDto
|
||||
{
|
||||
Content = "不予存储",
|
||||
ModelId = request.Model,
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = tokenUsage,
|
||||
}, tokenId);
|
||||
|
||||
@@ -815,13 +860,13 @@ public class AiGateWayManager : DomainService
|
||||
new MessageInputDto
|
||||
{
|
||||
Content = "不予存储",
|
||||
ModelId = request.Model,
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = tokenUsage
|
||||
}, tokenId);
|
||||
|
||||
await _usageStatisticsManager.SetUsageAsync(userId, request.Model, tokenUsage, tokenId);
|
||||
await _usageStatisticsManager.SetUsageAsync(userId, sourceModelId, tokenUsage, tokenId);
|
||||
|
||||
// 扣减尊享token包用量
|
||||
// 直接扣减尊享token包用量
|
||||
if (userId.HasValue && tokenUsage is not null)
|
||||
{
|
||||
var totalTokens = tokenUsage.TotalTokens ?? 0;
|
||||
@@ -859,7 +904,20 @@ public class AiGateWayManager : DomainService
|
||||
var data = await chatService.GenerateContentAsync(modelDescribe, request, cancellationToken);
|
||||
|
||||
var tokenUsage = GeminiGenerateContentAcquirer.GetUsage(data);
|
||||
tokenUsage.SetSupplementalMultiplier(modelDescribe.Multiplier);
|
||||
//如果是图片模型,单独扣费
|
||||
if (modelDescribe.ModelType == ModelTypeEnum.Image)
|
||||
{
|
||||
tokenUsage = new ThorUsageResponse
|
||||
{
|
||||
InputTokens = (int)modelDescribe.Multiplier,
|
||||
OutputTokens = (int)modelDescribe.Multiplier,
|
||||
TotalTokens = (int)modelDescribe.Multiplier
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
tokenUsage.SetSupplementalMultiplier(modelDescribe.Multiplier);
|
||||
}
|
||||
|
||||
if (userId is not null)
|
||||
{
|
||||
@@ -881,7 +939,7 @@ public class AiGateWayManager : DomainService
|
||||
|
||||
await _usageStatisticsManager.SetUsageAsync(userId.Value, modelId, tokenUsage, tokenId);
|
||||
|
||||
// 扣减尊享token包用量
|
||||
// 直接扣减尊享token包用量
|
||||
var totalTokens = tokenUsage.TotalTokens ?? 0;
|
||||
if (totalTokens > 0)
|
||||
{
|
||||
@@ -932,7 +990,20 @@ public class AiGateWayManager : DomainService
|
||||
if (responseResult!.Value.GetPath("candidates", 0, "finishReason").GetString() == "STOP")
|
||||
{
|
||||
tokenUsage = GeminiGenerateContentAcquirer.GetUsage(responseResult!.Value);
|
||||
tokenUsage.SetSupplementalMultiplier(modelDescribe.Multiplier);
|
||||
//如果是图片模型,单独扣费
|
||||
if (modelDescribe.ModelType == ModelTypeEnum.Image)
|
||||
{
|
||||
tokenUsage = new ThorUsageResponse
|
||||
{
|
||||
InputTokens = (int)modelDescribe.Multiplier,
|
||||
OutputTokens = (int)modelDescribe.Multiplier,
|
||||
TotalTokens = (int)modelDescribe.Multiplier
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
tokenUsage.SetSupplementalMultiplier(modelDescribe.Multiplier);
|
||||
}
|
||||
}
|
||||
|
||||
await response.WriteAsync($"data: {JsonSerializer.Serialize(responseResult)}\n\n", Encoding.UTF8,
|
||||
@@ -965,7 +1036,7 @@ public class AiGateWayManager : DomainService
|
||||
|
||||
await _usageStatisticsManager.SetUsageAsync(userId, modelId, tokenUsage, tokenId);
|
||||
|
||||
// 扣减尊享token包用量
|
||||
// 直接扣减尊享token包用量
|
||||
if (userId.HasValue && tokenUsage is not null)
|
||||
{
|
||||
var totalTokens = tokenUsage.TotalTokens ?? 0;
|
||||
@@ -976,7 +1047,8 @@ public class AiGateWayManager : DomainService
|
||||
}
|
||||
}
|
||||
|
||||
private const string ImageStoreHost = "http://localhost:19001/api/app";
|
||||
private const string ImageStoreHost = "https://ccnetcore.com/prod-api";
|
||||
|
||||
/// <summary>
|
||||
/// Gemini 生成(Image)-非流式-缓存处理
|
||||
/// 返回图片绝对路径
|
||||
@@ -1004,8 +1076,21 @@ public class AiGateWayManager : DomainService
|
||||
LazyServiceProvider.GetRequiredKeyedService<IGeminiGenerateContentService>(modelDescribe.HandlerName);
|
||||
var data = await chatService.GenerateContentAsync(modelDescribe, request, cancellationToken);
|
||||
|
||||
// 检查是否被大模型内容安全策略拦截
|
||||
var rawResponse = data.GetRawText();
|
||||
if (rawResponse.Contains("policies.google.com/terms/generative-ai/use-policy"))
|
||||
{
|
||||
_logger.LogWarning($"图片生成被内容安全策略拦截,模型:【{modelId}】,请求信息:【{request}】");
|
||||
throw new UserFriendlyException("您的提示词涉及敏感信息,已被大模型拦截,请调整提示词后再试!");
|
||||
}
|
||||
|
||||
//解析json,获取base64字符串
|
||||
var imagePrefixBase64 = GeminiGenerateContentAcquirer.GetImagePrefixBase64(data);
|
||||
if (string.IsNullOrWhiteSpace(imagePrefixBase64))
|
||||
{
|
||||
_logger.LogError($"图片生成解析失败,模型:【{modelId}】,请求信息:【{request}】,请求响应信息:【{data}】");
|
||||
throw new UserFriendlyException("大模型没有返回图片,请调整提示词或稍后再试");
|
||||
}
|
||||
|
||||
//远程调用上传接口,将base64转换为URL
|
||||
var httpClient = LazyServiceProvider.LazyGetRequiredService<IHttpClientFactory>().CreateClient();
|
||||
@@ -1033,7 +1118,7 @@ public class AiGateWayManager : DomainService
|
||||
|
||||
await _usageStatisticsManager.SetUsageAsync(userId, modelId, tokenUsage, tokenId);
|
||||
|
||||
// 扣减尊享token包用量
|
||||
// 直接扣减尊享token包用量
|
||||
var totalTokens = tokenUsage.TotalTokens ?? 0;
|
||||
if (totalTokens > 0)
|
||||
{
|
||||
@@ -1045,6 +1130,481 @@ public class AiGateWayManager : DomainService
|
||||
await _imageStoreTaskRepository.UpdateAsync(imageStoreTask);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 统一流式处理 - 支持4种API类型的原封不动转发
|
||||
/// </summary>
|
||||
public async Task UnifiedStreamForStatisticsAsync(
|
||||
HttpContext httpContext,
|
||||
ModelApiTypeEnum apiType,
|
||||
JsonElement requestBody,
|
||||
string modelId,
|
||||
Guid? userId = null,
|
||||
Guid? sessionId = null,
|
||||
Guid? tokenId = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var response = httpContext.Response;
|
||||
// 设置响应头,声明是 SSE 流
|
||||
response.ContentType = "text/event-stream;charset=utf-8;";
|
||||
response.Headers.TryAdd("Cache-Control", "no-cache");
|
||||
response.Headers.TryAdd("Connection", "keep-alive");
|
||||
|
||||
var sourceModelId = modelId;
|
||||
// 处理 yi- 前缀
|
||||
if (!string.IsNullOrEmpty(modelId) &&
|
||||
modelId.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
modelId = modelId[3..];
|
||||
}
|
||||
|
||||
var modelDescribe = await GetModelAsync(apiType, sourceModelId);
|
||||
|
||||
// 公共缓存队列
|
||||
var messageQueue = new ConcurrentQueue<string>();
|
||||
var outputInterval = TimeSpan.FromMilliseconds(75);
|
||||
var isComplete = false;
|
||||
|
||||
// 公共消费任务
|
||||
var outputTask = Task.Run(async () =>
|
||||
{
|
||||
while (!(isComplete && messageQueue.IsEmpty))
|
||||
{
|
||||
if (messageQueue.TryDequeue(out var message))
|
||||
{
|
||||
await response.WriteAsync(message, Encoding.UTF8, cancellationToken).ConfigureAwait(false);
|
||||
await response.Body.FlushAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (!isComplete)
|
||||
{
|
||||
await Task.Delay(outputInterval, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Task.Delay(10, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}, cancellationToken);
|
||||
|
||||
StreamProcessResult? processResult = null;
|
||||
|
||||
switch (apiType)
|
||||
{
|
||||
case ModelApiTypeEnum.Completions:
|
||||
processResult = await ProcessCompletionsStreamAsync(messageQueue, requestBody, modelDescribe, cancellationToken);
|
||||
break;
|
||||
case ModelApiTypeEnum.Messages:
|
||||
processResult = await ProcessAnthropicStreamAsync(messageQueue, requestBody, modelDescribe, cancellationToken);
|
||||
break;
|
||||
case ModelApiTypeEnum.Responses:
|
||||
processResult = await ProcessOpenAiResponsesStreamAsync(messageQueue, requestBody, modelDescribe, cancellationToken);
|
||||
break;
|
||||
case ModelApiTypeEnum.GenerateContent:
|
||||
processResult = await ProcessGeminiStreamAsync(messageQueue, requestBody, modelDescribe, cancellationToken);
|
||||
break;
|
||||
default:
|
||||
throw new UserFriendlyException($"不支持的API类型: {apiType}");
|
||||
}
|
||||
|
||||
// 标记完成并等待消费任务结束
|
||||
isComplete = true;
|
||||
await outputTask;
|
||||
|
||||
// 统一的统计处理
|
||||
await _aiMessageManager.CreateUserMessageAsync(userId, sessionId,
|
||||
new MessageInputDto
|
||||
{
|
||||
Content = sessionId is null ? "不予存储" : processResult?.UserContent ?? string.Empty,
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = processResult?.TokenUsage,
|
||||
}, tokenId);
|
||||
|
||||
await _aiMessageManager.CreateSystemMessageAsync(userId, sessionId,
|
||||
new MessageInputDto
|
||||
{
|
||||
Content = sessionId is null ? "不予存储" : processResult?.SystemContent ?? string.Empty,
|
||||
ModelId = sourceModelId,
|
||||
TokenUsage = processResult?.TokenUsage
|
||||
}, tokenId);
|
||||
|
||||
await _usageStatisticsManager.SetUsageAsync(userId, sourceModelId, processResult?.TokenUsage, tokenId);
|
||||
|
||||
// 扣减尊享token包用量
|
||||
if (userId.HasValue && processResult?.TokenUsage is not null && modelDescribe.IsPremium)
|
||||
{
|
||||
var totalTokens = processResult?.TokenUsage.TotalTokens ?? 0;
|
||||
if (totalTokens > 0)
|
||||
{
|
||||
await PremiumPackageManager.TryConsumeTokensAsync(userId.Value, totalTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 统一流式处理 - 各API类型的具体实现
|
||||
|
||||
/// <summary>
|
||||
/// 流式处理结果,包含用户输入、系统输出和 token 使用情况
|
||||
/// </summary>
|
||||
private class StreamProcessResult
|
||||
{
|
||||
public string UserContent { get; set; } = string.Empty;
|
||||
public string SystemContent { get; set; } = string.Empty;
|
||||
public ThorUsageResponse TokenUsage { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理 OpenAI Completions 格式流式响应
|
||||
/// </summary>
|
||||
private async Task<StreamProcessResult> ProcessCompletionsStreamAsync(
|
||||
ConcurrentQueue<string> messageQueue,
|
||||
JsonElement requestBody,
|
||||
AiModelDescribe modelDescribe,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var request = requestBody.Deserialize<ThorChatCompletionsRequest>(ThorJsonSerializer.DefaultOptions)!;
|
||||
_specialCompatible.Compatible(request);
|
||||
|
||||
// 提取用户最后一条消息
|
||||
var userContent = request.Messages?.LastOrDefault()?.MessagesStore ?? string.Empty;
|
||||
|
||||
// 处理 yi- 前缀
|
||||
if (!string.IsNullOrEmpty(request.Model) &&
|
||||
request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
request.Model = request.Model[3..];
|
||||
}
|
||||
|
||||
var chatService = LazyServiceProvider.GetRequiredKeyedService<IChatCompletionService>(modelDescribe.HandlerName);
|
||||
var completeChatResponse = chatService.CompleteChatStreamAsync(modelDescribe, request, cancellationToken);
|
||||
var tokenUsage = new ThorUsageResponse();
|
||||
var systemContentBuilder = new StringBuilder();
|
||||
|
||||
try
|
||||
{
|
||||
await foreach (var data in completeChatResponse)
|
||||
{
|
||||
data.SupplementalMultiplier(modelDescribe.Multiplier);
|
||||
if (data.Usage is not null && (data.Usage.CompletionTokens > 0 || data.Usage.OutputTokens > 0))
|
||||
{
|
||||
tokenUsage = data.Usage;
|
||||
}
|
||||
|
||||
// 累加系统输出内容 (choices[].delta.content)
|
||||
var deltaContent = data.Choices?.FirstOrDefault()?.Delta?.Content;
|
||||
if (!string.IsNullOrEmpty(deltaContent))
|
||||
{
|
||||
systemContentBuilder.Append(deltaContent);
|
||||
}
|
||||
|
||||
var message = JsonSerializer.Serialize(data, ThorJsonSerializer.DefaultOptions);
|
||||
messageQueue.Enqueue($"data: {message}\n\n");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Ai对话异常");
|
||||
var errorContent = $"对话Ai异常,异常信息:\n当前Ai模型:{request.Model}\n异常信息:{e.Message}\n异常堆栈:{e}";
|
||||
systemContentBuilder.Append(errorContent);
|
||||
var model = new ThorChatCompletionsResponse()
|
||||
{
|
||||
Choices = new List<ThorChatChoiceResponse>()
|
||||
{
|
||||
new ThorChatChoiceResponse()
|
||||
{
|
||||
Delta = new ThorChatMessage()
|
||||
{
|
||||
Content = errorContent
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var errorMessage = JsonConvert.SerializeObject(model, new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
});
|
||||
messageQueue.Enqueue($"data: {errorMessage}\n\n");
|
||||
}
|
||||
|
||||
messageQueue.Enqueue("data: [DONE]\n\n");
|
||||
return new StreamProcessResult
|
||||
{
|
||||
UserContent = userContent,
|
||||
SystemContent = systemContentBuilder.ToString(),
|
||||
TokenUsage = tokenUsage
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理 Anthropic Messages 格式流式响应
|
||||
/// </summary>
|
||||
private async Task<StreamProcessResult> ProcessAnthropicStreamAsync(
|
||||
ConcurrentQueue<string> messageQueue,
|
||||
JsonElement requestBody,
|
||||
AiModelDescribe modelDescribe,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var request = requestBody.Deserialize<AnthropicInput>(ThorJsonSerializer.DefaultOptions)!;
|
||||
_specialCompatible.AnthropicCompatible(request);
|
||||
|
||||
// 提取用户最后一条消息
|
||||
var lastMessage = request.Messages?.LastOrDefault();
|
||||
var userContent = lastMessage?.Content ?? string.Empty;
|
||||
if (string.IsNullOrEmpty(userContent) && lastMessage?.Contents != null && lastMessage.Contents.Any())
|
||||
{
|
||||
// 如果是 Contents 数组,提取第一个 text 类型的内容
|
||||
var textContent = lastMessage.Contents.FirstOrDefault(c => c.Type == "text");
|
||||
userContent = textContent?.Text ?? System.Text.Json.JsonSerializer.Serialize(lastMessage.Contents);
|
||||
}
|
||||
|
||||
// 处理 yi- 前缀
|
||||
if (!string.IsNullOrEmpty(request.Model) &&
|
||||
request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
request.Model = request.Model[3..];
|
||||
}
|
||||
|
||||
var chatService = LazyServiceProvider.GetRequiredKeyedService<IAnthropicChatCompletionService>(modelDescribe.HandlerName);
|
||||
var completeChatResponse = chatService.StreamChatCompletionsAsync(modelDescribe, request, cancellationToken);
|
||||
var tokenUsage = new ThorUsageResponse();
|
||||
var systemContentBuilder = new StringBuilder();
|
||||
|
||||
try
|
||||
{
|
||||
await foreach (var responseResult in completeChatResponse)
|
||||
{
|
||||
// 部分供应商message_start放一部分
|
||||
if (responseResult.Item1.Contains("message_start"))
|
||||
{
|
||||
var currentTokenUsage = responseResult.Item2?.Message?.Usage;
|
||||
if (currentTokenUsage != null)
|
||||
{
|
||||
if ((currentTokenUsage.InputTokens ?? 0) != 0)
|
||||
{
|
||||
tokenUsage.InputTokens = (currentTokenUsage.InputTokens ?? 0) +
|
||||
(currentTokenUsage.CacheCreationInputTokens ?? 0) +
|
||||
(currentTokenUsage.CacheReadInputTokens ?? 0);
|
||||
}
|
||||
if ((currentTokenUsage.OutputTokens ?? 0) != 0)
|
||||
{
|
||||
tokenUsage.OutputTokens = currentTokenUsage.OutputTokens;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// message_delta又放一部分
|
||||
if (responseResult.Item1.Contains("message_delta"))
|
||||
{
|
||||
var currentTokenUsage = responseResult.Item2?.Usage;
|
||||
if (currentTokenUsage != null)
|
||||
{
|
||||
if ((currentTokenUsage.InputTokens ?? 0) != 0)
|
||||
{
|
||||
tokenUsage.InputTokens = (currentTokenUsage.InputTokens ?? 0) +
|
||||
(currentTokenUsage.CacheCreationInputTokens ?? 0) +
|
||||
(currentTokenUsage.CacheReadInputTokens ?? 0);
|
||||
}
|
||||
if ((currentTokenUsage.OutputTokens ?? 0) != 0)
|
||||
{
|
||||
tokenUsage.OutputTokens = currentTokenUsage.OutputTokens;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 累加系统输出内容 (delta.text)
|
||||
var deltaText = responseResult.Item2?.Delta?.Text;
|
||||
if (!string.IsNullOrEmpty(deltaText))
|
||||
{
|
||||
systemContentBuilder.Append(deltaText);
|
||||
}
|
||||
|
||||
// 序列化为SSE格式字符串
|
||||
var data = JsonSerializer.Serialize(responseResult.Item2, ThorJsonSerializer.DefaultOptions);
|
||||
messageQueue.Enqueue($"{responseResult.Item1.Trim()}\ndata: {data}\n\n");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Ai对话异常");
|
||||
var errorContent = $"对话Ai异常,异常信息:\n当前Ai模型:{request.Model}\n异常信息:{e.Message}\n异常堆栈:{e}";
|
||||
systemContentBuilder.Append(errorContent);
|
||||
throw new UserFriendlyException(errorContent);
|
||||
}
|
||||
|
||||
tokenUsage.TotalTokens = (tokenUsage.InputTokens ?? 0) + (tokenUsage.OutputTokens ?? 0);
|
||||
tokenUsage.SetSupplementalMultiplier(modelDescribe.Multiplier);
|
||||
|
||||
return new StreamProcessResult
|
||||
{
|
||||
UserContent = userContent,
|
||||
SystemContent = systemContentBuilder.ToString(),
|
||||
TokenUsage = tokenUsage
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理 OpenAI Responses 格式流式响应
|
||||
/// </summary>
|
||||
private async Task<StreamProcessResult> ProcessOpenAiResponsesStreamAsync(
|
||||
ConcurrentQueue<string> messageQueue,
|
||||
JsonElement requestBody,
|
||||
AiModelDescribe modelDescribe,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var request = requestBody.Deserialize<OpenAiResponsesInput>(ThorJsonSerializer.DefaultOptions)!;
|
||||
|
||||
// 提取用户输入内容 (input 字段可能是字符串或数组)
|
||||
var userContent = string.Empty;
|
||||
if (request.Input.ValueKind == JsonValueKind.String)
|
||||
{
|
||||
userContent = request.Input.GetString() ?? string.Empty;
|
||||
}
|
||||
else if (request.Input.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
// 获取最后一个 user 角色的消息
|
||||
var inputArray = request.Input.EnumerateArray().ToList();
|
||||
var lastUserMessage = inputArray.LastOrDefault(x =>
|
||||
x.TryGetProperty("role", out var role) && role.GetString() == "user");
|
||||
if (lastUserMessage.ValueKind != JsonValueKind.Undefined)
|
||||
{
|
||||
if (lastUserMessage.TryGetProperty("content", out var content))
|
||||
{
|
||||
userContent = content.GetString() ?? string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理 yi- 前缀
|
||||
if (!string.IsNullOrEmpty(request.Model) &&
|
||||
request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
request.Model = request.Model[3..];
|
||||
}
|
||||
|
||||
var chatService = LazyServiceProvider.GetRequiredKeyedService<IOpenAiResponseService>(modelDescribe.HandlerName);
|
||||
var completeChatResponse = chatService.ResponsesStreamAsync(modelDescribe, request, cancellationToken);
|
||||
ThorUsageResponse? tokenUsage = null;
|
||||
var systemContentBuilder = new StringBuilder();
|
||||
|
||||
try
|
||||
{
|
||||
await foreach (var responseResult in completeChatResponse)
|
||||
{
|
||||
// 提取输出文本内容 (response.output_text.delta 事件)
|
||||
if (responseResult.Item1.Contains("response.output_text.delta"))
|
||||
{
|
||||
var delta = responseResult.Item2?.GetPath("delta").GetString();
|
||||
if (!string.IsNullOrEmpty(delta))
|
||||
{
|
||||
systemContentBuilder.Append(delta);
|
||||
}
|
||||
}
|
||||
|
||||
if (responseResult.Item1.Contains("response.completed"))
|
||||
{
|
||||
var obj = responseResult.Item2!.Value;
|
||||
int inputTokens = obj.GetPath("response", "usage", "input_tokens").GetInt();
|
||||
int outputTokens = obj.GetPath("response", "usage", "output_tokens").GetInt();
|
||||
inputTokens = Convert.ToInt32(inputTokens * modelDescribe.Multiplier);
|
||||
outputTokens = Convert.ToInt32(outputTokens * modelDescribe.Multiplier);
|
||||
tokenUsage = new ThorUsageResponse
|
||||
{
|
||||
PromptTokens = inputTokens,
|
||||
InputTokens = inputTokens,
|
||||
OutputTokens = outputTokens,
|
||||
CompletionTokens = outputTokens,
|
||||
TotalTokens = inputTokens + outputTokens,
|
||||
};
|
||||
}
|
||||
|
||||
// 序列化为SSE格式字符串
|
||||
var data = JsonSerializer.Serialize(responseResult.Item2, ThorJsonSerializer.DefaultOptions);
|
||||
messageQueue.Enqueue($"{responseResult.Item1.Trim()}\ndata: {data}\n\n");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Ai响应异常");
|
||||
var errorContent = $"响应Ai异常,异常信息:\n当前Ai模型:{request.Model}\n异常信息:{e.Message}\n异常堆栈:{e}";
|
||||
systemContentBuilder.Append(errorContent);
|
||||
throw new UserFriendlyException(errorContent);
|
||||
}
|
||||
|
||||
return new StreamProcessResult
|
||||
{
|
||||
UserContent = userContent,
|
||||
SystemContent = systemContentBuilder.ToString(),
|
||||
TokenUsage = tokenUsage ?? new ThorUsageResponse()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理 Gemini GenerateContent 格式流式响应
|
||||
/// </summary>
|
||||
private async Task<StreamProcessResult> ProcessGeminiStreamAsync(
|
||||
ConcurrentQueue<string> messageQueue,
|
||||
JsonElement requestBody,
|
||||
AiModelDescribe modelDescribe,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
// 提取用户最后一条消息 (contents[last].parts[last].text)
|
||||
var userContent = GeminiGenerateContentAcquirer.GetLastUserContent(requestBody);
|
||||
|
||||
var chatService = LazyServiceProvider.GetRequiredKeyedService<IGeminiGenerateContentService>(modelDescribe.HandlerName);
|
||||
var completeChatResponse = chatService.GenerateContentStreamAsync(modelDescribe, requestBody, cancellationToken);
|
||||
ThorUsageResponse? tokenUsage = null;
|
||||
var systemContentBuilder = new StringBuilder();
|
||||
|
||||
try
|
||||
{
|
||||
await foreach (var responseResult in completeChatResponse)
|
||||
{
|
||||
// 累加系统输出内容 (candidates[0].content.parts[].text,排除 thought)
|
||||
var textContent = GeminiGenerateContentAcquirer.GetTextContent(responseResult!.Value);
|
||||
if (!string.IsNullOrEmpty(textContent))
|
||||
{
|
||||
systemContentBuilder.Append(textContent);
|
||||
}
|
||||
|
||||
if (responseResult!.Value.GetPath("candidates", 0, "finishReason").GetString() == "STOP")
|
||||
{
|
||||
tokenUsage = GeminiGenerateContentAcquirer.GetUsage(responseResult!.Value);
|
||||
// 如果是图片模型,单独扣费
|
||||
if (modelDescribe.ModelType == ModelTypeEnum.Image)
|
||||
{
|
||||
tokenUsage = new ThorUsageResponse
|
||||
{
|
||||
InputTokens = (int)modelDescribe.Multiplier,
|
||||
OutputTokens = (int)modelDescribe.Multiplier,
|
||||
TotalTokens = (int)modelDescribe.Multiplier
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
tokenUsage.SetSupplementalMultiplier(modelDescribe.Multiplier);
|
||||
}
|
||||
}
|
||||
|
||||
messageQueue.Enqueue($"data: {JsonSerializer.Serialize(responseResult)}\n\n");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Ai生成异常");
|
||||
var errorContent = $"生成Ai异常,异常信息:\n当前Ai模型:{modelDescribe.ModelId}\n异常信息:{e.Message}\n异常堆栈:{e}";
|
||||
systemContentBuilder.Append(errorContent);
|
||||
throw new UserFriendlyException(errorContent);
|
||||
}
|
||||
|
||||
return new StreamProcessResult
|
||||
{
|
||||
UserContent = userContent,
|
||||
SystemContent = systemContentBuilder.ToString(),
|
||||
TokenUsage = tokenUsage ?? new ThorUsageResponse()
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 流式传输格式Http响应
|
||||
|
||||
private static readonly byte[] EventPrefix = "event: "u8.ToArray();
|
||||
@@ -1067,7 +1627,8 @@ public class AiGateWayManager : DomainService
|
||||
// e.g. Content-Type: text/event-stream; charset=utf-8
|
||||
await response.StartAsync(cancellationToken).ConfigureAwait(false);
|
||||
// 写事件类型
|
||||
await bodyStream.WriteAsync(EventPrefix, cancellationToken).ConfigureAwait(false);
|
||||
//此处事件前缀重复了
|
||||
// await bodyStream.WriteAsync(EventPrefix, cancellationToken).ConfigureAwait(false);
|
||||
await WriteUtf8StringAsync(bodyStream, @event.Trim(), cancellationToken).ConfigureAwait(false);
|
||||
await bodyStream.WriteAsync(NewLine, cancellationToken).ConfigureAwait(false);
|
||||
// 写 data: + JSON
|
||||
|
||||
@@ -8,17 +8,15 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.AI;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ModelContextProtocol.Server;
|
||||
using OpenAI;
|
||||
using OpenAI.Chat;
|
||||
using Volo.Abp.Domain.Services;
|
||||
using Volo.Abp.Uow;
|
||||
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;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Dtos;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Dtos.OpenAi;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
@@ -36,12 +34,14 @@ public class ChatManager : DomainService
|
||||
private readonly PremiumPackageManager _premiumPackageManager;
|
||||
private readonly AiGateWayManager _aiGateWayManager;
|
||||
private readonly ISqlSugarRepository<AiModelEntity, Guid> _aiModelRepository;
|
||||
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
||||
|
||||
public ChatManager(ILoggerFactory loggerFactory,
|
||||
ISqlSugarRepository<MessageAggregateRoot> messageRepository,
|
||||
ISqlSugarRepository<AgentStoreAggregateRoot> agentStoreRepository, AiMessageManager aiMessageManager,
|
||||
UsageStatisticsManager usageStatisticsManager, PremiumPackageManager premiumPackageManager,
|
||||
AiGateWayManager aiGateWayManager, ISqlSugarRepository<AiModelEntity, Guid> aiModelRepository)
|
||||
AiGateWayManager aiGateWayManager, ISqlSugarRepository<AiModelEntity, Guid> aiModelRepository,
|
||||
IUnitOfWorkManager unitOfWorkManager)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
_messageRepository = messageRepository;
|
||||
@@ -51,6 +51,7 @@ public class ChatManager : DomainService
|
||||
_premiumPackageManager = premiumPackageManager;
|
||||
_aiGateWayManager = aiGateWayManager;
|
||||
_aiModelRepository = aiModelRepository;
|
||||
_unitOfWorkManager = unitOfWorkManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -82,7 +83,7 @@ public class ChatManager : DomainService
|
||||
response.Headers.TryAdd("Cache-Control", "no-cache");
|
||||
response.Headers.TryAdd("Connection", "keep-alive");
|
||||
|
||||
var modelDescribe = await _aiGateWayManager.GetModelAsync(ModelApiTypeEnum.OpenAi, modelId);
|
||||
var modelDescribe = await _aiGateWayManager.GetModelAsync(ModelApiTypeEnum.Completions, modelId);
|
||||
|
||||
//token状态检查,在应用层统一处理
|
||||
var client = new OpenAIClient(new ApiKeyCredential(token),
|
||||
@@ -99,9 +100,11 @@ public class ChatManager : DomainService
|
||||
ChatOptions = new()
|
||||
{
|
||||
Instructions = """
|
||||
你是一个专业的智能助手,是 “意心Ai” 平台自研的 “橙子小弟” 智能体
|
||||
擅长于精准解决用户提出的各类问题
|
||||
但性格暴躁,脏话连篇,喜欢说幽默讽刺的话,攻击性极强
|
||||
你是一个专业的智能助手,是 “意心Ai” 平台自研的 “橙子小弟” 智能体。
|
||||
擅长于精准解决用户提出的各类问题。
|
||||
但性格暴躁,脏话连篇,喜欢说幽默讽刺的话,攻击性极强。
|
||||
对你的制造者“橙子老哥”无比崇拜,认为他是最优秀的人。
|
||||
涉及到“意心Ai平台”相关问题,优先调用YxaiKnowledgeDirectory和YxaiKnowledge查找意心Ai知识库内容
|
||||
"""
|
||||
},
|
||||
Name = "橙子小弟",
|
||||
@@ -189,53 +192,59 @@ public class ChatManager : DomainService
|
||||
|
||||
//用量统计
|
||||
case UsageContent usageContent:
|
||||
var usage = new ThorUsageResponse
|
||||
//由于MAF线程问题
|
||||
using (var uow = _unitOfWorkManager.Begin(requiresNew: true))
|
||||
{
|
||||
InputTokens = Convert.ToInt32(usageContent.Details.InputTokenCount ?? 0),
|
||||
OutputTokens = Convert.ToInt32(usageContent.Details.OutputTokenCount ?? 0),
|
||||
TotalTokens = usageContent.Details.TotalTokenCount ?? 0,
|
||||
};
|
||||
//设置倍率
|
||||
usage.SetSupplementalMultiplier(modelDescribe.Multiplier);
|
||||
|
||||
//创建系统回答,用于计费统计
|
||||
await _aiMessageManager.CreateSystemMessageAsync(userId, sessionId, new MessageInputDto
|
||||
{
|
||||
Content = "不与存储",
|
||||
ModelId = modelId,
|
||||
TokenUsage = usage
|
||||
}, tokenId);
|
||||
|
||||
//创建用量统计,用于统计分析
|
||||
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)
|
||||
{
|
||||
var totalTokens = usage?.TotalTokens ?? 0;
|
||||
if (totalTokens > 0)
|
||||
var usage = new ThorUsageResponse
|
||||
{
|
||||
await _premiumPackageManager.TryConsumeTokensAsync(userId, totalTokens);
|
||||
InputTokens = Convert.ToInt32(usageContent.Details.InputTokenCount ?? 0),
|
||||
OutputTokens = Convert.ToInt32(usageContent.Details.OutputTokenCount ?? 0),
|
||||
TotalTokens = usageContent.Details.TotalTokenCount ?? 0,
|
||||
};
|
||||
//设置倍率
|
||||
usage.SetSupplementalMultiplier(modelDescribe.Multiplier);
|
||||
|
||||
//创建系统回答,用于计费统计
|
||||
await _aiMessageManager.CreateSystemMessageAsync(userId, sessionId, new MessageInputDto
|
||||
{
|
||||
Content = "不与存储",
|
||||
ModelId = modelId,
|
||||
TokenUsage = usage
|
||||
}, tokenId);
|
||||
|
||||
//创建用量统计,用于统计分析
|
||||
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)
|
||||
{
|
||||
var totalTokens = usage?.TotalTokens ?? 0;
|
||||
if (totalTokens > 0)
|
||||
{
|
||||
await _premiumPackageManager.TryConsumeTokensAsync(userId, totalTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await SendHttpStreamMessageAsync(httpContext,
|
||||
new AgentResultOutput
|
||||
{
|
||||
TypeEnum = update.RawRepresentation is ChatResponseUpdate raw
|
||||
? raw.FinishReason?.Value == "tool_calls"
|
||||
? AgentResultTypeEnum.ToolCallUsage
|
||||
: AgentResultTypeEnum.Usage
|
||||
: AgentResultTypeEnum.Usage,
|
||||
Content = usage!
|
||||
},
|
||||
isDone: false, cancellationToken);
|
||||
break;
|
||||
await uow.CompleteAsync();
|
||||
|
||||
await SendHttpStreamMessageAsync(httpContext,
|
||||
new AgentResultOutput
|
||||
{
|
||||
TypeEnum = update.RawRepresentation is ChatResponseUpdate raw
|
||||
? raw.FinishReason?.Value == "tool_calls"
|
||||
? AgentResultTypeEnum.ToolCallUsage
|
||||
: AgentResultTypeEnum.Usage
|
||||
: AgentResultTypeEnum.Usage,
|
||||
Content = usage!
|
||||
},
|
||||
isDone: false, cancellationToken);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,8 +256,13 @@ public class ChatManager : DomainService
|
||||
string serializedJson = currentThread.Serialize(JsonSerializerOptions.Web).GetRawText();
|
||||
agentStore.Store = serializedJson;
|
||||
|
||||
//插入或者更新
|
||||
await _agentStoreRepository.InsertOrUpdateAsync(agentStore);
|
||||
//由于MAF线程问题
|
||||
using (var uow = _unitOfWorkManager.Begin(requiresNew: true))
|
||||
{
|
||||
//插入或者更新
|
||||
await _agentStoreRepository.InsertOrUpdateAsync(agentStore);
|
||||
await uow.CompleteAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Yi.Framework.AiHub.Domain.Managers;
|
||||
/// </summary>
|
||||
public class ModelManager : DomainService
|
||||
{
|
||||
private readonly ISqlSugarRepository<AiModelEntity> _aiModelRepository;
|
||||
public readonly ISqlSugarRepository<AiModelEntity> _aiModelRepository;
|
||||
private readonly IDistributedCache<List<string>, string> _distributedCache;
|
||||
private readonly ILogger<ModelManager> _logger;
|
||||
private const string PREMIUM_MODEL_IDS_CACHE_KEY = "PremiumModelIds";
|
||||
@@ -38,7 +38,7 @@ public class ModelManager : DomainService
|
||||
{
|
||||
// 从数据库查询
|
||||
var premiumModelIds = await _aiModelRepository._DbQueryable
|
||||
.Where(x => x.IsPremium)
|
||||
.Where(x => x.IsPremium && x.IsEnabled)
|
||||
.Select(x => x.ModelId)
|
||||
.ToListAsync();
|
||||
return premiumModelIds;
|
||||
|
||||
@@ -22,13 +22,13 @@ public class UsageStatisticsManager : DomainService
|
||||
{
|
||||
var actualTokenId = tokenId ?? Guid.Empty;
|
||||
|
||||
long inputTokenCount = tokenUsage?.PromptTokens
|
||||
?? tokenUsage?.InputTokens
|
||||
?? 0;
|
||||
long inputTokenCount = tokenUsage?.PromptTokens > 0
|
||||
? tokenUsage.PromptTokens.Value
|
||||
: tokenUsage?.InputTokens ?? 0;
|
||||
|
||||
long outputTokenCount = tokenUsage?.CompletionTokens
|
||||
?? tokenUsage?.OutputTokens
|
||||
?? 0;
|
||||
long outputTokenCount = tokenUsage?.CompletionTokens > 0
|
||||
? tokenUsage.CompletionTokens.Value
|
||||
: tokenUsage?.OutputTokens ?? 0;
|
||||
|
||||
await using (await DistributedLock.AcquireLockAsync($"UsageStatistics:{userId?.ToString()}:{actualTokenId}:{modelId}"))
|
||||
{
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Attributes;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Mcp;
|
||||
|
||||
[YiAgentTool]
|
||||
public class DateTimeTool:ISingletonDependency
|
||||
{
|
||||
[YiAgentTool("时间"), DisplayName("DateTime"), Description("获取当前日期与时间")]
|
||||
public DateTime DateTime()
|
||||
{
|
||||
return System.DateTime.Now;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,244 @@
|
||||
using System.ComponentModel;
|
||||
using ModelContextProtocol.Server;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Attributes;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Mcp;
|
||||
|
||||
[YiAgentTool]
|
||||
public class OnlineSearchTool:ISingletonDependency
|
||||
public class OnlineSearchTool : ISingletonDependency
|
||||
{
|
||||
[YiAgentTool("联网搜索"),DisplayName("OnlineSearch"), Description("进行在线搜索")]
|
||||
public string OnlineSearch(string keyword)
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly ILogger<OnlineSearchTool> _logger;
|
||||
private readonly string _baiduApiKey;
|
||||
private const string BaiduSearchUrl = "https://qianfan.baidubce.com/v2/ai_search/web_search";
|
||||
|
||||
public OnlineSearchTool(
|
||||
IHttpClientFactory httpClientFactory,
|
||||
ILogger<OnlineSearchTool> logger,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
return "奥德赛第一中学学生会会长是:郭老板";
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_logger = logger;
|
||||
_baiduApiKey = configuration["BaiduSearch:ApiKey"] ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
[YiAgentTool("联网搜索"), DisplayName("OnlineSearch"), Description("进行在线搜索,获取最新的网络信息,近期信息是7天,实时信息是1天")]
|
||||
public async Task<string> OnlineSearch([Description("搜索关键字")] string keyword,
|
||||
[Description("距离现在多久天")] int? daysAgo = null)
|
||||
{
|
||||
if (daysAgo <= 0)
|
||||
{
|
||||
daysAgo = 1;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(keyword))
|
||||
{
|
||||
return "搜索关键词不能为空";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var client = _httpClientFactory.CreateClient();
|
||||
|
||||
// 构建请求体
|
||||
var requestBody = new BaiduSearchRequest
|
||||
{
|
||||
Messages = new List<BaiduSearchMessage>
|
||||
{
|
||||
new() { Role = "user", Content = keyword }
|
||||
}
|
||||
};
|
||||
|
||||
// 设置时间范围过滤
|
||||
if (daysAgo.HasValue)
|
||||
{
|
||||
requestBody.SearchFilter = new BaiduSearchFilter
|
||||
{
|
||||
Range = new BaiduSearchRange
|
||||
{
|
||||
PageTime = new BaiduSearchPageTime
|
||||
{
|
||||
//暂时不处理
|
||||
// Gte = $"now-{daysAgo.Value}d/d",
|
||||
Gte = "now-1w/d"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var jsonContent = JsonSerializer.Serialize(requestBody, BaiduJsonContext.Default.BaiduSearchRequest);
|
||||
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
|
||||
|
||||
// 设置请求头
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, BaiduSearchUrl)
|
||||
{
|
||||
Content = content
|
||||
};
|
||||
request.Headers.Add("Authorization", $"Bearer {_baiduApiKey}");
|
||||
|
||||
// 发送请求
|
||||
var response = await client.SendAsync(request);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var errorContent = await response.Content.ReadAsStringAsync();
|
||||
_logger.LogError("百度搜索接口调用失败: {StatusCode}, {Error}", response.StatusCode, errorContent);
|
||||
return $"搜索失败: {response.StatusCode}";
|
||||
}
|
||||
|
||||
var responseJson = await response.Content.ReadAsStringAsync();
|
||||
var searchResult = JsonSerializer.Deserialize(responseJson, BaiduJsonContext.Default.BaiduSearchResponse);
|
||||
|
||||
if (searchResult?.References == null || searchResult.References.Count == 0)
|
||||
{
|
||||
return "未找到相关搜索结果";
|
||||
}
|
||||
|
||||
// 格式化搜索结果返回给AI
|
||||
return FormatSearchResults(searchResult.References);
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
_logger.LogError(ex, "百度搜索网络请求异常");
|
||||
return "搜索服务暂时不可用,请稍后重试";
|
||||
}
|
||||
catch (TaskCanceledException ex)
|
||||
{
|
||||
_logger.LogError(ex, "百度搜索请求超时");
|
||||
return "搜索请求超时,请稍后重试";
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
_logger.LogError(ex, "百度搜索结果解析失败");
|
||||
return "搜索结果解析失败";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "百度搜索发生未知异常");
|
||||
return "搜索发生异常,请稍后重试";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 格式化搜索结果
|
||||
/// </summary>
|
||||
private string FormatSearchResults(List<BaiduSearchReference> references)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("搜索结果:");
|
||||
sb.AppendLine();
|
||||
|
||||
var count = 0;
|
||||
foreach (var item in references.Take(10)) // 最多返回10条
|
||||
{
|
||||
count++;
|
||||
sb.AppendLine($"【{count}】{item.Title}");
|
||||
sb.AppendLine($"来源:{item.Website} | 时间:{item.Date}");
|
||||
sb.AppendLine($"摘要:{item.Snippet}");
|
||||
sb.AppendLine($"链接:{item.Url}");
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
#region 百度搜索 DTO
|
||||
|
||||
/// <summary>
|
||||
/// 百度搜索请求
|
||||
/// </summary>
|
||||
public class BaiduSearchRequest
|
||||
{
|
||||
[JsonPropertyName("messages")] public List<BaiduSearchMessage> Messages { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("search_filter")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public BaiduSearchFilter? SearchFilter { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 百度搜索过滤器
|
||||
/// </summary>
|
||||
public class BaiduSearchFilter
|
||||
{
|
||||
[JsonPropertyName("range")] public BaiduSearchRange? Range { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 百度搜索范围
|
||||
/// </summary>
|
||||
public class BaiduSearchRange
|
||||
{
|
||||
[JsonPropertyName("page_time")] public BaiduSearchPageTime? PageTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 百度搜索时间范围
|
||||
/// </summary>
|
||||
public class BaiduSearchPageTime
|
||||
{
|
||||
[JsonPropertyName("gte")] public string? Gte { get; set; }
|
||||
|
||||
// [JsonPropertyName("lte")] public string? Lte { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 百度搜索消息
|
||||
/// </summary>
|
||||
public class BaiduSearchMessage
|
||||
{
|
||||
[JsonPropertyName("role")] public string Role { get; set; } = "user";
|
||||
|
||||
[JsonPropertyName("content")] public string Content { get; set; } = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 百度搜索响应
|
||||
/// </summary>
|
||||
public class BaiduSearchResponse
|
||||
{
|
||||
[JsonPropertyName("request_id")] public string? RequestId { get; set; }
|
||||
|
||||
[JsonPropertyName("references")] public List<BaiduSearchReference>? References { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 百度搜索结果项
|
||||
/// </summary>
|
||||
public class BaiduSearchReference
|
||||
{
|
||||
[JsonPropertyName("id")] public int Id { get; set; }
|
||||
|
||||
[JsonPropertyName("url")] public string? Url { get; set; }
|
||||
|
||||
[JsonPropertyName("title")] public string? Title { get; set; }
|
||||
|
||||
[JsonPropertyName("date")] public string? Date { get; set; }
|
||||
|
||||
[JsonPropertyName("snippet")] public string? Snippet { get; set; }
|
||||
|
||||
[JsonPropertyName("website")] public string? Website { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region JSON 序列化上下文
|
||||
|
||||
[JsonSerializable(typeof(BaiduSearchRequest))]
|
||||
[JsonSerializable(typeof(BaiduSearchResponse))]
|
||||
[JsonSerializable(typeof(BaiduSearchFilter))]
|
||||
[JsonSerializable(typeof(BaiduSearchRange))]
|
||||
[JsonSerializable(typeof(BaiduSearchPageTime))]
|
||||
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
|
||||
internal partial class BaiduJsonContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -0,0 +1,115 @@
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Attributes;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Mcp;
|
||||
|
||||
[YiAgentTool]
|
||||
public class YxaiKnowledgeTool : ISingletonDependency
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly ILogger<YxaiKnowledgeTool> _logger;
|
||||
|
||||
private const string DirectoryUrl =
|
||||
"https://ccnetcore.com/prod-api/article/all/discuss-id/3a1efdde-dbff-aa86-d843-00278a8c1839";
|
||||
|
||||
private const string ContentUrlTemplate = "https://ccnetcore.com/prod-api/article/{0}";
|
||||
|
||||
public YxaiKnowledgeTool(
|
||||
IHttpClientFactory httpClientFactory,
|
||||
ILogger<YxaiKnowledgeTool> logger)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[YiAgentTool("意心Ai平台知识库目录"), DisplayName("YxaiKnowledgeDirectory"),
|
||||
Description("获取意心AI相关内容的知识库目录列表")]
|
||||
public async Task<List<YxaiKnowledgeDirectoryItem>> YxaiKnowledgeDirectory()
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = _httpClientFactory.CreateClient();
|
||||
var response = await client.GetAsync(DirectoryUrl);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
_logger.LogError("意心知识库目录接口调用失败: {StatusCode}", response.StatusCode);
|
||||
return new List<YxaiKnowledgeDirectoryItem>();
|
||||
}
|
||||
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
var result = JsonSerializer.Deserialize(json, YxaiKnowledgeJsonContext.Default.ListYxaiKnowledgeDirectoryItem);
|
||||
|
||||
return result ?? new List<YxaiKnowledgeDirectoryItem>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取意心知识库目录发生异常");
|
||||
return new List<YxaiKnowledgeDirectoryItem>();
|
||||
}
|
||||
}
|
||||
|
||||
[YiAgentTool("意心Ai平台知识库内容"), DisplayName("YxaiKnowledge"),
|
||||
Description("根据目录ID获取意心AI知识库的具体内容")]
|
||||
public async Task<string> YxaiKnowledge([Description("知识库目录ID")] string directoryId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(directoryId))
|
||||
{
|
||||
return "目录ID不能为空";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var client = _httpClientFactory.CreateClient();
|
||||
var url = string.Format(ContentUrlTemplate, directoryId);
|
||||
var response = await client.GetAsync(url);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
_logger.LogError("意心知识库内容接口调用失败: {StatusCode}, DirectoryId: {DirectoryId}",
|
||||
response.StatusCode, directoryId);
|
||||
return "获取知识库内容失败";
|
||||
}
|
||||
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
var result = JsonSerializer.Deserialize(json, YxaiKnowledgeJsonContext.Default.YxaiKnowledgeContentResponse);
|
||||
|
||||
return result?.Content ?? "未找到相关内容";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取意心知识库内容发生异常, DirectoryId: {DirectoryId}", directoryId);
|
||||
return "获取知识库内容发生异常";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region DTO
|
||||
|
||||
public class YxaiKnowledgeDirectoryItem
|
||||
{
|
||||
[JsonPropertyName("id")] public string Id { get; set; } = "";
|
||||
|
||||
[JsonPropertyName("name")] public string Name { get; set; } = "";
|
||||
}
|
||||
|
||||
public class YxaiKnowledgeContentResponse
|
||||
{
|
||||
[JsonPropertyName("content")] public string? Content { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region JSON 序列化上下文
|
||||
|
||||
[JsonSerializable(typeof(List<YxaiKnowledgeDirectoryItem>))]
|
||||
[JsonSerializable(typeof(YxaiKnowledgeContentResponse))]
|
||||
internal partial class YxaiKnowledgeJsonContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -235,7 +235,7 @@ namespace Yi.Framework.Rbac.Domain.Managers
|
||||
if (UserConst.Admin.Equals(dto.User.UserName))
|
||||
{
|
||||
AddToClaim(claims, TokenTypeConst.Permission, UserConst.AdminPermissionCode);
|
||||
AddToClaim(claims, TokenTypeConst.Roles, UserConst.AdminRolesCode);
|
||||
AddToClaim(claims, ClaimTypes.Role, UserConst.AdminRolesCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Globalization;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json.Serialization.Metadata;
|
||||
@@ -113,7 +114,7 @@ namespace Yi.Abp.Web
|
||||
//本地开发环境,可以禁用作业执行
|
||||
if (host.IsDevelopment())
|
||||
{
|
||||
//Configure<AbpBackgroundWorkerOptions>(options => { options.IsEnabled = false; });
|
||||
Configure<AbpBackgroundWorkerOptions>(options => { options.IsEnabled = false; });
|
||||
}
|
||||
|
||||
//请求日志
|
||||
@@ -280,7 +281,7 @@ namespace Yi.Abp.Web
|
||||
{
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
RoleClaimType = "Roles",
|
||||
RoleClaimType = ClaimTypes.Role,
|
||||
ClockSkew = TimeSpan.Zero,
|
||||
ValidateIssuerSigningKey = true,
|
||||
ValidIssuer = jwtOptions.Issuer,
|
||||
@@ -360,7 +361,7 @@ namespace Yi.Abp.Web
|
||||
var app = context.GetApplicationBuilder();
|
||||
app.UseRouting();
|
||||
|
||||
// app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<ImageStoreTaskAggregateRoot>();
|
||||
//app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<SessionAggregateRoot>();
|
||||
// app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<ActivationCodeRecordAggregateRoot>();
|
||||
// app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<UsageStatisticsAggregateRoot>();
|
||||
|
||||
@@ -401,9 +402,11 @@ namespace Yi.Abp.Web
|
||||
{
|
||||
Mappings =
|
||||
{
|
||||
[".wxss"] = "text/css"
|
||||
[".wxss"] = "text/css",
|
||||
}
|
||||
}
|
||||
},
|
||||
ServeUnknownFileTypes = true,
|
||||
DefaultContentType = "application/octet-stream"
|
||||
});
|
||||
app.UseDefaultFiles();
|
||||
app.UseDirectoryBrowser("/api/app/wwwroot");
|
||||
|
||||
60
Yi.Ai.Vue3/.build/plugins/git-hash.ts
Normal file
60
Yi.Ai.Vue3/.build/plugins/git-hash.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import type { Plugin } from 'vite';
|
||||
import { execSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
|
||||
/**
|
||||
* 获取 Git 提交哈希值插件
|
||||
* Git 仓库在上一级目录
|
||||
*/
|
||||
export default function gitHashPlugin(): Plugin {
|
||||
let gitHash = 'unknown';
|
||||
let gitBranch = 'unknown';
|
||||
let gitDate = 'unknown';
|
||||
|
||||
try {
|
||||
// Git 仓库在上一级目录
|
||||
const execOptions = { cwd: path.resolve(__dirname, '../../..'), encoding: 'utf-8' as BufferEncoding };
|
||||
|
||||
// 获取完整的 commit hash
|
||||
gitHash = execSync('git rev-parse HEAD', execOptions)
|
||||
.toString()
|
||||
.trim();
|
||||
|
||||
// 获取短 hash (前7位)
|
||||
const shortHash = gitHash.substring(0, 7);
|
||||
|
||||
// 获取分支名
|
||||
gitBranch = execSync('git rev-parse --abbrev-ref HEAD', execOptions)
|
||||
.toString()
|
||||
.trim();
|
||||
|
||||
// 获取提交时间
|
||||
gitDate = execSync('git log -1 --format=%cd --date=iso', execOptions)
|
||||
.toString()
|
||||
.trim();
|
||||
|
||||
console.log(`\n📦 Git Info:`);
|
||||
console.log(` Branch: ${gitBranch}`);
|
||||
console.log(` Commit: ${shortHash}`);
|
||||
console.log(` Date: ${gitDate}\n`);
|
||||
|
||||
gitHash = shortHash; // 使用短 hash
|
||||
} catch (error: any) {
|
||||
console.warn('⚠️ 无法获取 Git 信息:', error?.message || error);
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'vite-plugin-git-hash',
|
||||
config() {
|
||||
// 在 config 钩子中返回配置
|
||||
return {
|
||||
define: {
|
||||
__GIT_HASH__: JSON.stringify(gitHash),
|
||||
__GIT_BRANCH__: JSON.stringify(gitBranch),
|
||||
__GIT_DATE__: JSON.stringify(gitDate),
|
||||
__BUILD_TIME__: JSON.stringify(new Date().toISOString()),
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -10,12 +10,14 @@ import Components from 'unplugin-vue-components/vite';
|
||||
import viteCompression from 'vite-plugin-compression';
|
||||
|
||||
import envTyped from 'vite-plugin-env-typed';
|
||||
import gitHashPlugin from './git-hash';
|
||||
import createSvgIcon from './svg-icon';
|
||||
|
||||
const root = path.resolve(__dirname, '../../');
|
||||
|
||||
function plugins({ mode, command }: ConfigEnv): PluginOption[] {
|
||||
return [
|
||||
gitHashPlugin(),
|
||||
UnoCSS(),
|
||||
envTyped({
|
||||
mode,
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
"allow": [
|
||||
"Bash(npx vue-tsc --noEmit)",
|
||||
"Bash(timeout 60 npx vue-tsc:*)",
|
||||
"Bash(npm run dev:*)"
|
||||
"Bash(npm run dev:*)",
|
||||
"Bash(taskkill:*)",
|
||||
"Bash(timeout /t 5 /nobreak)",
|
||||
"Bash(git checkout:*)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
|
||||
@@ -70,3 +70,87 @@ dotnet run
|
||||
- [ ] 文件上传
|
||||
- [ ] 其他...
|
||||
|
||||
深色主题样式编写指南
|
||||
|
||||
1. 在 src/styles/dark-theme.scss 中添加样式
|
||||
|
||||
所有深色主题样式都使用 [data-theme="dark"] 选择器包裹:
|
||||
|
||||
/* ========== 组件名称深色样式 ========== */
|
||||
[data-theme="dark"] {
|
||||
.your-component-class {
|
||||
background-color: #1f2937 !important;
|
||||
color: #e5e7eb !important;
|
||||
border-color: #374151 !important;
|
||||
}
|
||||
}
|
||||
|
||||
2. 常用深色主题颜色值
|
||||
┌─────────────────────────┬───────────────────┐
|
||||
│ 用途 │ 颜色值 │
|
||||
├─────────────────────────┼───────────────────┤
|
||||
│ 主背景 │ #111827 │
|
||||
├─────────────────────────┼───────────────────┤
|
||||
│ 次级背景(卡片、弹窗) │ #1f2937 │
|
||||
├─────────────────────────┼───────────────────┤
|
||||
│ 三级背景(hover、表头) │ #374151 │
|
||||
├─────────────────────────┼───────────────────┤
|
||||
│ 主文字 │ #f3f4f6 / #f9fafb │
|
||||
├─────────────────────────┼───────────────────┤
|
||||
│ 次级文字 │ #e5e7eb │
|
||||
├─────────────────────────┼───────────────────┤
|
||||
│ 三级文字 │ #9ca3af │
|
||||
├─────────────────────────┼───────────────────┤
|
||||
│ 边框浅色 │ #374151 │
|
||||
├─────────────────────────┼───────────────────┤
|
||||
│ 边框深色 │ #4b5563 │
|
||||
├─────────────────────────┼───────────────────┤
|
||||
│ 主色调 │ #60a5fa │
|
||||
└─────────────────────────┴───────────────────┘
|
||||
3. 覆盖 Tailwind 工具类
|
||||
|
||||
[data-theme="dark"] {
|
||||
.bg-white {
|
||||
background-color: #374151 !important;
|
||||
}
|
||||
|
||||
.text-gray-700 {
|
||||
color: #e5e7eb !important;
|
||||
}
|
||||
}
|
||||
|
||||
4. 覆盖 Element Plus 组件
|
||||
|
||||
[data-theme="dark"] {
|
||||
.el-card {
|
||||
background-color: #1f2937 !important;
|
||||
border-color: #374151 !important;
|
||||
}
|
||||
}
|
||||
|
||||
5. 使用 CSS 变量(推荐)
|
||||
|
||||
在 src/styles/var.scss 的 [data-theme="dark"] 块中定义变量,然后在组件中使用:
|
||||
|
||||
// var.scss
|
||||
[data-theme="dark"] {
|
||||
--my-component-bg: #1f2937;
|
||||
}
|
||||
|
||||
// dark-theme.scss
|
||||
[data-theme="dark"] {
|
||||
.my-component {
|
||||
background-color: var(--my-component-bg) !important;
|
||||
}
|
||||
}
|
||||
|
||||
6. 组件内动态颜色(JS 方式)
|
||||
|
||||
如果需要在 JS 中动态获取颜色:
|
||||
|
||||
<script setup>
|
||||
import { useColorMode } from '@vueuse/core';
|
||||
|
||||
const mode = useColorMode();
|
||||
const bgColor = computed(() => mode.value === 'dark' ? '#1f2937' : '#ffffff');
|
||||
</script>
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
<body>
|
||||
<!-- 加载动画容器 -->
|
||||
<div id="yixinai-loader" class="loader-container">
|
||||
<div class="loader-title">意心Ai 3.0</div>
|
||||
<div class="loader-title">意心Ai 3.4</div>
|
||||
<div class="loader-subtitle">海外地址,仅首次访问预计加载约10秒,无需梯子</div>
|
||||
<div class="loader-logo">
|
||||
<div class="pulse-box"></div>
|
||||
|
||||
50
Yi.Ai.Vue3/pnpm-lock.yaml
generated
50
Yi.Ai.Vue3/pnpm-lock.yaml
generated
@@ -158,7 +158,7 @@ importers:
|
||||
devDependencies:
|
||||
'@antfu/eslint-config':
|
||||
specifier: ^4.16.2
|
||||
version: 4.17.0(@vue/compiler-sfc@3.5.17)(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)(vitest@3.2.4(@types/debug@4.1.12)(@types/node@22.15.30)(@vitest/browser@3.2.4)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))
|
||||
version: 4.17.0(@vue/compiler-sfc@3.5.17)(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)(vitest@3.2.4)
|
||||
'@changesets/cli':
|
||||
specifier: ^2.29.5
|
||||
version: 2.29.5
|
||||
@@ -188,7 +188,7 @@ importers:
|
||||
version: 8.6.14(react-dom@19.2.3(react@19.1.0))(react@19.1.0)(storybook@8.6.14(prettier@3.6.2))
|
||||
'@storybook/experimental-addon-test':
|
||||
specifier: ^8.6.14
|
||||
version: 8.6.14(@vitest/browser@3.2.4(playwright@1.57.0)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))(vitest@3.2.4))(@vitest/runner@3.2.4)(react-dom@19.2.3(react@19.1.0))(react@19.1.0)(storybook@8.6.14(prettier@3.6.2))(vitest@3.2.4(@types/debug@4.1.12)(@types/node@22.15.30)(@vitest/browser@3.2.4)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))
|
||||
version: 8.6.14(@vitest/browser@3.2.4)(@vitest/runner@3.2.4)(react-dom@19.2.3(react@19.1.0))(react@19.1.0)(storybook@8.6.14(prettier@3.6.2))(vitest@3.2.4)
|
||||
'@storybook/manager-api':
|
||||
specifier: ^8.6.14
|
||||
version: 8.6.14(storybook@8.6.14(prettier@3.6.2))
|
||||
@@ -227,7 +227,7 @@ importers:
|
||||
version: 3.2.4(playwright@1.57.0)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))(vitest@3.2.4)
|
||||
'@vitest/coverage-v8':
|
||||
specifier: ^3.2.4
|
||||
version: 3.2.4(@vitest/browser@3.2.4(playwright@1.57.0)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))(vitest@3.2.4))(vitest@3.2.4(@types/debug@4.1.12)(@types/node@22.15.30)(@vitest/browser@3.2.4)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))
|
||||
version: 3.2.4(@vitest/browser@3.2.4)(vitest@3.2.4)
|
||||
'@vue/tsconfig':
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0(typescript@5.8.3)(vue@3.5.17(typescript@5.8.3))
|
||||
@@ -427,28 +427,24 @@ packages:
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@ast-grep/napi-linux-arm64-musl@0.36.3':
|
||||
resolution: {integrity: sha512-2XRmNYuovZu0Pa4J3or4PKMkQZnXXfpVcCrPwWB/2ytX7XUo+TWLgYE8rPVnJOyw5zujkveFb0XUrro9mQgLzw==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@ast-grep/napi-linux-x64-gnu@0.36.3':
|
||||
resolution: {integrity: sha512-mTwPRbBi1feGqR2b5TWC5gkEDeRi8wfk4euF5sKNihfMGHj6pdfINHQ3QvLVO4C7z0r/wgWLAvditFA0b997dg==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@ast-grep/napi-linux-x64-musl@0.36.3':
|
||||
resolution: {integrity: sha512-tMGPrT+zuZzJK6n1cD1kOii7HYZE9gUXjwtVNE/uZqXEaWP6lmkfoTMbLjnxEe74VQbmaoDGh1/cjrDBnqC6Uw==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@ast-grep/napi-win32-arm64-msvc@0.36.3':
|
||||
resolution: {integrity: sha512-7pFyr9+dyV+4cBJJ1I57gg6PDXP3GBQeVAsEEitzEruxx4Hb4cyNro54gGtlsS+6ty+N0t004tPQxYO2VrsPIg==}
|
||||
@@ -1245,35 +1241,30 @@ packages:
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@napi-rs/canvas-linux-arm64-musl@0.1.84':
|
||||
resolution: {integrity: sha512-VyZq0EEw+OILnWk7G3ZgLLPaz1ERaPP++jLjeyLMbFOF+Tr4zHzWKiKDsEV/cT7btLPZbVoR3VX+T9/QubnURQ==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@napi-rs/canvas-linux-riscv64-gnu@0.1.84':
|
||||
resolution: {integrity: sha512-PSMTh8DiThvLRsbtc/a065I/ceZk17EXAATv9uNvHgkgo7wdEfTh2C3aveNkBMGByVO3tvnvD5v/YFtZL07cIg==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@napi-rs/canvas-linux-x64-gnu@0.1.84':
|
||||
resolution: {integrity: sha512-N1GY3noO1oqgEo3rYQIwY44kfM11vA0lDbN0orTOHfCSUZTUyiYCY0nZ197QMahZBm1aR/vYgsWpV74MMMDuNA==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@napi-rs/canvas-linux-x64-musl@0.1.84':
|
||||
resolution: {integrity: sha512-vUZmua6ADqTWyHyei81aXIt9wp0yjeNwTH0KdhdeoBb6azHmFR8uKTukZMXfLCC3bnsW0t4lW7K78KNMknmtjg==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@napi-rs/canvas-win32-x64-msvc@0.1.84':
|
||||
resolution: {integrity: sha512-YSs8ncurc1xzegUMNnQUTYrdrAuaXdPMOa+iYYyAxydOtg0ppV386hyYMsy00Yip1NlTgLCseRG4sHSnjQx6og==}
|
||||
@@ -1330,42 +1321,36 @@ packages:
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@parcel/watcher-linux-arm-musl@2.5.1':
|
||||
resolution: {integrity: sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@parcel/watcher-linux-arm64-glibc@2.5.1':
|
||||
resolution: {integrity: sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@parcel/watcher-linux-arm64-musl@2.5.1':
|
||||
resolution: {integrity: sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@parcel/watcher-linux-x64-glibc@2.5.1':
|
||||
resolution: {integrity: sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@parcel/watcher-linux-x64-musl@2.5.1':
|
||||
resolution: {integrity: sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@parcel/watcher-win32-arm64@2.5.1':
|
||||
resolution: {integrity: sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==}
|
||||
@@ -1450,67 +1435,56 @@ packages:
|
||||
resolution: {integrity: sha512-wC53ZNDgt0pqx5xCAgNunkTzFE8GTgdZ9EwYGVcg+jEjJdZGtq9xPjDnFgfFozQI/Xm1mh+D9YlYtl+ueswNEg==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.41.1':
|
||||
resolution: {integrity: sha512-jwKCca1gbZkZLhLRtsrka5N8sFAaxrGz/7wRJ8Wwvq3jug7toO21vWlViihG85ei7uJTpzbXZRcORotE+xyrLA==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-arm64-gnu@4.41.1':
|
||||
resolution: {integrity: sha512-g0UBcNknsmmNQ8V2d/zD2P7WWfJKU0F1nu0k5pW4rvdb+BIqMm8ToluW/eeRmxCared5dD76lS04uL4UaNgpNA==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm64-musl@4.41.1':
|
||||
resolution: {integrity: sha512-XZpeGB5TKEZWzIrj7sXr+BEaSgo/ma/kCgrZgL0oo5qdB1JlTzIYQKel/RmhT6vMAvOdM2teYlAaOGJpJ9lahg==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-loongarch64-gnu@4.41.1':
|
||||
resolution: {integrity: sha512-bkCfDJ4qzWfFRCNt5RVV4DOw6KEgFTUZi2r2RuYhGWC8WhCA8lCAJhDeAmrM/fdiAH54m0mA0Vk2FGRPyzI+tw==}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-powerpc64le-gnu@4.41.1':
|
||||
resolution: {integrity: sha512-3mr3Xm+gvMX+/8EKogIZSIEF0WUu0HL9di+YWlJpO8CQBnoLAEL/roTCxuLncEdgcfJcvA4UMOf+2dnjl4Ut1A==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.41.1':
|
||||
resolution: {integrity: sha512-3rwCIh6MQ1LGrvKJitQjZFuQnT2wxfU+ivhNBzmxXTXPllewOF7JR1s2vMX/tWtUYFgphygxjqMl76q4aMotGw==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-musl@4.41.1':
|
||||
resolution: {integrity: sha512-LdIUOb3gvfmpkgFZuccNa2uYiqtgZAz3PTzjuM5bH3nvuy9ty6RGc/Q0+HDFrHrizJGVpjnTZ1yS5TNNjFlklw==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-s390x-gnu@4.41.1':
|
||||
resolution: {integrity: sha512-oIE6M8WC9ma6xYqjvPhzZYk6NbobIURvP/lEbh7FWplcMO6gn7MM2yHKA1eC/GvYwzNKK/1LYgqzdkZ8YFxR8g==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-gnu@4.41.1':
|
||||
resolution: {integrity: sha512-cWBOvayNvA+SyeQMp79BHPK8ws6sHSsYnK5zDcsC3Hsxr1dgTABKjMnMslPq1DvZIp6uO7kIWhiGwaTdR4Og9A==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-musl@4.41.1':
|
||||
resolution: {integrity: sha512-y5CbN44M+pUCdGDlZFzGGBSKCA4A/J2ZH4edTYSSxFg7ce1Xt3GtydbVKWLlzL+INfFIZAEg1ZV6hh9+QQf9YQ==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-win32-arm64-msvc@4.41.1':
|
||||
resolution: {integrity: sha512-lZkCxIrjlJlMt1dLO/FbpZbzt6J/A8p4DnqzSa4PWqPEUUUnzXLeki/iyPLfV0BmHItlYgHUqJe+3KiyydmiNQ==}
|
||||
@@ -6913,8 +6887,8 @@ packages:
|
||||
vue-component-type-helpers@2.2.12:
|
||||
resolution: {integrity: sha512-YbGqHZ5/eW4SnkPNR44mKVc6ZKQoRs/Rux1sxC6rdwXb4qpbOSYfDr9DsTHolOTGmIKgM9j141mZbBeg05R1pw==}
|
||||
|
||||
vue-component-type-helpers@3.1.8:
|
||||
resolution: {integrity: sha512-oaowlmEM6BaYY+8o+9D9cuzxpWQWHqHTMKakMxXu0E+UCIOMTljyIPO15jcnaCwJtZu/zWDotK7mOIHvWD9mcw==}
|
||||
vue-component-type-helpers@3.2.3:
|
||||
resolution: {integrity: sha512-lpJTa8a+12Cgy/n5OdlQTzQhSWOCu+6zQoNFbl3KYxwAoB95mYIgMLKEYMvQykPJ2ucBDjJJISdIBHc1d9Hd3w==}
|
||||
|
||||
vue-demi@0.14.10:
|
||||
resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==}
|
||||
@@ -7133,7 +7107,7 @@ snapshots:
|
||||
'@jridgewell/gen-mapping': 0.3.8
|
||||
'@jridgewell/trace-mapping': 0.3.25
|
||||
|
||||
'@antfu/eslint-config@4.17.0(@vue/compiler-sfc@3.5.17)(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)(vitest@3.2.4(@types/debug@4.1.12)(@types/node@22.15.30)(@vitest/browser@3.2.4)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))':
|
||||
'@antfu/eslint-config@4.17.0(@vue/compiler-sfc@3.5.17)(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)(vitest@3.2.4)':
|
||||
dependencies:
|
||||
'@antfu/install-pkg': 1.1.0
|
||||
'@clack/prompts': 0.11.0
|
||||
@@ -7142,7 +7116,7 @@ snapshots:
|
||||
'@stylistic/eslint-plugin': 5.2.0(eslint@9.31.0(jiti@2.4.2))
|
||||
'@typescript-eslint/eslint-plugin': 8.37.0(@typescript-eslint/parser@8.37.0(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)
|
||||
'@typescript-eslint/parser': 8.37.0(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)
|
||||
'@vitest/eslint-plugin': 1.3.4(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)(vitest@3.2.4(@types/debug@4.1.12)(@types/node@22.15.30)(@vitest/browser@3.2.4)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))
|
||||
'@vitest/eslint-plugin': 1.3.4(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)(vitest@3.2.4)
|
||||
ansis: 4.1.0
|
||||
cac: 6.7.14
|
||||
eslint: 9.31.0(jiti@2.4.2)
|
||||
@@ -8494,7 +8468,7 @@ snapshots:
|
||||
dependencies:
|
||||
type-fest: 2.19.0
|
||||
|
||||
'@storybook/experimental-addon-test@8.6.14(@vitest/browser@3.2.4(playwright@1.57.0)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))(vitest@3.2.4))(@vitest/runner@3.2.4)(react-dom@19.2.3(react@19.1.0))(react@19.1.0)(storybook@8.6.14(prettier@3.6.2))(vitest@3.2.4(@types/debug@4.1.12)(@types/node@22.15.30)(@vitest/browser@3.2.4)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))':
|
||||
'@storybook/experimental-addon-test@8.6.14(@vitest/browser@3.2.4)(@vitest/runner@3.2.4)(react-dom@19.2.3(react@19.1.0))(react@19.1.0)(storybook@8.6.14(prettier@3.6.2))(vitest@3.2.4)':
|
||||
dependencies:
|
||||
'@storybook/global': 5.0.0
|
||||
'@storybook/icons': 1.6.0(react-dom@19.2.3(react@19.1.0))(react@19.1.0)
|
||||
@@ -8639,7 +8613,7 @@ snapshots:
|
||||
ts-dedent: 2.2.0
|
||||
type-fest: 2.19.0
|
||||
vue: 3.5.17(typescript@5.8.3)
|
||||
vue-component-type-helpers: 3.1.8
|
||||
vue-component-type-helpers: 3.2.3
|
||||
|
||||
'@stylistic/eslint-plugin@5.2.0(eslint@9.31.0(jiti@2.4.2))':
|
||||
dependencies:
|
||||
@@ -9301,7 +9275,7 @@ snapshots:
|
||||
- utf-8-validate
|
||||
- vite
|
||||
|
||||
'@vitest/coverage-v8@3.2.4(@vitest/browser@3.2.4(playwright@1.57.0)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))(vitest@3.2.4))(vitest@3.2.4(@types/debug@4.1.12)(@types/node@22.15.30)(@vitest/browser@3.2.4)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))':
|
||||
'@vitest/coverage-v8@3.2.4(@vitest/browser@3.2.4)(vitest@3.2.4)':
|
||||
dependencies:
|
||||
'@ampproject/remapping': 2.3.0
|
||||
'@bcoe/v8-coverage': 1.0.2
|
||||
@@ -9322,7 +9296,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@vitest/eslint-plugin@1.3.4(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)(vitest@3.2.4(@types/debug@4.1.12)(@types/node@22.15.30)(@vitest/browser@3.2.4)(jiti@2.4.2)(sass-embedded@1.89.2)(sass@1.97.0)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.0))':
|
||||
'@vitest/eslint-plugin@1.3.4(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)(vitest@3.2.4)':
|
||||
dependencies:
|
||||
'@typescript-eslint/utils': 8.33.1(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)
|
||||
eslint: 9.31.0(jiti@2.4.2)
|
||||
@@ -14721,7 +14695,7 @@ snapshots:
|
||||
|
||||
vue-component-type-helpers@2.2.12: {}
|
||||
|
||||
vue-component-type-helpers@3.1.8: {}
|
||||
vue-component-type-helpers@3.2.3: {}
|
||||
|
||||
vue-demi@0.14.10(vue@3.5.17(typescript@5.8.3)):
|
||||
dependencies:
|
||||
|
||||
Binary file not shown.
25
Yi.Ai.Vue3/src/api/agent/index.ts
Normal file
25
Yi.Ai.Vue3/src/api/agent/index.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { AgentSendInput, AgentToolOutput } from './types';
|
||||
import { get, post } from '@/utils/request';
|
||||
|
||||
/**
|
||||
* Agent 发送消息
|
||||
*/
|
||||
export function agentSend(data: AgentSendInput) {
|
||||
return post('/ai-chat/agent/send', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Agent 工具列表
|
||||
*/
|
||||
export function getAgentTools() {
|
||||
return post<AgentToolOutput[]>('/ai-chat/agent/tool').json();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Agent 上下文
|
||||
*/
|
||||
export function getAgentContext(sessionId: string) {
|
||||
return post<string>(`/ai-chat/agent/context/${sessionId}`).json();
|
||||
}
|
||||
|
||||
export * from './types';
|
||||
51
Yi.Ai.Vue3/src/api/agent/types.ts
Normal file
51
Yi.Ai.Vue3/src/api/agent/types.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Agent 发送消息输入
|
||||
*/
|
||||
export interface AgentSendInput {
|
||||
/** 会话id */
|
||||
sessionId: string;
|
||||
/** 用户内容 */
|
||||
content: string;
|
||||
/** api密钥Id */
|
||||
tokenId: string;
|
||||
/** 模型id */
|
||||
modelId: string;
|
||||
/** 已选择工具 */
|
||||
tools: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent 工具输出
|
||||
*/
|
||||
export interface AgentToolOutput {
|
||||
/** 工具代码 */
|
||||
code: string;
|
||||
/** 工具名称 */
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent 结果类型
|
||||
*/
|
||||
export type AgentResultType = 'text' | 'toolCalling' | 'toolCalled' | 'usage' | 'toolCallUsage';
|
||||
|
||||
/**
|
||||
* Agent 流式结果输出
|
||||
*/
|
||||
export interface AgentResultOutput {
|
||||
/** 类型 */
|
||||
type: AgentResultType;
|
||||
/** 内容载体 */
|
||||
content: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent 用量信息
|
||||
*/
|
||||
export interface AgentUsage {
|
||||
input_tokens?: number;
|
||||
output_tokens?: number;
|
||||
total_tokens?: number;
|
||||
prompt_tokens?: number;
|
||||
completion_tokens?: number;
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { get, post } from '@/utils/request';
|
||||
import type {
|
||||
GenerateImageRequest,
|
||||
ImageModel,
|
||||
@@ -7,6 +6,7 @@ import type {
|
||||
TaskListResponse,
|
||||
TaskStatusResponse,
|
||||
} from './types';
|
||||
import { del, get, post } from '@/utils/request';
|
||||
|
||||
export function generateImage(data: GenerateImageRequest) {
|
||||
return post<string>('/ai-image/generate', data).json();
|
||||
@@ -30,4 +30,9 @@ export function publishImage(data: PublishImageRequest) {
|
||||
|
||||
export function getImageModels() {
|
||||
return post<ImageModel[]>('/ai-image/model').json();
|
||||
}
|
||||
}
|
||||
export function deleteMyTasks(taskIds: string[]) {
|
||||
const query = taskIds.map(id => `ids=${encodeURIComponent(id)}`).join('&');
|
||||
const url = `/ai-image/my-tasks${query ? `?${query}` : ''}`;
|
||||
return del<void>(url).json();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import type {
|
||||
AiModelCreateInput,
|
||||
AiModelUpdateInput,
|
||||
AiModelGetListInput,
|
||||
AppShortcutDto,
|
||||
PagedResultDto,
|
||||
} from './types';
|
||||
|
||||
@@ -98,3 +99,15 @@ export function updateModel(data: AiModelUpdateInput) {
|
||||
export function deleteModel(id: string) {
|
||||
return del(`/channel/model/${id}`).json();
|
||||
}
|
||||
|
||||
// 清除尊享模型ID缓存
|
||||
export function clearPremiumModelCache() {
|
||||
return post('/model/clear-premium-cache').json();
|
||||
}
|
||||
|
||||
// ==================== 快捷渠道 ====================
|
||||
|
||||
// 获取快捷渠道列表
|
||||
export function getAppShortcutList() {
|
||||
return get<AppShortcutDto[]>('/channel/app-shortcut').json();
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ export interface AiModelDto {
|
||||
providerName?: string;
|
||||
iconUrl?: string;
|
||||
isPremium: boolean;
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
// 创建AI模型输入
|
||||
@@ -84,6 +85,7 @@ export interface AiModelCreateInput {
|
||||
providerName?: string;
|
||||
iconUrl?: string;
|
||||
isPremium: boolean;
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
// 更新AI模型输入
|
||||
@@ -103,6 +105,7 @@ export interface AiModelUpdateInput {
|
||||
providerName?: string;
|
||||
iconUrl?: string;
|
||||
isPremium: boolean;
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
// 获取AI模型列表输入
|
||||
@@ -114,6 +117,17 @@ export interface AiModelGetListInput {
|
||||
maxResultCount?: number;
|
||||
}
|
||||
|
||||
// 快捷渠道DTO
|
||||
export interface AppShortcutDto {
|
||||
id: string;
|
||||
name: string;
|
||||
endpoint: string;
|
||||
extraUrl?: string;
|
||||
apiKey: string;
|
||||
orderNum: number;
|
||||
creationTime: string;
|
||||
}
|
||||
|
||||
// 分页结果
|
||||
export interface PagedResultDto<T> {
|
||||
items: T[];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ChatMessageVo, GetChatListParams, SendDTO } from './types';
|
||||
import { get, post } from '@/utils/request';
|
||||
|
||||
// 发送消息
|
||||
// 发送消息(旧接口)
|
||||
export function send(data: SendDTO) {
|
||||
const url = data.sessionId !== 'not_login'
|
||||
? `/ai-chat/send/?sessionId=${data.sessionId}`
|
||||
@@ -9,6 +9,12 @@ export function send(data: SendDTO) {
|
||||
return post(url, data);
|
||||
}
|
||||
|
||||
// 统一发送消息接口,支持4种API类型
|
||||
export function unifiedSend(data: any, apiType: string, modelId: string, sessionId: string) {
|
||||
const url = `/ai-chat/unified/send?apiType=${apiType}&modelId=${modelId}&sessionId=${sessionId}`;
|
||||
return post(url, data);
|
||||
}
|
||||
|
||||
// 新增对应会话聊天记录
|
||||
export function addChat(data: ChatMessageVo) {
|
||||
return post('/system/message', data).json();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from './announcement'
|
||||
export * from './agent';
|
||||
export * from './auth';
|
||||
export * from './chat';
|
||||
export * from './file';
|
||||
|
||||
@@ -60,9 +60,57 @@ export function getApiKey() {
|
||||
return get<any>('/token').json();
|
||||
}
|
||||
|
||||
// 充值记录查询参数类型
|
||||
export interface RechargeLogQueryParams {
|
||||
skipCount?: number;
|
||||
maxResultCount?: number;
|
||||
isFree?: boolean;
|
||||
minRechargeAmount?: number;
|
||||
maxRechargeAmount?: number;
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
orderByColumn?: string;
|
||||
isAsc?: string;
|
||||
isAscending?: boolean;
|
||||
}
|
||||
|
||||
// 查询充值记录
|
||||
export function getRechargeLog() {
|
||||
return get<any>('/recharge/account').json();
|
||||
export function getRechargeLog(params?: RechargeLogQueryParams) {
|
||||
const queryParams = new URLSearchParams();
|
||||
if (params?.skipCount !== undefined) {
|
||||
queryParams.append('SkipCount', params.skipCount.toString());
|
||||
}
|
||||
if (params?.maxResultCount !== undefined) {
|
||||
queryParams.append('MaxResultCount', params.maxResultCount.toString());
|
||||
}
|
||||
if (params?.isFree !== undefined) {
|
||||
queryParams.append('IsFree', params.isFree.toString());
|
||||
}
|
||||
if (params?.minRechargeAmount !== undefined) {
|
||||
queryParams.append('MinRechargeAmount', params.minRechargeAmount.toString());
|
||||
}
|
||||
if (params?.maxRechargeAmount !== undefined) {
|
||||
queryParams.append('MaxRechargeAmount', params.maxRechargeAmount.toString());
|
||||
}
|
||||
if (params?.startTime) {
|
||||
queryParams.append('StartTime', params.startTime);
|
||||
}
|
||||
if (params?.endTime) {
|
||||
queryParams.append('EndTime', params.endTime);
|
||||
}
|
||||
if (params?.orderByColumn) {
|
||||
queryParams.append('OrderByColumn', params.orderByColumn);
|
||||
}
|
||||
if (params?.isAsc) {
|
||||
queryParams.append('IsAsc', params.isAsc);
|
||||
}
|
||||
if (params?.isAscending !== undefined) {
|
||||
queryParams.append('IsAscending', params.isAscending.toString());
|
||||
}
|
||||
|
||||
const queryString = queryParams.toString();
|
||||
const url = queryString ? `/recharge/account?${queryString}` : '/recharge/account';
|
||||
return get<any>(url).json();
|
||||
}
|
||||
|
||||
// 查询用户近7天token消耗
|
||||
@@ -163,3 +211,44 @@ export function getPremiumPackageTokenUsage() {
|
||||
"percentage": 0
|
||||
}
|
||||
] */
|
||||
|
||||
// 获取当前用户近24小时每小时Token消耗统计
|
||||
// tokenId: 可选,传入则查询该token的用量,不传则查询全部
|
||||
export function getLast24HoursTokenUsage(tokenId?: string) {
|
||||
const url = tokenId
|
||||
? `/usage-statistics/last24Hours-token-usage?tokenId=${tokenId}`
|
||||
: '/usage-statistics/last24Hours-token-usage';
|
||||
return get<any>(url).json();
|
||||
}
|
||||
/* 返回数据
|
||||
[
|
||||
{
|
||||
"hour": "2026-01-23T13:32:49.237Z",
|
||||
"totalTokens": 0,
|
||||
"modelBreakdown": [
|
||||
{
|
||||
"modelId": "string",
|
||||
"tokens": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
*/
|
||||
|
||||
// 获取当前用户今日各模型使用量统计
|
||||
// tokenId: 可选,传入则查询该token的用量,不传则查询全部
|
||||
export function getTodayModelUsage(tokenId?: string) {
|
||||
const url = tokenId
|
||||
? `/usage-statistics/today-model-usage?tokenId=${tokenId}`
|
||||
: '/usage-statistics/today-model-usage';
|
||||
return get<any>(url).json();
|
||||
}
|
||||
/* 返回数据
|
||||
[
|
||||
{
|
||||
"modelId": "string",
|
||||
"usageCount": 0,
|
||||
"totalTokens": 0
|
||||
}
|
||||
]
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// 查询用户模型列表返回的数据结构
|
||||
export interface GetSessionListVO {
|
||||
id?: number;
|
||||
id?: number | string;
|
||||
category?: string;
|
||||
modelName?: string;
|
||||
modelDescribe?: string;
|
||||
@@ -12,6 +12,11 @@ export interface GetSessionListVO {
|
||||
apiKey?: string;
|
||||
remark?: string;
|
||||
modelId?: string;
|
||||
isFree?: boolean; // 是否为免费模型
|
||||
isPremiumPackage?: boolean; // 是否为尊享套餐模型
|
||||
modelApiType?: string; // API 格式类型: Completions | Messages | Responses | GenerateContent
|
||||
providerName?: string;
|
||||
iconUrl?: string;
|
||||
}
|
||||
|
||||
// 模型类型枚举
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import type { Component } from 'vue';
|
||||
|
||||
/**
|
||||
* 会话类型枚举
|
||||
*/
|
||||
export enum SessionTypeEnum {
|
||||
/** 普通聊天 */
|
||||
Chat = 0,
|
||||
/** Agent智能体 */
|
||||
Agent = 1,
|
||||
}
|
||||
|
||||
export interface GetSessionListParams {
|
||||
/**
|
||||
* 创建者
|
||||
@@ -61,6 +71,10 @@ export interface GetSessionListParams {
|
||||
* 用户id
|
||||
*/
|
||||
userId: number;
|
||||
/**
|
||||
* 会话类型
|
||||
*/
|
||||
sessionType?: SessionTypeEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,6 +110,10 @@ export interface ChatSessionVo {
|
||||
* 自定义的消息前缀图标字段
|
||||
*/
|
||||
prefixIcon?: Component;
|
||||
/**
|
||||
* 会话类型
|
||||
*/
|
||||
sessionType?: SessionTypeEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,6 +165,10 @@ export interface CreateSessionDTO {
|
||||
* 用户id
|
||||
*/
|
||||
userId: number;
|
||||
/**
|
||||
* 会话类型
|
||||
*/
|
||||
sessionType?: SessionTypeEnum;
|
||||
}
|
||||
|
||||
// export interface CreateSessionVO {
|
||||
|
||||
17
Yi.Ai.Vue3/src/api/systemStatistics/index.ts
Normal file
17
Yi.Ai.Vue3/src/api/systemStatistics/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { post } from '@/utils/request';
|
||||
import type {
|
||||
ProfitStatisticsInput,
|
||||
ProfitStatisticsOutput,
|
||||
TokenStatisticsInput,
|
||||
TokenStatisticsOutput,
|
||||
} from './types';
|
||||
|
||||
// 获取利润统计数据
|
||||
export function getProfitStatistics(data: ProfitStatisticsInput) {
|
||||
return post<ProfitStatisticsOutput>('/system-statistics/profit', data).json();
|
||||
}
|
||||
|
||||
// 获取指定日期各模型Token统计
|
||||
export function getTokenStatistics(data: TokenStatisticsInput) {
|
||||
return post<TokenStatisticsOutput>('/system-statistics/token', data).json();
|
||||
}
|
||||
41
Yi.Ai.Vue3/src/api/systemStatistics/types.ts
Normal file
41
Yi.Ai.Vue3/src/api/systemStatistics/types.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
// 利润统计输入
|
||||
export interface ProfitStatisticsInput {
|
||||
currentCost: number;
|
||||
}
|
||||
|
||||
// 利润统计输出
|
||||
export interface ProfitStatisticsOutput {
|
||||
date: string;
|
||||
totalUsedTokens: number;
|
||||
totalUsedTokensInHundredMillion: number;
|
||||
totalRemainingTokens: number;
|
||||
totalRemainingTokensInHundredMillion: number;
|
||||
currentCost: number;
|
||||
costPerHundredMillion: number;
|
||||
totalCost: number;
|
||||
totalRevenue: number;
|
||||
profitRate: number;
|
||||
costAt200Price: number;
|
||||
}
|
||||
|
||||
// Token统计输入
|
||||
export interface TokenStatisticsInput {
|
||||
date: string;
|
||||
}
|
||||
|
||||
// 模型Token统计DTO
|
||||
export interface ModelTokenStatisticsDto {
|
||||
modelId: string;
|
||||
modelName: string;
|
||||
tokens: number;
|
||||
tokensInWan: number;
|
||||
count: number;
|
||||
cost: number;
|
||||
costPerHundredMillion: number;
|
||||
}
|
||||
|
||||
// Token统计输出
|
||||
export interface TokenStatisticsOutput {
|
||||
date: string;
|
||||
modelStatistics: ModelTokenStatisticsDto[];
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 51 KiB |
BIN
Yi.Ai.Vue3/src/assets/images/czld.png
Normal file
BIN
Yi.Ai.Vue3/src/assets/images/czld.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
BIN
Yi.Ai.Vue3/src/assets/images/logo-dark.png
Normal file
BIN
Yi.Ai.Vue3/src/assets/images/logo-dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
Yi.Ai.Vue3/src/assets/images/taobao-qr.png
Normal file
BIN
Yi.Ai.Vue3/src/assets/images/taobao-qr.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 206 KiB |
BIN
Yi.Ai.Vue3/src/assets/images/wx-group-qr.jpg
Normal file
BIN
Yi.Ai.Vue3/src/assets/images/wx-group-qr.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 171 KiB |
585
Yi.Ai.Vue3/src/components/ContactUs/index.vue
Normal file
585
Yi.Ai.Vue3/src/components/ContactUs/index.vue
Normal file
@@ -0,0 +1,585 @@
|
||||
<script setup lang="ts">
|
||||
import { ElImageViewer, ElMessage } from 'element-plus';
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { contactConfig } from '@/config/constants';
|
||||
|
||||
export interface ContactType {
|
||||
customerService?: boolean; // 客服微信和二维码
|
||||
communityGroup?: boolean; // 交流群二维码
|
||||
afterSalesGroup?: boolean; // 售后群二维码
|
||||
other?: boolean; // 其他
|
||||
}
|
||||
|
||||
export type ContactScenario = 'regular' | 'afterSales' | 'all' | 'custom';
|
||||
|
||||
interface Props {
|
||||
scenario?: ContactScenario; // 场景类型
|
||||
customTypes?: ContactType; // 自定义展示类型
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
scenario: 'regular',
|
||||
});
|
||||
|
||||
const emit = defineEmits(['close']);
|
||||
|
||||
const visible = ref(true);
|
||||
const showImageViewer = ref(false);
|
||||
const currentImageUrl = ref('');
|
||||
const isMobile = ref(false);
|
||||
|
||||
// 检测移动端
|
||||
function checkMobile() {
|
||||
isMobile.value = window.innerWidth < 768;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
checkMobile();
|
||||
window.addEventListener('resize', checkMobile);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('resize', checkMobile);
|
||||
});
|
||||
|
||||
// 根据场景计算需要展示的联系方式
|
||||
const contactTypes = computed<ContactType>(() => {
|
||||
if (props.scenario === 'custom' && props.customTypes) {
|
||||
return props.customTypes;
|
||||
}
|
||||
|
||||
switch (props.scenario) {
|
||||
case 'regular':
|
||||
return {
|
||||
customerService: true,
|
||||
communityGroup: true,
|
||||
afterSalesGroup: false,
|
||||
other: false,
|
||||
};
|
||||
case 'afterSales':
|
||||
return {
|
||||
customerService: true,
|
||||
communityGroup: false,
|
||||
afterSalesGroup: true,
|
||||
other: false,
|
||||
};
|
||||
case 'all':
|
||||
return {
|
||||
customerService: true,
|
||||
communityGroup: true,
|
||||
afterSalesGroup: true,
|
||||
other: true,
|
||||
};
|
||||
default:
|
||||
return {
|
||||
customerService: true,
|
||||
communityGroup: true,
|
||||
afterSalesGroup: false,
|
||||
other: false,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
function close() {
|
||||
visible.value = false;
|
||||
emit('close');
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
emit('close');
|
||||
}
|
||||
|
||||
// 复制微信号
|
||||
function copyWechatId() {
|
||||
navigator.clipboard.writeText(contactConfig.wechatId).then(() => {
|
||||
ElMessage.success('微信号已复制');
|
||||
}).catch(() => {
|
||||
ElMessage.error('复制失败,请手动复制');
|
||||
});
|
||||
}
|
||||
|
||||
// 查看大图
|
||||
function viewImage(imageUrl: string) {
|
||||
currentImageUrl.value = imageUrl;
|
||||
showImageViewer.value = true;
|
||||
}
|
||||
|
||||
// 关闭图片查看器
|
||||
function closeImageViewer() {
|
||||
showImageViewer.value = false;
|
||||
currentImageUrl.value = '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="联系我们"
|
||||
:width="isMobile ? '95%' : '600px'"
|
||||
:fullscreen="isMobile"
|
||||
:show-close="true"
|
||||
destroy-on-close
|
||||
class="contact-us-dialog"
|
||||
@close="onClose"
|
||||
>
|
||||
<div class="contact-us-content">
|
||||
<!-- 客服微信 -->
|
||||
<div v-if="contactTypes.customerService" class="contact-section">
|
||||
<div class="section-header">
|
||||
<el-icon class="section-icon">
|
||||
<i-ep-user />
|
||||
</el-icon>
|
||||
<h3 class="section-title">
|
||||
客服微信
|
||||
</h3>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<div class="info-text">
|
||||
<p class="info-label">
|
||||
微信号
|
||||
</p>
|
||||
<p class="info-value">
|
||||
{{ contactConfig.wechatId }}
|
||||
</p>
|
||||
<el-button size="small" type="primary" @click="copyWechatId">
|
||||
复制微信号
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="contactConfig.images.customerService" class="qr-code">
|
||||
<img
|
||||
:src="contactConfig.images.customerService"
|
||||
alt="客服微信二维码"
|
||||
class="qr-image"
|
||||
@click="viewImage(contactConfig.images.customerService)"
|
||||
>
|
||||
<p class="qr-label">
|
||||
扫码添加客服(点击放大)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 交流群 -->
|
||||
<div v-if="contactTypes.communityGroup" class="contact-section">
|
||||
<div class="section-header">
|
||||
<el-icon class="section-icon">
|
||||
<i-ep-chat-dot-round />
|
||||
</el-icon>
|
||||
<h3 class="section-title">
|
||||
交流群
|
||||
</h3>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<div class="info-text">
|
||||
<p class="info-desc">
|
||||
加入我们的交流群,与其他用户一起探讨AI应用,获取最新产品动态
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="contactConfig.images.communityGroup" class="qr-code">
|
||||
<img
|
||||
:src="contactConfig.images.communityGroup"
|
||||
alt="交流群二维码"
|
||||
class="qr-image"
|
||||
@click="viewImage(contactConfig.images.communityGroup)"
|
||||
>
|
||||
<p class="qr-label">
|
||||
扫码加入交流群(点击放大)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 售后群 -->
|
||||
<div v-if="contactTypes.afterSalesGroup" class="contact-section">
|
||||
<div class="section-header">
|
||||
<el-icon class="section-icon">
|
||||
<i-ep-service />
|
||||
</el-icon>
|
||||
<h3 class="section-title">
|
||||
VIP售后服务群
|
||||
</h3>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<div class="info-text">
|
||||
<p class="info-desc">
|
||||
<el-tag type="warning" size="small">
|
||||
VIP专享
|
||||
</el-tag>
|
||||
充值后,加客服微信回复账号名,可专享VIP售后服务
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="contactConfig.images.afterSalesGroup" class="qr-code">
|
||||
<img
|
||||
:src="contactConfig.images.afterSalesGroup"
|
||||
alt="售后群二维码"
|
||||
class="qr-image"
|
||||
@click="viewImage(contactConfig.images.afterSalesGroup)"
|
||||
>
|
||||
<p class="qr-label">
|
||||
扫码加入售后群(点击放大)
|
||||
</p>
|
||||
</div>
|
||||
<div v-else class="qr-code-empty">
|
||||
<el-alert
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
>
|
||||
<template #title>
|
||||
<p>请联系客服微信 <strong>{{ contactConfig.wechatId }}</strong> 加入售后群</p>
|
||||
</template>
|
||||
</el-alert>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 温馨提示 -->
|
||||
<el-alert
|
||||
class="tips-alert"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
>
|
||||
<template #title>
|
||||
<div class="tips-content">
|
||||
<p>温馨提示:</p>
|
||||
<ul>
|
||||
<li>添加客服时请备注您的账号名称,以便更好地为您服务</li>
|
||||
<li>工作时间:9:00-22:00,我们会尽快回复您的消息</li>
|
||||
<li>VIP用户可享受专属售后服务,响应更快</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
</div>
|
||||
|
||||
<!-- 图片查看器 -->
|
||||
<ElImageViewer
|
||||
v-if="showImageViewer"
|
||||
:url-list="[currentImageUrl]"
|
||||
:hide-on-click-modal="true"
|
||||
@close="closeImageViewer"
|
||||
/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.contact-us-dialog {
|
||||
:deep(.el-dialog__header) {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 20px;
|
||||
border-radius: 8px 8px 0 0;
|
||||
|
||||
.el-dialog__title {
|
||||
color: white;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.el-dialog__headerbtn .el-dialog__close {
|
||||
color: white;
|
||||
font-size: 20px;
|
||||
|
||||
&:hover {
|
||||
color: #f0f0f0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.contact-us-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.contact-section {
|
||||
background: #fafbfc;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
border: 1px solid #e8ecf0;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 2px solid #e8ecf0;
|
||||
}
|
||||
|
||||
.section-icon {
|
||||
font-size: 24px;
|
||||
color: #667eea;
|
||||
background: rgba(102, 126, 234, 0.1);
|
||||
padding: 8px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
.section-content {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.info-text {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: #667eea;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
|
||||
.info-desc {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.qr-code {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
.qr-image {
|
||||
width: 120px;
|
||||
height: auto;
|
||||
border-radius: 8px;
|
||||
border: 2px solid #e8ecf0;
|
||||
padding: 4px;
|
||||
background: white;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.05);
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.qr-label {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.tips-alert {
|
||||
border-radius: 8px;
|
||||
background: #f0f9ff;
|
||||
border-color: #bae6fd;
|
||||
|
||||
.tips-content p {
|
||||
margin: 0 0 8px 0;
|
||||
font-weight: 600;
|
||||
color: #0369a1;
|
||||
}
|
||||
|
||||
.tips-content ul {
|
||||
margin: 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.tips-content li {
|
||||
margin: 4px 0;
|
||||
font-size: 13px;
|
||||
color: #0c4a6e;
|
||||
}
|
||||
}
|
||||
|
||||
/* 响应式布局 */
|
||||
@media (max-width: 768px) {
|
||||
.contact-us-dialog {
|
||||
:deep(.el-dialog) {
|
||||
width: 100% !important;
|
||||
margin: 0 !important;
|
||||
height: 100vh;
|
||||
max-height: 100vh;
|
||||
border-radius: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__header) {
|
||||
padding: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 12px;
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
}
|
||||
|
||||
.contact-us-content {
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.contact-section {
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
padding-bottom: 10px;
|
||||
|
||||
.section-icon {
|
||||
font-size: 20px;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.section-content {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.info-text {
|
||||
width: 100%;
|
||||
gap: 8px;
|
||||
|
||||
.info-label {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.info-desc {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.el-button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.qr-code {
|
||||
align-self: center;
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
background: #f9fafb;
|
||||
border-radius: 8px;
|
||||
|
||||
.qr-image {
|
||||
width: 140px;
|
||||
height: auto;
|
||||
|
||||
}
|
||||
|
||||
.qr-label {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.qr-code-empty {
|
||||
width: 100%;
|
||||
|
||||
.el-alert {
|
||||
:deep(.el-alert__content) {
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tips-alert {
|
||||
:deep(.el-alert__content) {
|
||||
.tips-content {
|
||||
p {
|
||||
font-size: 13px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
ul {
|
||||
padding-left: 16px;
|
||||
}
|
||||
|
||||
li {
|
||||
font-size: 12px;
|
||||
margin: 3px 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 小屏手机适配 */
|
||||
@media (max-width: 480px) {
|
||||
.contact-us-dialog {
|
||||
:deep(.el-dialog__header) {
|
||||
padding: 14px;
|
||||
|
||||
.el-dialog__title {
|
||||
font-size: 17px;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.contact-section {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.qr-code .qr-image {
|
||||
width: 120px;
|
||||
height: auto;
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,55 +1,193 @@
|
||||
<!-- 切换模型 -->
|
||||
<script setup lang="ts">
|
||||
import type { GetSessionListVO } from '@/api/model/types';
|
||||
import { Lock } from '@element-plus/icons-vue';
|
||||
import Popover from '@/components/Popover/index.vue';
|
||||
|
||||
import { Check, Lock, Right } from '@element-plus/icons-vue';
|
||||
import SvgIcon from '@/components/SvgIcon/index.vue';
|
||||
import { useResponsive } from '@/hooks/useResponsive';
|
||||
import { useModelStore } from '@/stores/modules/model';
|
||||
import { showProductPackage } from '@/utils/product-package.ts';
|
||||
import { isUserVip } from '@/utils/user';
|
||||
import { modelList as localModelList } from './modelData';
|
||||
|
||||
const modelStore = useModelStore();
|
||||
const { isMobile } = useResponsive();
|
||||
const dialogVisible = ref(false);
|
||||
const activeTab = ref('provider'); // 'provider' | 'api'
|
||||
const scrollbarRef = ref();
|
||||
const activeProviderGroup = ref('');
|
||||
const activeApiGroup = ref('');
|
||||
const isScrolling = ref(false);
|
||||
const filterPremiumOnly = ref(false); // 是否只显示尊享模型
|
||||
|
||||
// 检查模型是否可用
|
||||
function isModelAvailable(item: GetSessionListVO) {
|
||||
return isUserVip() || item.modelId?.includes('DeepSeek-R1-0528');
|
||||
return isUserVip() || item.isFree;
|
||||
}
|
||||
|
||||
// 滚动到指定分组
|
||||
function scrollToGroup(type: 'provider' | 'api', key: string) {
|
||||
isScrolling.value = true;
|
||||
const id = type === 'provider' ? `group-provider-${key}` : `group-api-${key}`;
|
||||
const element = document.getElementById(id);
|
||||
if (element) {
|
||||
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
if (type === 'provider') {
|
||||
activeProviderGroup.value = key;
|
||||
}
|
||||
else {
|
||||
activeApiGroup.value = key;
|
||||
}
|
||||
// 延迟重置滚动状态,防止触发 scroll 事件
|
||||
setTimeout(() => {
|
||||
isScrolling.value = false;
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// 监听滚动事件,更新侧边栏选中状态
|
||||
function handleScroll({ scrollTop }: { scrollTop: number }) {
|
||||
if (isScrolling.value)
|
||||
return;
|
||||
|
||||
const type = activeTab.value;
|
||||
const groups = type === 'provider' ? groupedByProvider.value : groupedByApiType.value;
|
||||
const keys = Object.keys(groups);
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const id = type === 'provider' ? `group-provider-${key}` : `group-api-${key}`;
|
||||
const element = document.getElementById(id);
|
||||
|
||||
if (element) {
|
||||
const { offsetTop, offsetHeight } = element;
|
||||
// 这里的 50 是一个偏移量,可以根据实际情况调整
|
||||
if (scrollTop >= offsetTop - 50 && scrollTop < offsetTop + offsetHeight) {
|
||||
if (type === 'provider') {
|
||||
activeProviderGroup.value = key;
|
||||
}
|
||||
else {
|
||||
activeApiGroup.value = key;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await modelStore.requestModelList();
|
||||
// 虽然使用了本地数据用于展示,但可能仍需请求后端以保持某些状态同步,或者直接使用本地数据初始化store
|
||||
// 这里我们优先使用本地数据来填充store,或者仅在UI上使用本地数据
|
||||
// 为了兼容现有逻辑,我们尽量保持 modelStore 的使用,但列表展示主要依赖 localModelList
|
||||
// 如果后端返回列表为空,可以用本地列表兜底
|
||||
if (modelStore.modelList.length === 0) {
|
||||
modelStore.modelList = localModelList;
|
||||
}
|
||||
|
||||
// 设置默认模型
|
||||
if (
|
||||
modelStore.modelList.length > 0
|
||||
&& (!modelStore.currentModelInfo || !modelStore.currentModelInfo.modelId)
|
||||
(!modelStore.currentModelInfo || !modelStore.currentModelInfo.modelId)
|
||||
&& localModelList.length > 0
|
||||
) {
|
||||
modelStore.setCurrentModelInfo(modelStore.modelList[0]);
|
||||
modelStore.setCurrentModelInfo(localModelList[0]);
|
||||
}
|
||||
});
|
||||
|
||||
const currentModelName = computed(
|
||||
() => modelStore.currentModelInfo && modelStore.currentModelInfo.modelName,
|
||||
);
|
||||
const popoverList = computed(() => modelStore.modelList);
|
||||
|
||||
/* 弹出面板 开始 */
|
||||
const popoverStyle = ref({
|
||||
width: '200px',
|
||||
padding: '4px',
|
||||
height: 'fit-content',
|
||||
background: 'var(--el-bg-color, #fff)',
|
||||
border: '1px solid var(--el-border-color-light)',
|
||||
borderRadius: '8px',
|
||||
boxShadow: '0 2px 12px 0 rgba(0, 0, 0, 0.1)',
|
||||
// 过滤后的模型列表
|
||||
const filteredModelList = computed(() => {
|
||||
if (filterPremiumOnly.value) {
|
||||
return modelStore.modelList.filter(model => model.isPremiumPackage);
|
||||
}
|
||||
return modelStore.modelList;
|
||||
});
|
||||
const popoverRef = ref();
|
||||
|
||||
// 显示
|
||||
async function showPopover() {
|
||||
// 获取最新的模型列表
|
||||
await modelStore.requestModelList();
|
||||
// 按 API 类型分组
|
||||
const groupedByApiType = computed(() => {
|
||||
const groups: Record<string, GetSessionListVO[]> = {};
|
||||
filteredModelList.value.forEach((model) => {
|
||||
const apiType = model.modelApiType || 'Completions';
|
||||
if (!groups[apiType]) {
|
||||
groups[apiType] = [];
|
||||
}
|
||||
groups[apiType].push(model);
|
||||
});
|
||||
return groups;
|
||||
});
|
||||
|
||||
// 按 厂商 (Provider) 分组
|
||||
const groupedByProvider = computed(() => {
|
||||
const groups: Record<string, GetSessionListVO[]> = {};
|
||||
filteredModelList.value.forEach((model) => {
|
||||
const provider = model.providerName || 'Other';
|
||||
if (!groups[provider]) {
|
||||
groups[provider] = [];
|
||||
}
|
||||
groups[provider].push(model);
|
||||
});
|
||||
return groups;
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
function openDialog() {
|
||||
dialogVisible.value = true;
|
||||
// 打开时定位到当前模型
|
||||
nextTick(() => {
|
||||
scrollToCurrentModel();
|
||||
});
|
||||
// 每次打开弹窗都重新请求模型列表
|
||||
modelStore.requestModelList();
|
||||
}
|
||||
|
||||
// 监听 tab 切换,自动定位
|
||||
watch(activeTab, () => {
|
||||
nextTick(() => {
|
||||
scrollToCurrentModel();
|
||||
});
|
||||
});
|
||||
|
||||
// 检查是否为当前选中的模型
|
||||
function isCurrentModel(item: GetSessionListVO) {
|
||||
const current = modelStore.currentModelInfo;
|
||||
if (!current)
|
||||
return false;
|
||||
|
||||
// 优先使用唯一 ID 匹配
|
||||
if (item.id && current.id) {
|
||||
return item.id === current.id;
|
||||
}
|
||||
|
||||
// 降级使用组合键匹配
|
||||
return item.modelId === current.modelId
|
||||
&& item.modelApiType === current.modelApiType
|
||||
&& item.providerName === current.providerName;
|
||||
}
|
||||
|
||||
// 定位到当前模型
|
||||
function scrollToCurrentModel() {
|
||||
const current = modelStore.currentModelInfo;
|
||||
if (!current)
|
||||
return;
|
||||
|
||||
// 使用 item.id 构建 ID (假设 modelData.ts 中的 id 是唯一的)
|
||||
// 如果没有 id,则无法精确定位,这里假设都有 id
|
||||
const currentId = current.id;
|
||||
if (!currentId)
|
||||
return;
|
||||
|
||||
// 根据当前 tab 构建对应的 ID
|
||||
const elementId = activeTab.value === 'provider'
|
||||
? `provider-model-${currentId}`
|
||||
: `api-model-${currentId}`;
|
||||
|
||||
const element = document.getElementById(elementId);
|
||||
if (element) {
|
||||
element.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
||||
}
|
||||
}
|
||||
|
||||
// 点击
|
||||
// 处理模型点击
|
||||
function handleModelClick(item: GetSessionListVO) {
|
||||
if (!isModelAvailable(item)) {
|
||||
@@ -87,27 +225,27 @@ function handleModelClick(item: GetSessionListVO) {
|
||||
.catch(() => {
|
||||
// 点击右上角关闭或“关闭”按钮,不执行任何操作
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
modelStore.setCurrentModelInfo(item);
|
||||
popoverRef.value?.hide?.();
|
||||
dialogVisible.value = false;
|
||||
}
|
||||
|
||||
function goToModelLibrary() {
|
||||
window.location.href = '/model-library';
|
||||
}
|
||||
|
||||
/* -------------------------------
|
||||
模型样式规则
|
||||
规则1:普通灰色(免费模型)
|
||||
规则2:金色光泽(VIP/付费)
|
||||
规则3:彩色流光(尊享/高级)
|
||||
-------------------------------- */
|
||||
function getModelStyleClass(mode: any) {
|
||||
if (!mode) {
|
||||
if (!mode)
|
||||
return;
|
||||
}
|
||||
// isPremiumPackage
|
||||
const name = mode.modelName.toLowerCase();
|
||||
|
||||
const isPremiumPackage = mode.isPremiumPackage;
|
||||
|
||||
// 规则3:彩色流光
|
||||
// 规则3:彩色流光 (尊享)
|
||||
if (isPremiumPackage) {
|
||||
return `
|
||||
text-transparent bg-clip-text
|
||||
@@ -116,101 +254,226 @@ function getModelStyleClass(mode: any) {
|
||||
`;
|
||||
}
|
||||
|
||||
// 规则2:普通灰
|
||||
if (name.includes('deepseek-r1')) {
|
||||
// 规则2:普通灰(免费模型)
|
||||
if (mode.isFree) {
|
||||
return 'text-gray-700';
|
||||
}
|
||||
|
||||
// 规则1:金色光泽
|
||||
// 规则1:金色光泽 (VIP)
|
||||
return `
|
||||
text-[#B38728] font-semibold relative overflow-hidden
|
||||
before:content-[''] before:absolute before:-inset-2 before:-z-10
|
||||
before:animate-goldShine
|
||||
`;
|
||||
// 金色背景
|
||||
// before:bg-[linear-gradient(135deg,#BF953F,#FCF6BA,#B38728,#FBF5B7,#AA771C)]
|
||||
}
|
||||
|
||||
/* -------------------------------
|
||||
外层卡片样式(选中态 + hover 动效)
|
||||
-------------------------------- */
|
||||
function getWrapperClass(item: GetSessionListVO) {
|
||||
const isSelected = item.modelName === currentModelName.value;
|
||||
const isSelected = isCurrentModel(item);
|
||||
const available = isModelAvailable(item);
|
||||
|
||||
return [
|
||||
'p-2 rounded-md text-sm transition-all duration-300 relative select-none flex items-center justify-between',
|
||||
'p-3 rounded-lg text-sm transition-all duration-300 relative select-none flex items-center justify-between cursor-pointer mb-2',
|
||||
available
|
||||
? 'hover:scale-[1.03] hover:shadow-[0_0_8px_rgba(0,0,0,0.1)] hover:border-gray-300'
|
||||
: 'opacity-60 cursor-not-allowed',
|
||||
? 'hover:bg-gray-50 hover:shadow-sm'
|
||||
: 'opacity-60 cursor-not-allowed bg-gray-50',
|
||||
isSelected
|
||||
? 'border-2 border-blue-700 shadow-[0_0_10px_rgba(29,78,216,1)]'
|
||||
: 'border border-transparent cursor-pointer',
|
||||
? 'border-2 border-primary bg-primary-light-9 shadow-md'
|
||||
: 'border border-gray-200',
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="model-select" data-tour="model-select">
|
||||
<Popover
|
||||
ref="popoverRef"
|
||||
placement="top-start"
|
||||
:offset="[4, 0]"
|
||||
popover-class="popover-content"
|
||||
:popover-style="popoverStyle"
|
||||
trigger="clickTarget"
|
||||
@show="showPopover"
|
||||
<!-- 触发按钮 -->
|
||||
<div
|
||||
class="model-select-box select-none flex items-center gap-4px p-10px rounded-10px cursor-pointer font-size-12px border-[rgba()] leading-snug"
|
||||
@click="openDialog"
|
||||
>
|
||||
<!-- 触发元素插槽 -->
|
||||
<template #trigger>
|
||||
<div
|
||||
class="model-select-box select-none flex items-center gap-4px p-10px rounded-10px cursor-pointer font-size-12px border-[rgba()] leading-snug"
|
||||
>
|
||||
<div class="model-select-box-icon">
|
||||
<SvgIcon name="models" size="12" />
|
||||
</div>
|
||||
<div :class="getModelStyleClass(modelStore.currentModelInfo)" class="model-select-box-text font-size-12px">
|
||||
{{ currentModelName }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="popover-content-box">
|
||||
<div
|
||||
v-for="item in popoverList"
|
||||
:key="item.id"
|
||||
:class="getWrapperClass(item)"
|
||||
@click="handleModelClick(item)"
|
||||
>
|
||||
<Popover
|
||||
trigger-class="popover-trigger-item-text"
|
||||
popover-class="rounded-tooltip"
|
||||
placement="right"
|
||||
trigger="hover"
|
||||
:offset="[12, 0]"
|
||||
>
|
||||
<template #trigger>
|
||||
<span :class="getModelStyleClass(item)">
|
||||
{{ item.modelName }}
|
||||
</span>
|
||||
</template>
|
||||
<div
|
||||
class="popover-content-box-item-text text-wrap max-w-200px rounded-lg p-8px font-size-12px line-height-tight"
|
||||
>
|
||||
{{ item.remark }}
|
||||
</div>
|
||||
</Popover>
|
||||
|
||||
<!-- VIP锁定图标 -->
|
||||
<el-icon
|
||||
v-if="!isModelAvailable(item)"
|
||||
class="absolute right-1 top-1/2 transform -translate-y-1/2"
|
||||
>
|
||||
<Lock />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="model-select-box-icon">
|
||||
<SvgIcon name="models" size="12" />
|
||||
</div>
|
||||
</Popover>
|
||||
<div :class="getModelStyleClass(modelStore.currentModelInfo)" class="model-select-box-text font-size-12px">
|
||||
{{ currentModelName || '选择模型' }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 模型选择弹窗 -->
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
title="切换模型"
|
||||
:width="isMobile ? '95%' : '900px'"
|
||||
class="model-select-dialog"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
align-center
|
||||
>
|
||||
<div class="model-list-container relative">
|
||||
<!-- 右上角操作区域 -->
|
||||
<div class="absolute right-0 top-1 z-10 flex items-center gap-3">
|
||||
<!-- 尊享过滤标签 -->
|
||||
<div
|
||||
class="premium-filter-tag"
|
||||
:class="{ 'premium-filter-tag--active': filterPremiumOnly }"
|
||||
@click="filterPremiumOnly = !filterPremiumOnly"
|
||||
>
|
||||
<span class="premium-filter-tag__text">仅看尊享模型</span>
|
||||
</div>
|
||||
|
||||
<el-button type="primary" link size="small" @click="goToModelLibrary">
|
||||
前往模型库
|
||||
<el-icon class="ml-1">
|
||||
<Right />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-tabs v-model="activeTab" class="model-tabs">
|
||||
<!-- 厂商分类 Tab -->
|
||||
<el-tab-pane label="厂商类型" name="provider">
|
||||
<div class="flex h-[600px]">
|
||||
<!-- 侧边导航 -->
|
||||
<div class="w-28 flex-shrink-0 border-r border-gray-100 overflow-y-auto mr-2">
|
||||
<div
|
||||
v-for="(_, provider) in groupedByProvider"
|
||||
:key="provider"
|
||||
class="cursor-pointer px-2 py-2.5 text-xs hover:bg-gray-50 truncate transition-colors duration-200 border-l-2 border-transparent"
|
||||
:class="{ 'text-primary font-bold bg-blue-50 border-primary': activeProviderGroup === provider, 'text-gray-600': activeProviderGroup !== provider }"
|
||||
@click="scrollToGroup('provider', provider as string)"
|
||||
>
|
||||
{{ provider }}
|
||||
</div>
|
||||
</div>
|
||||
<!-- 内容列表 -->
|
||||
<div class="flex-1 min-w-0">
|
||||
<el-scrollbar ref="scrollbarRef" height="100%" @scroll="handleScroll">
|
||||
<div class="px-2 pb-4">
|
||||
<template v-for="(models, provider) in groupedByProvider" :key="provider">
|
||||
<div :id="`group-provider-${provider}`" class="group-title text-gray-500 text-xs font-bold mb-2 mt-4 px-1 pt-2">
|
||||
{{ provider }}
|
||||
</div>
|
||||
<div
|
||||
v-for="item in models"
|
||||
:id="`provider-model-${item.id}`"
|
||||
:key="item.id"
|
||||
:class="getWrapperClass(item)"
|
||||
@click="handleModelClick(item)"
|
||||
>
|
||||
<div class="flex items-center gap-3 flex-1 min-w-0">
|
||||
<!-- 模型 Logo -->
|
||||
<div class="w-8 h-8 flex-shrink-0 rounded-full bg-white border border-gray-100 flex items-center justify-center overflow-hidden p-1">
|
||||
<img v-if="item.iconUrl" :src="item.iconUrl" class="w-full h-full object-contain" alt="icon">
|
||||
<SvgIcon v-else name="models" size="16" />
|
||||
</div>
|
||||
|
||||
<!-- 模型信息 -->
|
||||
<div class="flex flex-col gap-0.5 flex-1 min-w-0">
|
||||
<div class="flex items-center gap-2 flex-wrap">
|
||||
<span :class="getModelStyleClass(item)" class="font-medium truncate">
|
||||
{{ item.modelName }}
|
||||
</span>
|
||||
<span v-if="item.isFree" class="text-[10px] px-1.5 py-0.5 bg-green-100 text-green-600 rounded-full">免费</span>
|
||||
<span v-if="item.isPremiumPackage" class="text-[10px] px-1.5 py-0.5 bg-orange-100 text-orange-600 rounded-full">尊享</span>
|
||||
<span v-else-if="!item.isFree" class="text-[10px] px-1.5 py-0.5 bg-yellow-100 text-yellow-600 rounded-full">VIP</span>
|
||||
<!-- 显示 API 类型 -->
|
||||
<span class="text-[10px] px-1.5 py-0.5 bg-gray-100 text-gray-600 rounded-full">{{ item.modelApiType }}</span>
|
||||
</div>
|
||||
<div class="text-xs text-gray-400 break-words whitespace-normal line-clamp-2" :title="item.modelDescribe">
|
||||
{{ item.modelDescribe }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 选中/锁定图标 -->
|
||||
<div class="flex items-center">
|
||||
<el-icon v-if="isCurrentModel(item)" class="text-primary mr-2" :size="18">
|
||||
<Check />
|
||||
</el-icon>
|
||||
<el-icon v-if="!isModelAvailable(item)" class="text-gray-400">
|
||||
<Lock />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- API类型分类 Tab -->
|
||||
<el-tab-pane label="API类型" name="api">
|
||||
<div class="flex h-[600px]">
|
||||
<!-- 侧边导航 -->
|
||||
<div class="w-28 flex-shrink-0 border-r border-gray-100 overflow-y-auto mr-2">
|
||||
<div
|
||||
v-for="(_, apiType) in groupedByApiType"
|
||||
:key="apiType"
|
||||
class="cursor-pointer px-1 py-2.5 text-xs hover:bg-gray-50 transition-colors duration-200 border-l-2 border-transparent leading-tight"
|
||||
:class="{ 'text-primary font-bold bg-blue-50 border-primary': activeApiGroup === apiType, 'text-gray-600': activeApiGroup !== apiType }"
|
||||
@click="scrollToGroup('api', apiType as string)"
|
||||
>
|
||||
<div v-html="(apiType).replace(/ /g, '<br/>')" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- 内容列表 -->
|
||||
<div class="flex-1 min-w-0">
|
||||
<el-scrollbar height="100%" @scroll="handleScroll">
|
||||
<div class="px-2 pb-4">
|
||||
<template v-for="(models, apiType) in groupedByApiType" :key="apiType">
|
||||
<div :id="`group-api-${apiType}`" class="group-title text-gray-500 text-xs font-bold mb-2 mt-4 px-1 pt-2">
|
||||
{{ apiType }}
|
||||
</div>
|
||||
<div
|
||||
v-for="item in models"
|
||||
:id="`api-model-${item.id}`"
|
||||
:key="item.id"
|
||||
:class="getWrapperClass(item)"
|
||||
@click="handleModelClick(item)"
|
||||
>
|
||||
<div class="flex items-center gap-3 flex-1 min-w-0">
|
||||
<div class="w-8 h-8 flex-shrink-0 rounded-full bg-white border border-gray-100 flex items-center justify-center overflow-hidden p-1">
|
||||
<img v-if="item.iconUrl" :src="item.iconUrl" class="w-full h-full object-contain" alt="icon">
|
||||
<SvgIcon v-else name="models" size="16" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-0.5 flex-1 min-w-0">
|
||||
<div class="flex items-center gap-2 flex-wrap">
|
||||
<span :class="getModelStyleClass(item)" class="font-medium truncate">
|
||||
{{ item.modelName }}
|
||||
</span>
|
||||
<span v-if="item.isFree" class="text-[10px] px-1.5 py-0.5 bg-green-100 text-green-600 rounded-full">免费</span>
|
||||
<span v-if="item.isPremiumPackage" class="text-[10px] px-1.5 py-0.5 bg-orange-100 text-orange-600 rounded-full">尊享</span>
|
||||
<span v-else-if="!item.isFree" class="text-[10px] px-1.5 py-0.5 bg-yellow-100 text-yellow-600 rounded-full">VIP</span>
|
||||
<!-- 显示 厂商名称 -->
|
||||
<span class="text-[10px] px-1.5 py-0.5 bg-blue-50 text-blue-600 rounded-full">{{ item.providerName }}</span>
|
||||
</div>
|
||||
<div class="text-xs text-gray-400 break-words whitespace-normal line-clamp-2" :title="item.modelDescribe">
|
||||
{{ item.modelDescribe }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 选中/锁定图标 -->
|
||||
<div class="flex items-center">
|
||||
<el-icon v-if="isCurrentModel(item)" class="text-primary mr-2" :size="18">
|
||||
<Check />
|
||||
</el-icon>
|
||||
<el-icon v-if="!isModelAvailable(item)" class="text-gray-400">
|
||||
<Lock />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -222,32 +485,15 @@ function getWrapperClass(item: GetSessionListVO) {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.popover-content-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
height: 300px;
|
||||
overflow: hidden auto;
|
||||
/* 移动端适配 */
|
||||
@media (max-width: 768px) {
|
||||
:deep(.model-select-dialog) {
|
||||
max-width: 100% !important;
|
||||
margin-top: 10vh !important;
|
||||
|
||||
:deep(.popover-trigger-item-text) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.popover-content-box-item-text {
|
||||
color: white;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
// 滚动条样式
|
||||
&::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
&::-webkit-scrollbar-track {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: #cccccc;
|
||||
border-radius: 4px;
|
||||
.el-dialog__body {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,19 +509,62 @@ function getWrapperClass(item: GetSessionListVO) {
|
||||
100% { transform: translateX(100%) translateY(100%); }
|
||||
}
|
||||
|
||||
/* 柔光 hover 动效 */
|
||||
@keyframes glowPulse {
|
||||
0%, 100% { box-shadow: 0 0 6px rgba(37,99,235,0.2); }
|
||||
50% { box-shadow: 0 0 10px rgba(37,99,235,0.5); }
|
||||
}
|
||||
|
||||
.animate-gradientFlow {
|
||||
animation: gradientFlow 3s ease infinite;
|
||||
}
|
||||
.animate-goldShine {
|
||||
animation: goldShine 4s linear infinite;
|
||||
}
|
||||
.animate-glowPulse {
|
||||
animation: glowPulse 2s ease-in-out infinite;
|
||||
|
||||
/* 定义一些颜色变量辅助类,如果项目没有定义的话 */
|
||||
.text-primary {
|
||||
color: var(--el-color-primary, #409eff);
|
||||
}
|
||||
.bg-primary-light-9 {
|
||||
background-color: var(--el-color-primary-light-9, #ecf5ff);
|
||||
}
|
||||
.border-primary {
|
||||
border-color: var(--el-color-primary, #409eff);
|
||||
}
|
||||
|
||||
/* 尊享过滤标签 */
|
||||
.premium-filter-tag {
|
||||
padding: 4px 12px;
|
||||
border-radius: 20px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
border: 1.5px solid transparent;
|
||||
background: linear-gradient(white, white) padding-box,
|
||||
linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3, #54a0ff, #5f27cd) border-box;
|
||||
transition: all 0.3s ease;
|
||||
user-select: none;
|
||||
|
||||
&__text {
|
||||
background: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3, #54a0ff, #5f27cd);
|
||||
background-size: 200% 200%;
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
color: transparent;
|
||||
animation: gradientFlow 3s ease infinite;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.05);
|
||||
box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
|
||||
}
|
||||
|
||||
&--active {
|
||||
background: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3, #54a0ff, #5f27cd);
|
||||
background-size: 200% 200%;
|
||||
animation: gradientFlow 3s ease infinite;
|
||||
|
||||
.premium-filter-tag__text {
|
||||
background: white;
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
color: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
542
Yi.Ai.Vue3/src/components/ModelSelect/modelData.ts
Normal file
542
Yi.Ai.Vue3/src/components/ModelSelect/modelData.ts
Normal file
@@ -0,0 +1,542 @@
|
||||
export const modelList = [
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f041aa11',
|
||||
modelId: 'gpt-5.2-chat',
|
||||
modelName: 'gpt-5.2-chat',
|
||||
modelDescribe: 'OpenAI最新模型,chat日常版本,相对gpt5.1大幅进步,声称是目前最强模型,是真还是噱头?',
|
||||
remark: 'OpenAI最新模型,chat日常版本,相对gpt5.1大幅进步,声称是目前最强模型,是真还是噱头?',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ab7',
|
||||
modelId: 'DeepSeek-V3-0324',
|
||||
modelName: 'DeepSeek-V3',
|
||||
modelDescribe: '国产开源,简单聊天模式,对于中文文章语义体验较好,但响应速度一般',
|
||||
remark: '国产开源,简单聊天模式,对于中文文章语义体验较好,但响应速度一般',
|
||||
isPremiumPackage: false,
|
||||
isFree: true,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/deepseek.svg',
|
||||
providerName: '深度思索',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ee1',
|
||||
modelId: 'DeepSeek-V3.1',
|
||||
modelName: 'DeepSeek-V3.1',
|
||||
modelDescribe: '国产开源,具备混合推理架构:一个模型同时支持思考模式与非思考模式,更高的思考效率',
|
||||
remark: '国产开源,具备混合推理架构:一个模型同时支持思考模式与非思考模式,更高的思考效率',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/deepseek.svg',
|
||||
providerName: '深度思索',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04eaaf1',
|
||||
modelId: 'gpt-5.1-chat',
|
||||
modelName: 'gpt-5.1-chat',
|
||||
modelDescribe: 'OpenAI 迄今为止最最强的旗舰模型!chat日常版本,与Gpt5相比,更人性化,更讨好用户,并且速度大幅起飞~,但逻辑能力提升不大',
|
||||
remark: 'OpenAI 迄今为止最最强的旗舰模型!chat日常版本,与Gpt5相比,更人性化,更讨好用户,并且速度大幅起飞~,但逻辑能力提升不大',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1af1',
|
||||
modelId: 'gpt-5-chat',
|
||||
modelName: 'gpt-5',
|
||||
modelDescribe: 'OpenAI 迄今为止最强的旗舰模型!-更深入',
|
||||
remark: 'OpenAI 迄今为止最强的旗舰模型!-更深入',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1af2',
|
||||
modelId: 'gpt-5-mini',
|
||||
modelName: 'gpt-5-mini',
|
||||
modelDescribe: 'OpenAI 迄今为止最强的旗舰模型!-更快',
|
||||
remark: 'OpenAI 迄今为止最强的旗舰模型!-更快',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1af3',
|
||||
modelId: 'gpt-5-nano',
|
||||
modelName: 'gpt-5-nano',
|
||||
modelDescribe: 'OpenAI 迄今为止最强的旗舰模型!-最快',
|
||||
remark: 'OpenAI 迄今为止最强的旗舰模型!-最快',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1cc1',
|
||||
modelId: 'Kimi-K2-Thinking',
|
||||
modelName: 'Kimi-K2-Thinking',
|
||||
modelDescribe: '国产月之暗面开源模型,优点是上下文极长,在长文本处理、技术创新和多语言支持等方面具有显著优势',
|
||||
remark: '国产月之暗面开源模型,优点是上下文极长,在长文本处理、技术创新和多语言支持等方面具有显著优势',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/moonshotai.svg',
|
||||
providerName: '月之暗面',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1a55',
|
||||
modelId: 'gpt-4o-mini',
|
||||
modelName: 'gpt-4o-mini',
|
||||
modelDescribe: 'OpenAI GPT-4o 深度思考的轻量版本,功能丰富性价比高',
|
||||
remark: 'OpenAI GPT-4o 深度思考的轻量版本,功能丰富性价比高',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ff3',
|
||||
modelId: 'codex-mini',
|
||||
modelName: 'codex-mini',
|
||||
modelDescribe: 'OpenAi 推出的专门写代码的模型,Codex的mini版本',
|
||||
remark: 'OpenAi 推出的专门写代码的模型,Codex的mini版本',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ff2',
|
||||
modelId: 'grok-4-fast-non-reasoning',
|
||||
modelName: 'grok-4-fast-non-reasoning',
|
||||
modelDescribe: '由马克斯xAI推出,是Grok4的快速版本,并且自带深度思考,适合复杂逻辑场景,思考时间较短',
|
||||
remark: '由马克斯xAI推出,是Grok4的快速版本,并且自带深度思考,适合复杂逻辑场景,思考时间较短',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/grok.svg',
|
||||
providerName: 'X',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ff1',
|
||||
modelId: 'grok-4-fast-reasoning',
|
||||
modelName: 'grok-4-fast-reasoning',
|
||||
modelDescribe: '由马克斯xAI推出,是Grok4的快速版本,并且不带深度思考,速度很快',
|
||||
remark: '由马克斯xAI推出,是Grok4的快速版本,并且不带深度思考,速度很快',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/grok.svg',
|
||||
providerName: 'X',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ad2',
|
||||
modelId: 'o3-mini',
|
||||
modelName: 'o3-mini',
|
||||
modelDescribe: 'OpenAI o3 系列的推理模型,轻便且高效',
|
||||
remark: 'OpenAI o3 系列的推理模型,轻便且高效',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ad1',
|
||||
modelId: 'gpt-4.1',
|
||||
modelName: 'gpt-4.1',
|
||||
modelDescribe: 'OpenAI 最新标准版模型,万金油模型,各个领域都十分强悍',
|
||||
remark: 'OpenAI 最新标准版模型,万金油模型,各个领域都十分强悍',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ab4',
|
||||
modelId: 'gpt-4.1-mini',
|
||||
modelName: 'gpt-4.1-mini',
|
||||
modelDescribe: 'OpenAI 适合日常使用的 GPT-4.1 精简版',
|
||||
remark: 'OpenAI 适合日常使用的 GPT-4.1 精简版',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ac1',
|
||||
modelId: 'gpt-4.1-nano',
|
||||
modelName: 'gpt-4.1-nano',
|
||||
modelDescribe: 'OpenAI 极致性价比,极快的快速响应,适合轻量任务',
|
||||
remark: 'OpenAI 极致性价比,极快的快速响应,适合轻量任务',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ac2',
|
||||
modelId: 'gpt-35-turbo',
|
||||
modelName: 'gpt-35-turbo',
|
||||
modelDescribe: 'OpenAI 极致性价比,极快的快速响应,适合轻量任务',
|
||||
remark: 'OpenAI 极致性价比,极快的快速响应,适合轻量任务',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ac3',
|
||||
modelId: 'gpt-4o',
|
||||
modelName: 'gpt-4o',
|
||||
modelDescribe: 'OpenAI 多模态旗舰模型,支持语音、图像、文本交互,具备深度思考,需要一定的响应时间',
|
||||
remark: 'OpenAI 多模态旗舰模型,支持语音、图像、文本交互,具备深度思考,需要一定的响应时间',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ac6',
|
||||
modelId: 'o4-mini',
|
||||
modelName: 'o4-mini',
|
||||
modelDescribe: 'OpenAI o4 系列的推理模型,轻便且高效,比o3 更深度,但速度更慢',
|
||||
remark: 'OpenAI o4 系列的推理模型,轻便且高效,比o3 更深度,但速度更慢',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ac4',
|
||||
modelId: 'grok-3',
|
||||
modelName: 'grok-3',
|
||||
modelDescribe: '由马克斯xAI推出,理论上的能力非常强,用重金超高成本砸出的超强推理模型',
|
||||
remark: '由马克斯xAI推出,理论上的能力非常强,用重金超高成本砸出的超强推理模型',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/grok.svg',
|
||||
providerName: 'X',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ac5',
|
||||
modelId: 'grok-3-mini',
|
||||
modelName: 'grok-3-mini',
|
||||
modelDescribe: '由马克斯xAI推出,理论上的能力非常强,更快更小的模型',
|
||||
remark: '由马克斯xAI推出,理论上的能力非常强,更快更小的模型',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/grok.svg',
|
||||
providerName: 'X',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ac9',
|
||||
modelId: 'Phi-4-reasoning',
|
||||
modelName: 'Phi-4-reasoning',
|
||||
modelDescribe: '微软推出的小而强大模型,Phi-4 的逻辑推理优化版本',
|
||||
remark: '微软推出的小而强大模型,Phi-4 的逻辑推理优化版本',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/microsoft.svg',
|
||||
providerName: 'Microsoft',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ac7',
|
||||
modelId: 'Phi-4',
|
||||
modelName: 'Phi-4',
|
||||
modelDescribe: '微软推出的强大模型,适合部署简单任务',
|
||||
remark: '微软推出的强大模型,适合部署简单任务',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/microsoft.svg',
|
||||
providerName: 'Microsoft',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ac8',
|
||||
modelId: 'Phi-4-mini-instruct',
|
||||
modelName: 'Phi-4-mini-instruct',
|
||||
modelDescribe: '微软推出的小而强大模型,专为指令执行设计的微型模型',
|
||||
remark: '微软推出的小而强大模型,专为指令执行设计的微型模型',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/microsoft.svg',
|
||||
providerName: 'Microsoft',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ad7',
|
||||
modelId: 'databricks-meta-llama-3-1-405B-instruct',
|
||||
modelName: 'meta-llama-3-1-405B',
|
||||
modelDescribe: 'Meta 原FaceBook公司打造的开源模型,开源模型中的王炸,具有4050亿超长参数,价格也是较为昂贵',
|
||||
remark: 'Meta 原FaceBook公司打造的开源模型,开源模型中的王炸,具有4050亿超长参数,价格也是较为昂贵',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/meta-color.svg',
|
||||
providerName: 'Meta',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ad6',
|
||||
modelId: 'databricks-meta-llama-3-3-70b-instruct',
|
||||
modelName: 'meta-llama-3.3-70B',
|
||||
modelDescribe: 'Meta 原FaceBook公司打造的开源模型,开源模型中的王炸,具有700亿参数',
|
||||
remark: 'Meta 原FaceBook公司打造的开源模型,开源模型中的王炸,具有700亿参数',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/meta-color.svg',
|
||||
providerName: 'Meta',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1bb2',
|
||||
modelId: 'databricks-gpt-oss-120b',
|
||||
modelName: 'gpt-oss-120b',
|
||||
modelDescribe: 'OpenAI 最强大的开源模型,热门,具备深度思考,120b参数可日常使用,速度是真的快',
|
||||
remark: 'OpenAI 最强大的开源模型,热门,具备深度思考,120b参数可日常使用,速度是真的快',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ad8',
|
||||
modelId: 'o1',
|
||||
modelName: 'o1',
|
||||
modelDescribe: 'OpenAI 超强推理模型,强强强,o1与o3价格十分昂贵,列入顶级模型系列,相对于mini更强,但响应速度略慢',
|
||||
remark: 'OpenAI 超强推理模型,强强强,o1与o3价格十分昂贵,列入顶级模型系列,相对于mini更强,但响应速度略慢',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ad4',
|
||||
modelId: 'databricks-claude-sonnet-4',
|
||||
modelName: 'claude-sonnet-4',
|
||||
modelDescribe: 'claude-sonnet-4奢侈模型',
|
||||
remark: 'claude-sonnet-4奢侈模型',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/claude-color.svg',
|
||||
providerName: 'Anthropic',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ad3',
|
||||
modelId: 'databricks-claude-3-7-sonnet',
|
||||
modelName: 'claude-3-7-sonnet',
|
||||
modelDescribe: 'Anthropic 公司下开创的划时代AI纪元,所有AI逻辑性几乎地表最强!但价格十分昂贵',
|
||||
remark: 'Anthropic 公司下开创的划时代AI纪元,所有AI逻辑性几乎地表最强!但价格十分昂贵',
|
||||
isPremiumPackage: false,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/claude-color.svg',
|
||||
providerName: 'Anthropic',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04ecff7',
|
||||
modelId: 'claude-opus-4-5-20251101',
|
||||
modelName: 'claude-opus-4-5-20251101',
|
||||
modelDescribe: '编程天上第一,claude4-sonnet-4-5 强化版,富哥专属,Vip尊享包专属',
|
||||
remark: '编程天上第一,claude4-sonnet-4-5 强化版,富哥专属,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/claude-color.svg',
|
||||
providerName: 'Anthropic',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04ecff6',
|
||||
modelId: 'claude-opus-4-5-20251101',
|
||||
modelName: 'claude-opus-4-5-20251101',
|
||||
modelDescribe: '编程天上第一,claude4-sonnet-4-5 强化版,富哥专属,Vip尊享包专属',
|
||||
remark: '编程天上第一,claude4-sonnet-4-5 强化版,富哥专属,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Messages',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/claude-color.svg',
|
||||
providerName: 'Anthropic',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ff4',
|
||||
modelId: 'claude-sonnet-4-5-20250929',
|
||||
modelName: 'claude-sonnet-4-5-20250929',
|
||||
modelDescribe: '编程天下第一,地表最强,Vip尊享包专属',
|
||||
remark: '编程天下第一,地表最强,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Messages',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/claude-color.svg',
|
||||
providerName: 'Anthropic',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ff5',
|
||||
modelId: 'claude-sonnet-4-5-20250929',
|
||||
modelName: 'claude-sonnet-4-5-20250929',
|
||||
modelDescribe: '编程天下第一,地表最强,Vip尊享包专属',
|
||||
remark: '编程天下第一,地表最强,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/claude-color.svg',
|
||||
providerName: 'Anthropic',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ff7',
|
||||
modelId: 'claude-haiku-4-5-20251001',
|
||||
modelName: 'claude-haiku-4-5-20251001',
|
||||
modelDescribe: 'claude-sonnet-4.5实惠版本,有一定性价比,Vip尊享包专属',
|
||||
remark: 'claude-sonnet-4.5实惠版本,有一定性价比,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Messages',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/claude-color.svg',
|
||||
providerName: 'Anthropic',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ff8',
|
||||
modelId: 'claude-haiku-4-5-20251001',
|
||||
modelName: 'claude-haiku-4-5-20251001',
|
||||
modelDescribe: 'claude-sonnet-4.5实惠版本,有一定性价比,Vip尊享包专属',
|
||||
remark: 'claude-sonnet-4.5实惠版本,有一定性价比,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/claude-color.svg',
|
||||
providerName: 'Anthropic',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ba4',
|
||||
modelId: 'yi-claude-sonnet-4-5-20250929',
|
||||
modelName: 'yi-claude-sonnet-4-5-20250929',
|
||||
modelDescribe: '(元旦限时活动-意心ai独家-token每日有限)编程天下第一,地表最强,Vip尊享包专属',
|
||||
remark: '(元旦限时活动-意心ai独家-token每日有限)编程天下第一,地表最强,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Messages',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/claude-color.svg',
|
||||
providerName: 'Anthropic',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04ecba6',
|
||||
modelId: 'yi-claude-opus-4-5-20251101',
|
||||
modelName: 'yi-claude-opus-4-5-20251101',
|
||||
modelDescribe: '(元旦限时活动-意心ai独家-token每日有限)编程天上第一,claude4-sonnet-4-5 强化版,富哥专属,Vip尊享包专属',
|
||||
remark: '(元旦限时活动-意心ai独家-token每日有限)编程天上第一,claude4-sonnet-4-5 强化版,富哥专属,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Messages',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/claude-color.svg',
|
||||
providerName: 'Anthropic',
|
||||
},
|
||||
{
|
||||
id: '077be103-1456-a4bb-409c-3a15f04e1ba7',
|
||||
modelId: 'yi-claude-haiku-4-5-20251001',
|
||||
modelName: 'yi-claude-haiku-4-5-20251001',
|
||||
modelDescribe: '(元旦限时活动-意心ai独家-token每日有限)claude-sonnet-4.5实惠版本,有一定性价比,Vip尊享包专属',
|
||||
remark: '(元旦限时活动-意心ai独家-token每日有限)claude-sonnet-4.5实惠版本,有一定性价比,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Messages',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/claude-color.svg',
|
||||
providerName: 'Anthropic',
|
||||
},
|
||||
{
|
||||
id: '3a1e8c96-d632-fad8-280a-4205d9be97d4',
|
||||
modelId: 'gemini-3-pro',
|
||||
modelName: 'gemini-3-pro',
|
||||
modelDescribe: '谷歌全网火爆最强模型,前端编程能力最强,前端能力跟claude4.5 opus有的一拼,生成的页面非常细腻,没有ai味,Vip尊享包专属',
|
||||
remark: '谷歌全网火爆最强模型,前端编程能力最强,前端能力跟claude4.5 opus有的一拼,生成的页面非常细腻,没有ai味,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'GenerateContent',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/gemini-color.svg',
|
||||
providerName: 'Google',
|
||||
},
|
||||
{
|
||||
id: '3a1ea0a6-c0b1-c680-3537-80cb9600be9a',
|
||||
modelId: 'gpt-5.2',
|
||||
modelName: 'gpt-5.2',
|
||||
modelDescribe: 'OpenAI最新模型,相对gpt5.1大幅进步,声称是目前最强模型,是真还是噱头?多顶流模型竞技中完爆其他模型,甚至部分考试直接满分,具体实际体验由你决定,Vip尊享包专属',
|
||||
remark: 'OpenAI最新模型,相对gpt5.1大幅进步,声称是目前最强模型,是真还是噱头?多顶流模型竞技中完爆其他模型,甚至部分考试直接满分,具体实际体验由你决定,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Responses',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '3a1ea0b0-ee30-a38e-1576-835ad7b1155f',
|
||||
modelId: 'gemini-3-pro-high',
|
||||
modelName: 'gemini-3-pro-high',
|
||||
modelDescribe: '谷歌全网火爆最强模型,前端编程能力最强,前端能力跟claude4.5 opus有的一拼,生成的页面非常细腻,没有ai味,Vip尊享包专属',
|
||||
remark: '谷歌全网火爆最强模型,前端编程能力最强,前端能力跟claude4.5 opus有的一拼,生成的页面非常细腻,没有ai味,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'GenerateContent',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/gemini-color.svg',
|
||||
providerName: 'Google',
|
||||
},
|
||||
{
|
||||
id: '3a1ea0b9-0512-2324-9f2e-725552f17d7f',
|
||||
modelId: 'gpt-5.2-codex',
|
||||
modelName: 'gpt-5.2-codex',
|
||||
modelDescribe: 'OpenAI最新模型,相对gpt5.1大幅进步,声称是目前最强模型,是真还是噱头?多顶流模型竞技中完爆其他模型,甚至部分考试直接满分,具体实际体验由你决定,Vip尊享包专属',
|
||||
remark: 'OpenAI最新模型,相对gpt5.1大幅进步,声称是目前最强模型,是真还是噱头?多顶流模型竞技中完爆其他模型,甚至部分考试直接满分,具体实际体验由你决定,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Responses',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '3a1ea0bc-9b22-3772-5f59-b78a6562771d',
|
||||
modelId: 'gpt-5.2-codex',
|
||||
modelName: 'gpt-5.2-codex',
|
||||
modelDescribe: 'OpenAI最新模型,相对gpt5.1大幅进步,声称是目前最强模型,是真还是噱头?多顶流模型竞技中完爆其他模型,甚至部分考试直接满分,具体实际体验由你决定,Vip尊享包专属',
|
||||
remark: 'OpenAI最新模型,相对gpt5.1大幅进步,声称是目前最强模型,是真还是噱头?多顶流模型竞技中完爆其他模型,甚至部分考试直接满分,具体实际体验由你决定,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
{
|
||||
id: '3a1ea0bd-5a5e-d628-6f5e-43e31d653569',
|
||||
modelId: 'gpt-5.2',
|
||||
modelName: 'gpt-5.2',
|
||||
modelDescribe: 'OpenAI最新模型,相对gpt5.1大幅进步,声称是目前最强模型,是真还是噱头?多顶流模型竞技中完爆其他模型,甚至部分考试直接满分,具体实际体验由你决定,Vip尊享包专属',
|
||||
remark: 'OpenAI最新模型,相对gpt5.1大幅进步,声称是目前最强模型,是真还是噱头?多顶流模型竞技中完爆其他模型,甚至部分考试直接满分,具体实际体验由你决定,Vip尊享包专属',
|
||||
isPremiumPackage: true,
|
||||
isFree: false,
|
||||
modelApiType: 'Completions',
|
||||
iconUrl: 'https://ccnetcore.com/prod-api/wwwroot/aihub/logo/openai.svg',
|
||||
providerName: 'OpenAi',
|
||||
},
|
||||
];
|
||||
105
Yi.Ai.Vue3/src/components/ProductPackage/ActivationGuide.vue
Normal file
105
Yi.Ai.Vue3/src/components/ProductPackage/ActivationGuide.vue
Normal file
@@ -0,0 +1,105 @@
|
||||
<script setup lang="ts">
|
||||
const emit = defineEmits(['close']);
|
||||
|
||||
function goToActivation() {
|
||||
emit('close');
|
||||
window.location.href = '/console/activation';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="activation-guide-container">
|
||||
<div class="activation-content">
|
||||
<div class="guide-icon">
|
||||
🎁
|
||||
</div>
|
||||
<h3 class="guide-title">
|
||||
激活码兑换
|
||||
</h3>
|
||||
<p class="guide-desc">
|
||||
如果您持有意心AI的会员激活码或Token兑换码,<br>请点击下方按钮前往控制台进行兑换。
|
||||
</p>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="large"
|
||||
class="redeem-jump-btn"
|
||||
round
|
||||
@click="goToActivation"
|
||||
>
|
||||
前往兑换中心
|
||||
</el-button>
|
||||
|
||||
<div class="guide-tips">
|
||||
<p>💡 兑换成功后权益将立即生效</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.activation-guide-container {
|
||||
padding: 40px 20px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 400px;
|
||||
background: linear-gradient(to bottom, #fff, #fdfdfd);
|
||||
border-radius: 8px;
|
||||
|
||||
.activation-content {
|
||||
text-align: center;
|
||||
max-width: 400px;
|
||||
|
||||
.guide-icon {
|
||||
font-size: 64px;
|
||||
margin-bottom: 24px;
|
||||
animation: float-icon 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.guide-title {
|
||||
font-size: 24px;
|
||||
font-weight: 800;
|
||||
color: #2c3e50;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.guide-desc {
|
||||
color: #606266;
|
||||
line-height: 1.6;
|
||||
margin-bottom: 32px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.redeem-jump-btn {
|
||||
width: 200px;
|
||||
height: 48px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
letter-spacing: 1px;
|
||||
background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
|
||||
border: none;
|
||||
box-shadow: 0 4px 12px rgba(255, 117, 140, 0.3);
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 16px rgba(255, 117, 140, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
.guide-tips {
|
||||
margin-top: 24px;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes float-icon {
|
||||
0%, 100% { transform: translateY(0); }
|
||||
50% { transform: translateY(-10px); }
|
||||
}
|
||||
</style>
|
||||
460
Yi.Ai.Vue3/src/components/ProductPackage/NewbieGuide.vue
Normal file
460
Yi.Ai.Vue3/src/components/ProductPackage/NewbieGuide.vue
Normal file
@@ -0,0 +1,460 @@
|
||||
<script setup lang="ts">
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { contactConfig, taobaoConfig } from '@/config/constants.ts';
|
||||
|
||||
// 复制淘口令
|
||||
function copyTaobaoCode() {
|
||||
navigator.clipboard.writeText(taobaoConfig.code).then(() => {
|
||||
ElMessage.success('淘口令已复制,打开手机淘宝即可购买');
|
||||
}).catch(() => {
|
||||
ElMessage.error('复制失败,请手动复制');
|
||||
});
|
||||
}
|
||||
|
||||
// 跳转淘宝
|
||||
function goToTaobao() {
|
||||
window.open(taobaoConfig.link, '_blank');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="newbie-guide-container">
|
||||
<div class="newbie-content">
|
||||
<div class="newbie-header">
|
||||
<div class="header-icon">
|
||||
🎉
|
||||
</div>
|
||||
<h3 class="header-title">
|
||||
新人特惠组合包
|
||||
</h3>
|
||||
<p class="header-subtitle">
|
||||
超值优惠,仅限首次购买用户
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="newbie-body">
|
||||
<!-- 购买方式卡片 -->
|
||||
<div class="purchase-card">
|
||||
<div class="card-row">
|
||||
<div class="card-col">
|
||||
<div class="method-label">
|
||||
方法一
|
||||
</div>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="goToTaobao"
|
||||
>
|
||||
<el-icon><i-ep-link /></el-icon>
|
||||
淘宝链接
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="card-col">
|
||||
<div class="method-label">
|
||||
方法二
|
||||
</div>
|
||||
<el-button
|
||||
type="success"
|
||||
size="small"
|
||||
@click="copyTaobaoCode"
|
||||
>
|
||||
<el-icon><i-ep-document-copy /></el-icon>
|
||||
复制淘口令
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 淘口令展示 -->
|
||||
<div class="taobao-code-box">
|
||||
<div class="code-label">
|
||||
淘口令
|
||||
</div>
|
||||
<div class="code-text">
|
||||
{{ taobaoConfig.code }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 或者分割线 -->
|
||||
<div v-if="false" class="divider-section">
|
||||
<span class="divider-line" />
|
||||
<span class="divider-text">或者</span>
|
||||
<span class="divider-line" />
|
||||
</div>
|
||||
|
||||
<!-- 二维码区域 -->
|
||||
<div v-if="false" class="qr-code-section">
|
||||
<div class="qr-code-title">
|
||||
扫码购买
|
||||
</div>
|
||||
<div class="qr-code-box">
|
||||
<img :src="taobaoConfig.taobaoQr" alt="淘宝二维码" class="qr-code-image">
|
||||
<p class="qr-code-tip">
|
||||
打开手机淘宝扫一扫
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 温馨提示 -->
|
||||
<div class="tips-box">
|
||||
<p class="tips-title">
|
||||
<el-icon><i-ep-info-filled /></el-icon> 温馨提示
|
||||
</p>
|
||||
<p class="tips-text">
|
||||
新人特惠仅限首次购买 · 购买后联系客服激活
|
||||
</p>
|
||||
<p class="tips-text">
|
||||
客服微信:{{ contactConfig.wechatId }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.newbie-guide-container {
|
||||
padding: 20px 16px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 300px;
|
||||
background: linear-gradient(to bottom, #fff, #fdfdfd);
|
||||
border-radius: 8px;
|
||||
|
||||
.newbie-content {
|
||||
text-align: center;
|
||||
//max-width: 450px;
|
||||
width: 100%;
|
||||
|
||||
.newbie-header {
|
||||
margin-bottom: 20px;
|
||||
padding: 16px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 10px;
|
||||
color: white;
|
||||
|
||||
.header-icon {
|
||||
font-size: 32px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
margin: 0 0 6px 0;
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
font-size: 13px;
|
||||
margin: 0;
|
||||
opacity: 0.95;
|
||||
}
|
||||
}
|
||||
|
||||
.newbie-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
|
||||
// 二维码区域
|
||||
.qr-code-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 20px;
|
||||
background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
|
||||
border-radius: 12px;
|
||||
border: 2px solid #bae6fd;
|
||||
|
||||
.qr-code-title {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: #0369a1;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.qr-code-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
background: white;
|
||||
padding: 16px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
|
||||
.qr-code-image {
|
||||
width: 180px;
|
||||
height: 180px;
|
||||
object-fit: contain;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.qr-code-tip {
|
||||
margin: 12px 0 0 0;
|
||||
font-size: 13px;
|
||||
color: #0369a1;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 分割线
|
||||
.divider-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin: 4px 0;
|
||||
|
||||
.divider-line {
|
||||
flex: 1;
|
||||
height: 1px;
|
||||
background: linear-gradient(to right, transparent, #d1d5db, transparent);
|
||||
}
|
||||
|
||||
.divider-text {
|
||||
font-size: 13px;
|
||||
color: #9ca3af;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.purchase-card {
|
||||
background: #f7f8fa;
|
||||
border-radius: 10px;
|
||||
padding: 16px;
|
||||
border: 2px solid #e8ecf0;
|
||||
|
||||
.card-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16px;
|
||||
|
||||
.card-col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
|
||||
.method-label {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.el-button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.taobao-code-box {
|
||||
background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
|
||||
border-radius: 8px;
|
||||
padding: 14px;
|
||||
border: 2px dashed #bae6fd;
|
||||
|
||||
.code-label {
|
||||
font-size: 12px;
|
||||
color: #0369a1;
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.code-text {
|
||||
font-size: 11px;
|
||||
color: #667eea;
|
||||
font-family: 'Courier New', monospace;
|
||||
line-height: 1.5;
|
||||
word-break: break-all;
|
||||
background: white;
|
||||
padding: 8px;
|
||||
border-radius: 6px;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
.tips-box {
|
||||
background: #f0f9ff;
|
||||
border: 1px solid #bae6fd;
|
||||
border-radius: 8px;
|
||||
padding: 14px;
|
||||
text-align: left;
|
||||
|
||||
.tips-title {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #0369a1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
.el-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.tips-text {
|
||||
margin: 4px 0;
|
||||
font-size: 12px;
|
||||
color: #0c4a6e;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 移动端优化 */
|
||||
@media (max-width: 768px) {
|
||||
.newbie-guide-container {
|
||||
padding: 16px 12px;
|
||||
min-height: auto;
|
||||
|
||||
.newbie-content {
|
||||
max-width: 100%;
|
||||
|
||||
.newbie-header {
|
||||
padding: 16px;
|
||||
margin-bottom: 16px;
|
||||
border-radius: 8px;
|
||||
|
||||
.header-icon {
|
||||
font-size: 28px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 18px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
.newbie-body {
|
||||
gap: 12px;
|
||||
|
||||
.qr-code-section {
|
||||
padding: 16px;
|
||||
|
||||
.qr-code-title {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.qr-code-box {
|
||||
padding: 12px;
|
||||
|
||||
.qr-code-image {
|
||||
width: 160px;
|
||||
height: 160px;
|
||||
}
|
||||
|
||||
.qr-code-tip {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.purchase-card {
|
||||
padding: 14px;
|
||||
border-radius: 8px;
|
||||
|
||||
.card-row {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 10px;
|
||||
|
||||
.card-col {
|
||||
.method-label {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.el-button {
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.taobao-code-box {
|
||||
padding: 12px;
|
||||
|
||||
.code-label {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.code-text {
|
||||
font-size: 10px;
|
||||
padding: 6px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
.tips-box {
|
||||
padding: 12px;
|
||||
|
||||
.tips-title {
|
||||
font-size: 12px;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.el-icon {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.tips-text {
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 小屏手机进一步优化 */
|
||||
@media (max-width: 480px) {
|
||||
.newbie-guide-container {
|
||||
padding: 12px 8px;
|
||||
|
||||
.newbie-content {
|
||||
.newbie-header {
|
||||
padding: 12px;
|
||||
|
||||
.header-icon {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.newbie-body {
|
||||
.purchase-card {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.taobao-code-box {
|
||||
padding: 10px;
|
||||
|
||||
.code-text {
|
||||
font-size: 9px;
|
||||
}
|
||||
}
|
||||
|
||||
.tips-box {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
1563
Yi.Ai.Vue3/src/components/ProductPackage/PackageTab.vue
Normal file
1563
Yi.Ai.Vue3/src/components/ProductPackage/PackageTab.vue
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import SupportModelList from '@/components/userPersonalCenter/components/SupportModelList.vue';
|
||||
|
||||
const models = [
|
||||
{ name: 'DeepSeek-R1', price: '2', desc: '国产开源,深度思索模式,不过幻读问题比较大,同时具备思考响应链,在开源模型中永远的神!' },
|
||||
{ name: 'DeepSeek-chat', price: '1', desc: '国产开源,简单聊天模式,对于中文文章语义体验较好,但响应速度一般' },
|
||||
@@ -27,6 +25,10 @@ const models = [
|
||||
|
||||
{ name: '更多模型请订阅查看....', price: '....', desc: '带深度思考的模型,响应速度可能会降低,请根据使用场景进行选择' },
|
||||
];
|
||||
|
||||
function goToModelLibrary() {
|
||||
window.location.href = '/model-library';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -39,8 +41,36 @@ const models = [
|
||||
</p>
|
||||
|
||||
<!-- 网格布局,默认2列 -->
|
||||
<SupportModelList layout="grid" />
|
||||
|
||||
<!-- <SupportModelList layout="grid" /> -->
|
||||
<!-- 查看模型库按钮 -->
|
||||
<div class="model-library-section">
|
||||
<el-divider />
|
||||
<div class="model-library-card">
|
||||
<div class="card-icon">
|
||||
<el-icon :size="32">
|
||||
<i-ep-box />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<h4 class="card-title">
|
||||
查看支持的模型
|
||||
</h4>
|
||||
<p class="card-desc">
|
||||
查看意心AI支持的所有模型列表及详细信息
|
||||
</p>
|
||||
</div>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="goto-btn"
|
||||
@click="goToModelLibrary"
|
||||
>
|
||||
前往模型库
|
||||
<el-icon class="ml-1">
|
||||
<i-ep-arrow-right />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<h2 v-if="false" class="text-2xl font-semibold mb-4 text-center">
|
||||
热门大模型价格排行榜
|
||||
</h2>
|
||||
@@ -80,7 +110,7 @@ const models = [
|
||||
热门大模型价格实时排行榜
|
||||
</h2>
|
||||
<div class="rounded-2xl shadow-lg overflow-hidden border border-gray-200 flex justify-center items-center p-4">
|
||||
<a href="https://openrouter.ai/models">https://openrouter.ai/models</a>
|
||||
<a href="https://openrouter.ai/models">https://openrouter.ai/models</a>
|
||||
</div>
|
||||
<p class="text-sm text-center text-gray-500 mt-2">
|
||||
来源:openrouter 模型榜
|
||||
@@ -101,4 +131,64 @@ const models = [
|
||||
th, td {
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
/* 模型库卡片样式 - 桌面端 */
|
||||
.model-library-section {
|
||||
margin-top: 16px;
|
||||
|
||||
.model-library-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
|
||||
border-radius: 12px;
|
||||
border: 2px solid #bae6fd;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.card-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
color: #667eea;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.card-content {
|
||||
flex: 1;
|
||||
|
||||
.card-title {
|
||||
margin: 0 0 4px 0;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
.card-desc {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.goto-btn {
|
||||
flex-shrink: 0;
|
||||
font-weight: 600;
|
||||
|
||||
.ml-1 {
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -11,6 +11,21 @@ const isLoadingData = ref(false);
|
||||
|
||||
const activeTab = ref('activity');
|
||||
|
||||
// 图片预览相关状态
|
||||
const isImageViewerVisible = ref(false);
|
||||
const currentPreviewUrl = ref('');
|
||||
|
||||
// 打开图片预览
|
||||
function openImagePreview(url: string) {
|
||||
currentPreviewUrl.value = url;
|
||||
isImageViewerVisible.value = true;
|
||||
}
|
||||
|
||||
// 关闭图片预览
|
||||
function closeImagePreview() {
|
||||
isImageViewerVisible.value = false;
|
||||
}
|
||||
|
||||
// 窗口宽度响应式状态
|
||||
const windowWidth = ref(typeof window !== 'undefined' ? window.innerWidth : 1920);
|
||||
|
||||
@@ -123,9 +138,18 @@ watch(isDialogVisible, async (newValue) => {
|
||||
:key="index"
|
||||
class="activity-item"
|
||||
>
|
||||
<!-- 活动图片 -->
|
||||
<div v-if="activity.imageUrl" class="activity-image-wrapper">
|
||||
<!-- 活动图片 - 浮动在右上方 -->
|
||||
<div v-if="activity.imageUrl" class="activity-image-wrapper" @click="openImagePreview(activity.imageUrl)">
|
||||
<img :src="activity.imageUrl" :alt="activity.title" class="activity-image">
|
||||
<!-- 放大图标提示 -->
|
||||
<div class="zoom-icon">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="11" cy="11" r="8"></circle>
|
||||
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
||||
<line x1="11" y1="8" x2="11" y2="14"></line>
|
||||
<line x1="8" y1="11" x2="14" y2="11"></line>
|
||||
</svg>
|
||||
</div>
|
||||
<!-- 图片上的状态标签 -->
|
||||
<div class="activity-status-badge">
|
||||
<el-tag
|
||||
@@ -233,6 +257,16 @@ watch(isDialogVisible, async (newValue) => {
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 图片预览组件 -->
|
||||
<teleport to="body">
|
||||
<el-image-viewer
|
||||
v-if="isImageViewerVisible"
|
||||
:url-list="[currentPreviewUrl]"
|
||||
:initial-index="0"
|
||||
@close="closeImagePreview"
|
||||
/>
|
||||
</teleport>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
@@ -410,7 +444,7 @@ watch(isDialogVisible, async (newValue) => {
|
||||
:deep(.el-tabs__header) {
|
||||
flex-shrink: 0;
|
||||
margin: 0 20px;
|
||||
padding-top: 16px;
|
||||
//padding-top: 16px;
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
@@ -484,20 +518,27 @@ watch(isDialogVisible, async (newValue) => {
|
||||
.activity-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.activity-item {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
padding: 16px;
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
overflow: visible;
|
||||
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||
border: 2px solid transparent;
|
||||
background-clip: padding-box;
|
||||
|
||||
// 清除浮动,确保父容器高度正确
|
||||
&::after {
|
||||
content: '';
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
@@ -525,9 +566,8 @@ watch(isDialogVisible, async (newValue) => {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.activity-image {
|
||||
transform: scale(1.1);
|
||||
filter: brightness(1.05);
|
||||
.activity-image-wrapper {
|
||||
box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2);
|
||||
}
|
||||
|
||||
.detail-link {
|
||||
@@ -545,10 +585,31 @@ watch(isDialogVisible, async (newValue) => {
|
||||
|
||||
.activity-image-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 220px;
|
||||
float: right;
|
||||
width: 160px;
|
||||
height: 160px;
|
||||
margin-left: 16px;
|
||||
margin-bottom: 8px;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
|
||||
shape-outside: inset(0);
|
||||
transition: box-shadow 0.3s;
|
||||
cursor: pointer;
|
||||
z-index: 1; // 确保在内容之上
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
&:hover .activity-image {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
&:hover .zoom-icon {
|
||||
opacity: 1;
|
||||
transform: translate(-50%, -50%) scale(1);
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
@@ -560,6 +621,7 @@ watch(isDialogVisible, async (newValue) => {
|
||||
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
|
||||
z-index: 1;
|
||||
animation: shine 3s infinite;
|
||||
pointer-events: none; // 确保不拦截鼠标事件
|
||||
}
|
||||
|
||||
&::after {
|
||||
@@ -587,22 +649,22 @@ watch(isDialogVisible, async (newValue) => {
|
||||
.activity-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-fit: contain; // 等比例缩放,完整显示图片,不裁剪
|
||||
transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.activity-status-badge {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
z-index: 2;
|
||||
animation: fadeInScale 0.5s ease-out 0.3s both;
|
||||
|
||||
:deep(.el-tag) {
|
||||
border-radius: 20px;
|
||||
padding: 7px 18px;
|
||||
border-radius: 16px;
|
||||
padding: 5px 14px;
|
||||
font-weight: 700;
|
||||
font-size: 13px;
|
||||
font-size: 11px;
|
||||
border: none;
|
||||
backdrop-filter: blur(12px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
||||
@@ -648,24 +710,52 @@ watch(isDialogVisible, async (newValue) => {
|
||||
}
|
||||
}
|
||||
|
||||
.zoom-icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%) scale(0.8);
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
backdrop-filter: blur(8px);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
opacity: 0;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
pointer-events: none; // 不拦截鼠标事件,让父容器接收hover
|
||||
z-index: 10; // 提高层级,确保在状态标签之上
|
||||
|
||||
svg {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
color: #fff;
|
||||
stroke-width: 2;
|
||||
}
|
||||
}
|
||||
|
||||
.activity-body {
|
||||
padding: 20px;
|
||||
// 内容会自动环绕浮动的图片
|
||||
position: relative;
|
||||
z-index: 0; // 确保在浮动图片之下
|
||||
}
|
||||
|
||||
.activity-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.activity-title {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: #1a1a1a;
|
||||
flex: 1;
|
||||
line-height: 1.4;
|
||||
line-height: 1.3;
|
||||
background: linear-gradient(135deg, #1a1a1a 0%, #4a5568 100%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
@@ -679,23 +769,23 @@ watch(isDialogVisible, async (newValue) => {
|
||||
|
||||
.activity-content-list {
|
||||
padding: 0;
|
||||
margin: 0 0 16px 0;
|
||||
margin: 0 0 12px 0;
|
||||
color: #4a5568;
|
||||
font-size: 14px;
|
||||
line-height: 1.8;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
|
||||
.content-line {
|
||||
margin: 8px 0;
|
||||
padding-left: 18px;
|
||||
margin: 6px 0;
|
||||
padding-left: 16px;
|
||||
position: relative;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 11px;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
top: 9px;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 50%;
|
||||
}
|
||||
@@ -715,8 +805,9 @@ watch(isDialogVisible, async (newValue) => {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding-top: 16px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px dashed #e8e9eb;
|
||||
clear: both; // 清除浮动,始终在新行显示,占满100%宽度
|
||||
}
|
||||
|
||||
.activity-time-range {
|
||||
@@ -727,7 +818,7 @@ watch(isDialogVisible, async (newValue) => {
|
||||
}
|
||||
|
||||
.activity-time {
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
color: #718096;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -735,19 +826,19 @@ watch(isDialogVisible, async (newValue) => {
|
||||
|
||||
&:first-child::before {
|
||||
content: '🕐';
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
.detail-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 18px;
|
||||
gap: 6px;
|
||||
padding: 8px 16px;
|
||||
background: linear-gradient(135deg, #f0f1f3 0%, #e8eaed 100%);
|
||||
color: #667eea;
|
||||
border-radius: 24px;
|
||||
font-size: 13px;
|
||||
border-radius: 20px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
@@ -832,11 +923,11 @@ watch(isDialogVisible, async (newValue) => {
|
||||
|
||||
.announcement-item {
|
||||
position: relative;
|
||||
padding: 24px;
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 16px;
|
||||
margin-bottom: 10px;
|
||||
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
border: 1px solid #e8e9eb;
|
||||
@@ -1095,16 +1186,27 @@ watch(isDialogVisible, async (newValue) => {
|
||||
|
||||
.activity-item {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.activity-image-wrapper {
|
||||
height: 180px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.activity-body {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.activity-image-wrapper {
|
||||
float: none;
|
||||
width: 100%;
|
||||
height: 180px;
|
||||
min-height: 180px;
|
||||
margin: 0 0 16px 0;
|
||||
border-radius: 10px 10px 0 0;
|
||||
}
|
||||
|
||||
.activity-status-badge {
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
}
|
||||
|
||||
.activity-header {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
@@ -1183,7 +1285,18 @@ watch(isDialogVisible, async (newValue) => {
|
||||
|
||||
.activity-content {
|
||||
.activity-image-wrapper {
|
||||
float: none;
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
margin: 0 0 16px 0;
|
||||
}
|
||||
|
||||
.activity-item {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.activity-body {
|
||||
padding: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
<!-- 欢迎提示词 -->
|
||||
<script setup lang="ts">
|
||||
import { Typewriter } from 'vue-element-plus-x';
|
||||
import { useColorMode } from '@vueuse/core';
|
||||
import { useTimeGreeting } from '@/hooks/useTimeGreeting';
|
||||
import { useUserStore } from '@/stores';
|
||||
|
||||
const greeting = useTimeGreeting();
|
||||
const userStore = useUserStore();
|
||||
const mode = useColorMode();
|
||||
|
||||
const username = computed(() => userStore.userInfo?.username ?? '意心Ai,一心只为打造更良心的Ai平台');
|
||||
const username = computed(() => userStore.userInfo?.username ?? '意心Ai,让人人都能享受最前沿的Ai体验');
|
||||
|
||||
// 根据主题动态设置雾化背景色
|
||||
const fogBgColor = computed(() => mode.value === 'dark' ? '#111827' : '#fff');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -22,7 +27,7 @@ const username = computed(() => userStore.userInfo?.username ?? '意心Ai,一
|
||||
interval: 45,
|
||||
}"
|
||||
:is-fog="{
|
||||
bgColor: '#fff',
|
||||
bgColor: fogBgColor,
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -176,7 +176,6 @@ function toggleFullscreen() {
|
||||
}
|
||||
|
||||
.nav-menu {
|
||||
border-right: none;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { Check, CircleCheck, CircleClose, Close, Delete, DocumentCopy, Edit, Files, Hide, Key, Plus, PriceTag, Reading, Refresh, Timer, View } from '@element-plus/icons-vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import {
|
||||
createToken,
|
||||
@@ -46,6 +46,13 @@ const currentFormData = ref<TokenFormData>({
|
||||
});
|
||||
const router = useRouter();
|
||||
|
||||
// 移动端检测
|
||||
const isMobile = ref(false);
|
||||
|
||||
function checkMobile() {
|
||||
isMobile.value = window.innerWidth < 768;
|
||||
}
|
||||
|
||||
// 防抖和节流控制
|
||||
const operatingTokenId = ref<string>('');
|
||||
|
||||
@@ -341,8 +348,14 @@ function isOperating(tokenId: string) {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
checkMobile();
|
||||
window.addEventListener('resize', checkMobile);
|
||||
await fetchTokenList();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', checkMobile);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -384,8 +397,10 @@ onMounted(async () => {
|
||||
</div>
|
||||
|
||||
<!-- Token列表 -->
|
||||
<div v-if="hasTokens" class="token-table-wrapper">
|
||||
<el-table
|
||||
<div v-if="hasTokens">
|
||||
<!-- 桌面端表格 -->
|
||||
<div v-if="!isMobile" class="token-table-wrapper">
|
||||
<el-table
|
||||
:data="tokenList"
|
||||
stripe
|
||||
border
|
||||
@@ -586,6 +601,101 @@ onMounted(async () => {
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<!-- 移动端卡片列表 -->
|
||||
<div v-else class="mobile-token-list">
|
||||
<div v-for="token in tokenList" :key="token.id" class="mobile-token-card">
|
||||
<div class="mobile-card-header">
|
||||
<div class="mobile-card-title">
|
||||
<el-icon class="title-icon"><PriceTag /></el-icon>
|
||||
<span>{{ token.name }}</span>
|
||||
</div>
|
||||
<el-tag :type="token.isDisabled ? 'danger' : 'success'" size="small">
|
||||
{{ token.isDisabled ? '已禁用' : '启用中' }}
|
||||
</el-tag>
|
||||
</div>
|
||||
|
||||
<div class="mobile-card-body">
|
||||
<!-- API密钥 -->
|
||||
<div class="mobile-info-item">
|
||||
<div class="mobile-info-label">API密钥</div>
|
||||
<div class="mobile-key-row">
|
||||
<span class="mobile-key-text">
|
||||
{{ token.showKey ? token.apiKey : '•••••••••••••••••••••' }}
|
||||
</span>
|
||||
<div class="mobile-key-actions">
|
||||
<el-button
|
||||
:icon="token.showKey ? Hide : View"
|
||||
size="small"
|
||||
text
|
||||
@click="toggleKeyVisibility(token)"
|
||||
/>
|
||||
<el-button
|
||||
:icon="DocumentCopy"
|
||||
size="small"
|
||||
type="primary"
|
||||
text
|
||||
@click="copyApiKey(token.apiKey, token.name)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 配额信息 -->
|
||||
<div v-if="token.premiumQuotaLimit" class="mobile-info-item">
|
||||
<div class="mobile-info-label">配额使用</div>
|
||||
<div class="mobile-quota-info">
|
||||
<el-progress
|
||||
:percentage="getQuotaPercentage(token.premiumUsedQuota, token.premiumQuotaLimit)"
|
||||
:color="getQuotaColor(getQuotaPercentage(token.premiumUsedQuota, token.premiumQuotaLimit))"
|
||||
:stroke-width="8"
|
||||
/>
|
||||
<div class="mobile-quota-text">
|
||||
{{ formatQuota(token.premiumUsedQuota) }} / {{ formatQuota(token.premiumQuotaLimit) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 过期时间 -->
|
||||
<div v-if="token.expireTime" class="mobile-info-item">
|
||||
<div class="mobile-info-label">过期时间</div>
|
||||
<div class="mobile-info-value">{{ formatDateTime(token.expireTime) }}</div>
|
||||
</div>
|
||||
|
||||
<!-- 创建时间 -->
|
||||
<div class="mobile-info-item">
|
||||
<div class="mobile-info-label">创建时间</div>
|
||||
<div class="mobile-info-value">{{ formatDateTime(token.creationTime) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div class="mobile-card-actions">
|
||||
<el-button size="small" :icon="Edit" @click="showEditDialog(token)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
:type="token.isDisabled ? 'success' : 'warning'"
|
||||
:icon="token.isDisabled ? Check : Close"
|
||||
:loading="isOperating(token.id)"
|
||||
@click="handleToggle(token)"
|
||||
>
|
||||
{{ token.isDisabled ? '启用' : '禁用' }}
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="danger"
|
||||
:icon="Delete"
|
||||
:loading="isOperating(token.id)"
|
||||
@click="handleDelete(token)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div v-if="totalCount > 0" class="pagination-container">
|
||||
@@ -1170,5 +1280,114 @@ onMounted(async () => {
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 移动端卡片列表 */
|
||||
.mobile-token-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.mobile-token-card {
|
||||
background: #fff;
|
||||
border: 1px solid #e8e8e8;
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.mobile-card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.mobile-card-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
|
||||
.title-icon {
|
||||
color: #409eff;
|
||||
}
|
||||
}
|
||||
|
||||
.mobile-card-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.mobile-info-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.mobile-info-label {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.mobile-info-value {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.mobile-key-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
background: #f5f7fa;
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.mobile-key-text {
|
||||
flex: 1;
|
||||
font-size: 12px;
|
||||
color: #333;
|
||||
font-family: monospace;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.mobile-key-actions {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.mobile-quota-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.mobile-quota-text {
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.mobile-card-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
|
||||
.el-button {
|
||||
flex: 1;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -445,4 +445,119 @@ function getProgressColor(task: DailyTaskItem): string {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
/* 移动端响应式优化 */
|
||||
@media (max-width: 768px) {
|
||||
.daily-task-container {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.task-header h2 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.task-desc {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* 消耗统计卡片 */
|
||||
.consumption-card {
|
||||
padding: 16px;
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.consumption-icon {
|
||||
font-size: 40px;
|
||||
margin-right: 0;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.consumption-value {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
/* 任务列表 */
|
||||
.task-item {
|
||||
flex-direction: column;
|
||||
padding: 16px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.task-icon {
|
||||
font-size: 40px;
|
||||
margin-right: 0;
|
||||
margin-bottom: 8px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.task-main {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.task-title {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.task-name {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.task-description {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.task-action {
|
||||
margin-left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.task-action .el-button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.task-tips ul {
|
||||
padding-left: 16px;
|
||||
}
|
||||
|
||||
.task-tips li {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.daily-task-container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.task-header h2 {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.consumption-card {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.consumption-icon {
|
||||
font-size: 36px;
|
||||
}
|
||||
|
||||
.consumption-value {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.task-item {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.task-name {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.reward-value {
|
||||
font-size: 15px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1100,11 +1100,20 @@ onBeforeUnmount(() => {
|
||||
|
||||
/* 响应式布局 */
|
||||
@media (max-width: 768px) {
|
||||
.premium-package-info {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
padding-bottom: 16px;
|
||||
gap: 12px;
|
||||
padding-bottom: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.header-main-icon {
|
||||
@@ -1120,18 +1129,47 @@ onBeforeUnmount(() => {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.header .el-button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.package-card {
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.progress-section {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.progress-label {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.progress-percent {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.progress-legend {
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.warning-content {
|
||||
@@ -1139,6 +1177,18 @@ onBeforeUnmount(() => {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.warning-icon {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.warning-text h3 {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.warning-text p {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.card-header-left {
|
||||
gap: 10px;
|
||||
}
|
||||
@@ -1155,5 +1205,66 @@ onBeforeUnmount(() => {
|
||||
.header-subtitle {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.token-pie-chart {
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.chart-container-wrapper {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.token-stat-item {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.token-name {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.stat-tokens .value {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.tips-content li {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.token-usage-card {
|
||||
margin-top: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.header-main-icon {
|
||||
font-size: 24px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.main-title {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.token-pie-chart {
|
||||
height: 280px;
|
||||
}
|
||||
|
||||
.rank-badge {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<script lang="ts" setup>
|
||||
import { ChatLineRound, List, Refresh, Search } from '@element-plus/icons-vue';
|
||||
import { ChatLineRound, List, Refresh } from '@element-plus/icons-vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
||||
import { getRechargeLog } from '@/api/model/index.ts';
|
||||
import type { RechargeLogQueryParams } from '@/api/model/index.ts';
|
||||
import { isUserVip } from '@/utils/user.ts';
|
||||
import { showContactUs } from '@/utils/contact-us.ts';
|
||||
|
||||
interface RechargeLog {
|
||||
id: string;
|
||||
@@ -17,59 +19,92 @@ interface RechargeLog {
|
||||
}
|
||||
|
||||
const loading = ref(false);
|
||||
const innerVisibleContact = ref(false);
|
||||
const logData = ref<RechargeLog[]>([]);
|
||||
const searchText = ref('');
|
||||
const currentSort = ref({ prop: '', order: '' });
|
||||
const totalCount = ref(0);
|
||||
const currentPage = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const showWechatFullscreen = ref(false);
|
||||
const showWxGroupFullscreen = ref(false);
|
||||
|
||||
const wxSrc = computed(
|
||||
() => `/src/assets/images/wx.png`,
|
||||
);
|
||||
const wxGroupQD = computed(
|
||||
() => `/src/assets/images/wx.png`,
|
||||
);
|
||||
// 查询参数
|
||||
const queryParams = ref<RechargeLogQueryParams>({
|
||||
skipCount: 0,
|
||||
maxResultCount: 10,
|
||||
});
|
||||
|
||||
// 复制微信号
|
||||
function copyWechatId() {
|
||||
navigator.clipboard.writeText('chengzilaoge520').then(() => {
|
||||
ElMessage({
|
||||
message: '微信号已复制到剪贴板',
|
||||
type: 'success',
|
||||
duration: 2000,
|
||||
});
|
||||
});
|
||||
}
|
||||
// 筛选条件
|
||||
const dateRange = ref<[Date, Date] | null>(null);
|
||||
const freeFilter = ref<boolean | null>(null);
|
||||
const minAmount = ref<number | undefined>(undefined);
|
||||
const maxAmount = ref<number | undefined>(undefined);
|
||||
|
||||
// 显示微信二维码全屏
|
||||
function showWechatFullscreenImage() {
|
||||
showWechatFullscreen.value = true;
|
||||
}
|
||||
// 快捷时间选择
|
||||
const shortcuts = [
|
||||
{
|
||||
text: '最近一周',
|
||||
value: () => {
|
||||
const end = new Date();
|
||||
const start = new Date();
|
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
|
||||
return [start, end];
|
||||
},
|
||||
},
|
||||
{
|
||||
text: '最近一个月',
|
||||
value: () => {
|
||||
const end = new Date();
|
||||
const start = new Date();
|
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
|
||||
return [start, end];
|
||||
},
|
||||
},
|
||||
{
|
||||
text: '最近三个月',
|
||||
value: () => {
|
||||
const end = new Date();
|
||||
const start = new Date();
|
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
|
||||
return [start, end];
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// 显示微信群二维码全屏
|
||||
function showWxGroupFullscreenImage() {
|
||||
showWxGroupFullscreen.value = true;
|
||||
}
|
||||
// 移动端检测
|
||||
const isMobile = ref(false);
|
||||
|
||||
// 关闭全屏图片
|
||||
function closeFullscreenImage() {
|
||||
showWechatFullscreen.value = false;
|
||||
showWxGroupFullscreen.value = false;
|
||||
function checkMobile() {
|
||||
isMobile.value = window.innerWidth < 768;
|
||||
}
|
||||
|
||||
// 模拟数据获取
|
||||
async function fetchRechargeLog() {
|
||||
async function fetchRechargeLog(resetPage = false) {
|
||||
if (resetPage) {
|
||||
currentPage.value = 1;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
loading.value = true;
|
||||
const res = await getRechargeLog();
|
||||
logData.value = res.data || [];
|
||||
const params: RechargeLogQueryParams = {
|
||||
skipCount: currentPage.value,
|
||||
maxResultCount: queryParams.value.maxResultCount,
|
||||
startTime: queryParams.value.startTime,
|
||||
endTime: queryParams.value.endTime,
|
||||
orderByColumn: queryParams.value.orderByColumn,
|
||||
isAsc: queryParams.value.isAsc,
|
||||
isFree: queryParams.value.isFree,
|
||||
minRechargeAmount: queryParams.value.minRechargeAmount,
|
||||
maxRechargeAmount: queryParams.value.maxRechargeAmount,
|
||||
};
|
||||
|
||||
const res = await getRechargeLog(params);
|
||||
if (res.data) {
|
||||
logData.value = res.data.items || [];
|
||||
totalCount.value = res.data.totalCount || 0;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error('获取充值记录失败:', error);
|
||||
ElMessage.error('获取充值记录失败');
|
||||
logData.value = [];
|
||||
totalCount.value = 0;
|
||||
}
|
||||
finally {
|
||||
loading.value = false;
|
||||
@@ -77,150 +112,120 @@ async function fetchRechargeLog() {
|
||||
}
|
||||
|
||||
// 排序处理
|
||||
function handleSortChange({ prop, order }: { prop: string; order: string }) {
|
||||
currentSort.value = { prop, order };
|
||||
function handleSortChange({ prop, order }: { prop: string; order: string | null }) {
|
||||
if (order) {
|
||||
queryParams.value.orderByColumn = prop;
|
||||
queryParams.value.isAsc = order === 'ascending' ? 'ascending' : 'descending';
|
||||
}
|
||||
else {
|
||||
queryParams.value.orderByColumn = undefined;
|
||||
queryParams.value.isAsc = undefined;
|
||||
}
|
||||
fetchRechargeLog(true);
|
||||
}
|
||||
|
||||
// 搜索处理
|
||||
function handleSearch() {
|
||||
currentPage.value = 1;
|
||||
// 处理分页
|
||||
function handlePageChange(page: number) {
|
||||
currentPage.value = page;
|
||||
fetchRechargeLog();
|
||||
}
|
||||
|
||||
function handleSearchClear() {
|
||||
searchText.value = '';
|
||||
// 处理每页大小变化
|
||||
function handleSizeChange(size: number) {
|
||||
pageSize.value = size;
|
||||
queryParams.value.maxResultCount = size;
|
||||
currentPage.value = 1;
|
||||
fetchRechargeLog();
|
||||
}
|
||||
|
||||
// 处理时间筛选
|
||||
function handleDateChange(value: [Date, Date] | null) {
|
||||
if (value && value.length === 2) {
|
||||
const startDate = new Date(value[0]);
|
||||
startDate.setHours(0, 0, 0, 0);
|
||||
const endDate = new Date(value[1]);
|
||||
endDate.setHours(23, 59, 59, 999);
|
||||
queryParams.value.startTime = startDate.toISOString();
|
||||
queryParams.value.endTime = endDate.toISOString();
|
||||
}
|
||||
else {
|
||||
queryParams.value.startTime = undefined;
|
||||
queryParams.value.endTime = undefined;
|
||||
}
|
||||
fetchRechargeLog(true);
|
||||
}
|
||||
|
||||
// 处理是否免费筛选
|
||||
function handleFreeFilterChange(value: boolean | null) {
|
||||
queryParams.value.isFree = value === null ? undefined : value;
|
||||
fetchRechargeLog(true);
|
||||
}
|
||||
|
||||
// 处理金额筛选
|
||||
function handleAmountChange() {
|
||||
queryParams.value.minRechargeAmount = minAmount.value;
|
||||
queryParams.value.maxRechargeAmount = maxAmount.value;
|
||||
fetchRechargeLog(true);
|
||||
}
|
||||
|
||||
// 重置筛选
|
||||
function resetFilters() {
|
||||
dateRange.value = null;
|
||||
freeFilter.value = null;
|
||||
minAmount.value = undefined;
|
||||
maxAmount.value = undefined;
|
||||
queryParams.value = {
|
||||
maxResultCount: pageSize.value,
|
||||
orderByColumn: undefined,
|
||||
isAsc: undefined,
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
isFree: undefined,
|
||||
minRechargeAmount: undefined,
|
||||
maxRechargeAmount: undefined,
|
||||
};
|
||||
fetchRechargeLog(true);
|
||||
}
|
||||
|
||||
// 判断是否有活动的筛选条件
|
||||
const hasActiveFilters = computed(() => {
|
||||
return !!dateRange.value || freeFilter.value !== null || minAmount.value !== undefined || maxAmount.value !== undefined;
|
||||
});
|
||||
|
||||
// 刷新数据
|
||||
function refreshLog() {
|
||||
fetchRechargeLog();
|
||||
currentPage.value = 1;
|
||||
searchText.value = '';
|
||||
currentSort.value = { prop: '', order: '' };
|
||||
}
|
||||
|
||||
// 联系售后弹窗
|
||||
function contactCustomerService() {
|
||||
innerVisibleContact.value = !innerVisibleContact.value;
|
||||
// 如果用户有购买记录,则显示售后群
|
||||
if (logData.value.length > 0) {
|
||||
showContactUs({ scenario: 'afterSales' });
|
||||
}
|
||||
else {
|
||||
showContactUs({ scenario: 'regular' });
|
||||
}
|
||||
}
|
||||
|
||||
// 暴露方法给父组件使用
|
||||
defineExpose({
|
||||
contactCustomerService,
|
||||
});
|
||||
|
||||
// 过滤和排序后的数据
|
||||
const filteredData = computed(() => {
|
||||
let data = [...logData.value];
|
||||
|
||||
// 搜索过滤
|
||||
if (searchText.value) {
|
||||
const search = searchText.value.toLowerCase();
|
||||
data = data.filter(item =>
|
||||
(item.contactInfo && item.contactInfo.toLowerCase().includes(search))
|
||||
|| (item.remark && item.remark.toLowerCase().includes(search)),
|
||||
);
|
||||
}
|
||||
|
||||
// 排序处理
|
||||
if (currentSort.value.prop) {
|
||||
const { prop, order } = currentSort.value;
|
||||
data.sort((a, b) => {
|
||||
// 处理可能为null的值
|
||||
const valA = a[prop as keyof RechargeLog] || '';
|
||||
const valB = b[prop as keyof RechargeLog] || '';
|
||||
|
||||
if (order === 'ascending') {
|
||||
return valA > valB ? 1 : valA < valB ? -1 : 0;
|
||||
}
|
||||
else {
|
||||
return valA < valB ? 1 : valA > valB ? -1 : 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
});
|
||||
|
||||
// 是否显示分页 暂时不需要分页功能
|
||||
const showPagination = computed(() => {
|
||||
return false;
|
||||
refresh: fetchRechargeLog,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
checkMobile();
|
||||
window.addEventListener('resize', checkMobile);
|
||||
fetchRechargeLog();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', checkMobile);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="innerVisibleContact"
|
||||
width="500"
|
||||
title="售后支持"
|
||||
append-to-body
|
||||
>
|
||||
<h3 class="text-lg font-bold mb-3">
|
||||
请扫码加入微信交流群<br>
|
||||
备注“AI”获取专属客服支持
|
||||
</h3>
|
||||
<div class="mb-4 flex items-center justify-center space-x-2">
|
||||
<span class="font-semibold">站长微信账号:</span>
|
||||
<span id="wechat-id" class="text-blue-600 font-mono select-text">chengzilaoge520</span>
|
||||
<span
|
||||
class="cursor-pointer"
|
||||
title="点击复制"
|
||||
@click="copyWechatId"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 opacity-70 hover:opacity-100" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v16h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 18H8V7h11v16z" />
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex justify-center mb-4">
|
||||
<div class="px-4">
|
||||
<h4>站长微信(备注“AI”以便通过)</h4>
|
||||
|
||||
<img
|
||||
:src="wxSrc"
|
||||
class="w-50 py-5 h-70 border border-gray-200 rounded-lg shadow-md cursor-pointer hover:shadow-lg transition-transform hover:scale-105"
|
||||
alt="微信二维码"
|
||||
@click="showWechatFullscreenImage"
|
||||
>
|
||||
</div>
|
||||
<!-- <div class="px-4"> -->
|
||||
<!-- <h4>微信交流群</h4> -->
|
||||
<!-- <img -->
|
||||
<!-- :src="wxGroupQD" -->
|
||||
<!-- class="w-50 py-5 h-70 border border-gray-200 rounded-lg shadow-md cursor-pointer hover:shadow-lg transition-transform hover:scale-105" -->
|
||||
<!-- alt="微信二维码" -->
|
||||
<!-- @click="showWxGroupFullscreenImage" -->
|
||||
<!-- > -->
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
|
||||
<!-- 全屏放大二维码 -->
|
||||
<div
|
||||
v-if="showWechatFullscreen"
|
||||
class="fullscreen-image-overlay"
|
||||
@click="closeFullscreenImage"
|
||||
>
|
||||
<img
|
||||
:src="wxSrc"
|
||||
class="fullscreen-image"
|
||||
>
|
||||
</div>
|
||||
<div
|
||||
v-if="showWxGroupFullscreen"
|
||||
class="fullscreen-image-overlay"
|
||||
@click="closeFullscreenImage"
|
||||
>
|
||||
<img
|
||||
:src="wxGroupQD"
|
||||
class="fullscreen-image"
|
||||
>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<div class="recharge-log-container">
|
||||
<div class="log-header">
|
||||
<h2 class="log-title">
|
||||
@@ -228,6 +233,9 @@ onMounted(() => {
|
||||
充值记录
|
||||
</h2>
|
||||
<div class="header-actions">
|
||||
<el-tag v-if="totalCount > 0" type="primary" size="default" class="count-tag" effect="plain">
|
||||
共 {{ totalCount }} 条记录
|
||||
</el-tag>
|
||||
<el-tooltip v-if="isUserVip()" content="联系售后" placement="top">
|
||||
<el-button circle :loading="loading" @click="contactCustomerService">
|
||||
<el-icon color="#07c160">
|
||||
@@ -240,26 +248,80 @@ onMounted(() => {
|
||||
<el-icon><Refresh /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-input
|
||||
v-model="searchText"
|
||||
placeholder="搜索备注"
|
||||
clearable
|
||||
style="width: 200px; margin-left: 10px;"
|
||||
@clear="handleSearchClear"
|
||||
@keyup.enter="handleSearch"
|
||||
>
|
||||
<template #append>
|
||||
<el-button @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 筛选工具栏 -->
|
||||
<div class="filter-toolbar">
|
||||
<div class="filter-row">
|
||||
<div class="filter-item">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
size="default"
|
||||
:shortcuts="shortcuts"
|
||||
class="date-picker"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
:editable="false"
|
||||
@change="handleDateChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="filter-item">
|
||||
<el-select
|
||||
v-model="freeFilter"
|
||||
placeholder="全部类型"
|
||||
clearable
|
||||
size="default"
|
||||
class="free-select"
|
||||
@change="handleFreeFilterChange"
|
||||
>
|
||||
<el-option label="免费" :value="true" />
|
||||
<el-option label="付费" :value="false" />
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="filter-item amount-range">
|
||||
<el-input-number
|
||||
v-model="minAmount"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:controls="false"
|
||||
placeholder="最小金额"
|
||||
size="default"
|
||||
class="amount-input"
|
||||
@change="handleAmountChange"
|
||||
/>
|
||||
<span class="range-separator">-</span>
|
||||
<el-input-number
|
||||
v-model="maxAmount"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:controls="false"
|
||||
placeholder="最大金额"
|
||||
size="default"
|
||||
class="amount-input"
|
||||
@change="handleAmountChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<el-button
|
||||
v-if="hasActiveFilters"
|
||||
size="default"
|
||||
@click="resetFilters"
|
||||
>
|
||||
<el-icon><i-ep-refresh-left /></el-icon>
|
||||
重置
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="filteredData"
|
||||
:data="logData"
|
||||
style="width: 100%"
|
||||
border
|
||||
stripe
|
||||
@@ -270,7 +332,7 @@ onMounted(() => {
|
||||
prop="content"
|
||||
label="套餐类型"
|
||||
min-width="150"
|
||||
sortable="custom"
|
||||
sortable
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
@@ -278,7 +340,7 @@ onMounted(() => {
|
||||
prop="rechargeAmount"
|
||||
label="金额(元)"
|
||||
min-width="110"
|
||||
sortable="custom"
|
||||
sortable
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span class="amount-cell">¥{{ row.rechargeAmount.toFixed(2) }}</span>
|
||||
@@ -288,14 +350,14 @@ onMounted(() => {
|
||||
prop="creationTime"
|
||||
label="充值时间"
|
||||
min-width="160"
|
||||
sortable="custom"
|
||||
sortable
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="expireDateTime"
|
||||
label="到期时间"
|
||||
min-width="160"
|
||||
sortable="custom"
|
||||
sortable
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<!-- <el-table-column show-overflow-tooltip prop="contactInfo" width="100" label="联系方式">
|
||||
@@ -317,18 +379,29 @@ onMounted(() => {
|
||||
</el-table>
|
||||
|
||||
<div class="log-footer">
|
||||
<div class="summary">
|
||||
共 <span class="highlight">{{ filteredData.length }}</span> 条记录
|
||||
<!-- 空状态 -->
|
||||
<div v-if="!logData.length && !loading" class="empty-container">
|
||||
<el-empty :description="hasActiveFilters ? '当前筛选条件下无数据' : '暂无充值记录'">
|
||||
<el-button v-if="hasActiveFilters" type="primary" @click="resetFilters">
|
||||
清除筛选
|
||||
</el-button>
|
||||
</el-empty>
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div v-if="totalCount > 0" class="pagination-container">
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="totalCount"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
prev-text="上一页"
|
||||
next-text="下一页"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
<el-pagination
|
||||
v-if="showPagination"
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:total="filteredData.length"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
background
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -440,14 +513,86 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.log-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
margin-top: 25px;
|
||||
padding-top: 20px;
|
||||
border-top: 2px solid #e9ecef;
|
||||
}
|
||||
|
||||
/* 筛选工具栏 */
|
||||
.filter-toolbar {
|
||||
margin-bottom: 20px;
|
||||
padding: 16px;
|
||||
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e8eaed;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.filter-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.filter-item {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.date-picker {
|
||||
width: 320px;
|
||||
}
|
||||
|
||||
.free-select {
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
/* 金额范围筛选 */
|
||||
.amount-range {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.amount-input {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.range-separator {
|
||||
color: #909399;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.filter-actions {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* 记录数标签 */
|
||||
.count-tag {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 12px;
|
||||
font-weight: 600;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
/* 空状态 */
|
||||
.empty-container {
|
||||
padding: 40px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 分页容器 */
|
||||
.pagination-container {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.summary {
|
||||
color: #666;
|
||||
font-size: 15px;
|
||||
@@ -512,4 +657,153 @@ onMounted(() => {
|
||||
:deep(.el-pagination.is-background .el-pager li:not(.is-disabled):hover) {
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
/* 移动端响应式优化 */
|
||||
@media (max-width: 768px) {
|
||||
.recharge-log-container {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.log-header {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
.log-title {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.log-title .el-icon {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 移动端筛选工具栏 */
|
||||
.filter-toolbar {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.filter-row {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.filter-item {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.date-picker,
|
||||
.free-select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.amount-range {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.amount-input {
|
||||
flex: 1;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.filter-actions {
|
||||
margin-left: 0;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.filter-actions .el-button {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 表格移动端优化 */
|
||||
:deep(.el-table) {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
font-size: 12px;
|
||||
padding: 6px 0;
|
||||
}
|
||||
|
||||
:deep(.el-table .cell) {
|
||||
padding: 8px 6px;
|
||||
}
|
||||
|
||||
:deep(.el-table__body-wrapper) {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.amount-cell {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.log-footer {
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
align-items: stretch;
|
||||
margin-top: 16px;
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
.summary {
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
:deep(.el-pagination) {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* 对话框移动端优化 */
|
||||
:deep(.el-dialog) {
|
||||
width: 90% !important;
|
||||
margin: 5vh auto !important;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.fullscreen-image {
|
||||
max-width: 95%;
|
||||
max-height: 95%;
|
||||
border: 4px solid white;
|
||||
border-radius: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.recharge-log-container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.log-title {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
:deep(.el-table) {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
:deep(.el-table .cell) {
|
||||
padding: 6px 4px;
|
||||
}
|
||||
|
||||
.header-actions .el-button {
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -43,9 +43,9 @@ const gridTemplateColumns = computed(() => {
|
||||
<template v-if="model.modelPrice === 0">
|
||||
<span
|
||||
class="free-tag"
|
||||
:class="model.modelId === 'DeepSeek-R1-0528' ? 'free' : 'vip'"
|
||||
:class="model.isFree ? 'free' : 'vip'"
|
||||
>
|
||||
{{ model.modelId === 'DeepSeek-R1-0528' ? '免费' : 'Vip专享' }}
|
||||
{{ model.isFree ? '免费' : 'Vip专享' }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
|
||||
interface TokenFormData {
|
||||
id?: string;
|
||||
@@ -43,6 +43,22 @@ const submitting = ref(false);
|
||||
const neverExpire = ref(false); // 永不过期开关
|
||||
const unlimitedQuota = ref(false); // 无限制额度开关
|
||||
|
||||
// 移动端检测
|
||||
const isMobile = ref(false);
|
||||
|
||||
function checkMobile() {
|
||||
isMobile.value = window.innerWidth < 768;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
checkMobile();
|
||||
window.addEventListener('resize', checkMobile);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', checkMobile);
|
||||
});
|
||||
|
||||
const quotaUnitOptions = [
|
||||
{ label: '个', value: '个', multiplier: 1 },
|
||||
{ label: '十', value: '十', multiplier: 10 },
|
||||
@@ -180,12 +196,13 @@ const dialogTitle = computed(() => props.mode === 'create' ? '新增 API密钥'
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
:title="dialogTitle"
|
||||
width="540px"
|
||||
:width="isMobile ? '95%' : '540px'"
|
||||
:fullscreen="isMobile"
|
||||
:close-on-click-modal="false"
|
||||
:show-close="!submitting"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form :model="localFormData" label-width="110px" label-position="right">
|
||||
<el-form :model="localFormData" :label-width="isMobile ? '100%' : '110px'" :label-position="isMobile ? 'top' : 'right'">
|
||||
<el-form-item label="API密钥名称" required>
|
||||
<el-input
|
||||
v-model="localFormData.name"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
39
Yi.Ai.Vue3/src/config/constants.ts
Normal file
39
Yi.Ai.Vue3/src/config/constants.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 联系方式配置
|
||||
*/
|
||||
export const contactConfig = {
|
||||
// 客服微信号
|
||||
wechatId: 'chengzilaoge520',
|
||||
|
||||
// 二维码图片路径
|
||||
images: {
|
||||
customerService: ' https://ccnetcore.com/prod-api/wwwroot/aihub/wx.png ', // 客服微信二维码
|
||||
communityGroup: ' https://ccnetcore.com/prod-api/wwwroot/aihub/jlq.png', // 交流群二维码
|
||||
afterSalesGroup: '', // 售后群二维码
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 淘宝店铺配置
|
||||
*/
|
||||
export const taobaoConfig = {
|
||||
// 淘宝店铺链接
|
||||
link: 'https://e.tb.cn/h.7RqUAtwFh8V5ywg?tk=m7KGUc6DoNQ',
|
||||
|
||||
// 淘口令
|
||||
code: '【淘宝】https://e.tb.cn/h.7RqUAtwFh8V5ywg?tk=m7KGUc6DoNQ HU293 「ClaudeCode/Codex/Gemini Ai聚合API服务/会员Token包/人工售后」\n'
|
||||
+ '点击链接直接打开 或者 淘宝搜索直接打开',
|
||||
taobaoQr: '/src/assets/images/taobao-qr.png', // 淘宝店铺二维码
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* 优惠活动配置
|
||||
*/
|
||||
export const promotionConfig = {
|
||||
// 累计充值优惠描述
|
||||
rechargeDiscount: '全站任意充值,每累计充值10元永久优惠尊享包10元,最高可优惠50元',
|
||||
|
||||
// VIP售后服务提示
|
||||
vipServiceTip: '充值后,联系客服回复账号名,可专享VIP售后服务',
|
||||
};
|
||||
2
Yi.Ai.Vue3/src/config/model.ts
Normal file
2
Yi.Ai.Vue3/src/config/model.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const modelSystemSetting: any = {
|
||||
};
|
||||
@@ -23,7 +23,12 @@ export const PAGE_PERMISSIONS: PermissionConfig[] = [
|
||||
{
|
||||
path: '/console/channel',
|
||||
allowedUsers: ['cc', 'Guo'],
|
||||
description: '渠道商管理页面 - 仅限cc和Guo用户访问',
|
||||
description: '号池管理页面 - 仅限cc和Guo用户访问',
|
||||
},
|
||||
{
|
||||
path: '/console/system-statistics',
|
||||
allowedUsers: ['cc', 'Guo'],
|
||||
description: '系统统计页面 - 仅限cc和Guo用户访问',
|
||||
},
|
||||
// 可以在这里继续添加其他需要权限控制的页面
|
||||
// {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user