修改BUG:个人中心页面初始化时获得用户头像大小
This commit is contained in:
parent
8354b86aa1
commit
7480e821c3
|
@ -1,8 +1,5 @@
|
|||
using Bootstrap.DataAccess;
|
||||
using Bootstrap.Security;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Bootstrap.Admin.Models
|
||||
|
@ -22,8 +19,9 @@ namespace Bootstrap.Admin.Models
|
|||
/// <param name="controller"></param>
|
||||
public ProfilesModel(ControllerBase controller) : base(controller)
|
||||
{
|
||||
// TODO: 找到MapPath方法
|
||||
var fileName = AppContext.BaseDirectory + Icon;
|
||||
var host = controller.HttpContext.RequestServices.GetService(typeof(IHostingEnvironment)) as IHostingEnvironment;
|
||||
if (host == null) return;
|
||||
var fileName = Path.Combine(host.WebRootPath, Icon.TrimStart('~', '/').Replace('/', '\\'));
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
Size = new FileInfo(fileName).Length;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
preIcon
|
||||
],
|
||||
initialPreviewConfig: [
|
||||
{ caption: "现在头像", size: $('#fileIcon').attr('data-init'), showZoom: true },
|
||||
{ caption: "现在头像", size: $('#fileIcon').attr('data-init'), showZoom: true }
|
||||
],
|
||||
initialPreviewAsData: true,
|
||||
overwriteInitial: true,
|
||||
|
|
Loading…
Reference in New Issue