feat: 关闭前端动画
This commit is contained in:
@@ -6,8 +6,10 @@ using System.Threading.Tasks;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Caching;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Guids;
|
||||
using Yi.Framework.Core.Enums;
|
||||
@@ -16,6 +18,7 @@ using Yi.Framework.Rbac.Application.Contracts.Dtos.FileManager;
|
||||
using Yi.Framework.Rbac.Application.Contracts.IServices;
|
||||
using Yi.Framework.Rbac.Domain.Entities;
|
||||
using Yi.Framework.Rbac.Domain.Managers;
|
||||
using Yi.Framework.Rbac.Domain.Shared.Caches;
|
||||
|
||||
namespace Yi.Framework.Rbac.Application.Services
|
||||
{
|
||||
@@ -23,11 +26,13 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
{
|
||||
private readonly IRepository<FileAggregateRoot> _repository;
|
||||
private readonly FileManager _fileManager;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
|
||||
public FileService(IRepository<FileAggregateRoot> repository, FileManager fileManager)
|
||||
public FileService(IRepository<FileAggregateRoot> repository, FileManager fileManager, IMemoryCache memoryCache)
|
||||
{
|
||||
_repository = repository;
|
||||
_fileManager = fileManager;
|
||||
_memoryCache = memoryCache;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -37,12 +42,20 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
[Route("file/{code}/{isThumbnail?}")]
|
||||
public async Task<IActionResult> Get([FromRoute] Guid code, [FromRoute] bool? isThumbnail)
|
||||
{
|
||||
var file = await _repository.GetAsync(x => x.Id == code);
|
||||
var fileCache = await _memoryCache.GetOrCreateAsync($"File:{code}", async (options) =>
|
||||
{
|
||||
options.AbsoluteExpiration = DateTime.Now.AddDays(1);
|
||||
var file = await _repository.GetAsync(x => x.Id == code);
|
||||
if (file == null!) return null;
|
||||
return file.Adapt<FileCacheItem>();
|
||||
});
|
||||
var file = fileCache?.Adapt<FileAggregateRoot>();
|
||||
var path = file?.GetQueryFileSavePath(isThumbnail);
|
||||
if (path is null || !File.Exists(path))
|
||||
{
|
||||
return new NotFoundResult();
|
||||
}
|
||||
|
||||
var steam = await File.ReadAllBytesAsync(path);
|
||||
return new FileContentResult(steam, file.GetMimeMapping());
|
||||
}
|
||||
@@ -57,12 +70,13 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
|
||||
for (int i = 0; i < file.Count; i++)
|
||||
{
|
||||
var entity= entities[i];
|
||||
using (var steam = file[i].OpenReadStream())
|
||||
{
|
||||
await _fileManager.SaveFileAsync(entity,steam);
|
||||
}
|
||||
var entity = entities[i];
|
||||
using (var steam = file[i].OpenReadStream())
|
||||
{
|
||||
await _fileManager.SaveFileAsync(entity, steam);
|
||||
}
|
||||
}
|
||||
|
||||
return entities.Adapt<List<FileGetListOutputDto>>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace Yi.Framework.Rbac.Domain.Shared.Caches;
|
||||
|
||||
public class FileCacheItem
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
///</summary>
|
||||
public decimal FileSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件名
|
||||
///</summary>
|
||||
public string FileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件路径
|
||||
///</summary>
|
||||
public string FilePath { get; set; }
|
||||
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public Guid? CreatorId { get; set; }
|
||||
|
||||
public Guid? LastModifierId { get; set; }
|
||||
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
}
|
||||
@@ -2,11 +2,11 @@ VITE_APP_ENV_NAME = "pro"
|
||||
|
||||
# 接口前缀
|
||||
VITE_APP_BASEAPI="/prod-api"
|
||||
VITE_APP_URL="http://ccnetcore.com:19001/api/app"
|
||||
VITE_APP_URL="http://data.ccnetcore.com:19001/api/app"
|
||||
|
||||
# ws
|
||||
VITE_APP_BASE_WS = '/prod-ws'
|
||||
VITE_APP_BASE_URL_WS="http://ccnetcore.com:19001/hub"
|
||||
VITE_APP_BASE_URL_WS="http://data.ccnetcore.com:19001/hub"
|
||||
|
||||
# 是否开启ICP备案模式
|
||||
VITE_APP_ICP = false
|
||||
@@ -69,7 +69,7 @@ function drawStars() {
|
||||
|
||||
function animate() {
|
||||
drawStars();
|
||||
requestAnimationFrame(animate);
|
||||
// requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user