Merge branch 'dev-favicon' into dev

This commit is contained in:
Argo Zhang 2019-10-07 00:54:34 +08:00
commit daccc75d71
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
12 changed files with 50 additions and 18 deletions

View File

@ -284,8 +284,14 @@
},
{
"Category": "测试平台",
"Name": "网站图标",
"Name": "favicon",
"Code": "http://localhost:49185/favicon.ico",
"Define": NumberInt(1)
},
{
"Category": "测试平台",
"Name": "网站图标",
"Code": "http://localhost:49185/favicon.png",
"Define": NumberInt(1)
}
];

View File

@ -157,7 +157,8 @@ Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '网站
Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '个人中心地址', 'http://localhost:50852/Admin/Profiles', 1);
Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '系统设置地址', 'http://localhost:50852/Admin/Index', 1);
Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '系统通知地址', 'http://localhost:50852/Admin/Notifications', 1);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('测试平台', '网站图标', 'http://localhost:49185/favicon.ico', 1);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('测试平台', 'favicon', 'http://localhost:49185/favicon.ico', 1);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('测试平台', '网站图标', 'http://localhost:49185/favicon.png', 1);
Delete from Navigations where Application = 2;
INSERT into Navigations (ParentId, Name, `Order`, Icon, Url, Category, Application) VALUES (0, '首页', 10, 'fa fa-fa', '~/Home/Index', '1', 2);

View File

@ -158,7 +158,8 @@ Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '网站
Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '个人中心地址', 'http://localhost:50852/Admin/Profiles', 1);
Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '系统设置地址', 'http://localhost:50852/Admin/Index', 1);
Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '系统通知地址', 'http://localhost:50852/Admin/Notifications', 1);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('测试平台', '网站图标', 'http://localhost:49185/favicon.ico', 1);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('测试平台', 'favicon', 'http://localhost:49185/favicon.ico', 1);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('测试平台', '网站图标', 'http://localhost:49185/favicon.png', 1);
Delete from Navigations where Application = '2';
INSERT into Navigations (ParentId, Name, "order", Icon, Url, Category, Application) VALUES (0, '首页', 10, 'fa fa-fa', '~/Home/Index', '1', 2);

View File

@ -163,7 +163,8 @@ Insert into Dicts (Category, [Name], Code, Define) values ('测试平台', '网
Insert into Dicts (Category, [Name], Code, Define) values ('测试平台', '个人中心地址', 'http://localhost:50852/Admin/Profiles', 1);
Insert into Dicts (Category, [Name], Code, Define) values ('测试平台', '系统设置地址', 'http://localhost:50852/Admin/Index', 1);
Insert into Dicts (Category, [Name], Code, Define) values ('测试平台', '系统通知地址', 'http://localhost:50852/Admin/Notifications', 1);
INSERT INTO Dicts (Category, [Name], Code, Define) VALUES ('测试平台', '网站图标', 'http://localhost:49185/favicon.ico', 1);
INSERT INTO Dicts (Category, [Name], Code, Define) VALUES ('测试平台', 'favicon', 'http://localhost:49185/favicon.ico', 1);
INSERT INTO Dicts (Category, [Name], Code, Define) VALUES ('测试平台', '网站图标', 'http://localhost:49185/favicon.png', 1);
Delete from [Navigations] where Application = 2;
INSERT into [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category], [Application]) VALUES (0, '首页', 10, 'fa fa-fa', '~/Home/Index', '1', 2);

View File

@ -170,7 +170,8 @@ Insert Dicts (Category, Name, Code, Define) values (@AppName, N'网站页脚', N
Insert Dicts (Category, Name, Code, Define) values (@AppName, N'个人中心地址', N'http://localhost:50852/Admin/Profiles', 1);
Insert Dicts (Category, Name, Code, Define) values (@AppName, N'系统设置地址', N'http://localhost:50852/Admin/Index', 1);
Insert Dicts (Category, Name, Code, Define) values (@AppName, N'系统通知地址', N'http://localhost:50852/Admin/Notifications', 1);
INSERT Dicts (Category, Name, Code, Define) VALUES (@AppName, N'网站图标', N'http://localhost:49185/favicon.ico', 1);
INSERT Dicts (Category, Name, Code, Define) VALUES (@AppName, N'favicon', N'http://localhost:49185/favicon.ico', 1);
INSERT Dicts (Category, Name, Code, Define) VALUES (@AppName, N'网站图标', 'http://localhost:49185/favicon.png', 1);
-- 菜单
DELETE FROM Navigations Where [Application] = @AppId

View File

@ -31,7 +31,7 @@ namespace Bootstrap.Admin.Models
// feat: https://gitee.com/LongbowEnterprise/dashboard/issues?id=I12VKZ
// 后台系统网站图标跟随个人中心设置的默认应用站点的展示
WebSiteLogo = DictHelper.RetrieveWebLogo(AppId);
WebSiteIcon = DictHelper.RetrieveWebIcon(AppId);
}
}

View File

@ -1,13 +1,13 @@
namespace Bootstrap.Admin.Models
{
/// <summary>
///
/// Model 基类
/// </summary>
public class ModelBase
{
/// <summary>
/// 获取 网站 logo 小图标
/// </summary>
public string WebSiteLogo { get; protected set; } = "~/favicon.ico";
public string WebSiteIcon { get; protected set; } = "~/favicon.ico";
}
}

View File

@ -8,12 +8,12 @@ using System.Linq;
namespace Bootstrap.Admin.Models
{
/// <summary>
///
/// 侧边栏导航条 Model
/// </summary>
public class NavigatorBarModel : HeaderBarModel
{
/// <summary>
///
/// 构造函数
/// </summary>
/// <param name="controller"></param>
public NavigatorBarModel(ControllerBase controller) : base(controller.User.Identity)
@ -21,15 +21,24 @@ namespace Bootstrap.Admin.Models
Navigations = MenuHelper.RetrieveSystemMenus(UserName, $"~{controller.HttpContext.Request.Path}");
var authApps = AppHelper.RetrievesByUserName(controller.User.Identity.Name);
Applications = DictHelper.RetrieveApps().Where(app => app.Key == "0" || authApps.Any(key => key.Equals(app.Key, StringComparison.OrdinalIgnoreCase)));
// feat: https://gitee.com/LongbowEnterprise/dashboard/issues?id=I12VKZ
// 后台系统网站图标跟随个人中心设置的默认应用站点的展示
WebSiteLogo = DictHelper.RetrieveWebLogo(AppId);
}
/// <summary>
///
/// 获得 网站图标
/// </summary>
public string WebSiteLogo { get; protected set; }
/// <summary>
/// 获得 网站菜单
/// </summary>
public IEnumerable<BootstrapMenu> Navigations { get; private set; }
/// <summary>
///
/// 获得 网站应用程序
/// </summary>
public IEnumerable<KeyValuePair<string, string>> Applications { get; private set; }
}

View File

@ -3,7 +3,7 @@
<div class="bg"></div>
<div class="nav-brand justify-content-center">
<a href="#">
<img src="~/favicon.png" />
<img src="@Url.Content(@Model.WebSiteLogo)" />
<span>@Model.Title</span>
</a>
</div>

View File

@ -5,8 +5,8 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" href="@Url.Content(Model.WebSiteLogo)" type="image/x-icon" />
<link rel="shortcut icon" href="@Url.Content(Model.WebSiteLogo)" type="image/x-icon" />
<link rel="icon" href="@Url.Content(Model.WebSiteIcon)" type="image/x-icon" />
<link rel="shortcut icon" href="@Url.Content(Model.WebSiteIcon)" type="image/x-icon" />
<link rel="apple-touch-icon" href="~/favicon.png"/>
<title>@ViewBag.Title</title>
@RenderSection("css", false)

View File

@ -31,6 +31,19 @@ namespace Bootstrap.DataAccess
private static IEnumerable<BootstrapDict> RetrieveProtectedDicts() => RetrieveDicts().Where(d => d.Define == 0 || d.Category == "测试平台");
/// <summary>
/// 获取网站 favicon 图标
/// </summary>
/// <param name="appId"></param>
/// <returns></returns>
public static string RetrieveWebIcon(string appId)
{
// 获取应用程序 logo
var ditcs = RetrieveDicts();
var platName = ditcs.FirstOrDefault(d => d.Category == "应用程序" && d.Code == appId)?.Name;
return ditcs.FirstOrDefault(d => d.Category == platName && d.Name == "favicon")?.Code ?? $"~/favicon.ico";
}
/// <summary>
/// 获取网站 logo 小图标
/// </summary>
@ -41,7 +54,7 @@ namespace Bootstrap.DataAccess
// 获取应用程序 logo
var ditcs = RetrieveDicts();
var platName = ditcs.FirstOrDefault(d => d.Category == "应用程序" && d.Code == appId)?.Name;
return ditcs.FirstOrDefault(d => d.Category == platName && d.Name == "网站图标")?.Code ?? $"~/favicon.ico";
return ditcs.FirstOrDefault(d => d.Category == platName && d.Name == "网站图标")?.Code ?? $"~/favicon.png";
}
/// <summary>