修改BUG:个人中心页面初始化时获得用户头像大小

This commit is contained in:
Argo-MacBookPro 2018-09-28 09:54:26 +08:00
parent 8354b86aa1
commit 7480e821c3
2 changed files with 5 additions and 7 deletions

View File

@ -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;

View File

@ -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,