Skip to content

Commit

Permalink
魔方不再强依赖Session,有就用,没有就降级到Cookie,最后降级到Token。
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Aug 1, 2024
1 parent a9765c8 commit 1b8eb97
Show file tree
Hide file tree
Showing 16 changed files with 286 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@using System.Runtime.Versioning;
@using Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Http.Extensions
@using Microsoft.AspNetCore.Http.Features
@using NewLife.Caching
@using NewLife.Common;
@using NewLife.Serialization;
Expand Down Expand Up @@ -106,7 +107,7 @@
</el-descriptions-item>
<el-descriptions-item label="进程时间">@process.TotalProcessorTime.TotalSeconds.ToString("N2")秒 启动于 @process.StartTime.ToLocalTime().ToFullString()</el-descriptions-item>
<el-descriptions-item label="Session">
@httpContext.Session.Keys.Count()
@(httpContext.Features.Get<ISessionFeature>()?.Session.Keys.Count() ?? 0)
<a href="@Url.Action("Main", new{ id = "Session" })" target="_blank" title="点击打开Session列表">Session列表</a>
@gc
</el-descriptions-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@using System.Runtime.Versioning;
@using Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Http.Extensions
@using Microsoft.AspNetCore.Http.Features
@using NewLife
@using NewLife.Caching
@using NewLife.Common;
Expand Down Expand Up @@ -287,7 +288,7 @@
</td>
<td>
<div class="layui-table-cell laytable-cell-1-0-1">
@httpContext.Session.Keys.Count()
@(httpContext.Features.Get<ISessionFeature>()?.Session.Keys.Count() ?? 0)
<a href="@Url.Action("Main", new{ id = "Session" })" target="_blank" title="点击打开Session列表">Session列表</a>
@gc
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,89 @@
@using System.Reflection;
@using System.Runtime.Versioning;
@using Microsoft.AspNetCore.Http
@using Microsoft.AspNetCore.Http.Features
@using NewLife.Common;
@using NewLife.Serialization
@inject IHttpContextAccessor HttpContextAccessor
@{
//Layout = NewLife.Cube.Setting.Current.Layout;
var session = HttpContextAccessor.HttpContext.Session;
var session = HttpContextAccessor.HttpContext.Features.Get<ISessionFeature>()?.Session;
var session2 = HttpContextAccessor.HttpContext.Items["Session"] as IDictionary<String, Object>;
ViewBag.Title = "Session列表";
}

<div class="layui-fluid" id="mainpage">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">
Session列表(@session.Keys.Count())
</div>
<div class="layui-card-body">
<div class="layui-form layui-border-box layui-table-view">
<div class="layui-table-box">
<div class="layui-table-header">
<table class="layui-table" cellspacing="0" cellpadding="0" border="0" lay-size="sm" style="width:100%">
<thead>
<tr>
<th>
<div class="layui-table-cell laytable-cell-1-0-0" data-id="1-0-0">
<span>
名称
</span>
</div>
</th>
<th>
<div class="layui-table-cell laytable-cell-1-0-1" data-id="1-0-1">
<span>
类型
</span>
</div>
</th>
<th>
<div class="layui-table-cell laytable-cell-1-0-2" data-id="1-0-2">
<span>
数值
</span>
</div>
</th>
</tr>
</thead>
</table>
</div>
<div class="layui-table-body layui-table-main">
<table class="layui-table" cellspacing="0" cellpadding="0" border="0" lay-size="sm" style="width:100%">
<tbody>
@foreach (String item in session.Keys)
{
@if (session != null)
{
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">
Session列表(@session.Keys.Count())
</div>
<div class="layui-card-body">
<div class="layui-form layui-border-box layui-table-view">
<div class="layui-table-box">
<div class="layui-table-header">
<table class="layui-table" cellspacing="0" cellpadding="0" border="0" lay-size="sm" style="width:100%">
<thead>
<tr>
<td>
<th>
<div class="layui-table-cell laytable-cell-1-0-0" data-id="1-0-0">
@item
<span>
名称
</span>
</div>
</td>
<td>
</th>
<th>
<div class="layui-table-cell laytable-cell-1-0-1" data-id="1-0-1">
<span>
类型
</span>
</div>
</td>
<td>
</th>
<th>
<div class="layui-table-cell laytable-cell-1-0-2" data-id="1-0-2">
@session.GetString(item)
<span>
数值
</span>
</div>
</td>
</th>
</tr>
}
</tbody>
</table>
</thead>
</table>
</div>
<div class="layui-table-body layui-table-main">
<table class="layui-table" cellspacing="0" cellpadding="0" border="0" lay-size="sm" style="width:100%">
<tbody>
@foreach (String item in session.Keys)
{
<tr>
<td>
<div class="layui-table-cell laytable-cell-1-0-0" data-id="1-0-0">
@item
</div>
</td>
<td>
<div class="layui-table-cell laytable-cell-1-0-1" data-id="1-0-1">
</div>
</td>
<td>
<div class="layui-table-cell laytable-cell-1-0-2" data-id="1-0-2">
@session.GetString(item)
</div>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
}
@if (session2 != null)
{
<div class="layui-col-md12">
Expand Down Expand Up @@ -157,7 +161,7 @@
</div>


@section scripts{
@section scripts {
<script>
layui.use(['jquery'], function () {
var $ = layui.$;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@using System.Runtime.Versioning;
@using Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Http.Extensions
@using Microsoft.AspNetCore.Http.Features
@using NewLife.Caching
@using NewLife.Common;
@inject Microsoft.AspNetCore.Http.IHttpContextAccessor HttpContextAccessor
Expand Down Expand Up @@ -204,7 +205,7 @@
Session:
</td>
<td class="value" style="max-width:400px;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">
@httpContext.Session.Keys.Count()
@(httpContext.Features.Get<ISessionFeature>()?.Session.Keys.Count() ?? 0)
<a href="@Url.Action("Main", new{ id = "Session" })" target="_self" data-toggle="tooltip" data-placement="top" title="点击打开Session列表">Session列表</a>
@gc
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,49 @@
@using System.Reflection;
@using System.Runtime.Versioning;
@using Microsoft.AspNetCore.Http
@using Microsoft.AspNetCore.Http.Features
@using NewLife.Common;
@using NewLife.Serialization
@inject IHttpContextAccessor HttpContextAccessor
@{
//Layout = NewLife.Cube.Setting.Current.Layout;
var session = HttpContextAccessor.HttpContext.Session;
var session = HttpContextAccessor.HttpContext.Features.Get<ISessionFeature>()?.Session;
var session2 = HttpContextAccessor.HttpContext.Items["Session"] as IDictionary<String, Object>;
ViewBag.Title = "Session列表";
}

<div class="row d-flex align-items-lg-stretch">
<div class="col-lg-6">
<div class="card card-custom card-stretch gutter-b">
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered table-hover table-condensed">
<tr>
<th class="text-dark text-hover-primary font-size-h5 font-weight-bold" colspan="6">
Session列表(@session.Keys.Count())
</th>
</tr>
<tr>
<th>名称</th>
<th>类型</th>
<th>数值</th>
</tr>
@foreach (String item in session.Keys)
{
@if (session != null)
{
<div class="card card-custom card-stretch gutter-b">
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered table-hover table-condensed">
<tr>
<td>@item</td>
<td></td>
<td>@session.GetString(item)</td>
<th class="text-dark text-hover-primary font-size-h5 font-weight-bold" colspan="6">
Session列表(@session.Keys.Count())
</th>
</tr>
}
</table>
<tr>
<th>名称</th>
<th>类型</th>
<th>数值</th>
</tr>
@foreach (String item in session.Keys)
{
<tr>
<td>@item</td>
<td></td>
<td>@session.GetString(item)</td>
</tr>
}
</table>
</div>
</div>
</div>
</div>
}
</div>

<div class="col-lg-6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,16 @@

<div class="tab-pane" id="user_change_password" role="tabpanel">
<div class="container">
@{
var model = new ChangePasswordModel { Name = user.Name, SsoName = Context.Session.Get<String>("Cube_Sso") };
@{
var ss = Context.Items[""] as IDictionary<String, Object>;
var model = new ChangePasswordModel { Name = user.Name, SsoName = (String)ss["Cube_Sso"] };
}
@await Html.PartialAsync("ChangePassword", model)
@await Html.PartialAsync("ChangePassword", model)
</div>
</div>

<div class="tab-pane" id="user_log" role="tabpanel">
<div class="container">

</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@using System.Runtime.Versioning;
@using Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Http.Extensions
@using Microsoft.AspNetCore.Http.Features
@using NewLife
@using NewLife.Caching
@using NewLife.Common;
Expand Down Expand Up @@ -221,7 +222,7 @@
Session:
</td>
<td class="value" style="max-width:400px;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">
@httpContext.Session.Keys.Count()
@(httpContext.Features.Get<ISessionFeature>()?.Session.Keys.Count() ?? 0)
<a href="@Url.Action("Main", new{ id = "Session" })" target="_self" data-bs-toggle="tooltip" title="点击打开Session列表">Session列表</a>
@gc
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,49 @@
@using System.Reflection;
@using System.Runtime.Versioning;
@using Microsoft.AspNetCore.Http
@using Microsoft.AspNetCore.Http.Features
@using NewLife.Common;
@using NewLife.Serialization
@inject IHttpContextAccessor HttpContextAccessor
@{
//Layout = NewLife.Cube.Setting.Current.Layout;
var session = HttpContextAccessor.HttpContext.Session;
var session = HttpContextAccessor.HttpContext.Features.Get<ISessionFeature>()?.Session;
var session2 = HttpContextAccessor.HttpContext.Items["Session"] as IDictionary<String, Object>;
ViewBag.Title = "Session列表";
}

<div class="row d-flex align-items-lg-stretch">
<div class="col-lg-6">
<div class="card card-stretch gutter-b">
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-row-bordered table-row-dashed gy-4">
<tr>
<th class="text-dark text-hover-primary text-uppercase fs-3" colspan="6">
Session列表(@session.Keys.Count())
</th>
</tr>
<tr class="fs-4">
<th>名称</th>
<th>类型</th>
<th>数值</th>
</tr>
@foreach (String item in session.Keys)
{
@if (session != null)
{
<div class="card card-stretch gutter-b">
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-row-bordered table-row-dashed gy-4">
<tr>
<td>@item</td>
<td></td>
<td>@session.GetString(item)</td>
<th class="text-dark text-hover-primary text-uppercase fs-3" colspan="6">
Session列表(@session.Keys.Count())
</th>
</tr>
}
</table>
<tr class="fs-4">
<th>名称</th>
<th>类型</th>
<th>数值</th>
</tr>
@foreach (String item in session.Keys)
{
<tr>
<td>@item</td>
<td></td>
<td>@session.GetString(item)</td>
</tr>
}
</table>
</div>
</div>
</div>
</div>
}
</div>

<div class="col-lg-6">
Expand Down
Loading

0 comments on commit 1b8eb97

Please sign in to comment.