初步增加后台附件管理功能
This commit is contained in:
@@ -38,4 +38,29 @@ namespace COMCMS.Core.Models
|
||||
public int qty { get; set; } = 1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 系统文件目录信息列表
|
||||
/// <summary>
|
||||
/// 系统文件目录信息
|
||||
/// </summary>
|
||||
public class DirInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 目录名称
|
||||
/// </summary>
|
||||
public string name { get; set; }
|
||||
/// <summary>
|
||||
/// 目录
|
||||
/// </summary>
|
||||
public string path { get; set; }
|
||||
/// <summary>
|
||||
/// 目录详情
|
||||
/// </summary>
|
||||
public string fullPath { get; set; }
|
||||
/// <summary>
|
||||
/// 子目录
|
||||
/// </summary>
|
||||
public List<DirInfo> subList { get; set; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -37,7 +37,13 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
[MyAuthorize("viewlist", "attach")]
|
||||
public IActionResult AttachList()
|
||||
{
|
||||
List<DirInfo> all = getAllAttach("");
|
||||
string allJson = JsonConvert.SerializeObject(all);
|
||||
//string basePath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";//基础目录
|
||||
|
||||
//string[] arrDirs = Directory.GetDirectories(basePath);
|
||||
return View();
|
||||
//return Content(JsonConvert.SerializeObject(allJson));
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -46,7 +52,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
[MyAuthorize("viewlist", "attach","JSON")]
|
||||
public IActionResult GetDirList(string subdir)
|
||||
{
|
||||
string attachPath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";
|
||||
//string attachPath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";
|
||||
|
||||
|
||||
|
||||
@@ -54,5 +60,42 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取附件目录和所有子目录树
|
||||
/// <summary>
|
||||
/// 所有所有附件目录树
|
||||
/// </summary>
|
||||
/// <param name="subdir">子目录,需要完整,如:images/2020</param>
|
||||
/// <returns></returns>
|
||||
public List<DirInfo> getAllAttach(string subdir)
|
||||
{
|
||||
List<DirInfo> list = new List<DirInfo>();
|
||||
string basePath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";//基础目录
|
||||
if (!string.IsNullOrEmpty(subdir))
|
||||
{
|
||||
basePath += subdir.Replace("/", Path.DirectorySeparatorChar.ToString());
|
||||
}
|
||||
|
||||
string[] arrDirs = Directory.GetDirectories(basePath);
|
||||
|
||||
if (arrDirs !=null && arrDirs.Length > 0)
|
||||
{
|
||||
foreach (var item in arrDirs)
|
||||
{
|
||||
string nextSubDir = subdir + "/" + item.Substring(item.LastIndexOf(Path.DirectorySeparatorChar)+1);
|
||||
var tpmList = getAllAttach(nextSubDir);
|
||||
list.Add(new DirInfo()
|
||||
{
|
||||
name = item.Substring(item.LastIndexOf(Path.DirectorySeparatorChar)+1),
|
||||
path = nextSubDir,
|
||||
//fullPath = item,
|
||||
subList = tpmList
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
@{
|
||||
ViewBag.title = "附件管理";
|
||||
}
|
||||
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-content">
|
||||
<div class="file-manager">
|
||||
<h5>显示:</h5>
|
||||
<a href="file_manager.html#" class="file-control active">所有</a>
|
||||
<a href="file_manager.html#" class="file-control">文档</a>
|
||||
<a href="file_manager.html#" class="file-control">视频</a>
|
||||
<a href="file_manager.html#" class="file-control">图片</a>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<button class="btn btn-primary btn-block">上传文件</button>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<h5>文件夹</h5>
|
||||
<ul class="folder-list" style="padding: 0">
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> 文件</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> 图片</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> Web页面</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> 插图</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> 电影</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> 书籍</a>
|
||||
</li>
|
||||
</ul>
|
||||
<h5 class="tag-title">标签</h5>
|
||||
<ul class="tag-list" style="padding: 0">
|
||||
<li>
|
||||
<a href="file_manager.html">爱人</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">工作</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">家庭</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">孩子</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">假期</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">音乐</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">照片</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">电影</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user