增加功能:设置网站自定义样式

This commit is contained in:
Argo-Lenovo 2016-12-09 20:13:22 +08:00
parent 896a106749
commit 5a17768d98
11 changed files with 758 additions and 156 deletions

View File

@ -1,46 +1,571 @@
body {
color: #797979;
background: #f1f2f7;
font-family: 'Open Sans', sans-serif;
padding: 0px !important;
margin: 0px !important;
font-size: 13px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;
}
.form-control {
border: solid 1px #41cac0;
ul li {
list-style: none;
}
.panel-default {
border-color: #41cac0;
a, a:hover, a:focus {
text-decoration: none;
outline: none;
}
.panel-default > .panel-heading{
border-color: #41cac0;
.dropdown-menu {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.176) !important;
}
.body-header {
border-color: #41cac0;
.well-bg {
color: #fff;
}
.lgbBreadcrumb {
border-color: #41cac0;
.header, .footer {
padding: 0 15px;
}
.breadcrumb > li + li:before {
color: #41cac0;
.header {
height: 94px;
border-color: #ddd;
border-width: 0 0 1px 0;
border-style: solid;
}
ul.top-menu > li > a {
border-color: #41cac0 !important;
.white-bg {
background: #5992ad;
border-bottom: 1px solid #000;
}
ul.top-menu > li > a:hover {
border-color: #3c763d !important;
.arrow-up {
background: url("../images/arrow-up.png") no-repeat;
width: 20px;
height: 11px;
position: absolute;
right: 20px;
top: -10px;
}
/*Title*/
.sidebar-toggle-box {
font-size: 21px;
color: #333;
float: left;
margin-top: 15px;
text-transform: uppercase;
}
.site-footer {
background: #5b6e84;
color: #fff;
padding: 10px 4px;
height: 40px;
}
.site-footer {
position: fixed;
left: 0;
bottom: 0;
right: 0;
z-index: 50;
}
/*end title*/
.go-top {
margin-right: 1%;
float: right;
background: rgba(255,255,255,.5);
width: 20px;
height: 20px;
border-radius: 50%;
-webkit-border-radius: 50%;
}
.go-top:hover {
background-color: white;
}
ul.top-menu > li > a:focus {
border-color: #3c763d !important;
.go-top i {
color: #2A3542;
}
.dropdown-menu.logout {
border: 1px solid #41cac0 !important;
/*Right Profile*/
.top-menu {
margin-top: 7px;
}
.dropdown-menu.logout > li:nth-child(5) {
border-top: solid 1px #41cac0;
.top-menu .username {
font-size: 13px;
color: #b90000;
display: inline-block;
min-width: 18px;
}
.top-menu li {
float: left;
}
.top-menu > li {
margin-left: 10px;
}
.top-menu > li > a:hover, top-menu > li > a:focus {
border: 1px solid #F1F2F7;
background: #F1F2F7;
}
.top-menu > li > a > img {
height: 29px;
width: 29px;
}
.top-menu > li > a {
border: 1px solid #333;
border-radius: 4px;
-webkit-border-radius: 4px;
padding: 6px;
background: none;
margin-right: 0;
display: block;
white-space: nowrap;
}
.top-menu > li > a:hover .caret {
border-bottom-color: #000;
border-top-color: #000;
}
.top-menu > li > a:hover, .top-menu > li > a:focus {
border: 1px solid #000 !important;
background-color: #5992ad !important;
text-decoration: none;
border-radius: 4px;
-webkit-border-radius: 4px;
color: #2E2E2E !important;
}
.top-menu .caret {
border-bottom-color: #A4AABA;
border-top-color: #A4AABA;
}
.top-menu .dropdown-menu.logout {
width: 268px !important;
top: 50px;
left: auto;
right: 0;
padding: 0;
}
.top-menu .dropdown-menu.logout li {
text-align: center;
width: 33.3%;
}
.top-menu .dropdown-menu.logout li:last-child {
float: left;
width: 100%;
background: #a9d96c;
border-radius: 0 0 3px 3px;
}
.top-menu .dropdown-menu.logout li:last-child a, .top-menu .dropdown-menu.logout li:last-child a:hover {
color: #fff;
text-transform: uppercase;
}
.top-menu .dropdown-menu.logout li:last-child a:hover, .top-menu .dropdown-menu.logout li:last-child a:hover i {
color: #FF6C60;
}
.top-menu .dropdown-menu.logout li a {
color: #a4abbb;
border-bottom: none;
padding: 15px 10px;
}
.top-menu .dropdown-menu.logout li a:hover {
background: none !important;
color: #337ab7;
}
.top-menu .dropdown-menu.logout li a:hover i {
color: #50c8ea;
}
.top-menu .dropdown-menu.logout li a i {
font-size: 17px;
display: block;
margin-bottom: 4px;
}
.top-menu .dropdown-menu.logout li a .badge {
position: absolute;
right: 20px;
top: 4px;
background: #5cb85c;
}
.top-menu .search {
margin-top: 6px;
width: 20px;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
border: 1px solid #fff;
box-shadow: none;
background: url("../images/search-icon.png") no-repeat 10px 8px;
padding: 0 5px 0 35px;
color: #000;
}
.top-menu .search:focus {
margin-top: 5px;
width: 180px;
border: 1px solid #eaeaea;
box-shadow: none;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
color: #c8c8c8;
font-weight: 300;
}
/*end*/
/*notify bar*/
.notify-row {
margin-top: 20px;
padding-left: 20px;
display: inline-block;
}
.notify-row .bg-success, .notify-row .dropdown-menu.tasks-bar li p {
background: #a9d86e;
}
.notify-row .bg-important, .notify-row .dropdown-menu.inbox li p {
background: #ff6c60;
}
.notify-row .bg-user, .notify-row .dropdown-menu.users li p {
background: #5cb85c;
}
.notify-row .bg-warning, .notify-row .dropdown-menu.notification li p {
background: #FCB322;
}
.notify-row .bg-db, .notify-row .dropdown-menu.dbs li p {
background: #d03633;
}
.notify-row > li {
float: left;
position: relative;
display: block;
}
.notify-row > li > a {
color: #333;
border-radius: 4px;
-webkit-border-radius: 4px;
font-size: 16px;
border: 1px solid #000;
padding: 2px 6px;
margin-right: 15px;
}
.notify-row > li > a .badge {
position: absolute;
top: -10px;
z-index: 1;
}
.notify-row .dropdown-menu {
float: left;
max-width: 300px !important;
min-width: 160px !important;
top: 32px;
left: -74px;
width: 235px !important;
padding: 0;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.176) !important;
border: none;
}
.notify-row .dropdown-menu .notify-arrow {
border-style: solid;
border-width: 0 9px 9px;
height: 0;
margin-top: 0;
opacity: 0;
position: absolute;
left: 80px;
top: -18px;
transition: all 0.25s ease 0s;
width: 0;
z-index: 10;
margin-top: 10px;
opacity: 1;
}
.notify-row .dropdown-menu .notify-arrow.notify-arrow-green {
border-color: transparent transparent #a9d86e;
border-bottom-color: #a9d86e;
border-top-color: #a9d86e;
}
.notify-row .dropdown-menu .notify-arrow.notify-arrow-yellow {
border-color: transparent transparent #FCB322;
border-bottom-color: #FCB322;
border-top-color: #FCB322;
}
.notify-row .dropdown-menu .notify-arrow.notify-arrow-red {
border-color: transparent transparent #ff6c60;
border-bottom-color: #ff6c60;
border-top-color: #ff6c60;
}
.notify-row .dropdown-menu .notify-arrow.notify-arrow-db {
border-color: transparent transparent #d03633;
border-bottom-color: #d03633;
border-top-color: #d03633;
}
.notify-row .dropdown-menu .notify-arrow.notify-arrow-user {
border-color: transparent transparent #5cb85c;
border-bottom-color: #5cb85c;
border-top-color: #5cb85c;
}
.notify-row .dropdown-menu li:last-child, .notify-row .dropdown-menu li:last-child a:hover {
border-radius: 0 0 4px 4px;
}
.notify-row .dropdown-menu li:last-child a {
border-bottom: 0;
}
.notify-row .dropdown-menu li a {
border-bottom: 1px solid #EBEBEB;
font-size: 12px;
list-style: none;
padding: 15px 10px;
width: 100%;
display: inline-block;
}
.notify-row .dropdown-menu li a:hover {
background-color: #F7F8F9;
color: #2E2E2E;
}
.notify-row .dropdown-menu p {
color: #fff;
margin: 0;
padding: 10px;
border-radius: 4px 4px 0px 0px;
-webkit-border-radius: 4px 4px 0px 0px;
}
.notify-row .dropdown-menu .content {
position: absolute;
left: 36px;
right: 44px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: inline-block;
}
.notify-row .dropdown-menu .label {
display: inline-block;
height: 18px;
width: 20px;
padding: 5px;
margin-right: 5px;
}
.notify-row .dropdown-menu .small {
font-size: 10px;
font-style: italic;
font-weight: bold;
float: right;
padding-top: 2px;
}
.notify-row .dropdown-menu.tasks-bar .desc {
font-size: 13px;
font-weight: normal;
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.notify-row .dropdown-menu.tasks-bar .percent {
display: inline-block;
float: right;
font-size: 13px;
font-weight: 600;
}
.notify-row .dropdown-menu.tasks-bar .progress {
margin-top: 4px;
height: 10px;
margin-right: 34px;
margin-bottom: 0;
}
.notify-row .dropdown-menu.inbox .photo img {
border-radius: 2px 2px 2px 2px;
float: left;
height: 42px;
margin-right: 4px;
width: 42px;
border: solid 1px #EBEBEB;
border-radius: 3px;
}
.notify-row .dropdown-menu.inbox .subject {
display: block;
}
.notify-row .dropdown-menu.inbox .subject .from {
font-weight: 600;
}
.notify-row .dropdown-menu.inbox .subject .time {
font-size: 11px;
font-style: italic;
font-weight: bold;
float: right;
}
.notify-row .dropdown-menu.inbox .message {
font-size: 11px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
position: absolute;
right: 6px;
left: 56px;
margin-top: 2px;
}
.dropdown-menu.menu {
top: 50px;
left: 6px;
margin-right: 15px;
min-height: 160px;
min-width: 280px;
}
.dropdown-menu.menu .arrow-up {
left: 8px;
top: -10px;
}
.dropdown-menu.menu .menu-submenu {
padding: 0 16px;
}
.dropdown-menu.menu .menu-submenu ul {
float: left;
padding-left: 10px;
padding-right: 10px;
}
.dropdown-menu.menu .menu-submenu li p {
color: #323232;
font-size: 14px;
text-transform: none;
font-weight: bold;
border-bottom: solid 1px #a9d86e;
padding: 10px 0 4px 0;
margin-bottom: 14px;
}
.dropdown-menu.menu .menu-submenu li a {
margin-bottom: 15px;
display: inline-block;
color: #323232;
font-size: 13px;
}
.dropdown-menu.menu .menu-submenu li a.active, .dropdown-menu.menu .menu-submenu li p.active {
color: #0376d8;
}
.dropdown-menu.menu .menu-submenu li a:hover {
color: #2e6da4;
}
.dropdown-menu.menu .menu-submenu li a i {
padding-right: 6px;
}
/*end*/
ul.breadcrumb {
position: absolute;
top: 56px;
left: 15px;
right: 15px;
border-color: #000;
border-width: 1px 0 0 0;
border-style: solid;
background-color: transparent;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
ul.breadcrumb > li {
color: #000;
}
ul.breadcrumb > li + li:before {
color: #000;
}
ul.breadcrumb > li.active {
display: inline-block;
}
ul.breadcrumb > li.load {
display: none;
}
ul.breadcrumb > li > a {
color: #000;
}
ul.breadcrumb > li > a > i {
padding-right: 6px;
}
.content-body {
position: fixed;
left: 0;
bottom: 40px;
right: 0;
top: 94px;
background-image: url('../images/bg.jpg');
overflow: hidden;
}
.content-body iframe {
width: 100%;
height: 100%;
border: none;
}

View File

@ -145,7 +145,6 @@ a, a:hover, a:focus {
.top-menu > li > a:hover, .top-menu > li > a:focus {
border: 1px solid #f0f0f8 !important;
background-color: #fff !important;
border-color: #f0f0f8 !important;
text-decoration: none;
border-radius: 4px;
-webkit-border-radius: 4px;
@ -543,7 +542,6 @@ ul.breadcrumb {
padding-right: 6px;
}
.content-body {
position: fixed;
left: 0;

View File

@ -110,6 +110,115 @@
language: (navigator.browserLanguage || navigator.language).toLowerCase()
}
$.extend({
bc: function (options, callback) {
var data = $.extend({
remote: true,
Id: "",
url: this.url,
data: {},
method: "POST",
htmlTemplate: '<div class="form-group checkbox col-lg-3 col-xs-4"><label class="tooltips" data-placement="top" data-original-title="{3}" title="{3}"><input type="checkbox" value="{0}" {2}/>{1}</label></div>',
title: this.title,
swal: true,
modal: null,
callback: null
}, options);
if (!data.url || data.url == "") {
swal('参数错误', '未设置请求地址Url', 'error');
return;
}
if (data.remote && data.url) {
$.ajax({
url: data.url + data.Id,
data: data.data,
type: data.method,
success: function (result) {
success(result);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
if ($.isFunction(data.callback)) data.callback(false);
}
});
}
function success(result) {
if ($.isFunction(data.callback)) {
data.callback(result);
}
if (data.modal !== null) {
$("#" + data.modal).modal('hide');
}
if (data.swal) {
if (result) { swal("成功", data.title, "success"); }
else { swal("失败", data.title, "error"); }
}
}
}
});
// Roles
Role = {
url: '../api/Roles/',
title: "授权角色"
};
// Users
User = {
url: '../api/Users/',
title: "授权用户"
};
// Groups
Group = {
url: '../api/Groups/',
title: "授权部门"
};
// Menus
Menu = {
url: '../api/Menus/',
title: "授权菜单"
};
// Exceptions
Exceptions = {
url: '../api/Exceptions/',
title: "程序异常日志"
};
// Dicts
Dicts = {
url: '../api/Dicts/'
};
// Infos
Infos = {
url: '../api/Infos/'
}
// Profiles
Profiles = {
url: '../api/Profiles/',
title: '网站设置'
}
// Messages
Messages = {
url: '../api/Messages/'
}
// Tasks
Tasks = {
url: '../api/Tasks/'
}
// Notifications
Notifications = {
url: '../api/Notifications/'
}
$.fn.extend({
adjustDialog: function () {
var $modal_dialog = this;
@ -234,6 +343,13 @@
})(jQuery);
$(function () {
// loading customer css
$.bc({
Id: 1, url: Dicts.url, data: { type: 'activeCss' }, swal: false,
callback: function (result) {
$('head').append($.format('<link href="../Content/css/{0}" rel="stylesheet" type="text/css" />', result[0].Code));
}
});
if ($.isFunction($.validator)) {
jQuery.validator.addMethod("ip", function (value, element) {
return this.optional(element) || /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/.test(value);

View File

@ -232,114 +232,4 @@
if ($.isFunction(callback)) callback.call(e, data);
if ($.isFunction(this.options.callback)) this.options.callback.call(e, data);
}
$.extend({
bc: function (options, callback) {
var data = $.extend({
remote: true,
Id: "",
url: this.url,
data: {},
method: "POST",
htmlTemplate: '<div class="form-group checkbox col-lg-3 col-xs-4"><label class="tooltips" data-placement="top" data-original-title="{3}" title="{3}"><input type="checkbox" value="{0}" {2}/>{1}</label></div>',
title: this.title,
swal: true,
modal: null,
callback: null
}, options);
if (!data.url || data.url == "") {
swal('参数错误', '未设置请求地址Url', 'error');
return;
}
if (data.remote && data.url) {
$.ajax({
url: data.url + data.Id,
data: data.data,
type: data.method,
success: function (result) {
success(result);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
if ($.isFunction(data.callback)) data.callback(false);
}
});
}
function success(result) {
if ($.isFunction(data.callback)) {
data.callback(result);
}
if (data.modal !== null) {
$("#" + data.modal).modal('hide');
}
if (data.swal) {
if (result) { swal("成功", data.title, "success"); }
else { swal("失败", data.title, "error"); }
}
}
}
});
// Roles
Role = {
url: '../api/Roles/',
title: "授权角色"
};
// Users
User = {
url: '../api/Users/',
title: "授权用户"
};
// Groups
Group = {
url: '../api/Groups/',
title: "授权部门"
};
// Menus
Menu = {
url: '../api/Menus/',
title: "授权菜单"
};
// Exceptions
Exceptions = {
url: '../api/Exceptions/',
title: "程序异常日志"
};
// Dicts
Dicts = {
url: '../api/Dicts/'
};
// Infos
Infos = {
url: '../api/Infos/'
}
// Profiles
Profiles = {
url: '../api/Profiles/',
title: '网站设置'
}
// Messages
Messages = {
url: '../api/Messages/'
}
// Tasks
Tasks = {
url: '../api/Tasks/'
}
// Notifications
Notifications = {
url: '../api/Notifications/'
}
})(jQuery);

View File

@ -45,14 +45,21 @@ namespace Bootstrap.Admin.Controllers
/// </summary>
/// <returns></returns>
[HttpPost]
public IEnumerable<string> Post(int id, [FromBody]JObject value)
[AllowAnonymous]
public IEnumerable<Dict> Post(int id, [FromBody]JObject value)
{
var ret = new List<string>();
IEnumerable<Dict> ret = new List<Dict>();
dynamic json = value;
switch ((string)json.type)
{
case "category":
ret = DictHelper.RetrieveCategories().ToList();
ret = DictHelper.RetrieveCategories();
break;
case "css":
ret = DictHelper.RetrieveWebCss();
break;
case "activeCss":
ret = DictHelper.RetrieveActiveCss();
break;
default:
break;

View File

@ -22,7 +22,7 @@
{ title: "字典分项", field: "Category", sortable: true },
{ title: "字典名称", field: "Name", sortable: false },
{ title: "字典代码", field: "Code", sortable: false },
{ title: "字典类别", field: "DefineName", sortable: true }
{ title: "字典类别", field: "Define", sortable: true, formatter: function (value, row, index) { return value == "0" ? "系统使用" : "自定义"; } }
]
});
@ -52,8 +52,9 @@
$.bc({
Id: 1, url: Dicts.url, data: { type: 'category' }, swal: false,
callback: function (result) {
var data = result.map(function (ele, index) { return ele.Category; });
$('#txt_dict_cate').typeahead({
source: result,
source: data,
autoSelect: true
});
}

View File

@ -53,6 +53,21 @@
});
}
}
}, {
id: 'cssSave',
click: function (row, data) {
var cssDefine = $('#dictCssDefine').attr('data-val');
if (cssDefine) {
$.bc({
url: Profiles.url, data: { name: '使用样式', code: cssDefine, category: '当前样式' }, title: '网站样式',
callback: function (result) {
if (result) {
window.setTimeout(function () { window.location.reload(true); }, 1000);
}
}
});
}
}
}]
}
});
@ -151,4 +166,19 @@
listCache({ key: $(this).attr('data-key'), url: $(this).attr('data-url') });
listCacheUrl();
});
$.bc({
Id: 1, url: Dicts.url, data: { type: 'css' }, swal: false,
callback: function (result) {
var html = result.map(function (ele, index) { return $.format('<li><a href="#" data-val="{1}">{0}</a></li>', ele.Name, ele.Code); }).join('');
$('#cssContainer').html(html);
$('.btn-select').select();
$.bc({
Id: 1, url: Dicts.url, data: { type: 'activeCss' }, swal: false,
callback: function (result) {
$('#dictCssDefine').selectval(result[0].Code);
}
});
}
});
})

View File

@ -46,6 +46,27 @@
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">网站样式</div>
<div class="panel-body">
<form id="CssDataForm" class="form-inline" name="CssDataForm">
<div class="form-group col-xs-12">
<label class="control-label" for="dictDefine">网站样式</label>
<div class="btn-group btn-select">
<button id="dictCssDefine" type="button" class="btn btn-success" data-default-val="site.css" data-val="site.css">默认样式</button>
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">网站样式</span>
</button>
<ul class="dropdown-menu" role="menu" id="cssContainer">
<li><a href="#" data-val="site.css">默认样式</a></li>
</ul>
</div>
<button class="btn btn-default pull-right" type="button" id="cssSave">保存</button>
</div>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">网站缓存<a id="clearCache" href="#" class="clearcache fa fa-times-circle-o" data-admin="@LgbPrincipal.IsAdmin(Model.UserName)" title="全部清除(WebAdmin可用)"></a><a id="refreshCache" href="#" class="pull-right fa fa-refresh" title="点击刷新"></a></div>
<div class="panel-body">

View File

@ -27,9 +27,5 @@
/// 1表示系统使用0表示用户自定义 默认为1
/// </summary>
public int Define { get; set; }
/// <summary>
/// 获得/设置 字典定义类别名称
/// </summary>
public string DefineName { get; set; }
}
}

View File

@ -25,7 +25,7 @@ namespace Bootstrap.DataAccess
{
return CacheManager.GetOrAdd(RetrieveDictsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveDictsDataKey), key =>
{
string sql = "select ID, Category, Name, Code, Define, case Define when 0 then '系统使用' else '自定义' end DefineName from Dicts";
string sql = "select ID, Category, Name, Code, Define from Dicts";
List<Dict> Dicts = new List<Dict>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try
@ -40,8 +40,7 @@ namespace Bootstrap.DataAccess
Category = (string)reader[1],
Name = (string)reader[2],
Code = (string)reader[3],
Define = (int)reader[4],
DefineName = (string)reader[5]
Define = (int)reader[4]
});
}
}
@ -114,7 +113,7 @@ namespace Bootstrap.DataAccess
{
return CacheManager.GetOrAdd(RetrieveWebSettingsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveWebSettingsDataKey), key =>
{
string sql = "select ID, Category, Name, Code, Define, case Define when 0 then '系统使用' else '用户自定义' end DefineName from Dicts where Category = N'网站设置' and Define = 0";
string sql = "select ID, Category, Name, Code, Define from Dicts where Category = N'网站设置' and Define = 0";
List<Dict> Dicts = new List<Dict>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try
@ -129,8 +128,7 @@ namespace Bootstrap.DataAccess
Category = (string)reader[1],
Name = (string)reader[2],
Code = (string)reader[3],
Define = (int)reader[4],
DefineName = (string)reader[5]
Define = (int)reader[4]
});
}
}
@ -158,6 +156,24 @@ namespace Bootstrap.DataAccess
return (settings.FirstOrDefault(d => d.Name == "网站页脚") ?? new Dict() { Code = "2016 © 通用后台管理系统" }).Code;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public static IEnumerable<Dict> RetrieveWebCss()
{
var data = RetrieveDicts();
return data.Where(d => d.Category == "网站样式");
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public static IEnumerable<Dict> RetrieveActiveCss()
{
var data = RetrieveDicts();
return data.Where(d => d.Category == "当前样式");
}
/// <summary>
/// 保存网站个性化设置
/// </summary>
/// <param name="name"></param>
@ -177,7 +193,7 @@ namespace Bootstrap.DataAccess
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", category, ParameterDirection.Input));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
}
CacheManager.Clear(key => key == RetrieveWebSettingsDataKey);
CacheManager.Clear(key => key.Contains(RetrieveDictsDataKey));
ret = true;
}
catch (DbException ex)
@ -194,7 +210,7 @@ namespace Bootstrap.DataAccess
{
return CacheManager.GetOrAdd(RetrieveIconPathSettingsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveIconPathSettingsDataKey), key =>
{
string sql = "select ID, Category, Name, Code, Define, case Define when 0 then '系统使用' else '用户自定义' end DefineName from Dicts where Category = N'头像地址' and Name = N'头像路径' and Define = 0";
string sql = "select ID, Category, Name, Code, Define from Dicts where Category = N'头像地址' and Name = N'头像路径' and Define = 0";
var dict = new Dict() { Code = "~/Content/images/uploader/" };
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try
@ -209,8 +225,7 @@ namespace Bootstrap.DataAccess
Category = (string)reader[1],
Name = (string)reader[2],
Code = (string)reader[3],
Define = (int)reader[4],
DefineName = (string)reader[5]
Define = (int)reader[4]
};
}
}
@ -223,11 +238,11 @@ namespace Bootstrap.DataAccess
/// 获取字典分类名称
/// </summary>
/// <returns></returns>
public static IEnumerable<string> RetrieveCategories()
public static IEnumerable<Dict> RetrieveCategories()
{
return CacheManager.GetOrAdd(RetrieveCategoryDataKey, CacheSection.RetrieveIntervalByKey(RetrieveCategoryDataKey), key =>
{
var ret = new List<string>();
var ret = new List<Dict>();
string sql = "select distinct Category from Dicts";
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try
@ -236,7 +251,7 @@ namespace Bootstrap.DataAccess
{
while (reader.Read())
{
ret.Add((string)reader[0]);
ret.Add(new Dict() { Category = (string)reader[0] });
}
}
}

View File

@ -24,6 +24,9 @@ INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (13, N'
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (14, N'消息标签', N'一般', N'0', 0)
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (15, N'消息标签', N'紧要', N'1', 0)
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (16, N'头像地址', N'头像路径', N'~/Content/images/uploader/', 0)
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (17, N'网站样式', N'默认样式', N'site.css', 0)
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (18, N'网站样式', N'蓝色样式', N'blue.css', 0)
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (19, N'当前样式', N'使用样式', N'site.css', 0)
SET IDENTITY_INSERT [dbo].[Dicts] OFF
DELETE FROM Navigations