Compare commits

..

58 Commits

Author SHA1 Message Date
chenchun
bb894e14a4 Merge remote-tracking branch 'origin/card-flip' into card-flip
# Conflicts:
#	Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Repositories/SqlSugarRepository.cs
2025-11-17 11:22:44 +08:00
chenchun
b492d82442 Merge branch 'abp' into card-flip
# Conflicts:
#	Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore.Abstractions/DbConnOptions.cs
#	Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Repositories/SqlSugarRepository.cs
#	Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Caches/FileCacheItem.cs
#	Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
2025-11-17 11:21:14 +08:00
chenchun
5eaffe2ec2 feat: 新增更新并发乐观锁配置与支持
- 在 DbConnOptions 新增 EnabledConcurrencyException(bool,默认 false) 配置项。
- 在 SqlSugarRepository 引入 IAbpLazyServiceProvider,通过 IOptions<DbConnOptions> 延迟获取配置。
- UpdateAsync 改为仅当 EnabledConcurrencyException 为 true 且实体实现 IHasConcurrencyStamp 时,使用 ExecuteCommandWithOptLockAsync 并捕获 VersionExceptions 抛出 AbpDbConcurrencyException;否则回退到原有的 UpdateAsync 实现。
- 清理/调整部分 using 引用,新增 Microsoft.Extensions.Options 与 Volo.Abp.DependencyInjection 引用。

注意:默认值为 false,需在配置中显式开启 EnabledConcurrencyException 才会启用乐观并发校验,开启后会改变之前对带版本实体自动使用乐观锁的行为。
2025-11-17 11:19:15 +08:00
Gsh
d7bcad9da7 feat: 前端打包报错处理 2025-11-17 02:03:10 +08:00
Gsh
04e11d15e2 feat: 新手引导优化 2025-11-17 01:39:13 +08:00
Gsh
97e3dc5eed feat: 公告弹窗优化 2025-11-17 01:20:20 +08:00
Gsh
695bd56a27 feat: 增加新手引导 2025-11-17 01:05:57 +08:00
ccnetcore
7919383be3 feat: 完成v2.3.0发布 2025-11-17 00:43:41 +08:00
ccnetcore
d6cc3c5d96 Merge branch 'abp' into card-flip
# Conflicts:
#	Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Repositories/SqlSugarRepository.cs
#	Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Caches/FileCacheItem.cs
2025-11-17 00:43:27 +08:00
Gsh
19f0d05a69 fix: 尊享明细表格优化 2025-11-16 23:00:19 +08:00
Gsh
3c5e575e9b fix: 公告优化 2025-11-16 22:39:42 +08:00
Gsh
f875617de1 fix: 版本号2.3 2025-11-16 22:05:44 +08:00
Gsh
9976e8a6e2 fix: 翻牌机制优化 2025-11-16 22:05:01 +08:00
Gsh
38e8cbc5ca fix: 优化邀请 2025-11-16 21:50:54 +08:00
Gsh
d95c14c903 fix: 优化尊享包记录 2025-11-16 21:39:08 +08:00
ccnetcore
ffb2f2fb4c fix: 修复尊享包查询条件并新增时间范围筛选 2025-11-16 21:32:41 +08:00
ccnetcore
4bd2fc357d refactor: 邀请码逻辑调整,支持双方填写/使用邀请码统计,并移除已被邀请状态字段 2025-11-14 23:53:29 +08:00
chenchun
da23d17af8 feat: 为尊享包 Token 列表新增按是否免费过滤并添加请求 DTO
- 新增 PremiumTokenUsageGetListInput,包含 IsFree 过滤项并继承分页 DTO
- 修改 UsageStatisticsService.GetPremiumTokenUsageListAsync 签名为使用新的输入 DTO,并根据 IsFree 添加 WhereIF 过滤
- 微调 DTO 导入与格式化(PremiumTokenUsageGetListOutput)
2025-11-14 18:00:49 +08:00
chenchun
c1a6046107 feat: 完成公告、尊享记录功能 2025-11-14 17:54:40 +08:00
chenchun
2ec7b5f4fd fix: 修复软删除时空引用异常
在 SqlSugarRepository.cs 中对 ISoftDelete 分支增加 GetByIdAsync 返回 null 的判断,避免在实体为 null 时继续反射赋值导致 NullReferenceException。若实体不存在,直接返回 false。
2025-11-13 16:49:44 +08:00
Gsh
d21f61646a fix: 系统公告与尊享额度明细 2025-11-12 23:08:52 +08:00
chenchun
eecdf442fb feat: 新增公告跳转链接字段 Url
- 在 AnnouncementAggregateRoot、AnnouncementLogDto、AnnouncementCacheDto 中新增 string? Url 属性,用于存储公告的跳转链接。
- 如果需要持久化到数据库,请同步添加对应的迁移/映射配置。
2025-11-12 21:49:31 +08:00
chenchun
1b4c3cbb8d feat: 支持尊享包用量统计 2025-11-10 15:18:05 +08:00
chenchun
b7756e2112 feat: 新增功能
- 概要
  - 重构并扩展公告相关模型、DTO、服务,新增公告类型、图片与时间字段,调整缓存与查询处理。
  - 新增枚举 AnnouncementTypeEnum。

- 主要改动(简要)
  - Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementLogDto.cs
    - 新增 ImageUrl、StartTime、EndTime、Type 字段,移除 Date 字段,Title 不再默认空串。
  - Yi.Framework.AiHub.Domain/Entities
    - 重命名 AnnouncementLogAggregateRoot -> AnnouncementAggregateRoot
    - 表名由 Ai_AnnouncementLog 改为 Ai_Announcement(SugarTable 标注)
    - 新增 ImageUrl、StartTime、EndTime、Type、Remark 字段(Remark 已存在,保持)
  - Yi.Framework.AiHub.Domain.Shared/Enums/AnnouncementTypeEnum.cs
    - 新增枚举文件(Activity=1, System=2)
  - Yi.Framework.AiHub.Application.Contracts/IServices/IAnnouncementService.cs
    - GetAsync 返回类型由 AnnouncementOutput 改为 List<AnnouncementLogDto>
  - Yi.Framework.AiHub.Application/Services/AnnouncementService.cs
    - 使用 Mapster 进行 DTO 映射
    - 查询按 StartTime 降序,返回 List<AnnouncementLogDto>,缓存结构简化
  - Yi.Abp.Web/YiAbpWebModule.cs
    - 改为初始化 AnnouncementAggregateRoot 的表(Ai_Announcement)
  - Yi.Ai.Vue3/types/import_meta.d.ts
    - 移除 VITE_BUILD_COMPRESS 环境变量声明

- 重要注意/兼容性提示
  - 接口变更:IAnnouncementService.GetAsync 返回类型已改变,调用方需同步更新(之前返回 AnnouncementOutput 的代码需调整)。
  - 数据库表变更:表名从 Ai_AnnouncementLog -> Ai_Announcement,若需保留历史数据,请在部署前做好数据迁移(重命名表或迁移数据到新表结构),或使用 CodeFirst 初始化新表(当前代码在启动时会 InitTables<AnnouncementAggregateRoot>())。
  - 新增 Mapster 适配(确保项目有 Mapster 依赖)。
  - 前端类型声明移除环境变量后,前端构建/运行脚本若依赖 VITE_BUILD_COMPRESS 需同步调整。
  - 若有缓存结构(AnnouncementCacheDto)或序列化相关约定变更,确认兼容性。

- 建议操作
  - 更新所有使用 IAnnouncementService 的代码(API 层/前端适配返回结构)。
  - 在非生产环境先执行数据迁移验证(保留旧表数据或写迁移脚本)。
  - 确认 Mapster 包已安装并编译通过。
  - 前端项目检查并同步 import_meta.d.ts 变更。
2025-11-10 15:03:02 +08:00
chenchun
cb49059e84 feat: 翻牌与邀请码逻辑重构,新增中奖记录与前7次中奖概率
- CardFlipTaskAggregateRoot.cs
  - 用 WinRecords(Dictionary<int,long>) 替代原先第8/9/10次的各自字段,且以 JSON 存库(SugarColumn IsJson)。
  - 构造函数初始化 WinRecords。
  - 新增 SetWinReward(int flipCount, long amount) 统一记录中奖。

- CardFlipService.cs
  - 读取并展示 WinRecords,按翻牌顺序映射中奖信息(不再依赖单独的第8/9/10字段)。

- CardFlipManager.cs
  - 重构中奖逻辑:
    - 前7次翻牌改为 50% 概率可中奖,奖励范围 1w–3w(新增配置常量 FREE_*)。
    - 统一通过 SetWinReward 记录任意次的中奖金额。
    - GenerateRandomReward 根据最小值自动选单位(1w 或 100w)。
  - 邀请类型翻牌校验由“仅统计被填写次数”改为“统计本周作为邀请人或被邀请人的邀请记录数量”(双方都计入),并据此判断是否可解锁邀请翻牌次数。

- InviteCodeManager.cs
  - 使用邀请码时:
    - 验证规则调整:一个账号只能填写别人的邀请码一次(hasUsedOthersCode 检查)。
    - 邀请记录的语义变化:当使用邀请码时,邀请记录同时代表邀请人和被邀请人各增加一次翻牌机会。
    - 不再将邀请码标记为单次已用;改为增加 UsedCount(一个邀请码可以被多人使用)。
    - 优化日志与提示信息。

- InviteCodeAggregateRoot.cs
  - 移除 IsUsed、UsedTime、UsedByUserId、MarkAsUsed 等单次使用相关字段/方法。
  - 保留 IsUserInvited(被邀请后不能再作为被邀请者使用)和 UsedCount(统计多人使用次数)。

注意事项
- 这是数据结构与业务逻辑的变更,数据库表结构发生变化(新增 WinRecords JSON 字段,移除若干字段)。上线前请准备相应的迁移脚本或数据迁移方案,确保历史中奖数据平滑迁移到 WinRecords。
- 变更会影响相关单元/集成测试、前端展示字段,需同步更新对应测试与界面展示逻辑。
2025-11-07 21:31:18 +08:00
chenchun
690cabfd96 feat: 新增公告功能 2025-11-06 16:59:29 +08:00
chenchun
4521212a90 feat: 新增文件缓存功能
- 在 Yi.Framework.Rbac.Application.Services.FileService 中注入 IMemoryCache,用于缓存文件元数据,减少对仓储的重复读取。
  - 在 Get 方法中通过 key "File:{code}" 缓存 FileCacheItem,设置绝对过期时间为 1 天。
  - 缓存项使用 Mapster 适配为 FileCacheItem,再适配回 FileAggregateRoot(保留现有逻辑判断和路径获取)。
- 新增缓存模型 Yi.Framework.Rbac.Domain.Shared.Caches.FileCacheItem(包含 Id、FileSize、FileName、FilePath、创建/修改信息等)。
- 增加并调整相关 using 引用(Microsoft.Extensions.Caching.Memory、Volo.Abp.Caching、Domain.Shared.Caches)。
- 同时修复了保存多文件时的缩进/空格格式(不影响功能)。
2025-11-06 11:29:21 +08:00
chenchun
771ecd9d81 Merge branch 'abp' into ai-hub
# Conflicts:
#	Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/FileService.cs
2025-11-06 11:23:46 +08:00
chenchun
94834f45c3 perf: 使用 FileStreamResult 流式返回文件,避免一次性读取到内存
改为 FileStream 并返回 FileStreamResult,减小内存占用并支持大型文件;修正变量名拼写并添加 null-forgiving 标记。
2025-11-06 11:13:50 +08:00
chenchun
a9b2979a21 Merge branch 'abp' into ai-hub 2025-11-06 11:00:04 +08:00
chenchun
22ac150acd fix: 修正 FileAggregateRoot.FilePath 的赋值,保存目录路径而非包含文件名的完整路径 2025-11-06 10:58:33 +08:00
Gsh
17337b8d78 fix: 系统公告弹窗前端 2025-11-05 23:12:23 +08:00
chenchun
09fb43ee14 refactor: 修改 YiCrudAppService.DeleteAsync 的参数名 ids -> id
在 Yi.Abp.Net8/framework/Yi.Framework.Ddd.Application/YiCrudAppService.cs 中,将 DeleteAsync 方法的参数名由 ids 改为 id,更新了对应的 XML 注释与对 Repository.DeleteManyAsync 的调用参数。仅为参数重命名,无功能变更。
2025-11-05 16:28:52 +08:00
ccnetcore
477c0e3f2c Merge branch 'invitation' into ai-hub 2025-11-02 13:00:36 +08:00
chenchun
5beef22269 fix: 修复权限判断逻辑(应为 &&,避免始终抛出权限异常)
修正 AiAccountService.GetProfitStatisticsAsync 中的条件判断,原先使用 || 导致即使为 Guo 或 cc 仍被拒绝访问。
2025-10-30 14:48:53 +08:00
chenchun
933cbb91d8 feat: 新增尊享包利润统计接口及 ElCollapseTransition 类型声明
- 在 AiAccountService 中新增 GetProfitStatisticsAsync 接口(GET account/profit-statistics),注入 PremiumPackage 仓储并统计尊享包已消耗/剩余、总成本、总收益、利润率及按200售价的成本估算。接口受授权控制。
- 注入 ISqlSugarRepository<PremiumPackageAggregateRoot> 并在构造函数中赋值。
- 在 types/components.d.ts 中新增 ElCollapseTransition 类型声明,补充前端组件类型提示。
- 注意:接口中对用户权限的判断使用了 "CurrentUser.UserName != \"Guo\" || CurrentUser.UserName != \"cc\"",该逻辑可能有误(应为 &&),建议确认并修正权限校验。
2025-10-30 14:38:58 +08:00
chenchun
cf137f6307 fix: 兼容客户端空值,Contents 为空时返回 "_" 并修正 Content 判空逻辑
修复 AnthropicMessageInput 中对 Content/Contents 的判空处理:
- 当 Contents 为 null 或 Count==0 时返回 "_",以兼容客户端对空值的特殊处理。
- 修正对 Content 的判空逻辑,使用 !string.IsNullOrEmpty(...) 确保非空字符串优先返回,避免将空字符串当作有效内容。
2025-10-29 22:23:09 +08:00
chenchun
3e75792e43 fix: 修复bug - 在可用性检查中支持忽略剩余令牌校验,避免负数用量包被错误过滤
- 将 PremiumPackageAggregateRoot.IsAvailable 增加参数 isVerifyRemainingToken=true,保持默认行为不变,允许按需跳过对 RemainingTokens 的校验。
- 在 UsageStatisticsService 中计算可用包时改为使用 p.IsAvailable(false),仅过滤过期或禁用的包,但不再因 RemainingTokens 为负而将包排除,从而保证统计(如 TotalTokens/RemainingTokens 汇总)包含负数用量的包,修正统计错误。

修改文件:
- Yi.Framework.AiHub.Domain/Entities/PremiumPackageAggregateRoot.cs
- Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs
2025-10-29 16:34:53 +08:00
chenchun
108ba348f6 feat: 扣减尊享包用量并调整日常任务奖励
- 在 AiGateWayManager 中新增:当请求使用尊享包模型时,按实际使用的 totalTokens 调用 PremiumPackageManager.TryConsumeTokensAsync 扣减用户尊享包用量(仅在 totalTokens > 0 时)。
- 调整 DailyTaskService 中两项日常任务的奖励配置:1000w 消耗奖励由 200w -> 100w,3000w 消耗奖励由 400w -> 200w。
- 兼顾少量格式化优化(if 条件空格调整)。
2025-10-28 17:43:23 +08:00
chenchun
bcdcec40e0 Merge remote-tracking branch 'origin/ai-hub' into ai-hub 2025-10-28 16:13:13 +08:00
chenchun
2ce8baea42 fix: 优化对话异常提示信息
将抛出异常的消息从 "OpenAI对话异常{StatusCode}" 修改为更详细的中文提示,包含 StatusCode 与 Response 内容,便于排查。未改变逻辑,仅调整异常文本。
2025-10-28 16:12:52 +08:00
ccnetcore
609de29e71 feat: AnthropicMessageContent 新增 Signature 字段 2025-10-26 14:51:48 +08:00
ccnetcore
2efed4f4a5 feat: AnthropicThinkingInput 新增 signature、thinking、data、text 字段 2025-10-26 10:38:01 +08:00
ccnetcore
1cc5f2a14f refactor: 注释掉 Furion 统一结果 API 注册,保留 ABP 默认处理方式 2025-09-27 17:26:13 +08:00
橙子
d9997eeb28 !100 update Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/Fiters/FriendlyExceptionFilter.cs.
Merge pull request !100 from Gary/N/A
2025-09-22 07:14:02 +00:00
Gary
06e77aa8fd update Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/Fiters/FriendlyExceptionFilter.cs.
判断是否为模型验证错误,如果是,将errors传回,并打印日志

Signed-off-by: Gary <1511313969@qq.com>
2025-09-22 07:13:46 +00:00
橙子
e9e2228f6e !97 岗位状态修改
Merge pull request !97 from 嗳摸嫫/jun
2025-09-22 07:13:45 +00:00
橙子
d516a381d0 !98 update Yi.Abp.Net8/framework/Yi.Framework.Mapster/YiFrameworkMapsterModule.cs.
Merge pull request !98 from Gary/N/A
2025-09-22 07:13:26 +00:00
Gary
4e792ba976 update Yi.Abp.Net8/framework/Yi.Framework.Mapster/YiFrameworkMapsterModule.cs.
自动扫描所有继承IRegister 的Mapster 配置

Signed-off-by: Gary <1511313969@qq.com>
2025-09-22 02:58:59 +00:00
chenchun
f90d3871fa feat: 启用 Furion 统一返回结果并优化过滤器配置
- 在 `YiAbpWebModule` 中启用 `AddFurionUnifyResultApi` 以支持 Furion 风格的统一 API 返回格式
- 调整 `UnifyResultExtensions`,移除 `AbpExceptionFilter` 和 `AbpNoContentActionFilter`,确保统一结果过滤器优先执行
2025-09-16 11:48:36 +08:00
HW-July
6005b9329d 岗位状态修改 2025-08-25 17:12:18 +08:00
橙子
9d4b3e7d0c update README.md.
Signed-off-by: 橙子 <454313500@qq.com>
2025-07-05 07:50:10 +00:00
chenchun
72795382a1 style: 调整样式 2025-07-02 15:03:16 +08:00
橙子
35cdff2afa update README.md.
Signed-off-by: 橙子 <454313500@qq.com>
2025-07-02 06:04:18 +00:00
橙子
dcf547f513 style: 新增赞助
Signed-off-by: 橙子 <454313500@qq.com>
2025-07-02 06:03:28 +00:00
橙子
8660d45f36 update README.md.
Signed-off-by: 橙子 <454313500@qq.com>
2025-07-02 06:01:51 +00:00
橙子
63dd55e7a4 !95 修正分页导致部门结构显示异常。取消后台分页功能,同菜单结构无需分页。
Merge pull request !95 from Po/N/A
2025-07-02 03:49:56 +00:00
Po
40cd89f90c 修正分页导致部门结构显示异常。取消后台分页功能,同菜单结构无需分页。
Signed-off-by: Po <448443959@qq.com>
2025-07-02 02:50:06 +00:00
81 changed files with 5683 additions and 862 deletions

1
.gitignore vendored
View File

@@ -265,6 +265,7 @@ src/Acme.BookStore.Blazor.Server.Tiered/Logs/*
**/wwwroot/libs/*
public
dist
dist - 副本
.vscode
/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.Development.json
/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.Production.json

View File

@@ -7,6 +7,12 @@
[![fork](https://gitee.com/ccnetcore/yi/badge/fork.svg?theme=dark)](https://gitee.com/ccnetcore/Yi)
[![license](https://img.shields.io/badge/license-MIT-yellow)](https://gitee.com/ccnetcore/Yi)
本项目 CDN 加速及安全防护由 Tencent EdgeOne 赞助
[亚洲最佳CDN、边缘和安全解决方案 - Tencent EdgeOne](https://edgeone.ai/zh?from=github)
<img src="readme/edgeone.png"/>
[English](README-en.md) | 简体中文
****
## 🍍 简介:
@@ -60,9 +66,9 @@ bbs前端`docker run -d --name yi.bbs -p 18001:18001 -v /home/Yi/Yi.Bbs.Vue3/
Yi社区官网网址Bbs社区正式[ccnetcore.com](https://ccnetcore.com) (已上线,欢迎加入)
Rbac后台演示地址https://ccnetcore.com:1000 用户cc、密码123456
Rbac后台演示地址https://data.ccnetcore.com:1000 用户cc、密码123456
Pure后台演示地址https://ccnetcore.com:1001 用户cc、密码123456
Pure后台演示地址https://data.ccnetcore.com:1001 用户cc、密码123456
## 🍏 支持:

View File

@@ -1,4 +1,4 @@
// MIT 许可证
// MIT 许可证
//
// 版权 © 2020-present 百小僧, 百签科技(广东)有限公司 和所有贡献者
//
@@ -17,25 +17,25 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Validation;
using Yi.Framework.Core.Extensions;
namespace Yi.Framework.AspNetCore.UnifyResult.Fiters;
/// <summary>
/// 友好异常拦截器
/// 友好异常拦截器
/// </summary>
public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
{
/// <summary>
/// 异常拦截
/// 异常拦截
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public async Task OnExceptionAsync(ExceptionContext context)
{
// 排除 WebSocket 请求处理
if (context.HttpContext.IsWebSocketRequest()) return;
@@ -44,20 +44,23 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
// 解析异常信息
var exceptionMetadata = GetExceptionMetadata(context);
IUnifyResultProvider unifyResult = context.GetRequiredService<IUnifyResultProvider>();
var unifyResult = context.GetRequiredService<IUnifyResultProvider>();
// 执行规范化异常处理
context.Result = unifyResult.OnException(context, exceptionMetadata);
// 创建日志记录器
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<FriendlyExceptionFilter>>();
var errorMsg = "";
if (exceptionMetadata.Errors != null) errorMsg = "\n" + JsonConvert.SerializeObject(exceptionMetadata.Errors);
// 记录拦截日常
logger.LogError(context.Exception, context.Exception.Message);
logger.LogError(context.Exception, context.Exception.Message + errorMsg);
}
/// <summary>
/// 获取异常元数据
/// 获取异常元数据
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
@@ -74,22 +77,25 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
// 判断是否是 ExceptionContext 或者 ActionExecutedContext
var exception = context is ExceptionContext exContext
? exContext.Exception
: (
context is ActionExecutedContext edContext
? edContext.Exception
: default
);
: context is ActionExecutedContext edContext
? edContext.Exception
: default;
if (exception is AbpValidationException validationException)
{
errors = validationException.ValidationErrors;
isValidationException = true;
}
// 判断是否是友好异常
if (exception is UserFriendlyException friendlyException)
{
int statusCode2 = 500;
var statusCode2 = 500;
int.TryParse(friendlyException.Code, out statusCode2);
isFriendlyException = true;
errorCode = friendlyException.Code;
originErrorCode = friendlyException.Code;
statusCode = statusCode2==0?403:statusCode2;
isValidationException = false;
statusCode = statusCode2 == 0 ? 403 : statusCode2;
errors = friendlyException.Message;
data = friendlyException.Data;
}

View File

@@ -2,6 +2,7 @@
using Microsoft.Extensions.DependencyInjection;
using Swashbuckle.AspNetCore.SwaggerGen;
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc.Response;
using Yi.Framework.AspNetCore.UnifyResult.Fiters;
namespace Yi.Framework.AspNetCore.UnifyResult;
@@ -20,9 +21,10 @@ public static class UnifyResultExtensions
services.AddTransient<FriendlyExceptionFilter>();
services.AddMvc(options =>
{
options.Filters.RemoveAll(x => (x as ServiceFilterAttribute)?.ServiceType == typeof(AbpExceptionFilter));
options.Filters.RemoveAll(x => (x as ServiceFilterAttribute)?.ServiceType == typeof(AbpNoContentActionFilter));
options.Filters.AddService<SucceededUnifyResultFilter>(99);
options.Filters.AddService<FriendlyExceptionFilter>(100);
options.Filters.RemoveAll(x => (x as ServiceFilterAttribute)?.ServiceType == typeof(AbpExceptionFilter));
});
return services;
}

View File

@@ -199,11 +199,11 @@ namespace Yi.Framework.Ddd.Application
/// <summary>
/// 批量删除实体
/// </summary>
/// <param name="ids">实体ID集合</param>
/// <param name="id">实体ID集合</param>
[RemoteService(isEnabled: true)]
public virtual async Task DeleteAsync(IEnumerable<TKey> ids)
public virtual async Task DeleteAsync(IEnumerable<TKey> id)
{
await Repository.DeleteManyAsync(ids);
await Repository.DeleteManyAsync(id);
}
/// <summary>

View File

@@ -1,7 +1,8 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
using Volo.Abp.ObjectMapping;
using Yi.Framework.Core;
using Mapster;
namespace Yi.Framework.Mapster
{
@@ -22,7 +23,8 @@ namespace Yi.Framework.Mapster
public override void ConfigureServices(ServiceConfigurationContext context)
{
var services = context.Services;
// 扫描并注册所有映射配置
TypeAdapterConfig.GlobalSettings.Scan(AppDomain.CurrentDomain.GetAssemblies());
// 注册Mapster相关服务
services.AddTransient<IAutoObjectMappingProvider, MapsterAutoObjectMappingProvider>();
services.AddTransient<IObjectMapper, MapsterObjectMapper>();

View File

@@ -60,8 +60,8 @@ namespace Yi.Framework.SqlSugarCore.Abstractions
public bool EnabledSaasMultiTenancy { get; set; } = false;
/// <summary>
/// 并发乐观锁异常,否则不处理
/// 是否开启更新并发乐观锁
/// </summary>
public bool EnabledConcurrencyException { get; set; } = true;
public bool EnabledConcurrencyException { get;set; } = false;
}
}

View File

@@ -1,12 +1,7 @@
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Nito.AsyncEx;
using SqlSugar;
using Volo.Abp;
using Volo.Abp.Auditing;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
@@ -17,18 +12,17 @@ using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.SqlSugarCore.Repositories
{
public class SqlSugarRepository<TEntity> : ISqlSugarRepository<TEntity>, IRepository<TEntity>
where TEntity : class, IEntity, new()
public class SqlSugarRepository<TEntity> : ISqlSugarRepository<TEntity>, IRepository<TEntity> where TEntity : class, IEntity, new()
{
public ISqlSugarClient _Db => AsyncContext.Run(async () => await GetDbContextAsync());
public ISugarQueryable<TEntity> _DbQueryable => _Db.Queryable<TEntity>();
private readonly ISugarDbContextProvider<ISqlSugarDbContext> _dbContextProvider;
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
protected DbConnOptions? Options => LazyServiceProvider?.LazyGetService<IOptions<DbConnOptions>>().Value;
/// <summary>
/// 异步查询执行器
/// </summary>
@@ -64,26 +58,22 @@ namespace Yi.Framework.SqlSugarCore.Repositories
#region Abp模块
public virtual async Task<TEntity?> FindAsync(Expression<Func<TEntity, bool>> predicate,
bool includeDetails = true, CancellationToken cancellationToken = default)
public virtual async Task<TEntity?> FindAsync(Expression<Func<TEntity, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default)
{
return await GetFirstAsync(predicate);
}
public virtual async Task<TEntity> GetAsync(Expression<Func<TEntity, bool>> predicate,
bool includeDetails = true, CancellationToken cancellationToken = default)
public virtual async Task<TEntity> GetAsync(Expression<Func<TEntity, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default)
{
return await GetFirstAsync(predicate);
}
public virtual async Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, bool autoSave = false,
CancellationToken cancellationToken = default)
public virtual async Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, bool autoSave = false, CancellationToken cancellationToken = default)
{
await this.DeleteAsync(predicate);
}
public virtual async Task DeleteDirectAsync(Expression<Func<TEntity, bool>> predicate,
CancellationToken cancellationToken = default)
public virtual async Task DeleteDirectAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default)
{
await this.DeleteAsync(predicate);
}
@@ -113,71 +103,60 @@ namespace Yi.Framework.SqlSugarCore.Repositories
throw new NotImplementedException();
}
public virtual async Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> predicate,
bool includeDetails = false, CancellationToken cancellationToken = default)
public virtual async Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> predicate, bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await GetListAsync(predicate);
}
public virtual async Task<TEntity> InsertAsync(TEntity entity, bool autoSave = false,
CancellationToken cancellationToken = default)
public virtual async Task<TEntity> InsertAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
{
return await InsertReturnEntityAsync(entity);
}
public virtual async Task InsertManyAsync(IEnumerable<TEntity> entities, bool autoSave = false,
CancellationToken cancellationToken = default)
public virtual async Task InsertManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default)
{
await InsertRangeAsync(entities.ToList());
}
public virtual async Task<TEntity> UpdateAsync(TEntity entity, bool autoSave = false,
CancellationToken cancellationToken = default)
public virtual async Task<TEntity> UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
{
await UpdateAsync(entity);
return entity;
}
public virtual async Task UpdateManyAsync(IEnumerable<TEntity> entities, bool autoSave = false,
CancellationToken cancellationToken = default)
public virtual async Task UpdateManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default)
{
await UpdateRangeAsync(entities.ToList());
}
public virtual async Task DeleteAsync(TEntity entity, bool autoSave = false,
CancellationToken cancellationToken = default)
public virtual async Task DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
{
await DeleteAsync(entity);
}
public virtual async Task DeleteManyAsync(IEnumerable<TEntity> entities, bool autoSave = false,
CancellationToken cancellationToken = default)
public virtual async Task DeleteManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default)
{
await DeleteAsync(entities.ToList());
}
public virtual async Task<List<TEntity>> GetListAsync(bool includeDetails = false,
CancellationToken cancellationToken = default)
public virtual async Task<List<TEntity>> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await GetListAsync();
}
public virtual async Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{
return await this.CountAsync(_ => true);
return await this.CountAsync(_=>true);
}
public virtual async Task<List<TEntity>> GetPagedListAsync(int skipCount, int maxResultCount, string sorting,
bool includeDetails = false, CancellationToken cancellationToken = default)
public virtual async Task<List<TEntity>> GetPagedListAsync(int skipCount, int maxResultCount, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await GetPageListAsync(_ => true, skipCount, maxResultCount);
}
#endregion
#region DB快捷操作
public virtual async Task<IDeleteable<TEntity>> AsDeleteable()
{
return (await GetDbSimpleClientAsync()).AsDeleteable();
@@ -192,7 +171,7 @@ namespace Yi.Framework.SqlSugarCore.Repositories
{
return (await GetDbSimpleClientAsync()).AsInsertable(insertObj);
}
public virtual async Task<IInsertable<TEntity>> AsInsertable(TEntity[] insertObjs)
{
return (await GetDbSimpleClientAsync()).AsInsertable(insertObjs);
@@ -232,11 +211,9 @@ namespace Yi.Framework.SqlSugarCore.Repositories
{
return (await GetDbSimpleClientAsync()).AsUpdateable(updateObjs);
}
#endregion
#region SimpleClient模块
public virtual async Task<int> CountAsync(Expression<Func<TEntity, bool>> whereExpression)
{
return await (await GetDbSimpleClientAsync()).CountAsync(whereExpression);
@@ -253,6 +230,7 @@ namespace Yi.Framework.SqlSugarCore.Repositories
{
return await (await GetDbSimpleClientAsync()).DeleteAsync(deleteObj);
}
}
public virtual async Task<bool> DeleteAsync(List<TEntity> deleteObjs)
@@ -272,13 +250,13 @@ namespace Yi.Framework.SqlSugarCore.Repositories
{
if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)))
{
return await (await GetDbSimpleClientAsync()).AsUpdateable()
.SetColumns(nameof(ISoftDelete.IsDeleted), true).Where(whereExpression).ExecuteCommandAsync() > 0;
return await (await GetDbSimpleClientAsync()).AsUpdateable().SetColumns(nameof(ISoftDelete.IsDeleted), true).Where(whereExpression).ExecuteCommandAsync() > 0;
}
else
{
return await (await GetDbSimpleClientAsync()).DeleteAsync(whereExpression);
}
}
public virtual async Task<bool> DeleteByIdAsync(dynamic id)
@@ -286,11 +264,7 @@ namespace Yi.Framework.SqlSugarCore.Repositories
if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)))
{
var entity = await GetByIdAsync(id);
if (entity is null)
{
return false;
}
if (entity == null) return false;
//反射赋值
ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, entity);
return await UpdateAsync(entity);
@@ -311,7 +285,6 @@ namespace Yi.Framework.SqlSugarCore.Repositories
{
return false;
}
//反射赋值
entities.ForEach(e => ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, e));
return await UpdateRangeAsync(entities);
@@ -320,6 +293,7 @@ namespace Yi.Framework.SqlSugarCore.Repositories
{
return await (await GetDbSimpleClientAsync()).DeleteByIdAsync(ids);
}
}
public virtual async Task<TEntity> GetByIdAsync(dynamic id)
@@ -328,6 +302,7 @@ namespace Yi.Framework.SqlSugarCore.Repositories
}
public virtual async Task<TEntity> GetFirstAsync(Expression<Func<TEntity, bool>> whereExpression)
{
return await (await GetDbSimpleClientAsync()).GetFirstAsync(whereExpression);
@@ -343,19 +318,14 @@ namespace Yi.Framework.SqlSugarCore.Repositories
return await (await GetDbSimpleClientAsync()).GetListAsync(whereExpression);
}
public virtual async Task<List<TEntity>> GetPageListAsync(Expression<Func<TEntity, bool>> whereExpression,
int pageNum, int pageSize)
public virtual async Task<List<TEntity>> GetPageListAsync(Expression<Func<TEntity, bool>> whereExpression, int pageNum, int pageSize)
{
return await (await GetDbSimpleClientAsync()).GetPageListAsync(whereExpression,
new PageModel() { PageIndex = pageNum, PageSize = pageSize });
return await (await GetDbSimpleClientAsync()).GetPageListAsync(whereExpression, new PageModel() { PageIndex = pageNum, PageSize = pageSize });
}
public virtual async Task<List<TEntity>> GetPageListAsync(Expression<Func<TEntity, bool>> whereExpression,
int pageNum, int pageSize, Expression<Func<TEntity, object>>? orderByExpression = null,
OrderByType orderByType = OrderByType.Asc)
public virtual async Task<List<TEntity>> GetPageListAsync(Expression<Func<TEntity, bool>> whereExpression, int pageNum, int pageSize, Expression<Func<TEntity, object>>? orderByExpression = null, OrderByType orderByType = OrderByType.Asc)
{
return await (await GetDbSimpleClientAsync()).GetPageListAsync(whereExpression,
new PageModel { PageIndex = pageNum, PageSize = pageSize }, orderByExpression, orderByType);
return await (await GetDbSimpleClientAsync()).GetPageListAsync(whereExpression, new PageModel { PageIndex = pageNum, PageSize = pageSize }, orderByExpression, orderByType);
}
public virtual async Task<TEntity> GetSingleAsync(Expression<Func<TEntity, bool>> whereExpression)
@@ -410,9 +380,9 @@ namespace Yi.Framework.SqlSugarCore.Repositories
public virtual async Task<bool> UpdateAsync(TEntity updateObj)
{
if (typeof(TEntity).IsAssignableTo<IHasConcurrencyStamp>()) //带版本号乐观锁更新
if (Options is not null && Options.EnabledConcurrencyException)
{
if (Options is not null && Options.EnabledConcurrencyException)
if (typeof(TEntity).IsAssignableTo<IHasConcurrencyStamp>()) //带版本号乐观锁更新
{
try
{
@@ -426,24 +396,18 @@ namespace Yi.Framework.SqlSugarCore.Repositories
$"{ex.Message}[更新失败ConcurrencyStamp不是最新版本],entityInfo{updateObj}", ex);
}
}
else
{
int num = await (await GetDbSimpleClientAsync())
.Context.Updateable(updateObj).ExecuteCommandAsync();
return num > 0;
}
}
return await (await GetDbSimpleClientAsync()).UpdateAsync(updateObj);
}
public virtual async Task<bool> UpdateAsync(Expression<Func<TEntity, TEntity>> columns,
Expression<Func<TEntity, bool>> whereExpression)
public virtual async Task<bool> UpdateAsync(Expression<Func<TEntity, TEntity>> columns, Expression<Func<TEntity, bool>> whereExpression)
{
return await (await GetDbSimpleClientAsync()).UpdateAsync(columns, whereExpression);
}
public virtual async Task<bool> UpdateRangeAsync(List<TEntity> updateObjs)
{
return await (await GetDbSimpleClientAsync()).UpdateRangeAsync(updateObjs);
@@ -452,36 +416,30 @@ namespace Yi.Framework.SqlSugarCore.Repositories
#endregion
}
public class SqlSugarRepository<TEntity, TKey> : SqlSugarRepository<TEntity>, ISqlSugarRepository<TEntity, TKey>,
IRepository<TEntity, TKey> where TEntity : class, IEntity<TKey>, new()
public class SqlSugarRepository<TEntity, TKey> : SqlSugarRepository<TEntity>, ISqlSugarRepository<TEntity, TKey>, IRepository<TEntity, TKey> where TEntity : class, IEntity<TKey>, new()
{
public SqlSugarRepository(ISugarDbContextProvider<ISqlSugarDbContext> dbContextProvider) : base(
dbContextProvider)
public SqlSugarRepository(ISugarDbContextProvider<ISqlSugarDbContext> sugarDbContextProvider) : base(sugarDbContextProvider)
{
}
public virtual async Task DeleteAsync(TKey id, bool autoSave = false,
CancellationToken cancellationToken = default)
public virtual async Task DeleteAsync(TKey id, bool autoSave = false, CancellationToken cancellationToken = default)
{
await DeleteByIdAsync(id);
}
public virtual async Task DeleteManyAsync(IEnumerable<TKey> ids, bool autoSave = false,
CancellationToken cancellationToken = default)
public virtual async Task DeleteManyAsync(IEnumerable<TKey> ids, bool autoSave = false, CancellationToken cancellationToken = default)
{
await DeleteByIdsAsync(ids.Select(x => (object)x).ToArray());
}
public virtual async Task<TEntity?> FindAsync(TKey id, bool includeDetails = true,
CancellationToken cancellationToken = default)
public virtual async Task<TEntity?> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default)
{
return await GetByIdAsync(id);
}
public virtual async Task<TEntity> GetAsync(TKey id, bool includeDetails = true,
CancellationToken cancellationToken = default)
public virtual async Task<TEntity> GetAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default)
{
return await GetByIdAsync(id);
}
}
}
}

View File

@@ -0,0 +1,22 @@
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Announcement;
/// <summary>
/// 公告缓存 DTO
/// </summary>
public class AnnouncementCacheDto
{
/// <summary>
/// 版本号
/// </summary>
public string Version { get; set; } = string.Empty;
/// <summary>
/// 公告日志列表
/// </summary>
public List<AnnouncementLogDto> Logs { get; set; } = new List<AnnouncementLogDto>();
/// <summary>
/// 跳转链接
/// </summary>
public string? Url { get; set; }
}

View File

@@ -0,0 +1,44 @@
using Yi.Framework.AiHub.Domain.Shared.Enums;
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Announcement;
/// <summary>
/// 公告日志 DTO
/// </summary>
public class AnnouncementLogDto
{
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 内容列表
/// </summary>
public List<string> Content { get; set; } = new List<string>();
/// <summary>
/// 图片url
/// </summary>
public string? ImageUrl { get; set; }
/// <summary>
/// 开始时间(系统公告时间、活动开始时间)
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 活动结束时间
/// </summary>
public DateTime? EndTime { get; set; }
/// <summary>
/// 公告类型(系统、活动)
/// </summary>
public AnnouncementTypeEnum Type{ get; set; }
/// <summary>
/// 跳转链接
/// </summary>
public string? Url { get; set; }
}

View File

@@ -0,0 +1,17 @@
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Announcement;
/// <summary>
/// 公告输出 DTO
/// </summary>
public class AnnouncementOutput
{
/// <summary>
/// 版本号
/// </summary>
public string Version { get; set; } = string.Empty;
/// <summary>
/// 公告日志列表
/// </summary>
public List<AnnouncementLogDto> Logs { get; set; } = new List<AnnouncementLogDto>();
}

View File

@@ -39,12 +39,7 @@ public class CardFlipStatusOutput
/// 本周邀请人数
/// </summary>
public int InvitedCount { get; set; }
/// <summary>
/// 是否已被邀请(被邀请后不可再提供邀请码)
/// </summary>
public bool IsInvited { get; set; }
/// <summary>
/// 翻牌记录
/// </summary>
@@ -54,6 +49,11 @@ public class CardFlipStatusOutput
/// 下次可翻牌提示
/// </summary>
public string? NextFlipTip { get; set; }
/// <summary>
/// 当前用户是否已经填写过邀请码
/// </summary>
public bool IsFilledInviteCode { get; set; }
}
/// <summary>

View File

@@ -0,0 +1,12 @@
using Volo.Abp.Application.Dtos;
using Yi.Framework.Ddd.Application.Contracts;
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.UsageStatistics;
public class PremiumTokenUsageGetListInput : PagedAllResultRequestDto
{
/// <summary>
/// 是否免费
/// </summary>
public bool? IsFree { get; set; }
}

View File

@@ -0,0 +1,57 @@
using Volo.Abp.Application.Dtos;
using Yi.Framework.Ddd.Application.Contracts;
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.UsageStatistics;
public class PremiumTokenUsageGetListOutput : CreationAuditedEntityDto
{
/// <summary>
/// id
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// 用户ID
/// </summary>
public Guid UserId { get; set; }
/// <summary>
/// 包名称
/// </summary>
public string PackageName { get; set; }
/// <summary>
/// 总用量总token数
/// </summary>
public long TotalTokens { get; set; }
/// <summary>
/// 剩余用量剩余token数
/// </summary>
public long RemainingTokens { get; set; }
/// <summary>
/// 已使用token数
/// </summary>
public long UsedTokens { get; set; }
/// <summary>
/// 到期时间
/// </summary>
public DateTime? ExpireDateTime { get; set; }
/// <summary>
/// 是否激活
/// </summary>
public bool IsActive { get; set; }
/// <summary>
/// 购买金额
/// </summary>
public decimal PurchaseAmount { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Remark { get; set; }
}

View File

@@ -0,0 +1,15 @@
using Yi.Framework.AiHub.Application.Contracts.Dtos.Announcement;
namespace Yi.Framework.AiHub.Application.Contracts.IServices;
/// <summary>
/// 公告服务接口
/// </summary>
public interface IAnnouncementService
{
/// <summary>
/// 获取公告信息
/// </summary>
/// <returns>公告信息</returns>
Task<List<AnnouncementLogDto>> GetAsync();
}

View File

@@ -17,15 +17,18 @@ public class AiAccountService : ApplicationService
private IAccountService _accountService;
private ISqlSugarRepository<AiUserExtraInfoEntity> _userRepository;
private ISqlSugarRepository<AiRechargeAggregateRoot> _rechargeRepository;
private ISqlSugarRepository<PremiumPackageAggregateRoot> _premiumPackageRepository;
public AiAccountService(
IAccountService accountService,
ISqlSugarRepository<AiUserExtraInfoEntity> userRepository,
ISqlSugarRepository<AiRechargeAggregateRoot> rechargeRepository)
ISqlSugarRepository<AiRechargeAggregateRoot> rechargeRepository,
ISqlSugarRepository<PremiumPackageAggregateRoot> premiumPackageRepository)
{
_accountService = accountService;
_userRepository = userRepository;
_rechargeRepository = rechargeRepository;
_premiumPackageRepository = premiumPackageRepository;
}
/// <summary>
@@ -72,4 +75,77 @@ 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;
}
}

View File

@@ -0,0 +1,68 @@
using Mapster;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Configuration;
using Volo.Abp.Application.Services;
using Volo.Abp.Caching;
using Yi.Framework.AiHub.Application.Contracts.Dtos.Announcement;
using Yi.Framework.AiHub.Application.Contracts.IServices;
using Yi.Framework.AiHub.Domain.Entities;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.AiHub.Application.Services;
/// <summary>
/// 公告服务
/// </summary>
public class AnnouncementService : ApplicationService, IAnnouncementService
{
private readonly ISqlSugarRepository<AnnouncementAggregateRoot> _announcementRepository;
private readonly IConfiguration _configuration;
private readonly IDistributedCache<AnnouncementCacheDto> _announcementCache;
private const string AnnouncementCacheKey = "AiHub:Announcement";
public AnnouncementService(
ISqlSugarRepository<AnnouncementAggregateRoot> announcementRepository,
IConfiguration configuration,
IDistributedCache<AnnouncementCacheDto> announcementCache)
{
_announcementRepository = announcementRepository;
_configuration = configuration;
_announcementCache = announcementCache;
}
/// <summary>
/// 获取公告信息
/// </summary>
public async Task<List<AnnouncementLogDto>> GetAsync()
{
// 使用 GetOrAddAsync 从缓存获取或添加数据缓存1小时
var cacheData = await _announcementCache.GetOrAddAsync(
AnnouncementCacheKey,
async () => await LoadAnnouncementDataAsync(),
() => new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1)
}
);
return cacheData?.Logs ?? new List<AnnouncementLogDto>();
}
/// <summary>
/// 从数据库加载公告数据
/// </summary>
private async Task<AnnouncementCacheDto> LoadAnnouncementDataAsync()
{
// 查询所有公告日志,按日期降序排列
var logs = await _announcementRepository._DbQueryable
.OrderByDescending(x => x.StartTime)
.ToListAsync();
// 转换为 DTO
var logDtos = logs.Adapt<List<AnnouncementLogDto>>();
return new AnnouncementCacheDto
{
Logs = logDtos
};
}
}

View File

@@ -51,9 +51,8 @@ public class CardFlipService : ApplicationService, ICardFlipService
// 统计本周邀请人数
var invitedCount = await _inviteCodeManager.GetWeeklyInvitationCountAsync(userId, weekStart);
// 检查用户是否已邀请
var isInvited = await _inviteCodeManager.IsUserInvitedAsync(userId);
//当前用户是否已填写过邀请
var isFilledInviteCode = await _inviteCodeManager.IsFilledInviteCodeAsync(userId);
var output = new CardFlipStatusOutput
{
TotalFlips = task?.TotalFlips ?? 0,
@@ -63,8 +62,8 @@ public class CardFlipService : ApplicationService, ICardFlipService
CanFlip = _cardFlipManager.CanFlipCard(task),
MyInviteCode = inviteCode?.Code,
InvitedCount = invitedCount,
IsInvited = isInvited,
FlipRecords = BuildFlipRecords(task)
FlipRecords = BuildFlipRecords(task),
IsFilledInviteCode = isFilledInviteCode
};
// 生成提示信息
@@ -87,7 +86,7 @@ public class CardFlipService : ApplicationService, ICardFlipService
// 如果中奖,发放奖励
if (result.IsWin)
{
await GrantRewardAsync(userId, result.RewardAmount, $"翻牌活动{input.FlipNumber}中奖");
await GrantRewardAsync(userId, result.RewardAmount, $"翻牌活动-序号{input.FlipNumber}中奖");
}
// 构建输出
@@ -147,7 +146,6 @@ public class CardFlipService : ApplicationService, ICardFlipService
{
MyInviteCode = inviteCode?.Code,
InvitedCount = invitedCount,
IsInvited = inviteCode?.IsUserInvited ?? false,
InvitationHistory = invitationHistory.Select(x => new InvitationHistoryItem
{
InvitedUserName = x.InvitedUserName,
@@ -183,6 +181,9 @@ public class CardFlipService : ApplicationService, ICardFlipService
var flippedOrder = task != null ? _cardFlipManager.GetFlippedOrder(task) : new List<int>();
var flippedNumbers = new HashSet<int>(flippedOrder);
// 获取中奖记录
var winRecords = task?.WinRecords ?? new Dictionary<int, long>();
// 构建记录按照原始序号1-10排列
for (int i = 1; i <= CardFlipManager.TOTAL_MAX_FLIPS; i++)
{
@@ -202,23 +203,11 @@ public class CardFlipService : ApplicationService, ICardFlipService
{
var flipOrderIndex = flippedOrder.IndexOf(i) + 1; // 第几次翻的1-based
// 第8次翻的卡中奖
if (flipOrderIndex == 8)
// 检查这次翻牌是否中奖
if (winRecords.TryGetValue(flipOrderIndex, out var rewardAmount))
{
record.IsWin = true;
record.RewardAmount = task.EighthRewardAmount;
}
// 第9次翻的卡中奖
else if (flipOrderIndex == 9)
{
record.IsWin = true;
record.RewardAmount = task.NinthRewardAmount;
}
// 第10次翻的卡中奖
else if (flipOrderIndex == 10)
{
record.IsWin = true;
record.RewardAmount = task.TenthRewardAmount;
record.RewardAmount = rewardAmount;
}
}
@@ -246,10 +235,10 @@ public class CardFlipService : ApplicationService, ICardFlipService
{
if (status.TotalFlips >= 7)
{
return $"本周使用他人邀请码可解锁{status.RemainingInviteFlips}次翻牌,且必中大奖!每次中奖最大额度将翻倍!";
return $"本周使用他人邀请码或他人使用你的邀请码,可解锁{status.RemainingInviteFlips}次翻牌且必中大奖!每次中奖最大额度将翻倍!";
}
return $"本周使用他人邀请码可解锁{status.RemainingInviteFlips}次翻牌,必中大奖!每次中奖最大额度将翻倍!";
return $"本周使用他人邀请码或他人使用你的邀请码,可解锁{status.RemainingInviteFlips}次翻牌必中大奖!每次中奖最大额度将翻倍!";
}
return "继续加油!";

View File

@@ -28,8 +28,8 @@ public class DailyTaskService : ApplicationService
private readonly Dictionary<int, (long RequiredTokens, long RewardTokens, string Name, string Description)>
_taskConfigs = new()
{
{ 1, (10000000, 2000000, "尊享包1000w token任务", "累积使用尊享包 1000w token") }, // 1000w消耗 -> 200w奖励
{ 2, (30000000, 4000000, "尊享包3000w token任务", "累积使用尊享包 3000w token") } // 3000w消耗 -> 600w奖励
{ 1, (10000000, 1000000, "尊享包1000w token任务", "累积使用尊享包 1000w token") }, // 1000w消耗 -> 100w奖励
{ 2, (30000000, 2000000, "尊享包3000w token任务", "累积使用尊享包 3000w token") } // 3000w消耗 -> 200w奖励
};
public DailyTaskService(

View File

@@ -1,5 +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.UsageStatistics;
@@ -7,6 +10,7 @@ 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.Extensions;
using Yi.Framework.Ddd.Application.Contracts;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.AiHub.Application.Services;
@@ -125,9 +129,9 @@ public class UsageStatisticsService : ApplicationService, IUsageStatisticsServic
if (premiumPackages.Any())
{
// 过滤掉已过期的包
// 过滤掉已过期、禁用的包,不过滤用量负数的包
var validPackages = premiumPackages
.Where(p => p.IsAvailable())
.Where(p => p.IsAvailable(false))
.ToList();
result.PremiumTotalTokens = validPackages.Sum(x => x.TotalTokens);
@@ -137,4 +141,27 @@ public class UsageStatisticsService : ApplicationService, IUsageStatisticsServic
return result;
}
/// <summary>
/// 获取当前用户尊享服务token用量统计列表
/// </summary>
/// <returns></returns>
[HttpGet("usage-statistics/premium-token-usage/list")]
public async Task<PagedResultDto<PremiumTokenUsageGetListOutput>> GetPremiumTokenUsageListAsync(
PremiumTokenUsageGetListInput input)
{
var userId = CurrentUser.GetId();
RefAsync<int> total = 0;
// 获取尊享包Token信息
var entities = await _premiumPackageRepository._DbQueryable
.Where(x => x.UserId == userId)
.WhereIF(input.IsFree == false, x => x.PurchaseAmount > 0)
.WhereIF(input.IsFree == true, x => x.PurchaseAmount == 0)
.WhereIF(input.StartTime is not null && input.EndTime is not null,
x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
.OrderByDescending(x => x.CreationTime)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto<PremiumTokenUsageGetListOutput>(total,
entities.Adapt<List<PremiumTokenUsageGetListOutput>>());
}
}

View File

@@ -109,8 +109,15 @@ public sealed class AnthropicInput
public class AnthropicThinkingInput
{
[JsonPropertyName("type")] public string? Type { get; set; }
[JsonPropertyName("budget_tokens")] public int? BudgetTokens { get; set; }
[JsonPropertyName("signature")] public string? Signature { get; set; }
[JsonPropertyName("thinking")] public string? Thinking { get; set; }
[JsonPropertyName("data")] public string? Data { get; set; }
[JsonPropertyName("text")] public string? Text { get; set; }
}
public class AnthropicTooChoiceInput

View File

@@ -20,6 +20,8 @@ public class AnthropicMessageContent
[JsonPropertyName("thinking")] public string? Thinking { get; set; }
[JsonPropertyName("signature")] public string? Signature { get; set; }
[JsonPropertyName("input")] public object? Input { get; set; }
[JsonPropertyName("content")]

View File

@@ -22,11 +22,15 @@ public class AnthropicMessageInput
throw new ValidationException("Messages 中 Content 和 Contents 字段不能同时有值");
}
if (Content is not null)
if (!string.IsNullOrEmpty(Content))
{
return Content;
}
// 如果 Contents 为空或 null返回空字符串而不是 null
if (Contents == null || Contents.Count == 0)
{
return "_"; // 兼容客户端空值问题
}
return Contents!;
}
set

View File

@@ -0,0 +1,7 @@
namespace Yi.Framework.AiHub.Domain.Shared.Enums;
public enum AnnouncementTypeEnum
{
Activity=1,
System=2
}

View File

@@ -0,0 +1,57 @@
using SqlSugar;
using Volo.Abp.Domain.Entities.Auditing;
using Yi.Framework.AiHub.Domain.Shared.Enums;
namespace Yi.Framework.AiHub.Domain.Entities;
/// <summary>
/// 公告日志
/// </summary>
[SugarTable("Ai_Announcement")]
public class AnnouncementAggregateRoot : FullAuditedAggregateRoot<Guid>
{
public AnnouncementAggregateRoot()
{
}
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; } = string.Empty;
/// <summary>
/// 内容列表JSON格式存储
/// </summary>
[SugarColumn(IsJson = true, IsNullable = false)]
public List<string> Content { get; set; } = new List<string>();
/// <summary>
/// 备注
/// </summary>
public string? Remark { get; set; }
/// <summary>
/// 图片url
/// </summary>
public string? ImageUrl { get; set; }
/// <summary>
/// 开始时间(系统公告时间、活动开始时间)
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 活动结束时间
/// </summary>
public DateTime? EndTime { get; set; }
/// <summary>
/// 公告类型(系统、活动)
/// </summary>
public AnnouncementTypeEnum Type{ get; set; }
/// <summary>
/// 跳转链接
/// </summary>
public string? Url { get; set; }
}

View File

@@ -25,9 +25,8 @@ public class CardFlipTaskAggregateRoot : FullAuditedAggregateRoot<Guid>
BonusFlipsUsed = 0;
InviteFlipsUsed = 0;
IsFirstFlipDone = false;
HasNinthReward = false;
HasTenthReward = false;
FlippedOrder = new List<int>();
WinRecords = new Dictionary<int, long>();
}
/// <summary>
@@ -66,34 +65,10 @@ public class CardFlipTaskAggregateRoot : FullAuditedAggregateRoot<Guid>
public bool IsFirstFlipDone { get; set; }
/// <summary>
/// 是否已获得第8次奖励
/// 中奖记录以翻牌顺序为key例如第1次翻牌中奖则key为1奖励金额为value
/// </summary>
public bool HasEighthReward { get; set; }
/// <summary>
/// 第8次奖励金额100-300w
/// </summary>
public long? EighthRewardAmount { get; set; }
/// <summary>
/// 是否已获得第9次奖励
/// </summary>
public bool HasNinthReward { get; set; }
/// <summary>
/// 第9次奖励金额100-500w
/// </summary>
public long? NinthRewardAmount { get; set; }
/// <summary>
/// 是否已获得第10次奖励
/// </summary>
public bool HasTenthReward { get; set; }
/// <summary>
/// 第10次奖励金额100-1000w
/// </summary>
public long? TenthRewardAmount { get; set; }
[SugarColumn(IsJson = true, IsNullable = true)]
public Dictionary<int, long>? WinRecords { get; set; }
/// <summary>
/// 备注信息
@@ -135,33 +110,17 @@ public class CardFlipTaskAggregateRoot : FullAuditedAggregateRoot<Guid>
}
/// <summary>
/// 记录第8次奖励
/// 记录中奖
/// </summary>
/// <param name="flipCount">第几次翻牌1-10</param>
/// <param name="amount">奖励金额</param>
public void SetEighthReward(long amount)
public void SetWinReward(int flipCount, long amount)
{
HasEighthReward = true;
EighthRewardAmount = amount;
}
/// <summary>
/// 记录第9次奖励
/// </summary>
/// <param name="amount">奖励金额</param>
public void SetNinthReward(long amount)
{
HasNinthReward = true;
NinthRewardAmount = amount;
}
/// <summary>
/// 记录第10次奖励
/// </summary>
/// <param name="amount">奖励金额</param>
public void SetTenthReward(long amount)
{
HasTenthReward = true;
TenthRewardAmount = amount;
if (WinRecords == null)
{
WinRecords = new Dictionary<int, long>();
}
WinRecords[flipCount] = amount;
}
}

View File

@@ -19,8 +19,6 @@ public class InviteCodeAggregateRoot : FullAuditedAggregateRoot<Guid>
{
UserId = userId;
Code = code;
IsUsed = false;
IsUserInvited = false;
UsedCount = 0;
}
@@ -34,55 +32,16 @@ public class InviteCodeAggregateRoot : FullAuditedAggregateRoot<Guid>
/// </summary>
[SugarColumn(Length = 50)]
public string Code { get; set; } = string.Empty;
/// <summary>
/// 是否已被使用(一个邀请码只能被使用一次
/// </summary>
public bool IsUsed { get; set; }
/// <summary>
/// 邀请码拥有者是否已被他人邀请(被邀请后不可再提供邀请码)
/// </summary>
public bool IsUserInvited { get; set; }
/// <summary>
/// 被使用次数(统计用)
/// 被使用次数(统计用,一个邀请码可以被多人使用
/// </summary>
public int UsedCount { get; set; }
/// <summary>
/// 使用时间
/// </summary>
public DateTime? UsedTime { get; set; }
/// <summary>
/// 使用人ID
/// </summary>
public Guid? UsedByUserId { get; set; }
/// <summary>
/// 备注信息
/// </summary>
[SugarColumn(Length = 500, IsNullable = true)]
public string? Remark { get; set; }
/// <summary>
/// 标记邀请码已被使用
/// </summary>
/// <param name="usedByUserId">使用者ID</param>
public void MarkAsUsed(Guid usedByUserId)
{
IsUsed = true;
UsedTime = DateTime.Now;
UsedByUserId = usedByUserId;
UsedCount++;
}
/// <summary>
/// 标记用户已被邀请
/// </summary>
public void MarkUserAsInvited()
{
IsUserInvited = true;
}
}

View File

@@ -86,14 +86,14 @@ public class PremiumPackageAggregateRoot : FullAuditedAggregateRoot<Guid>
/// 检查是否可用
/// </summary>
/// <returns>是否可用</returns>
public bool IsAvailable()
public bool IsAvailable(bool isVerifyRemainingToken=true)
{
if (!IsActive)
{
return false;
}
if (RemainingTokens <= 0)
if (isVerifyRemainingToken&&RemainingTokens <= 0)
{
return false;
}

View File

@@ -154,6 +154,16 @@ public class AiGateWayManager : DomainService
});
await _usageStatisticsManager.SetUsageAsync(userId.Value, request.Model, data.Usage);
// 扣减尊享token包用量
if (PremiumPackageConst.ModeIds.Contains(request.Model))
{
var totalTokens = data.Usage?.TotalTokens ?? 0;
if (totalTokens > 0)
{
await PremiumPackageManager.TryConsumeTokensAsync(userId.Value, totalTokens);
}
}
}
await response.WriteAsJsonAsync(data, cancellationToken);
@@ -225,7 +235,7 @@ public class AiGateWayManager : DomainService
{
await foreach (var data in completeChatResponse)
{
if (data.Usage is not null&&(data.Usage.CompletionTokens>0||data.Usage.OutputTokens>0))
if (data.Usage is not null && (data.Usage.CompletionTokens > 0 || data.Usage.OutputTokens > 0))
{
tokenUsage = data.Usage;
}

View File

@@ -24,6 +24,11 @@ public class CardFlipManager : DomainService
private const int NINTH_FLIP = 9; // 第9次翻牌
private const int TENTH_FLIP = 10; // 第10次翻牌
// 前7次免费翻牌奖励配置
private const long FREE_MIN_REWARD = 10000; // 前7次最小奖励 1w
private const long FREE_MAX_REWARD = 30000; // 前7次最大奖励 3w
private const double FREE_WIN_RATE = 0.5; // 前7次中奖概率 50%
private const long EIGHTH_MIN_REWARD = 1000000; // 第8次最小奖励 100w
private const long EIGHTH_MAX_REWARD = 3000000; // 第8次最大奖励 300w
private const long NINTH_MIN_REWARD = 1000000; // 第9次最小奖励 100w
@@ -112,23 +117,23 @@ public class CardFlipManager : DomainService
throw new UserFriendlyException(GetFlipTypeErrorMessage(flipType));
}
// 如果是邀请类型翻牌,必须验证用户本周填写的邀请数量足够
// 如果是邀请类型翻牌,必须验证用户本周的邀请记录数量足够(包括填写别人的邀请码和别人填写我的邀请码)
if (flipType == FlipType.Invite)
{
// 查询本周已使用的邀请码数量
var weeklyInviteCodeUsedCount = await _invitationRecordRepository._DbQueryable
.Where(x => x.InvitedUserId == userId)
// 查询本周作为邀请人或被邀请人的记录数量(双方都会增加翻牌次数)
var weeklyInviteRecordCount = await _invitationRecordRepository._DbQueryable
.Where(x => x.InviterId == userId || x.InvitedUserId == userId)
.Where(x => x.InvitationTime >= weekStart)
.CountAsync();
// 本周填写的邀请码数量必须 >= 即将使用的邀请翻牌次数
// 例如: 要翻第8次(InviteFlipsUsed=0->1), 需要至少填写了1个邀请码
// 要翻第9次(InviteFlipsUsed=1->2), 需要至少填写了2个邀请码
// 要翻第10次(InviteFlipsUsed=2->3), 需要至少填写了3个邀请码
var requiredInviteCodeCount = task.InviteFlipsUsed + 1;
if (weeklyInviteCodeUsedCount < requiredInviteCodeCount)
// 本周邀请记录数量必须 >= 即将使用的邀请翻牌次数
// 例如: 要翻第8次(InviteFlipsUsed=0->1), 需要至少有1条邀请记录我邀请别人或别人邀请我
// 要翻第9次(InviteFlipsUsed=1->2), 需要至少有2条邀请记录
// 要翻第10次(InviteFlipsUsed=2->3), 需要至少有3条邀请记录
var requiredInviteRecordCount = task.InviteFlipsUsed + 1;
if (weeklyInviteRecordCount < requiredInviteRecordCount)
{
throw new UserFriendlyException($"需本周累积使用{requiredInviteCodeCount}个他人邀请码才能解锁第{task.TotalFlips + 1}次翻牌,您还差一个~");
throw new UserFriendlyException($"需本周累积{requiredInviteRecordCount}次邀请记录(填写别人的邀请码或别人填写你的邀请码)才能解锁第{task.TotalFlips + 1}次翻牌");
}
}
@@ -152,18 +157,7 @@ public class CardFlipManager : DomainService
// 如果中奖,记录奖励金额(用于后续查询显示)
if (result.IsWin)
{
if (flipCount == EIGHTH_FLIP)
{
task.SetEighthReward(result.RewardAmount);
}
else if (flipCount == NINTH_FLIP)
{
task.SetNinthReward(result.RewardAmount);
}
else if (flipCount == TENTH_FLIP)
{
task.SetTenthReward(result.RewardAmount);
}
task.SetWinReward(flipCount, result.RewardAmount);
}
await _cardFlipTaskRepository.UpdateAsync(task);
@@ -223,11 +217,24 @@ public class CardFlipManager : DomainService
IsWin = false
};
// 前7次固定失败
var random = new Random();
// 前7次: 50%概率中奖奖励1w-3w
if (flipCount <= 7)
{
result.IsWin = false;
result.RewardDesc = "很遗憾,未中奖";
// 50%概率中奖
if (random.NextDouble() < FREE_WIN_RATE)
{
var rewardAmount = GenerateRandomReward(FREE_MIN_REWARD, FREE_MAX_REWARD);
result.IsWin = true;
result.RewardAmount = rewardAmount;
result.RewardDesc = $"恭喜获得尊享包 {rewardAmount / 10000m:0.##}w tokens!";
}
else
{
result.IsWin = false;
result.RewardDesc = "很遗憾,未中奖";
}
}
// 第8次中奖 (邀请码解锁)
else if (flipCount == EIGHTH_FLIP)
@@ -271,21 +278,24 @@ public class CardFlipManager : DomainService
}
/// <summary>
/// 生成随机奖励金额 (最小单位100w)
/// 生成随机奖励金额
/// </summary>
private long GenerateRandomReward(long min, long max)
{
var random = new Random();
const long unit = 1000000; // 100w的单位
// 将min和max转换为100w的倍数
// 根据最小值判断单位
// 如果min小于100000则使用1w(10000)作为单位否则使用100w(1000000)作为单位
long unit = min < 100000 ? 10000 : 1000000;
// 将min和max转换为单位的倍数
long minUnits = min / unit;
long maxUnits = max / unit;
// 在倍数范围内随机
long randomUnits = random.Next((int)minUnits, (int)maxUnits + 1);
// 返回100w的倍数
// 返回单位的倍数
return randomUnits * unit;
}

View File

@@ -63,14 +63,19 @@ public class InviteCodeManager : DomainService
}
/// <summary>
/// 统计用户本周邀请人数
/// 统计用户本周邀请人数(别人填写我的邀请码的次数/或者我填写别人邀请码)
/// </summary>
public async Task<int> GetWeeklyInvitationCountAsync(Guid userId, DateTime weekStart)
{
return await _invitationRecordRepository._DbQueryable
var inviterCount= await _invitationRecordRepository._DbQueryable
.Where(x => x.InviterId == userId)
.Where(x => x.InvitationTime >= weekStart)
.CountAsync();
var invitedUserIdCount= await _invitationRecordRepository._DbQueryable
.Where(x => x.InvitedUserId == userId)
.Where(x => x.InvitationTime >= weekStart)
.CountAsync();
return inviterCount + invitedUserIdCount;
}
/// <summary>
@@ -91,7 +96,7 @@ public class InviteCodeManager : DomainService
}
/// <summary>
/// 使用邀请码
/// 使用邀请码(双方都增加翻牌次数)
/// </summary>
/// <param name="userId">使用者ID</param>
/// <param name="inviteCode">邀请码</param>
@@ -118,75 +123,40 @@ public class InviteCodeManager : DomainService
{
throw new UserFriendlyException("不能使用自己的邀请码");
}
// 检查当前用户是否已经填写过别人的邀请码(一辈子只能填写一次)
var hasUsedOthersCode = await IsFilledInviteCodeAsync(userId);
// 验证邀请码是否已被使用
if (inviteCodeEntity.IsUsed)
if (hasUsedOthersCode)
{
throw new UserFriendlyException("该邀请码已被使用");
throw new UserFriendlyException("您已经填写过别人的邀请码了,每个账号只能填写一次");
}
// 验证邀请码拥有者是否已被邀请
if (inviteCodeEntity.IsUserInvited)
{
throw new UserFriendlyException("该用户已被邀请,邀请码无效");
}
// 验证本周邀请码使用次数
var weekStart = CardFlipManager.GetWeekStartDate(DateTime.Now);
var weeklyUseCount = await _invitationRecordRepository._DbQueryable
.Where(x => x.InvitedUserId == userId)
.Where(x => x.InvitationTime >= weekStart)
.CountAsync();
if (weeklyUseCount >= CardFlipManager.MAX_INVITE_FLIPS)
{
throw new UserFriendlyException($"本周邀请码使用次数已达上限({CardFlipManager.MAX_INVITE_FLIPS}次),请下周再来");
}
// 检查当前用户的邀请码信息
var myInviteCode = await _inviteCodeRepository._DbQueryable
.Where(x => x.UserId == userId)
.FirstAsync();
// 标记邀请码为已使用
inviteCodeEntity.MarkAsUsed(userId);
// 增加邀请码被使用次数
inviteCodeEntity.UsedCount++;
await _inviteCodeRepository.UpdateAsync(inviteCodeEntity);
// 标记当前用户已被邀请(仅第一次使用邀请码时标记)
if (myInviteCode == null)
{
myInviteCode = new InviteCodeAggregateRoot(userId, GenerateUniqueInviteCode());
myInviteCode.MarkUserAsInvited();
await _inviteCodeRepository.InsertAsync(myInviteCode);
}
else if (!myInviteCode.IsUserInvited)
{
myInviteCode.MarkUserAsInvited();
await _inviteCodeRepository.UpdateAsync(myInviteCode);
}
// 创建邀请记录
// 创建邀请记录(双方都会因为这条记录增加一次翻牌机会)
var invitationRecord = new InvitationRecordAggregateRoot(
inviteCodeEntity.UserId,
userId,
inviteCode);
await _invitationRecordRepository.InsertAsync(invitationRecord);
_logger.LogInformation($"用户 {userId} 使用邀请码 {inviteCode} 成功");
_logger.LogInformation($"用户 {userId} 使用邀请码 {inviteCode} 成功,邀请人 {inviteCodeEntity.UserId} 和被邀请人 {userId} 都增加一次翻牌机会");
return inviteCodeEntity.UserId;
}
/// <summary>
/// 检查用户是否已邀请
/// 检查用户是否已填写过邀请
/// </summary>
public async Task<bool> IsUserInvitedAsync(Guid userId)
public async Task<bool> IsFilledInviteCodeAsync(Guid userId)
{
var inviteCode = await _inviteCodeRepository._DbQueryable
.Where(x => x.UserId == userId)
.FirstAsync();
return inviteCode?.IsUserInvited ?? false;
// 检查当前用户是否已经填写过别人的邀请码(一辈子只能填写一次)
return await _invitationRecordRepository._DbQueryable
.Where(x => x.InvitedUserId == userId)
.AnyAsync();
}
/// <summary>

View File

@@ -55,11 +55,11 @@ namespace Yi.Framework.Rbac.Application.Services
{
return new NotFoundResult();
}
var steam = await File.ReadAllBytesAsync(path);
return new FileContentResult(steam, file.GetMimeMapping());
var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
return new FileStreamResult(stream, file!.GetMimeMapping());
}
/// <summary>
/// 上传文件
/// </summary>

View File

@@ -51,7 +51,7 @@ namespace Yi.Framework.Rbac.Application.Services.System
.WhereIF(!string.IsNullOrEmpty(input.DeptName), u => u.DeptName.Contains(input.DeptName!))
.WhereIF(input.State is not null, u => u.State == input.State)
.OrderBy(u => u.OrderNum, OrderByType.Asc)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
.ToListAsync();
return new PagedResultDto<DeptGetListOutputDto>
{
Items = await MapToGetListOutputDtosAsync(entities),

View File

@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Volo.Abp.Application.Dtos;
using Yi.Framework.Ddd.Application;
@@ -54,5 +55,25 @@ namespace Yi.Framework.Rbac.Application.Services.System
throw new UserFriendlyException(RoleConst.Exist);
}
}
/// <summary>
/// 更新状态
/// </summary>
/// <param name="id"></param>
/// <param name="state"></param>
/// <returns></returns>
[Route("post/{id}/{state}")]
public async Task<PostGetOutputDto> UpdateStateAsync([FromRoute] Guid id, [FromRoute] bool state)
{
var entity = await _repository.GetByIdAsync(id);
if (entity is null)
{
throw new ApplicationException("岗位未存在");
}
entity.State = state;
await _repository.UpdateAsync(entity);
return await MapToGetOutputDtoAsync(entity);
}
}
}

View File

@@ -1,4 +1,4 @@
namespace Yi.Framework.Rbac.Domain.Shared.Caches;
namespace Yi.Framework.Rbac.Domain.Shared.Caches;
public class FileCacheItem
{

View File

@@ -34,8 +34,7 @@ namespace Yi.Framework.Rbac.Domain.Entities
var type = GetFileType();
var savePath = GetSaveFilePath();
var filePath = Path.Combine(savePath, this.FileName);
this.FilePath = filePath;
this.FilePath = savePath;
}
/// <summary>

View File

@@ -29,6 +29,7 @@ using Volo.Abp.Swashbuckle;
using Yi.Abp.Application;
using Yi.Abp.SqlsugarCore;
using Yi.Framework.AiHub.Application;
using Yi.Framework.AiHub.Application.Services;
using Yi.Framework.AiHub.Domain.Entities;
using Yi.Framework.AspNetCore;
using Yi.Framework.AspNetCore.Authentication.OAuth;
@@ -36,6 +37,7 @@ using Yi.Framework.AspNetCore.Authentication.OAuth.Gitee;
using Yi.Framework.AspNetCore.Authentication.OAuth.QQ;
using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder;
using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection;
using Yi.Framework.AspNetCore.UnifyResult;
using Yi.Framework.BackgroundWorkers.Hangfire;
using Yi.Framework.Bbs.Application;
using Yi.Framework.Bbs.Application.Extensions;
@@ -125,6 +127,7 @@ namespace Yi.Abp.Web
});
//采用furion格式的规范化api默认不开启使用abp优雅的方式
//前置需要将管道工作单元前加上app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
//你没看错。。。
//service.AddFurionUnifyResultApi();
@@ -352,9 +355,10 @@ namespace Yi.Abp.Web
var app = context.GetApplicationBuilder();
app.UseRouting();
// app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<AnnouncementAggregateRoot>();
// app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<CardFlipTaskAggregateRoot>();
// app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<InvitationRecordAggregateRoot>();
// app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<InviteCodeAggregateRoot>();
// app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<InvitationRecordAggregateRoot>();
//跨域
app.UseCors(DefaultCorsPolicyName);
@@ -400,8 +404,7 @@ namespace Yi.Abp.Web
app.UseDefaultFiles();
app.UseDirectoryBrowser("/api/app/wwwroot");
// app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
//app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
//工作单元
app.UseUnitOfWork();

View File

@@ -1,7 +0,0 @@
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-lVcGFMOQfXYtZWp1rD4SaBNDNpM270UX2wDqWh",
"ANTHROPIC_BASE_URL": "https://api.token-ai.cn",
"ANTHROPIC_MODEL": "gpt-4o-mini"
}
}

View File

@@ -1,7 +1,7 @@
{
"permissions": {
"allow": [
"WebFetch(domain:www.donet5.com)"
"Bash(npx vue-tsc --noEmit)"
],
"deny": [],
"ask": []

View File

@@ -112,7 +112,7 @@
<body>
<!-- 加载动画容器 -->
<div id="yixinai-loader" class="loader-container">
<div class="loader-title">意心Ai 2.2</div>
<div class="loader-title">意心Ai 2.3</div>
<div class="loader-subtitle">海外地址仅首次访问预计加载约10秒</div>
<div class="loader-logo">
<div class="pulse-box"></div>

View File

@@ -1,5 +1,4 @@
<script setup lang="ts">
</script>
<template>

View File

@@ -0,0 +1,12 @@
import type { AnnouncementLogDto } from './types';
import { get } from '@/utils/request';
/**
* 获取系统公告和活动数据
* 后端接口: GET /api/app/announcement
* 返回格式: AnnouncementLogDto[]
*/
export function getSystemAnnouncements() {
return get<AnnouncementLogDto[]>('/announcement').json();
}
export * from './types';

View File

@@ -0,0 +1,18 @@
// 公告类型(对应后端 AnnouncementTypeEnum
export type AnnouncementType = 'Activity' | 'System'
// 公告DTO对应后端 AnnouncementLogDto
export interface AnnouncementLogDto {
/** 标题 */
title: string
/** 内容列表 */
content: string[]
/** 图片url */
imageUrl?: string | null
/** 开始时间(系统公告时间、活动开始时间) */
startTime: string
/** 活动结束时间 */
endTime?: string | null
/** 公告类型(系统、活动) */
type: AnnouncementType
}

View File

@@ -7,9 +7,10 @@ export interface CardFlipStatusOutput {
canFlip: boolean; // 是否可以翻牌
myInviteCode?: string; // 用户的邀请码
invitedCount: number; // 本周邀请人数
isInvited: boolean; // 是否已被邀请
// isInvited: boolean; // 是否已被邀请
flipRecords: CardFlipRecord[]; // 翻牌记录
nextFlipTip?: string; // 下次可翻牌提示
isFilledInviteCode: boolean;// 当前用户是否已经填写过邀请码
}
// 翻牌记录

View File

@@ -1,3 +1,4 @@
export * from './announcement'
export * from './auth';
export * from './chat';
export * from './model';

View File

@@ -1,5 +1,61 @@
import { get, post } from '@/utils/request';
// 尊享包用量明细DTO
export interface PremiumTokenUsageDto {
/** id */
id: string;
/** 用户ID */
userId: string;
/** 包名称 */
packageName: string;
/** 总用量总token数 */
totalTokens: number;
/** 剩余用量剩余token数 */
remainingTokens: number;
/** 已使用token数 */
usedTokens: number;
/** 到期时间 */
expireDateTime?: string;
/** 是否激活 */
isActive: boolean;
/** 购买金额 */
purchaseAmount: number;
/** 备注 */
remark?: string;
/** 创建时间 */
creationTime?: string;
/** 创建者ID */
creatorId?: string;
}
// 查询参数接口 - 匹配后端 PagedAllResultRequestDto
export interface PremiumTokenUsageQueryParams {
/** 查询开始时间 */
startTime?: string;
/** 查询结束时间 */
endTime?: string;
/** 排序列名 */
orderByColumn?: string;
/** 排序方向ascending/descending */
isAsc?: string;
/** 跳过数量(分页) */
skipCount?: number;
/** 最大返回数量(分页) */
maxResultCount?: number;
/** 是否免费 */
isFree?: boolean;
// 是否为升序排序
isAscending?: boolean;
}
// 分页响应接口
export interface PagedResult<T> {
/** 数据列表 */
items: T[];
/** 总数量 */
totalCount: number;
}
// 获取用户信息
export function getUserInfo() {
return get<any>('/account/ai').json();
@@ -24,3 +80,63 @@ export function getWechatAuth(data: any) {
export function getPremiumTokenPackage() {
return get<any>('/usage-statistics/premium-token-usage').json();
}
// 获取尊享包用量明细列表
export function getPremiumTokenUsageList(params?: PremiumTokenUsageQueryParams) {
return get<PagedResult<PremiumTokenUsageDto>>('/usage-statistics/premium-token-usage/list', params).json();
}
// 查询条件的后端dto,其他查询或者排序由前端自己实现:
// using Volo.Abp.Application.Dtos;
//
// namespace Yi.Framework.Ddd.Application.Contracts
// {
// /// <summary>
// /// 分页查询请求DTO包含时间范围和自定义排序功能
// /// </summary>
// public class PagedAllResultRequestDto : PagedAndSortedResultRequestDto, IPagedAllResultRequestDto
// {
// /// <summary>
// /// 查询开始时间
// /// </summary>
// public DateTime? StartTime { get; set; }
//
// /// <summary>
// /// 查询结束时间
// /// </summary>
// public DateTime? EndTime { get; set; }
//
// /// <summary>
// /// 排序列名
// /// </summary>
// public string? OrderByColumn { get; set; }
//
// /// <summary>
// /// 排序方向ascending/descending
// /// </summary>
// public string? IsAsc { get; set; }
//
// /// <summary>
// /// 是否为升序排序
// /// </summary>
// public bool IsAscending => string.Equals(IsAsc, "ascending", StringComparison.OrdinalIgnoreCase);
//
// private string? _sorting;
//
// /// <summary>
// /// 排序表达式
// /// </summary>
// public override string? Sorting
// {
// get
// {
// if (!string.IsNullOrWhiteSpace(OrderByColumn))
// {
// return $"{OrderByColumn} {(IsAscending ? "ASC" : "DESC")}";
// }
// return _sorting;
// }
// set => _sorting = value;
// }
// }
// }

View File

@@ -7,6 +7,7 @@ import { getQrCode, getQrCodeResult, getUserInfo } from '@/api';
import { useUserStore } from '@/stores';
import { useSessionStore } from '@/stores/modules/session.ts';
import { WECHAT_QRCODE_TYPE } from '@/utils/user.ts';
import { useGuideTour } from '@/hooks/useGuideTour';
const props = defineProps({
type: {
@@ -29,6 +30,7 @@ const userStore = useUserStore();
const router = useRouter();
const sessionStore = useSessionStore();
const isQrCodeError = ref(false);
const { startFullTour } = useGuideTour();
// 二维码倒计时实例
const { start: qrStart, stop: qrStop } = useCountdown(shallowRef(600), {
interval: 1000,
@@ -126,6 +128,11 @@ async function handleLoginSuccess(token: string, refreshToken: string) {
stopPolling();
userStore.setToken(token, refreshToken);
const resUserInfo = await getUserInfo();
// 判断是否为新用户注册时间小于1小时
const creationTime = resUserInfo.data.user.creationTime; // 格式: "2024-11-01 12:01:34"
const isNewUser = checkIsNewUser(creationTime);
userStore.setUserInfo(resUserInfo.data);
// 提示用户
ElMessage.success('登录成功');
@@ -133,6 +140,34 @@ async function handleLoginSuccess(token: string, refreshToken: string) {
await router.replace('/');
await sessionStore.requestSessionList(1, true);
userStore.closeLoginDialog();
// 如果是新用户延迟500ms后自动触发新手引导
if (isNewUser) {
setTimeout(() => {
startFullTour();
}, 500);
}
}
// 判断是否为新用户注册时间距离当前时间小于1小时
function checkIsNewUser(creationTimeStr: string): boolean {
try {
// 解析注册时间字符串 "2024-11-01 12:01:34"
const creationTime = new Date(creationTimeStr.replace(' ', 'T'));
const currentTime = new Date();
// 计算时间差(毫秒)
const timeDiff = currentTime.getTime() - creationTime.getTime();
// 1小时 = 60分钟 * 60秒 * 1000毫秒 = 3600000毫秒
const oneHourInMs = 60 * 60 * 1000;
return timeDiff < oneHourInMs;
}
catch (error) {
console.error('解析注册时间失败:', error);
return false;
}
}
// 处理注册授权

View File

@@ -2,22 +2,17 @@
<script setup lang="ts">
import type { GetSessionListVO } from '@/api/model/types';
import { Lock } from '@element-plus/icons-vue';
import { useRouter } from 'vue-router';
import Popover from '@/components/Popover/index.vue';
import SvgIcon from '@/components/SvgIcon/index.vue';
import { useUserStore } from '@/stores';
import { useModelStore } from '@/stores/modules/model';
import { showProductPackage } from '@/utils/product-package.ts';
import { isUserVip } from '@/utils/user';
const router = useRouter();
const userStore = useUserStore();
const modelStore = useModelStore();
// 检查模型是否可用
function isModelAvailable(item: GetSessionListVO) {
return isUserVip() || item.modelId?.includes('DeepSeek-R1-0528') || userStore.userInfo?.user?.userName === 'cc';
return isUserVip() || item.modelId?.includes('DeepSeek-R1-0528');
}
onMounted(async () => {
@@ -88,11 +83,6 @@ function handleModelClick(item: GetSessionListVO) {
)
.then(() => {
showProductPackage();
// router.push({
// name: 'products', // 使用命名路由
// query: { from: isUserVip() ? 'vip' : 'user' }, // 可选:添加来源标识
// });
})
.catch(() => {
// 点击右上角关闭或“关闭”按钮,不执行任何操作
@@ -110,6 +100,9 @@ function handleModelClick(item: GetSessionListVO) {
规则3彩色流光尊享/高级)
-------------------------------- */
function getModelStyleClass(modelName: any) {
if (!modelName) {
return;
}
const name = modelName.toLowerCase();
// 规则3彩色流光
@@ -156,7 +149,7 @@ function getWrapperClass(item: GetSessionListVO) {
</script>
<template>
<div class="model-select">
<div class="model-select" data-tour="model-select">
<Popover
ref="popoverRef"
placement="top-start"

File diff suppressed because it is too large Load Diff

View File

@@ -98,7 +98,7 @@ function toggleFullscreen() {
<div class="dialog-container">
<!-- 左侧导航 -->
<div class="nav-side">
<div class="nav-side" data-tour="user-nav-menu">
<el-menu
:default-active="activeNav"
class="nav-menu"
@@ -108,6 +108,7 @@ function toggleFullscreen() {
v-for="item in navItems"
:key="item.name"
:index="item.name"
:data-tour="`nav-${item.name}`"
>
<template #title>
<el-icon v-if="item.icon">

View File

@@ -792,7 +792,7 @@ function generateShareContent(): string {
return `
🎁 【意心Ai】我来邀请你翻牌抽奖分享我的限时邀请码~
使用我的邀请码可为你解锁1次额外翻牌机会最大可白嫖官方Claude4.5 220RMB额度 Token💰
填写我的邀请码咱们双方各增加1次翻牌机会最大可白嫖官方Claude4.5 220RMB额度 Token💰
👉 点击链接立即参与我的专属邀请码链接:
${shareLink}
@@ -948,6 +948,7 @@ function getCardClass(record: CardFlipRecord): string[] {
type="primary"
size="small"
icon="Gift"
data-tour="my-invite-code-btn"
@click="showMyInviteCodeDialog = true"
>
我的邀请码
@@ -956,6 +957,7 @@ function getCardClass(record: CardFlipRecord): string[] {
type="warning"
size="small"
icon="Unlock"
data-tour="use-invite-code-btn"
@click="inviteCodeDialog = true"
>
使用邀请码
@@ -964,7 +966,7 @@ function getCardClass(record: CardFlipRecord): string[] {
</div>
<!-- 翻牌区域 -->
<div class="cards-section" :class="{ 'shuffle-mode': isShuffling }">
<div class="cards-section" :class="{ 'shuffle-mode': isShuffling }" data-tour="card-flip-area">
<!-- 洗牌动画遮罩提示 -->
<div v-if="isShuffling" class="shuffle-overlay">
<div class="shuffle-tip">
@@ -1094,27 +1096,42 @@ function getCardClass(record: CardFlipRecord): string[] {
class="invite-dialog"
>
<div class="invite-dialog-content">
<p class="dialog-tip">
输入好友的邀请码可增加翻牌次数必定中奖每次奖励最大额度翻倍使用其他人邀请码自己的邀请码将失效
</p>
<el-input
v-model="inputInviteCode"
placeholder="请输入8位邀请码"
maxlength="8"
clearable
size="large"
class="code-input"
>
<template #prefix>
<span style="font-size: 20px;">🎫</span>
</template>
</el-input>
<!-- 已填写过邀请码的提示 -->
<div v-if="taskData?.isFilledInviteCode" class="already-filled-box">
<span class="filled-icon"></span>
<p class="filled-text">
您已填写过邀请码每人仅能填写一次他人邀请码
</p>
</div>
<template v-else>
<p class="dialog-tip">
输入好友的邀请码双方各增加1次翻牌机会必定中奖每次奖励最大额度翻倍
</p>
<el-input
v-model="inputInviteCode"
placeholder="请输入8位邀请码"
maxlength="8"
clearable
size="large"
class="code-input"
>
<template #prefix>
<span style="font-size: 20px;">🎫</span>
</template>
</el-input>
</template>
</div>
<template #footer>
<el-button @click="inviteCodeDialog = false">
取消
</el-button>
<el-button type="primary" :loading="loading" @click="handleUseInviteCode">
<el-button
v-if="!taskData?.isFilledInviteCode"
type="primary"
:loading="loading"
@click="handleUseInviteCode"
>
确认使用
</el-button>
</template>
@@ -1129,16 +1146,8 @@ function getCardClass(record: CardFlipRecord): string[] {
class="my-invite-dialog"
>
<div class="my-invite-dialog-content">
<!-- 已使用过邀请码的提示 -->
<div v-if="taskData?.isInvited" class="invite-disabled-box">
<span class="disabled-icon">🔒</span>
<p class="disabled-text">
您已使用过他人的邀请码无法生成自己的邀请码
</p>
</div>
<!-- 显示已有的邀请码 -->
<div v-else-if="taskData?.myInviteCode" class="my-invite-code-display">
<div v-if="taskData?.myInviteCode" class="my-invite-code-display">
<div class="code-box">
<span class="code-text">{{ taskData.myInviteCode }}</span>
</div>
@@ -1158,9 +1167,20 @@ function getCardClass(record: CardFlipRecord): string[] {
复制分享链接
</el-button>
</div>
<!-- 显示当前用户是否已填写过邀请码 -->
<div v-if="taskData?.isFilledInviteCode" class="filled-status-info">
<span class="status-icon"></span>
<span class="status-text">您已填写过他人邀请码</span>
</div>
<div v-else class="unfilled-status-info">
<span class="status-icon">💡</span>
<span class="status-text">您还可以填写他人邀请码获得额外机会</span>
</div>
<p class="invite-tip">
💌 分享给好友好友使用后可解锁最后3次翻牌机会
💌 分享给好友好友填写您的邀请码后<br>
<strong>双方各增加1次翻牌机会</strong>
</p>
<div class="share-preview">
<div class="share-preview-title">
📱 分享预览
@@ -1174,7 +1194,7 @@ function getCardClass(record: CardFlipRecord): string[] {
<!-- 生成邀请码 -->
<div v-else class="generate-invite-box">
<p class="generate-tip">
您还没有邀请码生成后可以分享给好友
您还没有邀请码生成后分享给好友<strong>双方各增加1次翻牌机会</strong>
</p>
<el-button
type="primary"
@@ -2050,6 +2070,28 @@ function getCardClass(record: CardFlipRecord): string[] {
font-size: 16px;
}
}
.already-filled-box {
text-align: center;
padding: 24px 16px;
background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
border: 1px solid #bae6fd;
border-radius: 12px;
.filled-icon {
font-size: 48px;
display: block;
margin-bottom: 12px;
}
.filled-text {
font-size: 15px;
color: #0369a1;
line-height: 1.6;
margin: 0;
font-weight: 500;
}
}
}
/* 我的邀请码对话框样式 */
@@ -2109,7 +2151,45 @@ function getCardClass(record: CardFlipRecord): string[] {
font-size: 13px;
color: #909399;
line-height: 1.5;
margin: 0 0 16px 0;
margin: 0 0 12px 0;
strong {
color: #f56c6c;
font-weight: 600;
}
}
.filled-status-info,
.unfilled-status-info {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
padding: 8px 12px;
border-radius: 8px;
margin-bottom: 12px;
font-size: 13px;
font-weight: 500;
}
.filled-status-info {
background: #f0fdf4;
border: 1px solid #86efac;
color: #166534;
.status-icon {
font-size: 16px;
}
}
.unfilled-status-info {
background: #fefce8;
border: 1px solid #fde047;
color: #854d0e;
.status-icon {
font-size: 16px;
}
}
.share-preview {
@@ -2169,6 +2249,11 @@ function getCardClass(record: CardFlipRecord): string[] {
color: #606266;
margin-bottom: 20px;
line-height: 1.6;
strong {
color: #f56c6c;
font-weight: 600;
}
}
.el-button {

View File

@@ -0,0 +1,590 @@
<script lang="ts" setup>
import { Clock, Coin, TrophyBase, WarningFilled } from '@element-plus/icons-vue';
import { showProductPackage } from '@/utils/product-package.ts';
// Props
interface Props {
packageData: {
totalQuota: number;
usedQuota: number;
remainingQuota: number;
usagePercentage: number;
packageName: string;
expireDate: string;
};
loading?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
loading: false,
});
// Emits
const emit = defineEmits<{
refresh: [];
}>();
// 计算属性
const usagePercent = computed(() => {
if (props.packageData.totalQuota === 0)
return 0;
return Number(((props.packageData.usedQuota / props.packageData.totalQuota) * 100).toFixed(2));
});
const remainingPercent = computed(() => {
if (props.packageData.totalQuota === 0)
return 0;
return Number(((props.packageData.remainingQuota / props.packageData.totalQuota) * 100).toFixed(2));
});
// 获取进度条颜色(基于剩余百分比)
const progressColor = computed(() => {
const percent = remainingPercent.value;
if (percent <= 10)
return '#f56c6c'; // 红色 - 剩余很少
if (percent <= 30)
return '#e6a23c'; // 橙色 - 剩余较少
return '#67c23a'; // 绿色 - 剩余充足
});
// 格式化数字 - 转换为万为单位
function formatNumber(num: number): string {
if (num === 0)
return '0';
const wan = num / 10000;
// 保留2位小数去掉末尾的0
return wan.toFixed(2).replace(/\.?0+$/, '');
}
// 格式化原始数字(带千分位)
function formatRawNumber(num: number): string {
return num.toLocaleString();
}
function onProductPackage() {
showProductPackage();
}
</script>
<template>
<div v-loading="loading" class="premium-package-info">
<div class="header">
<div class="header-left">
<el-icon class="header-main-icon">
<TrophyBase />
</el-icon>
<div class="header-titles">
<h2 class="main-title">
尊享服务
</h2>
<p class="sub-title">
Premium Service
</p>
</div>
</div>
<el-button
type="primary"
size="default"
@click="emit('refresh')"
>
<el-icon><i-ep-refresh /></el-icon>
刷新数据
</el-button>
</div>
<!-- 套餐信息卡片 -->
<el-card class="package-card" shadow="hover">
<template #header>
<div class="card-header">
<div class="card-header-left">
<el-icon class="header-icon">
<Coin />
</el-icon>
<div class="header-text">
<span class="header-title">尊享TOKEN包总览</span>
<span class="header-subtitle">{{ packageData.packageName }}</span>
</div>
</div>
</div>
</template>
<div class="package-content">
<!-- 统计数据 -->
<div class="stats-grid">
<div class="stat-item total">
<div class="stat-label">
购买总额度
</div>
<div class="stat-value">
{{ formatNumber(packageData.totalQuota) }}
</div>
<div class="stat-unit">
Tokens
</div>
<div class="stat-raw" :title="`原始值: ${formatRawNumber(packageData.totalQuota)} Tokens`">
({{ formatRawNumber(packageData.totalQuota) }})
</div>
</div>
<div class="stat-item used">
<div class="stat-label">
已用额度
</div>
<div class="stat-value">
{{ formatNumber(packageData.usedQuota) }}
</div>
<div class="stat-unit">
Tokens
</div>
<div class="stat-raw" :title="`原始值: ${formatRawNumber(packageData.usedQuota)} Tokens`">
({{ formatRawNumber(packageData.usedQuota) }})
</div>
</div>
<div class="stat-item remaining">
<div class="stat-label">
剩余额度
</div>
<div class="stat-value">
{{ formatNumber(packageData.remainingQuota) }}
</div>
<div class="stat-unit">
Tokens
</div>
<div class="stat-raw" :title="`原始值: ${formatRawNumber(packageData.remainingQuota)} Tokens`">
({{ formatRawNumber(packageData.remainingQuota) }})
</div>
</div>
</div>
<!-- 进度条 -->
<div class="progress-section">
<div class="progress-header">
<span class="progress-label">剩余进度</span>
<span class="progress-percent" :style="{ color: progressColor }">
{{ remainingPercent }}%
</span>
</div>
<el-progress
:percentage="remainingPercent"
:color="progressColor"
:stroke-width="20"
:show-text="false"
/>
<div class="progress-legend">
<div class="legend-item">
<span class="legend-dot " :style="{ background: progressColor }" />
<span class="legend-text">剩余: {{ remainingPercent }}%</span>
</div>
<div class="legend-item">
<span class="legend-dot used-dot" />
<span class="legend-text">已使用: {{ usagePercent }}%</span>
</div>
</div>
</div>
<!-- 购买提示卡片额度不足时显示 -->
<el-card
v-if="remainingPercent < 20"
class="warning-card"
shadow="hover"
>
<div class="warning-content">
<el-icon class="warning-icon" color="#e6a23c">
<WarningFilled />
</el-icon>
<div class="warning-text">
<h3>额度即将用完</h3>
<p>您的Token额度已使用{{ usagePercent }}%剩余额度较少建议及时充值</p>
</div>
<el-button type="warning" @click="onProductPackage()">
立即充值
</el-button>
</div>
</el-card>
<!-- 过期时间 -->
<div v-if="packageData.expireDate" class="expire-info">
<el-icon><Clock /></el-icon>
<span>有效期至: {{ packageData.expireDate }}</span>
</div>
<!-- 温馨提示 -->
<el-alert
class="tips-alert"
type="info"
:closable="false"
show-icon
>
<template #title>
<div class="tips-content">
<p>温馨提示</p>
<ul>
<li>Token额度根据不同模型消耗速率不同</li>
<li>建议合理使用避免额度过快消耗</li>
<li>额度不足时请及时充值避免影响使用</li>
</ul>
</div>
</template>
</el-alert>
</div>
</el-card>
</div>
</template>
<style scoped lang="scss">
.premium-package-info {
width: 100%;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24px;
padding-bottom: 20px;
border-bottom: 2px solid #f0f2f5;
}
.header-left {
display: flex;
align-items: center;
gap: 16px;
}
.header-main-icon {
font-size: 36px;
color: #f59e0b;
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
padding: 12px;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}
.header-titles {
display: flex;
flex-direction: column;
gap: 4px;
}
.main-title {
margin: 0;
font-size: 24px;
font-weight: 700;
color: #1a1a1a;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.sub-title {
margin: 0;
font-size: 13px;
color: #909399;
font-weight: 500;
letter-spacing: 0.5px;
}
/* 套餐卡片 */
.package-card {
border-radius: 16px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
border: 1px solid #f0f2f5;
transition: all 0.3s;
&:hover {
box-shadow: 0 8px 24px rgba(102, 126, 234, 0.12);
border-color: #667eea;
}
:deep(.el-card__header) {
background: linear-gradient(to bottom, #fafbfc 0%, #ffffff 100%);
border-bottom: 2px solid #f0f2f5;
}
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
}
.card-header-left {
display: flex;
align-items: center;
gap: 12px;
}
.header-icon {
font-size: 24px;
color: #f59e0b;
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
padding: 8px;
border-radius: 8px;
}
.header-text {
display: flex;
flex-direction: column;
gap: 4px;
}
.header-title {
font-size: 18px;
font-weight: 700;
color: #1a1a1a;
}
.header-subtitle {
font-size: 13px;
color: #909399;
}
.package-content {
display: flex;
flex-direction: column;
gap: 24px;
}
/* 统计数据网格 */
.stats-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
}
.stat-item {
padding: 20px;
border-radius: 8px;
text-align: center;
transition: transform 0.2s;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.stat-item:hover {
transform: translateY(-4px);
}
.stat-item.total {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.stat-item.used {
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}
.stat-item.remaining {
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}
.stat-label {
font-size: 14px;
opacity: 0.9;
margin-bottom: 8px;
}
.stat-value {
font-size: 28px;
font-weight: 700;
margin-bottom: 4px;
}
.stat-unit {
font-size: 12px;
opacity: 0.8;
}
.stat-raw {
font-size: 11px;
opacity: 0.7;
margin-top: 4px;
cursor: help;
transition: opacity 0.2s;
}
.stat-raw:hover {
opacity: 1;
}
/* 进度条部分 */
.progress-section {
padding: 20px;
background: #f7f8fa;
border-radius: 8px;
}
.progress-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.progress-label {
font-size: 16px;
font-weight: 600;
color: #333;
}
.progress-percent {
font-size: 20px;
font-weight: 700;
}
.progress-legend {
display: flex;
justify-content: center;
gap: 24px;
margin-top: 12px;
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
}
.legend-dot {
width: 12px;
height: 12px;
border-radius: 50%;
}
.used-dot {
background: #409eff;
}
.legend-text {
font-size: 14px;
color: #606266;
}
/* 过期信息 */
.expire-info {
display: flex;
align-items: center;
gap: 8px;
padding: 12px 16px;
background: #f0f9ff;
border-radius: 6px;
color: #0369a1;
font-size: 14px;
}
/* 温馨提示 */
.tips-alert {
border-radius: 8px;
}
.tips-content p {
margin: 0 0 8px 0;
font-weight: 600;
}
.tips-content ul {
margin: 0;
padding-left: 20px;
}
.tips-content li {
margin: 4px 0;
font-size: 13px;
}
/* 警告卡片 */
.warning-card {
border-radius: 12px;
border: 2px solid #e6a23c;
background: #fef3e9;
}
.warning-content {
display: flex;
align-items: center;
gap: 16px;
}
.warning-icon {
font-size: 40px;
flex-shrink: 0;
}
.warning-text {
flex: 1;
}
.warning-text h3 {
margin: 0 0 8px 0;
color: #e6a23c;
font-size: 18px;
}
.warning-text p {
margin: 0;
color: #606266;
font-size: 14px;
}
/* 响应式布局 */
@media (max-width: 768px) {
.header {
flex-direction: column;
align-items: flex-start;
gap: 16px;
padding-bottom: 16px;
}
.header-main-icon {
font-size: 28px;
padding: 10px;
}
.main-title {
font-size: 20px;
}
.sub-title {
font-size: 12px;
}
.stats-grid {
grid-template-columns: 1fr;
gap: 12px;
}
.stat-value {
font-size: 24px;
}
.progress-legend {
flex-direction: column;
gap: 8px;
}
.warning-content {
flex-direction: column;
text-align: center;
}
.card-header-left {
gap: 10px;
}
.header-icon {
font-size: 20px;
padding: 6px;
}
.header-title {
font-size: 16px;
}
.header-subtitle {
font-size: 12px;
}
}
</style>

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { Clock, Coin, TrophyBase, WarningFilled } from '@element-plus/icons-vue';
import { getPremiumTokenPackage } from '@/api/user';
import { showProductPackage } from '@/utils/product-package.ts';
import PremiumPackageInfo from './PremiumPackageInfo.vue';
import PremiumUsageList from './PremiumUsageList.vue';
// 尊享服务数据
const loading = ref(false);
@@ -14,59 +14,8 @@ const packageData = ref<any>({
expireDate: '', // 过期时间
});
// 计算属性
const usagePercent = computed(() => {
if (packageData.value.totalQuota === 0)
return 0;
return Number(((packageData.value.usedQuota / packageData.value.totalQuota) * 100).toFixed(2));
});
const remainingPercent = computed(() => {
if (packageData.value.totalQuota === 0)
return 0;
return Number(((packageData.value.remainingQuota / packageData.value.totalQuota) * 100).toFixed(2));
});
// 获取进度条颜色(基于剩余百分比)
const progressColor = computed(() => {
const percent = remainingPercent.value;
if (percent <= 10)
return '#f56c6c'; // 红色 - 剩余很少
if (percent <= 30)
return '#e6a23c'; // 橙色 - 剩余较少
return '#67c23a'; // 绿色 - 剩余充足
});
// 格式化数字 - 转换为万为单位
function formatNumber(num: number): string {
if (num === 0)
return '0';
const wan = num / 10000;
// 保留2位小数去掉末尾的0
return wan.toFixed(2).replace(/\.?0+$/, '');
}
// 格式化原始数字(带千分位)
function formatRawNumber(num: number): string {
return num.toLocaleString();
}
/*
前端已准备好后端需要提供以下API
接口地址: GET /account/premium/token-package
返回数据格式:
{
"success": true,
"data": {
"totalQuota": 1000000, // 购买总额度
"usedQuota": 350000, // 已使用额度
"remainingQuota": 650000, // 剩余额度(可选,前端会自动计算)
"usagePercentage": 35, // 使用百分比(可选)
"packageName": "尊享VIP套餐", // 套餐名称(可选)
"expireDate": "2024-12-31" // 过期时间(可选)
}
} */
// 子组件引用
const usageListRef = ref<InstanceType<typeof PremiumUsageList>>();
// 获取尊享服务Token包数据
async function fetchPremiumTokenPackage() {
@@ -103,434 +52,86 @@ async function fetchPremiumTokenPackage() {
}
}
// 刷新数据
// 刷新所有数据
function refreshData() {
fetchPremiumTokenPackage();
usageListRef.value?.refresh();
}
onMounted(() => {
fetchPremiumTokenPackage();
});
function onProductPackage() {
showProductPackage();
}
</script>
<template>
<div v-loading="loading" class="premium-service">
<div class="header">
<h2>
<el-icon><TrophyBase /></el-icon>
尊享服务
</h2>
<el-button
type="primary"
size="small"
@click="refreshData"
>
刷新数据
</el-button>
<div class="premium-service">
<!-- 套餐信息 -->
<div data-tour="premium-package-info">
<PremiumPackageInfo
:package-data="packageData"
:loading="loading"
@refresh="refreshData"
/>
</div>
<!-- 套餐信息卡片 -->
<el-card class="package-card" shadow="hover">
<template #header>
<div class="card-header">
<el-icon class="header-icon">
<Coin />
</el-icon>
<span class="header-title">{{ packageData.packageName }}</span>
</div>
</template>
<div class="package-content">
<!-- 统计数据 -->
<div class="stats-grid">
<div class="stat-item total">
<div class="stat-label">
购买总额度
</div>
<div class="stat-value">
{{ formatNumber(packageData.totalQuota) }}
</div>
<div class="stat-unit">
Tokens
</div>
<div class="stat-raw" :title="`原始值: ${formatRawNumber(packageData.totalQuota)} Tokens`">
({{ formatRawNumber(packageData.totalQuota) }})
</div>
</div>
<div class="stat-item used">
<div class="stat-label">
已用额度
</div>
<div class="stat-value">
{{ formatNumber(packageData.usedQuota) }}
</div>
<div class="stat-unit">
Tokens
</div>
<div class="stat-raw" :title="`原始值: ${formatRawNumber(packageData.usedQuota)} Tokens`">
({{ formatRawNumber(packageData.usedQuota) }})
</div>
</div>
<div class="stat-item remaining">
<div class="stat-label">
剩余额度
</div>
<div class="stat-value">
{{ formatNumber(packageData.remainingQuota) }}
</div>
<div class="stat-unit">
Tokens
</div>
<div class="stat-raw" :title="`原始值: ${formatRawNumber(packageData.remainingQuota)} Tokens`">
({{ formatRawNumber(packageData.remainingQuota) }})
</div>
</div>
</div>
<!-- 进度条 -->
<div class="progress-section">
<div class="progress-header">
<span class="progress-label">剩余进度</span>
<span class="progress-percent" :style="{ color: progressColor }">
{{ remainingPercent }}%
</span>
</div>
<el-progress
:percentage="remainingPercent"
:color="progressColor"
:stroke-width="20"
:show-text="false"
/>
<div class="progress-legend">
<div class="legend-item">
<span class="legend-dot " :style="{ background: progressColor }" />
<span class="legend-text">剩余: {{ remainingPercent }}%</span>
</div>
<div class="legend-item">
<span class="legend-dot used-dot" />
<span class="legend-text">已使用: {{ usagePercent }}%</span>
</div>
</div>
</div>
<!-- 购买提示卡片额度不足时显示 -->
<el-card
v-if="remainingPercent < 20"
class="warning-card"
shadow="hover"
>
<div class="warning-content">
<el-icon class="warning-icon" color="#e6a23c">
<WarningFilled />
</el-icon>
<div class="warning-text">
<h3>额度即将用完</h3>
<p>您的Token额度已使用{{ usagePercent }}%剩余额度较少建议及时充值</p>
</div>
<el-button type="warning" @click="onProductPackage()">
立即充值
</el-button>
</div>
</el-card>
<!-- 过期时间 -->
<div v-if="packageData.expireDate" class="expire-info">
<el-icon><Clock /></el-icon>
<span>有效期至: {{ packageData.expireDate }}</span>
</div>
<!-- 温馨提示 -->
<el-alert
class="tips-alert"
type="info"
:closable="false"
show-icon
>
<template #title>
<div class="tips-content">
<p>温馨提示</p>
<ul>
<li>Token额度根据不同模型消耗速率不同</li>
<li>建议合理使用避免额度过快消耗</li>
<li>额度不足时请及时充值避免影响使用</li>
</ul>
</div>
</template>
</el-alert>
</div>
</el-card>
<!-- 额度明细列表 -->
<div class="usage-list-wrapper" data-tour="premium-usage-list">
<PremiumUsageList ref="usageListRef" />
</div>
</div>
</template>
<style scoped>
<style scoped lang="scss">
.premium-service {
padding: 20px;
position: relative;
padding: 24px;
height: 100%;
overflow-y: auto;
background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
// 美化滚动条
&::-webkit-scrollbar {
width: 8px;
}
&::-webkit-scrollbar-track {
background: #f1f3f5;
border-radius: 4px;
}
&::-webkit-scrollbar-thumb {
background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
border-radius: 4px;
&:hover {
background: linear-gradient(180deg, #5568d3 0%, #65408b 100%);
}
}
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
.usage-list-wrapper {
margin-top: 24px;
animation: slideInUp 0.4s ease-out;
}
.header h2 {
display: flex;
align-items: center;
margin: 0;
font-size: 20px;
color: #333;
}
.header .el-icon {
margin-right: 8px;
color: #f59e0b;
}
/* 套餐卡片 */
.package-card {
margin-bottom: 20px;
border-radius: 12px;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}
.card-header {
display: flex;
align-items: center;
gap: 8px;
font-size: 18px;
font-weight: 600;
color: #333;
}
.header-icon {
font-size: 20px;
color: #f59e0b;
}
.package-content {
display: flex;
flex-direction: column;
gap: 24px;
}
/* 统计数据网格 */
.stats-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
}
.stat-item {
padding: 20px;
border-radius: 8px;
text-align: center;
transition: transform 0.2s;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.stat-item:hover {
transform: translateY(-4px);
}
.stat-item.total {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.stat-item.used {
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}
.stat-item.remaining {
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}
.stat-label {
font-size: 14px;
opacity: 0.9;
margin-bottom: 8px;
}
.stat-value {
font-size: 28px;
font-weight: 700;
margin-bottom: 4px;
}
.stat-unit {
font-size: 12px;
opacity: 0.8;
}
.stat-raw {
font-size: 11px;
opacity: 0.7;
margin-top: 4px;
cursor: help;
transition: opacity 0.2s;
}
.stat-raw:hover {
opacity: 1;
}
/* 进度条部分 */
.progress-section {
padding: 20px;
background: #f7f8fa;
border-radius: 8px;
}
.progress-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.progress-label {
font-size: 16px;
font-weight: 600;
color: #333;
}
.progress-percent {
font-size: 20px;
font-weight: 700;
}
.progress-legend {
display: flex;
justify-content: center;
gap: 24px;
margin-top: 12px;
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
}
.legend-dot {
width: 12px;
height: 12px;
border-radius: 50%;
}
.used-dot {
background: #409eff;
}
.remaining-dot {
background: #e4e7ed;
}
.legend-text {
font-size: 14px;
color: #606266;
}
/* 过期信息 */
.expire-info {
display: flex;
align-items: center;
gap: 8px;
padding: 12px 16px;
background: #f0f9ff;
border-radius: 6px;
color: #0369a1;
font-size: 14px;
}
/* 温馨提示 */
.tips-alert {
border-radius: 8px;
}
.tips-content p {
margin: 0 0 8px 0;
font-weight: 600;
}
.tips-content ul {
margin: 0;
padding-left: 20px;
}
.tips-content li {
margin: 4px 0;
font-size: 13px;
}
/* 警告卡片 */
.warning-card {
border-radius: 12px;
border: 2px solid #e6a23c;
background: #fef3e9;
}
.warning-content {
display: flex;
align-items: center;
gap: 16px;
}
.warning-icon {
font-size: 40px;
flex-shrink: 0;
}
.warning-text {
flex: 1;
}
.warning-text h3 {
margin: 0 0 8px 0;
color: #e6a23c;
font-size: 18px;
}
.warning-text p {
margin: 0;
color: #606266;
font-size: 14px;
@keyframes slideInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* 响应式布局 */
@media (max-width: 768px) {
.premium-service {
padding: 10px;
padding: 12px;
}
.stats-grid {
grid-template-columns: 1fr;
gap: 12px;
}
.stat-value {
font-size: 24px;
}
.progress-legend {
flex-direction: column;
gap: 8px;
}
.warning-content {
flex-direction: column;
text-align: center;
.usage-list-wrapper {
margin-top: 16px;
}
}
</style>

View File

@@ -0,0 +1,826 @@
<script lang="ts" setup>
import type { PremiumTokenUsageDto, PremiumTokenUsageQueryParams } from '@/api/user';
import { Clock, Refresh } from '@element-plus/icons-vue';
import { getPremiumTokenUsageList } from '@/api/user';
// 额度明细列表
const usageList = ref<PremiumTokenUsageDto[]>([]);
const listLoading = ref(false);
const totalCount = ref(0);
// 查询参数
const queryParams = ref<PremiumTokenUsageQueryParams>({
skipCount: 0,
maxResultCount: 10,
});
// 当前页码
const currentPage = ref(1);
const pageSize = ref(10);
// 筛选条件
const dateRange = ref<[Date, Date] | null>(null);
const freeFilter = ref<boolean | null>(null);
// 快捷时间选择
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 formatNumber(num: number): string {
if (num === 0)
return '0';
const wan = num / 10000;
return wan.toFixed(2).replace(/\.?0+$/, '');
}
// 格式化日期时间
function formatDateTime(dateTime: string): string {
return new Date(dateTime).toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
});
}
// 获取使用率颜色
function getUsageColor(used: number, total: number): string {
if (total === 0)
return '#e4e7ed';
const percent = (used / total) * 100;
if (percent >= 90)
return '#f56c6c'; // 红色
if (percent >= 70)
return '#e6a23c'; // 橙色
return '#409eff'; // 蓝色
}
// 获取额度明细列表
async function fetchUsageList(resetPage = false) {
if (resetPage) {
currentPage.value = 1;
}
listLoading.value = true;
try {
const params: PremiumTokenUsageQueryParams = {
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,
};
console.log('发送到后端的参数:', params);
const res = await getPremiumTokenUsageList(params);
console.log('后端返回结果:', res);
if (res.data) {
usageList.value = res.data.items || [];
totalCount.value = res.data.totalCount || 0;
}
}
catch (error) {
console.error('获取额度明细列表失败:', error);
ElMessage.error('获取额度明细列表失败');
usageList.value = [];
totalCount.value = 0;
}
finally {
listLoading.value = false;
}
}
// 处理分页
function handlePageChange(page: number) {
console.log('切换页码:', page);
currentPage.value = page;
fetchUsageList();
}
// 处理每页大小变化
function handleSizeChange(size: number) {
console.log('修改每页大小:', size);
pageSize.value = size;
queryParams.value.maxResultCount = size;
currentPage.value = 1;
fetchUsageList();
}
// 处理排序(使用 OrderByColumn 和 IsAsc
function handleSortChange({ prop, order }: { prop: string; order: string | null }) {
console.log('排序变化:', { prop, order });
if (order) {
queryParams.value.orderByColumn = prop;
queryParams.value.isAsc = order === 'ascending' ? 'ascending' : 'descending';
}
else {
queryParams.value.orderByColumn = undefined;
queryParams.value.isAsc = undefined;
}
fetchUsageList(true);
}
// 处理时间筛选
function handleDateChange(value: [Date, Date] | null) {
console.log('时间筛选变化:', value);
if (value && value.length === 2) {
// 设置开始时间为当天00:00:00
const startDate = new Date(value[0]);
startDate.setHours(0, 0, 0, 0);
// 设置结束时间为当天23:59:59
const endDate = new Date(value[1]);
endDate.setHours(23, 59, 59, 999);
queryParams.value.startTime = startDate.toISOString();
queryParams.value.endTime = endDate.toISOString();
console.log('时间范围:', {
start: queryParams.value.startTime,
end: queryParams.value.endTime,
});
}
else {
queryParams.value.startTime = undefined;
queryParams.value.endTime = undefined;
}
fetchUsageList(true); // 重置到第一页并获取数据
}
// 重置筛选
function resetFilters() {
console.log('重置所有筛选条件');
dateRange.value = null;
freeFilter.value = null;
// 重置后端查询参数
queryParams.value = {
maxResultCount: pageSize.value,
orderByColumn: undefined,
isAsc: undefined,
startTime: undefined,
endTime: undefined,
isFree: undefined,
};
fetchUsageList(true);
}
// 处理是否免费筛选
function handleFreeFilterChange(value: boolean | null) {
console.log('是否免费筛选:', value);
queryParams.value.isFree = value === null ? undefined : value;
fetchUsageList(true);
}
// 判断是否有活动的筛选条件
const hasActiveFilters = computed(() => {
return !!dateRange.value || freeFilter.value !== null;
});
// 对外暴露刷新方法
defineExpose({
refresh: fetchUsageList,
});
onMounted(() => {
fetchUsageList();
});
</script>
<template>
<el-card v-loading="listLoading" class="usage-list-card" shadow="hover">
<template #header>
<div class="list-header">
<div class="header-left">
<el-icon class="header-icon">
<i-ep-document />
</el-icon>
<div class="header-text">
<span class="header-title">尊享包额度明细</span>
<!-- <span class="header-subtitle">Premium Package Usage Details</span> -->
</div>
</div>
<div class="header-right">
<el-tag v-if="totalCount > 0" type="primary" size="default" class="count-tag" effect="plain">
<el-icon><i-ep-data-line /></el-icon>
{{ totalCount }} 条记录
</el-tag>
</div>
</div>
</template>
<!-- 筛选工具栏 -->
<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-actions">
<el-button
v-if="hasActiveFilters"
size="default"
@click="resetFilters"
>
<el-icon><i-ep-refresh-left /></el-icon>
重置
</el-button>
<el-button
type="primary"
size="default"
:icon="Refresh"
@click="fetchUsageList"
>
刷新
</el-button>
</div>
</div>
</div>
<!-- 数据表格 -->
<el-table
:data="usageList"
stripe
class="usage-table"
empty-text="暂无数据"
border
@sort-change="handleSortChange"
>
<el-table-column prop="packageName" label="包名称" min-width="200" sortable show-overflow-tooltip align="center" header-align="center" resizable>
<template #default="{ row }">
<div class="package-name-cell">
<el-icon class="package-icon" color="#409eff">
<i-ep-box />
</el-icon>
<span>{{ row.packageName }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="总额度" min-width="130" prop="totalTokens" sortable align="center" header-align="center" resizable>
<template #default="{ row }">
<div class="token-cell">
<span class="token-value">{{ formatNumber(row.totalTokens) }}</span>
<span class="token-unit"></span>
</div>
</template>
</el-table-column>
<el-table-column label="已使用" min-width="130" prop="usedTokens" sortable align="center" header-align="center" resizable>
<template #default="{ row }">
<div class="token-cell used">
<span class="token-value">{{ formatNumber(row.usedTokens) }}</span>
<span class="token-unit"></span>
</div>
</template>
</el-table-column>
<el-table-column label="剩余" min-width="130" prop="remainingTokens" sortable align="center" header-align="center" resizable>
<template #default="{ row }">
<div class="token-cell remaining">
<span
class="token-value"
:style="{ color: row.remainingTokens > 0 ? '#67c23a' : '#f56c6c', fontWeight: '600' }"
>
{{ formatNumber(row.remainingTokens) }}
</span>
<span class="token-unit"></span>
</div>
</template>
</el-table-column>
<el-table-column label="使用率" min-width="130" align="center" header-align="center" resizable>
<template #default="{ row }">
<div class="usage-progress-cell">
<el-progress
:percentage="row.totalTokens > 0 ? Number(((row.usedTokens / row.totalTokens) * 100).toFixed(1)) : 0"
:color="getUsageColor(row.usedTokens, row.totalTokens)"
:stroke-width="8"
:show-text="true"
:text-inside="false"
>
<template #default="{ percentage }">
<span class="percentage-text">{{ percentage }}%</span>
</template>
</el-progress>
</div>
</template>
</el-table-column>
<el-table-column label="购买金额" min-width="110" prop="purchaseAmount" sortable align="center" header-align="center" resizable>
<template #default="{ row }">
<span class="amount-cell">¥{{ row.purchaseAmount.toFixed(2) }}</span>
</template>
</el-table-column>
<el-table-column label="状态" min-width="90" prop="isActive" sortable align="center" header-align="center" resizable>
<template #default="{ row }">
<el-tag :type="row.isActive ? 'success' : 'info'" size="small" effect="dark">
{{ row.isActive ? '激活' : '未激活' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="创建时间" min-width="170" prop="creationTime" sortable align="center" header-align="center" resizable>
<template #default="{ row }">
<div v-if="row.creationTime" class="creation-cell">
<el-icon class="creation-icon">
<Clock />
</el-icon>
<span>{{ formatDateTime(row.creationTime) }}</span>
</div>
<span v-else class="no-data">-</span>
</template>
</el-table-column>
<el-table-column label="到期时间" min-width="170" prop="expireDateTime" sortable align="center" header-align="center" resizable>
<template #default="{ row }">
<div v-if="row.expireDateTime" class="expire-cell">
<el-icon class="expire-icon">
<Clock />
</el-icon>
<span>{{ formatDateTime(row.expireDateTime) }}</span>
</div>
<span v-else class="no-data">-</span>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" min-width="150" show-overflow-tooltip align="center" header-align="center" resizable>
<template #default="{ row }">
<span class="remark-cell">{{ row.remark || '-' }}</span>
</template>
</el-table-column>
</el-table>
<!-- 空状态 -->
<div v-if="!usageList.length && !listLoading" 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-card>
</template>
<style scoped lang="scss">
/* 额度明细列表卡片 */
.usage-list-card {
border-radius: 16px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
border: 1px solid #f0f2f5;
transition: all 0.3s;
&:hover {
box-shadow: 0 8px 24px rgba(102, 126, 234, 0.12);
border-color: #667eea;
}
:deep(.el-card__header) {
background: linear-gradient(to bottom, #fafbfc 0%, #ffffff 100%);
border-bottom: 2px solid #f0f2f5;
}
}
.list-header {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}
.list-header .header-left {
display: flex;
align-items: center;
gap: 12px;
}
.header-icon {
font-size: 24px;
color: #f59e0b;
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
padding: 8px;
border-radius: 8px;
}
.header-text {
display: flex;
flex-direction: column;
gap: 4px;
}
.header-title {
font-size: 18px;
font-weight: 700;
color: #1a1a1a;
}
.header-subtitle {
font-size: 13px;
color: #909399;
}
.header-right {
display: flex;
align-items: center;
gap: 12px;
}
.count-tag {
display: flex;
align-items: center;
gap: 6px;
padding: 6px 16px;
font-weight: 600;
border-radius: 20px;
.el-icon {
font-size: 14px;
}
}
/* 筛选工具栏 */
.filter-toolbar {
margin-bottom: 20px;
padding: 20px;
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-tip {
display: flex;
align-items: center;
gap: 6px;
margin-top: 12px;
padding: 8px 12px;
background: #fff;
border-radius: 4px;
font-size: 13px;
color: #606266;
border-left: 3px solid #409eff;
}
.filter-item {
flex: 0 0 auto;
}
.date-picker {
width: 320px;
}
.free-select {
width: 140px;
}
.filter-actions {
margin-left: auto;
display: flex;
gap: 8px;
}
/* 表格样式 */
.usage-table {
width: 100%;
}
.package-name-cell {
display: flex;
align-items: center;
gap: 8px;
}
.package-icon {
font-size: 16px;
flex-shrink: 0;
}
.usage-progress-cell {
display: flex;
align-items: center;
gap: 8px;
padding: 0 12px;
}
.usage-progress-cell :deep(.el-progress) {
flex: 1;
}
.usage-progress-cell :deep(.el-progress__text) {
font-size: 13px !important;
font-weight: 600;
min-width: 45px;
text-align: right;
}
.percentage-text {
font-size: 13px;
font-weight: 600;
}
.token-cell {
display: flex;
align-items: baseline;
gap: 4px;
justify-content: center;
}
.token-value {
font-size: 14px;
font-weight: 500;
color: #303133;
}
.token-unit {
font-size: 12px;
color: #909399;
}
.amount-cell {
font-weight: 600;
color: #f56c6c;
}
.creation-cell {
display: flex;
align-items: center;
gap: 6px;
color: #606266;
}
.creation-icon {
font-size: 14px;
color: #67c23a;
}
.expire-cell {
display: flex;
align-items: center;
gap: 6px;
color: #606266;
}
.expire-icon {
font-size: 14px;
color: #909399;
}
.remark-cell {
color: #606266;
font-size: 13px;
}
.no-data {
color: #c0c4cc;
}
/* 空状态 */
.empty-container {
padding: 40px 0;
}
/* 分页容器 */
.pagination-container {
margin-top: 20px;
padding: 20px 0;
display: flex;
justify-content: center;
border-top: 2px solid #f0f2f5;
:deep(.el-pagination) {
gap: 8px;
.btn-prev,
.btn-next {
border-radius: 8px;
padding: 0 16px;
border: 1px solid #dcdfe6;
background: #fff;
font-weight: 500;
&:hover {
color: #667eea;
border-color: #667eea;
background: #f5f7fa;
}
}
.el-pager li {
border-radius: 8px;
min-width: 36px;
height: 36px;
line-height: 36px;
border: 1px solid transparent;
transition: all 0.3s;
&:hover {
color: #667eea;
background: #f5f7fa;
}
&.is-active {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #fff;
border-color: transparent;
}
}
.el-pagination__sizes {
.el-select {
.el-input__wrapper {
border-radius: 8px;
}
}
}
.el-pagination__jump {
.el-input__wrapper {
border-radius: 8px;
}
}
}
}
/* 响应式布局 */
@media (max-width: 768px) {
.list-header {
flex-direction: column;
align-items: flex-start;
gap: 12px;
}
.header-icon {
font-size: 20px;
padding: 6px;
}
.header-title {
font-size: 16px;
}
.header-subtitle {
font-size: 12px;
}
.header-right {
width: 100%;
}
.count-tag {
width: 100%;
justify-content: center;
}
/* 移动端筛选工具栏 */
.filter-toolbar {
padding: 16px;
}
.filter-row {
flex-direction: column;
align-items: stretch;
gap: 10px;
}
.filter-item {
width: 100%;
}
.date-picker,
.free-select {
width: 100%;
}
.filter-actions {
margin-left: 0;
display: flex;
gap: 8px;
}
.filter-actions .el-button {
flex: 1;
}
/* 移动端分页 */
.pagination-container {
padding: 16px 0;
}
.pagination-container :deep(.el-pagination) {
flex-wrap: wrap;
justify-content: center;
gap: 6px;
.btn-prev,
.btn-next {
padding: 0 12px;
font-size: 13px;
}
.el-pager li {
min-width: 32px;
height: 32px;
line-height: 32px;
font-size: 13px;
}
}
}
/* 平板适配 */
@media (min-width: 769px) and (max-width: 1024px) {
.filter-row {
gap: 10px;
}
.search-input {
width: 180px;
}
.date-picker {
width: 280px;
}
}
</style>

View File

@@ -0,0 +1,301 @@
import type { Activity, Announcement, CarouselItem, SystemAnnouncementResponse } from '@/api'
/**
* 模拟数据 - 系统公告
* 这些数据可以用于开发和测试实际使用时应从后端API获取
*/
// 轮播图数据
export const mockCarousels: CarouselItem[] = [
{
id: 1,
imageUrl: 'https://images.unsplash.com/photo-1607827448387-a67db1383b59?w=800&h=400&fit=crop',
title: '新年特惠活动',
link: '/activity/1',
},
{
id: 2,
imageUrl: 'https://images.unsplash.com/photo-1557683316-973673baf926?w=800&h=400&fit=crop',
title: '新功能上线',
link: '/activity/2',
},
{
id: 3,
imageUrl: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=800&h=400&fit=crop',
title: '限时优惠',
link: '/activity/3',
},
]
// 活动数据
export const mockActivities: Activity[] = [
{
id: 1,
title: '新年特惠活动',
description: '参与新年特惠活动即可获得丰厚奖励。活动期间充值即送额外积分最高可获得50%额外积分奖励!',
content: `
<h2>活动详情</h2>
<p>为了感谢各位用户的支持,我们特别推出新年特惠活动!</p>
<h3>活动时间</h3>
<p>2025年1月1日 00:00 - 2025年1月31日 23:59</p>
<h3>活动规则</h3>
<ul>
<li>充值满100元赠送10%积分</li>
<li>充值满500元赠送20%积分</li>
<li>充值满1000元赠送30%积分</li>
<li>充值满5000元赠送50%积分</li>
</ul>
<h3>注意事项</h3>
<ol>
<li>每个用户在活动期间最多可参与5次</li>
<li>赠送的积分将在充值成功后24小时内到账</li>
<li>本活动最终解释权归平台所有</li>
</ol>
<blockquote>
机会难得,不要错过!
</blockquote>
`,
coverImage: 'https://images.unsplash.com/photo-1607827448387-a67db1383b59?w=1200&h=600&fit=crop',
startTime: '2025-01-01T00:00:00Z',
endTime: '2025-01-31T23:59:59Z',
status: 'active',
createdAt: '2024-12-25T10:00:00Z',
updatedAt: '2024-12-26T15:30:00Z',
},
{
id: 2,
title: 'AI功能免费体验',
description: '全新AI功能上线限时免费体验。包括智能对话、图像生成、代码辅助等多项功能。',
content: `
<h2>新功能介绍</h2>
<p>我们很高兴地宣布全新的AI功能已经正式上线</p>
<h3>功能亮点</h3>
<ul>
<li><strong>智能对话</strong>: 更自然的对话体验,支持上下文理解</li>
<li><strong>图像生成</strong>: 通过文字描述生成精美图片</li>
<li><strong>代码辅助</strong>: 智能代码补全和错误检测</li>
<li><strong>文档分析</strong>: 快速提取文档关键信息</li>
</ul>
<h3>体验时间</h3>
<p>2025年1月1日 - 2025年2月28日</p>
<p>在体验期间,所有功能完全免费使用!</p>
`,
coverImage: 'https://images.unsplash.com/photo-1557683316-973673baf926?w=1200&h=600&fit=crop',
startTime: '2025-01-01T00:00:00Z',
endTime: '2025-02-28T23:59:59Z',
status: 'active',
createdAt: '2024-12-28T08:00:00Z',
updatedAt: '2024-12-28T08:00:00Z',
},
{
id: 3,
title: '推荐好友得奖励',
description: '邀请好友注册使用,双方均可获得积分奖励。推荐越多,奖励越多!',
content: `
<h2>推荐计划</h2>
<p>邀请您的朋友一起体验我们的服务,双方都能获得丰厚奖励!</p>
<h3>奖励规则</h3>
<ul>
<li>好友通过您的邀请链接注册您和好友各得50积分</li>
<li>好友首次充值您额外获得其充值金额10%的积分</li>
<li>推荐5位好友额外奖励200积分</li>
<li>推荐10位好友额外奖励500积分</li>
</ul>
<h3>如何参与</h3>
<ol>
<li>登录您的账户</li>
<li>进入"推荐好友"页面</li>
<li>复制您的专属邀请链接</li>
<li>分享给您的朋友</li>
</ol>
`,
status: 'active',
createdAt: '2024-12-20T10:00:00Z',
},
]
// 公告数据
export const mockAnnouncements: Announcement[] = [
{
id: 1,
title: '系统维护升级公告',
content: `
<p>尊敬的用户:</p>
<p>为了给您提供更好的服务体验,我们计划于<strong>2025年1月10日 22:00 - 2025年1月11日 02:00</strong>对系统进行维护升级。</p>
<h3>维护内容</h3>
<ul>
<li>优化系统性能,提升响应速度</li>
<li>修复已知问题</li>
<li>更新安全补丁</li>
<li>新增部分功能</li>
</ul>
<h3>影响范围</h3>
<p>维护期间,系统将暂时无法访问,给您带来不便敬请谅解。</p>
<p>如有紧急问题请联系客服service@example.com</p>
<p>感谢您的理解与支持!</p>
`,
type: 'latest',
isImportant: true,
publishTime: '2025-01-05T10:00:00Z',
createdAt: '2025-01-05T09:30:00Z',
},
{
id: 2,
title: '隐私政策更新通知',
content: `
<p>尊敬的用户:</p>
<p>我们更新了隐私政策,新政策将于<strong>2025年1月15日</strong>生效。</p>
<h3>主要变更</h3>
<ul>
<li>明确了数据收集和使用范围</li>
<li>增加了用户数据控制权说明</li>
<li>完善了第三方数据共享规则</li>
</ul>
<p>详细内容请查看完整的<a href="/privacy-policy" target="_blank">隐私政策</a>。</p>
<p>如有疑问,欢迎联系我们。</p>
`,
type: 'latest',
isImportant: false,
publishTime: '2025-01-03T14:00:00Z',
createdAt: '2025-01-03T13:30:00Z',
},
{
id: 3,
title: 'API接口升级通知',
content: `
<p>开发者们注意:</p>
<p>我们的API接口将进行版本升级新版本为<code>v2.0</code>。</p>
<h3>升级时间</h3>
<p>2025年2月1日</p>
<h3>主要变化</h3>
<ul>
<li>优化了响应数据结构</li>
<li>新增多个端点</li>
<li>提升了并发处理能力</li>
</ul>
<p>旧版本API将继续维护至2025年6月1日。</p>
`,
type: 'history',
isImportant: false,
publishTime: '2024-12-28T10:00:00Z',
createdAt: '2024-12-28T09:00:00Z',
},
{
id: 4,
title: '新年假期客服安排',
content: `
<p>尊敬的用户:</p>
<p>新年假期期间1月1日-1月3日客服工作时间调整为</p>
<ul>
<li>在线客服10:00 - 18:00</li>
<li>邮件客服:正常响应,回复时间可能延迟</li>
</ul>
<p>1月4日起恢复正常工作时间。</p>
`,
type: 'history',
isImportant: false,
publishTime: '2024-12-25T15:00:00Z',
createdAt: '2024-12-25T14:00:00Z',
},
{
id: 5,
title: '用户协议更新',
content: `
<p>我们更新了用户服务协议,主要涉及:</p>
<ul>
<li>账户安全责任条款</li>
<li>服务使用规范</li>
<li>争议解决方式</li>
</ul>
<p>继续使用服务即表示您同意新的用户协议。</p>
`,
type: 'history',
isImportant: false,
publishTime: '2024-12-20T10:00:00Z',
createdAt: '2024-12-20T09:00:00Z',
},
]
// 完整的系统公告响应数据
export const mockSystemAnnouncementData: SystemAnnouncementResponse = {
carousels: mockCarousels,
activities: mockActivities,
announcements: mockAnnouncements,
}
/**
* 模拟API延迟
*/
export function mockDelay(ms: number = 500): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms))
}
/**
* 模拟获取系统公告API
*/
export async function getMockSystemAnnouncements(): Promise<{ data: SystemAnnouncementResponse }> {
await mockDelay()
return { data: mockSystemAnnouncementData }
}
/**
* 模拟获取活动详情API
*/
export async function getMockActivityDetail(id: string | number) {
await mockDelay()
const activity = mockActivities.find(a => a.id.toString() === id.toString())
if (!activity) {
throw new Error('活动不存在')
}
return {
data: {
...activity,
views: Math.floor(Math.random() * 10000) + 1000,
participantCount: Math.floor(Math.random() * 1000) + 100,
},
}
}
/**
* 模拟获取公告详情API
*/
export async function getMockAnnouncementDetail(id: string | number) {
await mockDelay()
const announcement = mockAnnouncements.find(a => a.id.toString() === id.toString())
if (!announcement) {
throw new Error('公告不存在')
}
return {
data: {
...announcement,
views: Math.floor(Math.random() * 10000) + 1000,
},
}
}

View File

@@ -0,0 +1,334 @@
import { driver } from 'driver.js';
import { useGuideTourStore } from '@/stores';
import 'driver.js/dist/driver.css';
// 引导步骤接口
interface TourStep {
element: string;
popover: {
title: string;
description: string;
side?: 'top' | 'right' | 'bottom' | 'left';
align?: 'start' | 'center' | 'end';
};
onHighlightStarted?: () => void;
onDeselected?: () => void;
}
export function useGuideTour() {
const guideTourStore = useGuideTourStore();
// 创建 driver 实例
const driverInstance = ref<ReturnType<typeof driver> | null>(null);
// 初始化 driver
function initDriver() {
driverInstance.value = driver({
showProgress: true,
animate: true,
allowClose: true,
overlayClickNext: false,
stagePadding: 10,
stageRadius: 8,
popoverClass: 'guide-tour-popover',
nextBtnText: '下一步',
prevBtnText: '上一步',
doneBtnText: '完成',
progressText: '{{current}} / {{total}}',
onDestroyed: () => {
guideTourStore.setCurrentPhase('idle');
},
});
}
// Header 区域引导步骤(包含聊天功能)
const headerSteps: TourStep[] = [
{
element: '[data-tour="tutorial-btn"]',
popover: {
title: '新手教程',
description: '欢迎使用意心AI-YiXinAI点击这里可以随时重新查看新手引导教程帮助您快速了解系统功能。',
side: 'bottom',
align: 'center',
},
},
{
element: '[data-tour="model-select"]',
popover: {
title: '模型选择',
description: '点击这里可以切换不同的AI模型每个模型有不同的特点和能力。VIP用户可以更多高级模型。',
side: 'top',
align: 'start',
},
},
{
element: '[data-tour="chat-sender"]',
popover: {
title: '对话输入框',
description: '在这里输入您的问题或指令按回车或点击发送按钮即可与AI对话。支持语音输入',
side: 'top',
align: 'center',
},
},
{
element: '[data-tour="announcement-btn"]',
popover: {
title: '公告/活动',
description: '这里会显示系统公告和最新活动信息,请及时查看以获取重要通知和福利活动。',
side: 'bottom',
align: 'center',
},
},
{
element: '[data-tour="ai-tutorial-link"]',
popover: {
title: 'AI使用教程',
description: '点击这里可以跳转到YiXinAI玩法指南专栏学习更多AI使用技巧和最佳实践。',
side: 'bottom',
align: 'center',
},
},
{
element: '[data-tour="buy-btn"]',
popover: {
title: '立即购买',
description: '点击这里可以成为VIP会员和升级尊享服务享受更多专属服务和权益。',
side: 'bottom',
align: 'center',
},
},
{
element: '[data-tour="user-avatar"]',
popover: {
title: '用户中心',
description: '点击头像可以进入用户中心管理您的账户信息、查看使用统计、API密钥等。接下来将为您详细介绍用户中心的各项功能。',
side: 'bottom',
align: 'end',
},
},
];
// 用户中心弹窗引导步骤
const userCenterSteps: TourStep[] = [
{
element: '[data-tour="user-nav-menu"]',
popover: {
title: '导航菜单',
description: '左侧是功能导航菜单,您可以切换不同的功能模块。接下来我们将逐一介绍各个功能。',
side: 'right',
align: 'start',
},
},
{
element: '[data-tour="nav-user"]',
popover: {
title: '用户信息',
description: '查看您的个人信息,包括头像、昵称等。',
side: 'right',
align: 'center',
},
onHighlightStarted: () => {
guideTourStore.changeUserCenterNav('user');
},
},
{
element: '[data-tour="nav-apiKey"]',
popover: {
title: 'API密钥',
description: '管理您的API密钥用于第三方接入和开发集成。',
side: 'right',
align: 'center',
},
onHighlightStarted: () => {
guideTourStore.changeUserCenterNav('apiKey');
},
},
{
element: '[data-tour="nav-rechargeLog"]',
popover: {
title: '充值记录',
description: '查看您的充值历史和交易记录,了解消费明细。',
side: 'right',
align: 'center',
},
onHighlightStarted: () => {
guideTourStore.changeUserCenterNav('rechargeLog');
},
},
{
element: '[data-tour="nav-usageStatistics"]',
popover: {
title: '用量统计',
description: '查看您的AI模型使用情况和消费统计掌握使用详情。',
side: 'right',
align: 'center',
},
onHighlightStarted: () => {
guideTourStore.changeUserCenterNav('usageStatistics');
},
},
{
element: '[data-tour="nav-premiumService"]',
popover: {
title: '尊享服务',
description: '了解尊享服务包专属特权和服务,我们将详细介绍这个页面的功能。',
side: 'right',
align: 'center',
},
onHighlightStarted: () => {
guideTourStore.changeUserCenterNav('premiumService');
},
},
{
element: '[data-tour="premium-package-info"]',
popover: {
title: '套餐信息',
description: '这里显示您的尊享服务套餐详情,包括总额度、已使用额度、剩余额度等信息。',
side: 'left',
align: 'start',
},
},
{
element: '[data-tour="premium-usage-list"]',
popover: {
title: '额度明细列表',
description: '查看您的额度使用明细记录,包括每次使用的时间、消耗的额度等详细信息。',
side: 'left',
align: 'start',
},
},
{
element: '[data-tour="nav-dailyTask"]',
popover: {
title: '每日任务',
description: '完成每日任务获取额外奖励,提升您的使用体验。',
side: 'right',
align: 'center',
},
onHighlightStarted: () => {
guideTourStore.changeUserCenterNav('dailyTask');
},
},
{
element: '[data-tour="nav-cardFlip"]',
popover: {
title: '每周邀请',
description: '邀请好友加入,获得丰厚奖励。接下来将详细介绍这个页面的各项功能。',
side: 'right',
align: 'center',
},
onHighlightStarted: () => {
guideTourStore.changeUserCenterNav('cardFlip');
},
},
{
element: '[data-tour="card-flip-area"]',
popover: {
title: '每周免费翻牌',
description: '每周您有10次免费翻牌机会前7次为基础免费次数。翻牌可获得Token奖励幸运值随着翻牌次数增加而提升。',
side: 'left',
align: 'start',
},
},
{
element: '[data-tour="use-invite-code-btn"]',
popover: {
title: '使用邀请码',
description: '输入好友的邀请码双方各增加1次翻牌机会填写邀请码后第8-10次翻牌必定中奖每次奖励最大额度翻倍',
side: 'left',
align: 'center',
},
},
{
element: '[data-tour="my-invite-code-btn"]',
popover: {
title: '我的邀请码',
description: '生成您的专属邀请码分享给好友。好友使用您的邀请码后双方各获得1次额外翻牌机会。您可以复制邀请码或分享带邀请码的链接。',
side: 'left',
align: 'center',
},
},
];
// 开始 Header 引导
async function startHeaderTour() {
if (!driverInstance.value) {
initDriver();
}
guideTourStore.setCurrentPhase('header');
// 等待 DOM 更新
await nextTick();
// 配置完成回调,触发用户中心引导
driverInstance.value?.setConfig({
onDestroyStarted: () => {
if (!driverInstance.value?.hasNextStep()) {
// Header 引导完成,触发打开用户中心弹窗
guideTourStore.triggerUserCenterTour();
}
driverInstance.value?.destroy();
},
});
driverInstance.value?.setSteps(headerSteps);
driverInstance.value?.drive();
}
// 开始用户中心引导
async function startUserCenterTour() {
if (!driverInstance.value) {
initDriver();
}
guideTourStore.setCurrentPhase('userCenter');
// 等待弹窗完全打开
await new Promise(resolve => setTimeout(resolve, 500));
// 配置完成回调,关闭弹窗并标记引导完成
driverInstance.value?.setConfig({
onDestroyStarted: () => {
if (!driverInstance.value?.hasNextStep()) {
// 用户中心引导完成,先关闭弹窗
guideTourStore.closeUserCenterDialog();
// 等待弹窗关闭后标记整个引导流程完成
setTimeout(() => {
guideTourStore.markTourCompleted();
}, 500);
}
driverInstance.value?.destroy();
},
});
driverInstance.value?.setSteps(userCenterSteps);
driverInstance.value?.drive();
}
// 开始完整引导流程
async function startFullTour() {
await startHeaderTour();
}
// 销毁 driver 实例
function destroyTour() {
if (driverInstance.value) {
driverInstance.value.destroy();
driverInstance.value = null;
}
}
// 组件卸载时清理
onUnmounted(() => {
destroyTour();
});
return {
startHeaderTour,
startUserCenterTour,
startFullTour,
destroyTour,
};
}

View File

@@ -1,13 +1,15 @@
<!-- 纵向布局作为基础布局 -->
<script setup lang="ts">
import SystemAnnouncementDialog from '@/components/SystemAnnouncementDialog/index.vue';
import { useSafeArea } from '@/hooks/useSafeArea';
import { useWindowWidthObserver } from '@/hooks/useWindowWidthObserver';
import Aside from '@/layouts/components/Aside/index.vue';
import Header from '@/layouts/components/Header/index.vue';
import Main from '@/layouts/components/Main/index.vue';
import { useDesignStore } from '@/stores';
import { useAnnouncementStore, useDesignStore } from '@/stores';
const designStore = useDesignStore();
const announcementStore = useAnnouncementStore();
const isCollapse = computed(() => designStore.isCollapse);
@@ -24,6 +26,16 @@ useSafeArea({
/** 监听窗口大小变化,折叠侧边栏 */
useWindowWidthObserver();
// 应用加载时检查是否需要显示公告弹窗
onMounted(() => {
console.log('announcementStore.shouldShowDialog--', announcementStore.shouldShowDialog);
// 检查是否应该显示弹窗(只有"关闭一周"且未超过7天才不显示
// 数据获取已移至 SystemAnnouncementDialog 组件内部,每次打开弹窗时都会获取最新数据
if (announcementStore.shouldShowDialog) {
announcementStore.openDialog();
}
});
</script>
<template>
@@ -39,6 +51,8 @@ useWindowWidthObserver();
</el-main>
</el-container>
</el-container>
<!-- 系统公告弹窗 -->
<SystemAnnouncementDialog />
</template>
<style lang="scss" scoped>

View File

@@ -385,5 +385,8 @@ function handleMenuCommand(command: string, item: ConversationItem<ChatSessionVo
{
z-index: 0 ;
}
.conversation-group .sticky-title{
z-index: 0 ;
}
}
</style>

View File

@@ -0,0 +1,100 @@
<script setup lang="ts">
import { Bell } from '@element-plus/icons-vue';
import { storeToRefs } from 'pinia';
import { useAnnouncementStore } from '@/stores';
const announcementStore = useAnnouncementStore();
const { announcements } = storeToRefs(announcementStore);
// 计算未读公告数量(系统公告数量)
const unreadCount = computed(() => {
if (!Array.isArray(announcements.value))
return 0;
return announcements.value.filter(a => a.type === 'System').length;
});
// 打开公告弹窗
function openAnnouncement() {
announcementStore.openDialog();
}
</script>
<template>
<div class="announcement-btn-container" data-tour="announcement-btn">
<el-badge
is-dot
class="announcement-badge"
>
<!-- :value="unreadCount" -->
<!-- :hidden="unreadCount === 0" -->
<!-- :max="99" -->
<div
class="announcement-btn"
@click="openAnnouncement"
>
<!-- PC端显示文字 -->
<span class="pc-text">公告/活动</span>
<!-- 移动端显示图标 -->
<el-icon class="mobile-icon" :size="20">
<Bell />
</el-icon>
</div>
</el-badge>
</div>
</template>
<style scoped lang="scss">
.announcement-btn-container {
display: flex;
align-items: center;
.announcement-badge {
:deep(.el-badge__content) {
background-color: #f56c6c;
border: none;
}
}
.announcement-btn {
display: flex;
align-items: center;
gap: 6px;
cursor: pointer;
font-size: 1.2rem;
font-weight: bold;
color: #e6a23c;
transition: all 0.2s;
&:hover {
color: #ebb563;
transform: translateY(-1px);
}
// PC端显示文字隐藏图标
.pc-text {
display: inline;
margin: 0 12px;
}
.mobile-icon {
display: none;
}
}
}
// 移动端显示图标,隐藏文字
@media (max-width: 768px) {
.announcement-btn-container {
.announcement-btn {
.pc-text {
display: none;
}
.mobile-icon {
display: inline;
}
}
}
}
</style>

View File

@@ -6,7 +6,8 @@ import { computed, nextTick, onMounted, ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import Popover from '@/components/Popover/index.vue';
import SvgIcon from '@/components/SvgIcon/index.vue';
import { useUserStore } from '@/stores';
import { useGuideTour } from '@/hooks/useGuideTour';
import { useGuideTourStore, useUserStore } from '@/stores';
import { useSessionStore } from '@/stores/modules/session';
import { showProductPackage } from '@/utils/product-package';
import { getUserProfilePicture, isUserVip } from '@/utils/user';
@@ -15,6 +16,8 @@ const router = useRouter();
const userStore = useUserStore();
const sessionStore = useSessionStore();
const guideTourStore = useGuideTourStore();
const { startUserCenterTour } = useGuideTour();
// const src = computed(
// () => userStore.userInfo?.avatar ?? 'https://avatars.githubusercontent.com/u/76239030',
@@ -243,6 +246,34 @@ onMounted(() => {
// URL 参数会在对话框关闭时清除
}
});
// ============ 监听引导状态,自动打开用户中心并开始引导 ============
watch(() => guideTourStore.shouldStartUserCenterTour, (shouldStart) => {
if (shouldStart) {
// 清除触发标记
guideTourStore.clearUserCenterTourTrigger();
// 注册导航切换回调
guideTourStore.setUserCenterNavChangeCallback((nav: string) => {
activeNav.value = nav;
});
// 注册关闭弹窗回调
guideTourStore.setUserCenterCloseCallback(() => {
dialogVisible.value = false;
});
// 打开用户中心弹窗
nextTick(() => {
dialogVisible.value = true;
// 等待弹窗打开后开始引导
setTimeout(() => {
startUserCenterTour();
}, 600);
});
}
});
</script>
<template>
@@ -259,7 +290,7 @@ onMounted(() => {
<!-- </a> -->
<!-- </div> -->
<div class="text-1.2xl font-bold text-gray-800 hover:text-blue-600 transition-colors">
<div class="text-1.2xl font-bold text-gray-800 hover:text-blue-600 transition-colors" data-tour="ai-tutorial-link">
<a
href="https://ccnetcore.com/article/3a1bc4d1-6a7d-751d-91cc-2817eb2ddcde"
target="_blank"
@@ -292,6 +323,7 @@ onMounted(() => {
<el-button
class="buy-btn flex items-center gap-2 px-5 py-2 font-semibold shadow-lg"
data-tour="buy-btn"
@click="onProductPackage"
>
<span>立即购买</span>
@@ -321,7 +353,7 @@ onMounted(() => {
</div>
<!-- 头像区域 -->
<div class="avatar-container">
<div class="avatar-container" data-tour="user-avatar">
<Popover
ref="popoverRef"
placement="bottom-end"

View File

@@ -0,0 +1,75 @@
<script setup lang="ts">
import { QuestionFilled } from '@element-plus/icons-vue';
import { useGuideTour } from '@/hooks/useGuideTour';
const { startHeaderTour } = useGuideTour();
// 开始引导教程
function handleStartTutorial() {
startHeaderTour();
}
</script>
<template>
<div class="tutorial-btn-container" data-tour="tutorial-btn">
<div
class="tutorial-btn"
@click="handleStartTutorial"
>
<!-- PC端显示文字 -->
<span class="pc-text">新手引导</span>
<!-- 移动端显示图标 -->
<el-icon class="mobile-icon" :size="20">
<QuestionFilled />
</el-icon>
</div>
</div>
</template>
<style scoped lang="scss">
.tutorial-btn-container {
display: flex;
align-items: center;
.tutorial-btn {
display: flex;
align-items: center;
gap: 6px;
cursor: pointer;
font-size: 1.2rem;
font-weight: bold;
color: #409eff;
transition: all 0.2s;
&:hover {
color: #66b1ff;
transform: translateY(-1px);
}
// PC端显示文字隐藏图标
.pc-text {
display: inline;
margin: 0 12px;
}
.mobile-icon {
display: none;
}
}
}
// 移动端显示图标,隐藏文字
@media (max-width: 768px) {
.tutorial-btn-container {
.tutorial-btn {
.pc-text {
display: none;
}
.mobile-icon {
display: inline;
}
}
}
}
</style>

View File

@@ -4,11 +4,13 @@ import { onKeyStroke } from '@vueuse/core';
import { SIDE_BAR_WIDTH } from '@/config/index';
import { useDesignStore, useUserStore } from '@/stores';
import { useSessionStore } from '@/stores/modules/session';
import AnnouncementBtn from './components/AnnouncementBtn.vue';
import Avatar from './components/Avatar.vue';
import Collapse from './components/Collapse.vue';
import CreateChat from './components/CreateChat.vue';
import LoginBtn from './components/LoginBtn.vue';
import TitleEditing from './components/TitleEditing.vue';
import TutorialBtn from './components/TutorialBtn.vue';
const userStore = useUserStore();
const designStore = useDesignStore();
@@ -69,6 +71,8 @@ onKeyStroke(event => event.ctrlKey && event.key.toLowerCase() === 'k', handleCtr
<!-- 右边 -->
<div class="right-box flex h-full items-center pr-20px flex-shrink-0 mr-auto flex-row">
<AnnouncementBtn />
<TutorialBtn />
<Avatar v-show="userStore.userInfo" />
<LoginBtn v-show="!userStore.userInfo" />
</div>

View File

@@ -0,0 +1,373 @@
<script lang="ts" setup>
import { ElMessage } from 'element-plus';
import { useRoute, useRouter } from 'vue-router';
// import { getActivityDetail } from '@/api'
// import type { ActivityDetailResponse } from '@/api'
const route = useRoute();
const router = useRouter();
const loading = ref(false);
// const activityDetail = ref<ActivityDetailResponse | null>(null)
const activityDetail = ref<any | null>(null);
// 获取活动详情
async function fetchActivityDetail() {
const id = route.params.id as string;
if (!id)
return;
loading.value = true;
try {
// const res = await getActivityDetail(id)
// activityDetail.value = res.data
}
catch (error) {
console.error('获取活动详情失败:', error);
ElMessage.error('获取活动详情失败');
}
finally {
loading.value = false;
}
}
// 返回上一页
function goBack() {
router.back();
}
// 格式化时间
function formatDateTime(time?: string) {
if (!time)
return '-';
const date = new Date(time);
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
}
// 页面加载时获取详情
onMounted(() => {
fetchActivityDetail();
});
</script>
<template>
<div class="activity-detail-page">
<el-card v-loading="loading" class="detail-card">
<template #header>
<div class="card-header">
<el-button type="primary" link @click="goBack">
<el-icon><i-ep-arrow-left /></el-icon>
返回
</el-button>
</div>
</template>
<div v-if="activityDetail" class="detail-content">
<!-- 活动头部 -->
<div class="detail-header">
<h1 class="detail-title">
{{ activityDetail.title }}
</h1>
<div class="detail-meta">
<el-tag
v-if="activityDetail.status === 'active'"
type="success"
size="large"
>
进行中
</el-tag>
<el-tag
v-else-if="activityDetail.status === 'expired'"
type="info"
size="large"
>
已结束
</el-tag>
<span class="meta-item">
<el-icon><i-ep-view /></el-icon>
浏览 {{ activityDetail.views || 0 }}
</span>
<span class="meta-item">
<el-icon><i-ep-user /></el-icon>
参与 {{ activityDetail.participantCount || 0 }}
</span>
</div>
</div>
<!-- 活动封面 -->
<div v-if="activityDetail.coverImage" class="detail-cover">
<img :src="activityDetail.coverImage" :alt="activityDetail.title">
</div>
<!-- 活动描述 -->
<div class="detail-description">
<h3>活动简介</h3>
<p>{{ activityDetail.description }}</p>
</div>
<!-- 活动时间 -->
<div class="detail-time">
<el-descriptions :column="2" border>
<el-descriptions-item label="开始时间">
{{ formatDateTime(activityDetail.startTime) }}
</el-descriptions-item>
<el-descriptions-item label="结束时间">
{{ formatDateTime(activityDetail.endTime) }}
</el-descriptions-item>
<el-descriptions-item label="发布时间">
{{ formatDateTime(activityDetail.createdAt) }}
</el-descriptions-item>
<el-descriptions-item label="更新时间">
{{ formatDateTime(activityDetail.updatedAt) }}
</el-descriptions-item>
</el-descriptions>
</div>
<!-- 活动详细内容 -->
<div class="detail-body">
<h3>活动详情</h3>
<div class="content-html" v-html="activityDetail.content" />
</div>
</div>
<el-empty v-else description="暂无活动详情" />
</el-card>
</div>
</template>
<style scoped lang="scss">
.activity-detail-page {
padding: 24px;
background: #f5f7fa;
min-height: 100vh;
.detail-card {
max-width: 1200px;
margin: 0 auto;
}
.card-header {
display: flex;
align-items: center;
}
.detail-content {
.detail-header {
margin-bottom: 24px;
padding-bottom: 24px;
border-bottom: 1px solid #e4e7ed;
.detail-title {
margin: 0 0 16px 0;
font-size: 28px;
font-weight: 600;
color: #303133;
line-height: 1.4;
}
.detail-meta {
display: flex;
align-items: center;
gap: 16px;
flex-wrap: wrap;
.meta-item {
display: flex;
align-items: center;
gap: 4px;
font-size: 14px;
color: #606266;
.el-icon {
font-size: 16px;
}
}
}
}
.detail-cover {
margin-bottom: 24px;
border-radius: 8px;
overflow: hidden;
img {
width: 100%;
height: auto;
display: block;
}
}
.detail-description {
margin-bottom: 24px;
padding: 20px;
background: #f9fafb;
border-radius: 8px;
h3 {
margin: 0 0 12px 0;
font-size: 18px;
font-weight: 600;
color: #303133;
}
p {
margin: 0;
font-size: 15px;
color: #606266;
line-height: 1.8;
}
}
.detail-time {
margin-bottom: 24px;
}
.detail-body {
h3 {
margin: 0 0 16px 0;
font-size: 18px;
font-weight: 600;
color: #303133;
}
.content-html {
font-size: 15px;
color: #303133;
line-height: 1.8;
:deep(img) {
max-width: 100%;
height: auto;
border-radius: 4px;
}
:deep(p) {
margin: 12px 0;
}
:deep(h1),
:deep(h2),
:deep(h3),
:deep(h4),
:deep(h5),
:deep(h6) {
margin: 20px 0 12px;
font-weight: 600;
color: #303133;
}
:deep(ul),
:deep(ol) {
padding-left: 24px;
margin: 12px 0;
}
:deep(li) {
margin: 8px 0;
}
:deep(blockquote) {
margin: 16px 0;
padding: 12px 16px;
background: #f5f7fa;
border-left: 4px solid #409eff;
color: #606266;
}
:deep(code) {
padding: 2px 6px;
background: #f5f7fa;
border-radius: 3px;
font-family: 'Courier New', monospace;
font-size: 14px;
}
:deep(pre) {
margin: 16px 0;
padding: 16px;
background: #282c34;
border-radius: 4px;
overflow-x: auto;
code {
background: none;
padding: 0;
color: #abb2bf;
}
}
}
}
}
}
// 移动端适配
@media screen and (max-width: 768px) {
.activity-detail-page {
padding: 12px;
.detail-card {
:deep(.el-card__header) {
padding: 12px;
}
:deep(.el-card__body) {
padding: 12px;
}
}
.detail-content {
.detail-header {
margin-bottom: 16px;
padding-bottom: 16px;
.detail-title {
font-size: 20px;
}
.detail-meta {
gap: 8px;
.meta-item {
font-size: 12px;
}
}
}
.detail-description {
padding: 12px;
margin-bottom: 16px;
h3 {
font-size: 16px;
}
p {
font-size: 14px;
}
}
.detail-time {
margin-bottom: 16px;
:deep(.el-descriptions__label) {
font-size: 12px;
}
:deep(.el-descriptions__content) {
font-size: 12px;
}
}
.detail-body {
h3 {
font-size: 16px;
}
.content-html {
font-size: 14px;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,364 @@
<script lang="ts" setup>
import { ElMessage } from 'element-plus';
import { useRoute, useRouter } from 'vue-router';
// import { getAnnouncementDetail } from '@/api'
// import type { AnnouncementDetailResponse } from '@/api'
const route = useRoute();
const router = useRouter();
const loading = ref(false);
const announcementDetail = ref<any | null>(null);
// 获取公告详情
async function fetchAnnouncementDetail() {
const id = route.params.id as string;
if (!id)
return;
loading.value = true;
try {
// const res = await getAnnouncementDetail(id)
// announcementDetail.value = res.data
}
catch (error) {
console.error('获取公告详情失败:', error);
ElMessage.error('获取公告详情失败');
}
finally {
loading.value = false;
}
}
// 返回上一页
function goBack() {
router.back();
}
// 格式化时间
function formatDateTime(time?: string) {
if (!time)
return '-';
const date = new Date(time);
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
}
// 页面加载时获取详情
onMounted(() => {
fetchAnnouncementDetail();
});
</script>
<template>
<div class="announcement-detail-page">
<el-card v-loading="loading" class="detail-card">
<template #header>
<div class="card-header">
<el-button type="primary" link @click="goBack">
<el-icon><i-ep-arrow-left /></el-icon>
返回
</el-button>
</div>
</template>
<div v-if="announcementDetail" class="detail-content">
<!-- 公告头部 -->
<div class="detail-header">
<h1 class="detail-title">
<el-icon v-if="announcementDetail.isImportant" color="#f56c6c" class="important-icon">
<i-ep-warning />
</el-icon>
{{ announcementDetail.title }}
</h1>
<div class="detail-meta">
<el-tag
v-if="announcementDetail.type === 'latest'"
type="success"
size="large"
>
最新公告
</el-tag>
<el-tag
v-else
type="info"
size="large"
>
历史公告
</el-tag>
<span class="meta-item">
<el-icon><i-ep-view /></el-icon>
浏览 {{ announcementDetail.views || 0 }}
</span>
<span class="meta-item">
<el-icon><i-ep-clock /></el-icon>
发布时间: {{ formatDateTime(announcementDetail.publishTime) }}
</span>
</div>
</div>
<!-- 公告详细内容 -->
<div class="detail-body">
<div class="content-html" v-html="announcementDetail.content" />
</div>
<!-- 公告底部信息 -->
<div class="detail-footer">
<el-divider />
<div class="footer-info">
<span>创建时间: {{ formatDateTime(announcementDetail.createdAt) }}</span>
<span v-if="announcementDetail.updatedAt">
更新时间: {{ formatDateTime(announcementDetail.updatedAt) }}
</span>
</div>
</div>
</div>
<el-empty v-else description="暂无公告详情" />
</el-card>
</div>
</template>
<style scoped lang="scss">
.announcement-detail-page {
padding: 24px;
background: #f5f7fa;
min-height: 100vh;
.detail-card {
max-width: 1200px;
margin: 0 auto;
}
.card-header {
display: flex;
align-items: center;
}
.detail-content {
.detail-header {
margin-bottom: 24px;
padding-bottom: 24px;
border-bottom: 1px solid #e4e7ed;
.detail-title {
margin: 0 0 16px 0;
font-size: 28px;
font-weight: 600;
color: #303133;
line-height: 1.4;
display: flex;
align-items: center;
gap: 8px;
.important-icon {
font-size: 30px;
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.6;
}
}
}
.detail-meta {
display: flex;
align-items: center;
gap: 16px;
flex-wrap: wrap;
.meta-item {
display: flex;
align-items: center;
gap: 4px;
font-size: 14px;
color: #606266;
.el-icon {
font-size: 16px;
}
}
}
}
.detail-body {
margin-bottom: 24px;
.content-html {
font-size: 16px;
color: #303133;
line-height: 1.8;
:deep(img) {
max-width: 100%;
height: auto;
border-radius: 4px;
}
:deep(p) {
margin: 12px 0;
}
:deep(h1),
:deep(h2),
:deep(h3),
:deep(h4),
:deep(h5),
:deep(h6) {
margin: 24px 0 12px;
font-weight: 600;
color: #303133;
}
:deep(ul),
:deep(ol) {
padding-left: 24px;
margin: 12px 0;
}
:deep(li) {
margin: 8px 0;
}
:deep(blockquote) {
margin: 16px 0;
padding: 12px 16px;
background: #f5f7fa;
border-left: 4px solid #409eff;
color: #606266;
}
:deep(code) {
padding: 2px 6px;
background: #f5f7fa;
border-radius: 3px;
font-family: 'Courier New', monospace;
font-size: 14px;
}
:deep(pre) {
margin: 16px 0;
padding: 16px;
background: #282c34;
border-radius: 4px;
overflow-x: auto;
code {
background: none;
padding: 0;
color: #abb2bf;
}
}
:deep(table) {
width: 100%;
margin: 16px 0;
border-collapse: collapse;
border-spacing: 0;
th,
td {
padding: 12px;
border: 1px solid #e4e7ed;
text-align: left;
}
th {
background: #f5f7fa;
font-weight: 600;
}
tr:hover {
background: #fafafa;
}
}
}
}
.detail-footer {
.footer-info {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 13px;
color: #909399;
flex-wrap: wrap;
gap: 12px;
}
}
}
}
// 移动端适配
@media screen and (max-width: 768px) {
.announcement-detail-page {
padding: 12px;
.detail-card {
:deep(.el-card__header) {
padding: 12px;
}
:deep(.el-card__body) {
padding: 12px;
}
}
.detail-content {
.detail-header {
margin-bottom: 16px;
padding-bottom: 16px;
.detail-title {
font-size: 20px;
.important-icon {
font-size: 24px;
}
}
.detail-meta {
gap: 8px;
.meta-item {
font-size: 12px;
}
}
}
.detail-body {
margin-bottom: 16px;
.content-html {
font-size: 14px;
:deep(table) {
display: block;
overflow-x: auto;
white-space: nowrap;
th,
td {
padding: 8px;
font-size: 12px;
}
}
}
}
.detail-footer {
.footer-info {
font-size: 11px;
flex-direction: column;
align-items: flex-start;
gap: 4px;
}
}
}
}
}
</style>

View File

@@ -7,7 +7,8 @@ import { ElMessage } from 'element-plus';
import { nextTick, ref, watch } from 'vue';
import ModelSelect from '@/components/ModelSelect/index.vue';
import WelecomeText from '@/components/WelecomeText/index.vue';
import { useUserStore } from '@/stores';
import { useGuideTour } from '@/hooks/useGuideTour';
import { useGuideTourStore, useUserStore } from '@/stores';
import { useFilesStore } from '@/stores/modules/files';
import { useSessionStore } from '@/stores/modules/session';
@@ -15,6 +16,7 @@ import { useSessionStore } from '@/stores/modules/session';
const userStore = useUserStore();
const sessionStore = useSessionStore();
const filesStore = useFilesStore();
const guideTourStore = useGuideTourStore();
const senderValue = ref('');
const senderRef = ref();
@@ -87,6 +89,7 @@ watch(
ref="senderRef"
v-model="senderValue"
class="chat-defaul-sender"
data-tour="chat-sender"
:auto-size="{
maxRows: 9,
minRows: 3,

View File

@@ -13,6 +13,8 @@ import { Sender } from 'vue-element-plus-x';
import { useRoute } from 'vue-router';
import { send } from '@/api';
import ModelSelect from '@/components/ModelSelect/index.vue';
import { useGuideTour } from '@/hooks/useGuideTour';
import { useGuideTourStore } from '@/stores';
import { useChatStore } from '@/stores/modules/chat';
import { useFilesStore } from '@/stores/modules/files';
import { useModelStore } from '@/stores/modules/model';
@@ -35,6 +37,7 @@ const chatStore = useChatStore();
const modelStore = useModelStore();
const filesStore = useFilesStore();
const userStore = useUserStore();
const guideTourStore = useGuideTourStore();
// 用户头像
const avatar = computed(() => {
@@ -336,7 +339,7 @@ function copy(item: any) {
</BubbleList>
<Sender
ref="senderRef" v-model="inputValue" class="chat-defaul-sender" :auto-size="{
ref="senderRef" v-model="inputValue" class="chat-defaul-sender" data-tour="chat-sender" :auto-size="{
maxRows: 6,
minRows: 2,
}" variant="updown" clearable allow-speech :loading="isLoading" @submit="startSSE" @cancel="cancelSSE"

View File

@@ -55,6 +55,26 @@ export const layoutRouter: RouteRecordRaw[] = [
},
},
{
path: '/activity/:id',
name: 'activityDetail',
component: () => import('@/pages/activity/detail.vue'),
meta: {
title: '活动详情',
isDefaultChat: false,
layout: 'blankPage',
},
},
{
path: '/announcement/:id',
name: 'announcementDetail',
component: () => import('@/pages/announcement/detail.vue'),
meta: {
title: '公告详情',
isDefaultChat: false,
layout: 'blankPage',
},
},
],
},
];

View File

@@ -7,6 +7,8 @@ store.use(piniaPluginPersistedstate);
export default store;
export * from './modules/announcement'
// export * from './modules/chat';
export * from './modules/design';
export * from './modules/user';
export * from './modules/guideTour';

View File

@@ -0,0 +1,79 @@
import type { AnnouncementLogDto } from '@/api';
import { defineStore } from 'pinia';
export type CloseType = 'today' | 'permanent';
export const useAnnouncementStore = defineStore(
'announcement',
() => {
// 弹窗显示状态
const isDialogVisible = ref(false);
// 公告数据(统一存储所有公告)
const announcements = ref<AnnouncementLogDto[]>([]);
// 关闭记录
const closeType = ref<CloseType | null>(null);
const closedAt = ref<number | null>(null);
// 打开弹窗
const openDialog = () => {
isDialogVisible.value = true;
};
// 关闭弹窗
const closeDialog = (type: CloseType) => {
isDialogVisible.value = false;
closeType.value = type;
closedAt.value = Date.now();
};
// 检查是否应该显示弹窗
const shouldShowDialog = computed(() => {
if (!closedAt.value || !closeType.value)
return true;
const now = Date.now();
const elapsed = now - closedAt.value;
if (closeType.value === 'permanent')
return true;
if (closeType.value === 'today') {
// 检查是否已过去一周7天
return elapsed > 7 * 24 * 60 * 60 * 1000;
}
return true;
});
// 设置公告数据
const setAnnouncementData = (data: AnnouncementLogDto[]) => {
announcements.value = data;
};
// 重置关闭状态(用于测试或管理员重置)
const resetCloseStatus = () => {
closeType.value = null;
closedAt.value = null;
};
return {
isDialogVisible,
announcements,
closeType,
closedAt,
shouldShowDialog,
openDialog,
closeDialog,
setAnnouncementData,
resetCloseStatus,
};
},
{
persist: {
// 只持久化关闭状态相关的数据,公告数据不缓存
paths: ['closeType', 'closedAt'],
},
},
);

View File

@@ -0,0 +1,105 @@
import { defineStore } from 'pinia';
// 存储键名
const TOUR_STORAGE_KEY = 'guide_tour_completed';
export const useGuideTourStore = defineStore('guideTour', () => {
// 是否是首次访问
const isFirstVisit = ref(!localStorage.getItem(TOUR_STORAGE_KEY));
// 当前引导阶段
const currentPhase = ref<'idle' | 'header' | 'userCenter' | 'chat'>('idle');
// 是否需要在用户中心弹窗打开后开始引导
const shouldStartUserCenterTour = ref(false);
// 是否需要在聊天页面开始引导
const shouldStartChatTour = ref(false);
// 用户中心导航切换回调
const userCenterNavChangeCallback = ref<((nav: string) => void) | null>(null);
// 用户中心弹窗关闭回调
const userCenterCloseCallback = ref<(() => void) | null>(null);
// 标记引导已完成
function markTourCompleted() {
localStorage.setItem(TOUR_STORAGE_KEY, Date.now().toString());
isFirstVisit.value = false;
}
// 重置引导状态
function resetTourStatus() {
localStorage.removeItem(TOUR_STORAGE_KEY);
isFirstVisit.value = true;
}
// 设置当前引导阶段
function setCurrentPhase(phase: 'idle' | 'header' | 'userCenter' | 'chat') {
currentPhase.value = phase;
}
// 触发用户中心引导
function triggerUserCenterTour() {
shouldStartUserCenterTour.value = true;
}
// 清除用户中心引导触发标记
function clearUserCenterTourTrigger() {
shouldStartUserCenterTour.value = false;
}
// 触发聊天页面引导
function triggerChatTour() {
shouldStartChatTour.value = true;
}
// 清除聊天页面引导触发标记
function clearChatTourTrigger() {
shouldStartChatTour.value = false;
}
// 设置用户中心导航切换回调
function setUserCenterNavChangeCallback(callback: (nav: string) => void) {
userCenterNavChangeCallback.value = callback;
}
// 设置用户中心弹窗关闭回调
function setUserCenterCloseCallback(callback: () => void) {
userCenterCloseCallback.value = callback;
}
// 切换用户中心导航
function changeUserCenterNav(nav: string) {
if (userCenterNavChangeCallback.value) {
userCenterNavChangeCallback.value(nav);
}
}
// 关闭用户中心弹窗
function closeUserCenterDialog() {
if (userCenterCloseCallback.value) {
userCenterCloseCallback.value();
}
}
return {
isFirstVisit,
currentPhase,
shouldStartUserCenterTour,
shouldStartChatTour,
userCenterNavChangeCallback,
userCenterCloseCallback,
markTourCompleted,
resetTourStatus,
setCurrentPhase,
triggerUserCenterTour,
clearUserCenterTourTrigger,
triggerChatTour,
clearChatTourTrigger,
setUserCenterNavChangeCallback,
setUserCenterCloseCallback,
changeUserCenterNav,
closeUserCenterDialog,
};
});

View File

@@ -0,0 +1,148 @@
// Guide Tour 自定义样式
// 覆盖 driver.js 默认样式
.driver-popover {
background-color: #fff;
border-radius: 12px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
border: none;
padding: 20px;
min-width: 300px;
max-width: 400px;
&.guide-tour-popover {
// 自定义样式类
}
.driver-popover-title {
font-size: 18px;
font-weight: 600;
color: #303133;
margin-bottom: 12px;
padding-right: 24px;
}
.driver-popover-description {
font-size: 14px;
color: #606266;
line-height: 1.6;
margin-bottom: 16px;
}
.driver-popover-progress-text {
font-size: 12px;
color: #909399;
margin-bottom: 12px;
}
.driver-popover-footer {
display: flex;
justify-content: space-between;
align-items: center;
gap: 8px;
}
.driver-popover-navigation-btns {
display: flex;
gap: 8px;
}
.driver-popover-prev-btn,
.driver-popover-next-btn {
padding: 8px 16px;
border-radius: 6px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s;
border: none;
}
.driver-popover-prev-btn {
background-color: #f5f7fa;
color: #606266;
&:hover {
background-color: #e6e8eb;
}
}
.driver-popover-next-btn {
background-color: #409eff;
color: #fff;
&:hover {
background-color: #66b1ff;
}
}
.driver-popover-close-btn {
position: absolute;
top: 12px;
right: 12px;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background-color: transparent;
border: none;
color: #909399;
cursor: pointer;
transition: all 0.3s;
font-size: 18px;
&:hover {
background-color: #f5f7fa;
color: #606266;
}
}
// 箭头样式
.driver-popover-arrow {
border: none;
}
&.driver-popover-side-top .driver-popover-arrow {
border-top-color: #fff;
}
&.driver-popover-side-bottom .driver-popover-arrow {
border-bottom-color: #fff;
}
&.driver-popover-side-left .driver-popover-arrow {
border-left-color: #fff;
}
&.driver-popover-side-right .driver-popover-arrow {
border-right-color: #fff;
}
}
// 高亮区域样式
.driver-highlighted-element {
outline: none !important;
}
// 遮罩层样式
.driver-overlay {
background-color: rgba(0, 0, 0, 0.65) !important;
}
// 动画效果
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.driver-popover {
animation: fadeInUp 0.3s ease-out;
}

View File

@@ -3,6 +3,7 @@
@use 'reset-css';
@use './element-plus';
@use './elx';
@use './guide-tour';
body{
overflow: hidden;
}

View File

@@ -77,10 +77,11 @@ function jwtPlugin(): {
afterResponse: (response: any) => Promise<any>;
beforeStream: (body: any, config: any) => Promise<void>;
} {
const userStore = useUserStore();
return {
name: 'jwt',
beforeRequest: async (config) => {
// 延迟获取 store确保 Pinia 已经初始化
const userStore = useUserStore();
config.headers = new Headers(config.headers);
if (userStore.refreshToken) {
config.headers.set('refresh_token', `${userStore.refreshToken}`);
@@ -94,6 +95,8 @@ function jwtPlugin(): {
// 响应后处理
afterResponse: async (response: any) => {
// 延迟获取 store确保 Pinia 已经初始化
const userStore = useUserStore();
if (response.response.headers.get('access_token')) {
userStore.setToken(response.response.headers.get('access_token'), response.response.headers.get('refresh_token'));
}
@@ -118,6 +121,8 @@ function jwtPlugin(): {
},
onError: async (error) => {
// 延迟获取 store确保 Pinia 已经初始化
const userStore = useUserStore();
if (error.status === 403) {
const data = await (error.response.json());
// 弹窗提示

View File

@@ -11,17 +11,20 @@ declare module 'vue' {
AccountPassword: typeof import('./../src/components/LoginDialog/components/FormLogin/AccountPassword.vue')['default']
APIKeyManagement: typeof import('./../src/components/userPersonalCenter/components/APIKeyManagement.vue')['default']
CardFlipActivity: typeof import('./../src/components/userPersonalCenter/components/CardFlipActivity.vue')['default']
CardFlipActivity2: typeof import('./../src/components/userPersonalCenter/components/CardFlipActivity2.vue')['default']
DailyTask: typeof import('./../src/components/userPersonalCenter/components/DailyTask.vue')['default']
DeepThinking: typeof import('./../src/components/DeepThinking/index.vue')['default']
ElAlert: typeof import('element-plus/es')['ElAlert']
ElAvatar: typeof import('element-plus/es')['ElAvatar']
ElBadge: typeof import('element-plus/es')['ElBadge']
ElButton: typeof import('element-plus/es')['ElButton']
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
ElCard: typeof import('element-plus/es')['ElCard']
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElContainer: typeof import('element-plus/es')['ElContainer']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDivider: typeof import('element-plus/es')['ElDivider']
ElEmpty: typeof import('element-plus/es')['ElEmpty']
@@ -34,11 +37,17 @@ declare module 'vue' {
ElMain: typeof import('element-plus/es')['ElMain']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElProgress: typeof import('element-plus/es')['ElProgress']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag']
ElTimeline: typeof import('element-plus/es')['ElTimeline']
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
FilesSelect: typeof import('./../src/components/FilesSelect/index.vue')['default']
IconSelect: typeof import('./../src/components/IconSelect/index.vue')['default']
@@ -48,7 +57,9 @@ declare module 'vue' {
ModelSelect: typeof import('./../src/components/ModelSelect/index.vue')['default']
NavDialog: typeof import('./../src/components/userPersonalCenter/NavDialog.vue')['default']
Popover: typeof import('./../src/components/Popover/index.vue')['default']
PremiumPackageInfo: typeof import('./../src/components/userPersonalCenter/components/PremiumPackageInfo.vue')['default']
PremiumService: typeof import('./../src/components/userPersonalCenter/components/PremiumService.vue')['default']
PremiumUsageList: typeof import('./../src/components/userPersonalCenter/components/PremiumUsageList.vue')['default']
ProductPackage: typeof import('./../src/components/ProductPackage/index.vue')['default']
QrCodeLogin: typeof import('./../src/components/LoginDialog/components/QrCodeLogin/index.vue')['default']
RechargeLog: typeof import('./../src/components/userPersonalCenter/components/RechargeLog.vue')['default']
@@ -57,6 +68,7 @@ declare module 'vue' {
RouterView: typeof import('vue-router')['RouterView']
SupportModelList: typeof import('./../src/components/userPersonalCenter/components/SupportModelList.vue')['default']
SvgIcon: typeof import('./../src/components/SvgIcon/index.vue')['default']
SystemAnnouncementDialog: typeof import('./../src/components/SystemAnnouncementDialog/index.vue')['default']
UsageStatistics: typeof import('./../src/components/userPersonalCenter/components/UsageStatistics.vue')['default']
UserManagement: typeof import('./../src/components/userPersonalCenter/components/UserManagement.vue')['default']
VerificationCode: typeof import('./../src/components/LoginDialog/components/FormLogin/VerificationCode.vue')['default']

View File

@@ -6,6 +6,7 @@ interface ImportMetaEnv {
readonly VITE_WEB_ENV: string;
readonly VITE_WEB_BASE_API: string;
readonly VITE_API_URL: string;
readonly VITE_BUILD_COMPRESS: string;
readonly VITE_SSO_SEVER_URL: string;
readonly VITE_APP_VERSION: string;
}

View File

@@ -103,7 +103,7 @@ export function usePost() {
`确认要<strong>${
row.state === false ? "停用" : "启用"
}</strong><strong style='color:var(--el-color-primary)'>${
row.roleName
row.postName
}</strong>吗?`,
"系统提示",
{
@@ -132,7 +132,7 @@ export function usePost() {
loading: false
}
);
message(`${row.state === false ? "停用" : "启用"}${row.roleName}`, {
message(`${row.state === false ? "停用" : "启用"}${row.postName}`, {
type: "success"
});
})
@@ -143,7 +143,7 @@ export function usePost() {
async function handleDelete(row) {
await delPost([row.id]);
message(`您删除了角色名称为${row.roleName}的这条数据`, { type: "success" });
message(`您删除了岗位名称为${row.postName}的这条数据`, { type: "success" });
onSearch();
}

BIN
readme/edgeone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB