😎1、增加请求 Url 参数验证 Token 2、代码调整及升级npm依赖

This commit is contained in:
zuohuaijun 2024-06-23 11:13:17 +08:00
parent dbcadf2ef8
commit e408d89043
3 changed files with 73 additions and 17 deletions

View File

@ -12,6 +12,7 @@ using Furion.SpecificationDocument;
using Furion.VirtualFileServer;
using IGeekFan.AspNetCore.Knife4jUI;
using IPTools.Core;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@ -22,6 +23,7 @@ using Newtonsoft.Json;
using OnceMi.AspNetCore.OSS;
using SixLabors.ImageSharp.Web.DependencyInjection;
using System;
using System.Threading.Tasks;
namespace Admin.NET.Web.Core;
@ -37,12 +39,25 @@ public class Startup : AppStartup
// SqlSugar
services.AddSqlSugar();
// JWT
services.AddJwt<JwtHandler>(enableGlobalAuthorize: true)
// 添加 Signature 身份验证
.AddSignatureAuthentication(options =>
services.AddJwt<JwtHandler>(enableGlobalAuthorize: true, jwtBearerConfigure: options =>
{
// 实现 JWT 身份验证过程控制
options.Events = new JwtBearerEvents
{
options.Events = SysOpenAccessService.GetSignatureAuthenticationEventImpl();
});
OnMessageReceived = context =>
{
var httpContext = context.HttpContext;
// 若请求 Url 包含 token 参数,则设置 Token 值
if (httpContext.Request.Query.ContainsKey("token"))
context.Token = httpContext.Request.Query["token"];
return Task.CompletedTask;
}
};
}).AddSignatureAuthentication(options => // 添加 Signature 身份验证
{
options.Events = SysOpenAccessService.GetSignatureAuthenticationEventImpl();
});
// 允许跨域
services.AddCorsAccessor();
// 远程请求

View File

@ -53,7 +53,7 @@
"splitpanes": "^3.1.5",
"vcrontab-3": "^3.3.22",
"vform3-builds": "^3.0.10",
"vue": "^3.4.29",
"vue": "^3.4.30",
"vue-clipboard3": "^2.0.0",
"vue-demi": "^0.14.8",
"vue-grid-layout": "3.0.0-beta1",
@ -69,14 +69,14 @@
"devDependencies": {
"@plugin-web-update-notification/vite": "^1.7.1",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.14.7",
"@types/node": "^20.14.8",
"@types/nprogress": "^0.2.3",
"@types/sortablejs": "^1.15.8",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@vitejs/plugin-vue": "^5.0.5",
"@vitejs/plugin-vue-jsx": "^4.0.0",
"@vue/compiler-sfc": "^3.4.29",
"@vue/compiler-sfc": "^3.4.30",
"code-inspector-plugin": "^0.14.2",
"eslint": "^9.5.0",
"eslint-plugin-vue": "^9.26.0",

View File

@ -6,6 +6,9 @@
</div>
<div v-loading="state.exportLoading" class="table-footer-tool">
<SvgIcon v-if="!config.hideRefresh" name="iconfont icon-shuaxin" :size="22" title="刷新" @click="onRefreshTable" />
<el-tooltip effect="light" :content="state.switchFixedContent" placement="bottom-start" :show-after="200" v-if="state.haveFixed">
<el-icon :style="{ color: state.fixedIconColor }" @click="switchFixed"><ele-Switch /></el-icon>
</el-tooltip>
<el-dropdown v-if="!config.hideExport" trigger="click">
<SvgIcon name="iconfont icon-yunxiazai_o" :size="22" title="导出" />
<template #dropdown>
@ -56,7 +59,7 @@
@sort-change="sortChange"
>
<el-table-column type="selection" :reserve-selection="true" :width="30" v-if="config.isSelection && config.showSelection" />
<el-table-column type="index" label="序号" align="center" :width="60" v-if="config.isSerialNo" />
<el-table-column type="index" :fixed="state.currentFixed && state.serialNoFixed" label="序号" align="center" :width="60" v-if="config.isSerialNo" />
<el-table-column v-for="(item, index) in setHeader" :key="index" v-bind="item">
<template #header v-if="!item.children && $slots[item.prop]">
<slot :name="`${item.prop}header`" />
@ -203,13 +206,20 @@ const state = reactive({
selectlist: [] as EmptyObjectType[],
checkListAll: true,
checkListIndeterminate: false,
oldColumns: [] as EmptyObjectType[],
columns: [] as EmptyObjectType[],
haveFixed: false,
currentFixed: false,
serialNoFixed: false,
switchFixedContent: '取消固定列',
fixedIconColor: themeConfig.value.primary,
});
const hideTool = computed(() => {
return props.config.hideTool ?? false;
});
const getProperty = (obj, property) => {
const getProperty = (obj: any, property: any) => {
const keys = property.split('.');
let value = obj;
for (const key of keys) {
@ -232,19 +242,19 @@ const getConfig = computed(() => {
});
// tool header
const setHeader = computed(() => {
return props.columns.filter((v) => v.isCheck);
return state.columns.filter((v) => v.isCheck);
});
// tool
const onCheckAllChange = <T,>(val: T) => {
if (val) props.columns.forEach((v) => (v.isCheck = true));
else props.columns.forEach((v) => (v.isCheck = false));
if (val) state.columns.forEach((v) => (v.isCheck = true));
else state.columns.forEach((v) => (v.isCheck = false));
state.checkListIndeterminate = false;
};
// tool
const onCheckChange = () => {
const headers = props.columns.filter((v) => v.isCheck).length;
state.checkListAll = headers === props.columns.length;
state.checkListIndeterminate = headers > 0 && headers < props.columns.length;
const headers = state.columns.filter((v) => v.isCheck).length;
state.checkListAll = headers === state.columns.length;
state.checkListIndeterminate = headers > 0 && headers < state.columns.length;
};
//
const onSelectionChange = (val: EmptyObjectType[]) => {
@ -362,7 +372,7 @@ const onSetTable = () => {
onEnd: () => {
const headerList: EmptyObjectType[] = [];
sortable.toArray().forEach((val: any) => {
props.columns.forEach((v) => {
state.columns.forEach((v) => {
if (v.prop === val) headerList.push({ ...v });
});
});
@ -419,12 +429,42 @@ const setTableData = (data: Array<EmptyObjectType>, add: boolean = false) => {
}
};
const clearFixed = () => {
for (let item of state.columns) {
delete item['fixed'];
}
};
const switchFixed = () => {
state.currentFixed = !state.currentFixed;
state.switchFixedContent = state.currentFixed ? '取消固定列' : '启用固定列';
if (state.currentFixed) {
state.fixedIconColor = themeConfig.value.primary;
state.columns = JSON.parse(JSON.stringify(state.oldColumns));
} else {
state.fixedIconColor = '';
clearFixed();
}
};
onMounted(() => {
if (props.defaultSort) {
state.page.field = props.defaultSort.prop;
state.page.order = props.defaultSort.order;
}
state.page.pageSize = props.config.pageSize ?? 10;
state.oldColumns = JSON.parse(JSON.stringify(props.columns));
state.columns = props.columns;
for (let item of state.columns) {
if (item.fixed !== undefined) {
state.haveFixed = true;
state.currentFixed = true;
if (item.fixed == 'left') {
state.serialNoFixed = true;
break;
}
}
}
handleList();
});
@ -435,6 +475,7 @@ defineExpose({
toggleSelection,
getTableData,
setTableData,
switchFixed,
});
</script>