Skip to content

Commit

Permalink
Update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
gdlcf88 committed Jan 12, 2024
1 parent 2e570eb commit 6a01813
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions host/EasyAbp.FileManagement.Web.Unified/Pages/MyFiles/Index.cshtml
@@ -1,8 +1,10 @@
@page
@using EasyAbp.FileManagement.Files
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@using EasyAbp.FileManagement.Localization
@using EasyAbp.FileManagement.Web.Pages.FileManagement.Components.FileManagerWidget
@using Microsoft.Extensions.DependencyInjection
@using Volo.Abp.Users
@inject IPageLayout PageLayout
@inject IHtmlLocalizer<FileManagementResource> L
Expand All @@ -13,21 +15,34 @@
PageLayout.Content.BreadCrumb.Add(L["Menu:File"].Value);
PageLayout.Content.MenuItemName = "FileManagementFile";

const string fileContainerName = "default";
var ownerUserId = CurrentUser.GetId();
Guid? parentId = null; // the root directory
var path = HttpContext.Request.Query["path"].FirstOrDefault();

if (path is not null)
{
var fileAppService = HttpContext.RequestServices.GetRequiredService<IFileAppService>();
var parent = await fileAppService.GetByPathAsync(path, fileContainerName, ownerUserId);
parentId = parent.Id;
}

// add a file manager widget
@await Component.InvokeAsync("FileManager", new
{
fileContainerName = "default", // specify a container
ownerUserId = CurrentUser.GetId(), // can be null if it's a shared container
parentId = (Guid?)null, // the root directory
policy = new FileManagerPolicyModel // with a custom policy model
{ CanUploadFile = false, CanMoveFile = false }
})
{
fileContainerName = "default", // specify a container
ownerUserId = CurrentUser.GetId(), // can be null if it's a shared container
parentId = parentId,
policy = new FileManagerPolicyModel // with a custom policy model
{ CanUploadFile = false, CanMoveFile = false }
})

// you can add more than one file manager widget on the same page
@await Component.InvokeAsync("FileManager", new
{
fileContainerName = "default",
ownerUserId = CurrentUser.GetId(),
parentId = (Guid?)null
})
{
fileContainerName = "default",
ownerUserId = CurrentUser.GetId(),
parentId = (Guid?)null
})
}

0 comments on commit 6a01813

Please sign in to comment.