前端大更新vuex
This commit is contained in:
@@ -28,7 +28,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 登录方法,要返回data:{user,token} token先写123456789,不要有导航属性
|
/// 登录方法,要返回data:{user,token} token
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="_user"></param>
|
/// <param name="_user"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
65
Yi.Framework/Yi.Framework.ApiMicroservice/Log4net.config
Normal file
65
Yi.Framework/Yi.Framework.ApiMicroservice/Log4net.config
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<log4net>
|
||||||
|
<!-- 将日志以回滚文件的形式写到文件中 -->
|
||||||
|
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
|
||||||
|
<!--Error-->
|
||||||
|
<appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
|
||||||
|
<!--不加utf-8编码格式,中文字符将显示成乱码-->
|
||||||
|
<param name="Encoding" value="utf-8" />
|
||||||
|
<file value="log/"/>
|
||||||
|
<appendToFile value="true" />
|
||||||
|
<rollingStyle value="Date" />
|
||||||
|
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
|
||||||
|
<datePattern value=""GlobalExceptionLogs_"yyyyMMdd".log"" />
|
||||||
|
<!--日志文件名是否为静态-->
|
||||||
|
<StaticLogFileName value="false"/>
|
||||||
|
<!--多线程时采用最小锁定-->
|
||||||
|
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||||
|
<!--布局(向用户显示最后经过格式化的输出信息)-->
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<conversionPattern value="%date| %-5level %newline%message%newline--------------------------------%newline" />
|
||||||
|
</layout>
|
||||||
|
<filter type="log4net.Filter.LevelRangeFilter">
|
||||||
|
<levelMin value="ERROR" />
|
||||||
|
<levelMax value="FATAL" />
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<!--Error-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--Info-->
|
||||||
|
<appender name="InfoLog" type="log4net.Appender.RollingFileAppender">
|
||||||
|
<!--不加utf-8编码格式,中文字符将显示成乱码-->
|
||||||
|
<param name="Encoding" value="utf-8" />
|
||||||
|
<!--定义文件存放位置-->
|
||||||
|
<file value="log/"/>
|
||||||
|
<appendToFile value="true" />
|
||||||
|
<rollingStyle value="Date" />
|
||||||
|
<!--日志文件名是否为静态-->
|
||||||
|
<StaticLogFileName value="false"/>
|
||||||
|
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
|
||||||
|
<datePattern value=""GlobalInfoLogs_"yyyyMMdd".log"" />
|
||||||
|
<!--多线程时采用最小锁定-->
|
||||||
|
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||||
|
<!--布局(向用户显示最后经过格式化的输出信息)-->
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<conversionPattern value="%date| %-5level%c %newline%message%newline--------------------------------%newline" />
|
||||||
|
</layout>
|
||||||
|
<filter type="log4net.Filter.LevelRangeFilter">
|
||||||
|
<levelMin value="DEBUG" />
|
||||||
|
<levelMax value="WARN" />
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<!--Info-->
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<!-- 控制级别,由低到高:ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF -->
|
||||||
|
<!-- 比如定义级别为INFO,则INFO级别向下的级别,比如DEBUG日志将不会被记录 -->
|
||||||
|
<!-- 如果没有定义LEVEL的值,则缺省为DEBUG -->
|
||||||
|
<level value="ALL" />
|
||||||
|
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
|
||||||
|
<appender-ref ref="ErrorLog" />
|
||||||
|
<appender-ref ref="InfoLog" />
|
||||||
|
</root>
|
||||||
|
</log4net>
|
||||||
@@ -7,6 +7,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.WebCore.BuilderExtend;
|
||||||
|
|
||||||
namespace Yi.Framework.ApiMicroservice
|
namespace Yi.Framework.ApiMicroservice
|
||||||
{
|
{
|
||||||
@@ -19,9 +20,25 @@ namespace Yi.Framework.ApiMicroservice
|
|||||||
|
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
Host.CreateDefaultBuilder(args)
|
Host.CreateDefaultBuilder(args)
|
||||||
|
|
||||||
|
.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) =>
|
||||||
|
{
|
||||||
|
configurationBuilder.AddCommandLine(args);
|
||||||
|
configurationBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false);
|
||||||
|
#region
|
||||||
|
//Apollo<6C><6F><EFBFBD><EFBFBD>
|
||||||
|
#endregion
|
||||||
|
//configurationBuilder.AddApolloService("Yi");
|
||||||
|
})
|
||||||
|
.ConfigureLogging(loggingBuilder =>
|
||||||
|
{
|
||||||
|
loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning);
|
||||||
|
loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning);
|
||||||
|
loggingBuilder.AddLog4Net();
|
||||||
|
})
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
webBuilder.UseStartup<Startup>();
|
webBuilder.UseStartup<Startup>().UseUrls("https://*:44329");
|
||||||
}).UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
}).UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,14 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Yi.Framework.ApiMicroservice.Utility;
|
|
||||||
using Yi.Framework.Common.IOCOptions;
|
using Yi.Framework.Common.IOCOptions;
|
||||||
using Yi.Framework.Interface;
|
using Yi.Framework.Interface;
|
||||||
using Yi.Framework.Model;
|
using Yi.Framework.Model;
|
||||||
using Yi.Framework.Service;
|
using Yi.Framework.Service;
|
||||||
using Yi.Framework.WebCore;
|
using Yi.Framework.WebCore;
|
||||||
|
using Yi.Framework.WebCore.FilterExtend;
|
||||||
using Yi.Framework.WebCore.MiddlewareExtend;
|
using Yi.Framework.WebCore.MiddlewareExtend;
|
||||||
|
using Yi.Framework.WebCore.Utility;
|
||||||
|
|
||||||
namespace Yi.Framework.ApiMicroservice
|
namespace Yi.Framework.ApiMicroservice
|
||||||
{
|
{
|
||||||
@@ -43,7 +44,9 @@ namespace Yi.Framework.ApiMicroservice
|
|||||||
#region
|
#region
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
#endregion
|
#endregion
|
||||||
services.AddControllers();
|
services.AddControllers(optios=> {
|
||||||
|
//optios.Filters.Add(typeof(CustomExceptionFilterAttribute));
|
||||||
|
});
|
||||||
|
|
||||||
#region
|
#region
|
||||||
//Swagger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//Swagger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
@@ -55,6 +58,11 @@ namespace Yi.Framework.ApiMicroservice
|
|||||||
#endregion
|
#endregion
|
||||||
services.AddCorsService();
|
services.AddCorsService();
|
||||||
|
|
||||||
|
#region
|
||||||
|
//Jwt<77><74>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
||||||
|
#endregion
|
||||||
|
services.AddJwtService();
|
||||||
|
|
||||||
#region
|
#region
|
||||||
//Sqlite<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//Sqlite<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
#endregion
|
#endregion
|
||||||
@@ -98,6 +106,10 @@ namespace Yi.Framework.ApiMicroservice
|
|||||||
#endregion
|
#endregion
|
||||||
app.UseSwaggerService();
|
app.UseSwaggerService();
|
||||||
}
|
}
|
||||||
|
#region
|
||||||
|
//<2F><><EFBFBD><EFBFBD>ץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||||
|
#endregion
|
||||||
|
app.UseErrorHandlingService();
|
||||||
|
|
||||||
#region
|
#region
|
||||||
//HttpsRedirectionע<6E><D7A2>
|
//HttpsRedirectionע<6E><D7A2>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<members>
|
<members>
|
||||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Login(Yi.Framework.Model.Models.user)">
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Login(Yi.Framework.Model.Models.user)">
|
||||||
<summary>
|
<summary>
|
||||||
登录方法,要返回data:{user,token} token先写123456789,不要有导航属性
|
登录方法,要返回data:{user,token} token
|
||||||
</summary>
|
</summary>
|
||||||
<param name="_user"></param>
|
<param name="_user"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
@@ -162,13 +162,5 @@
|
|||||||
<param name="idsListDto"></param>
|
<param name="idsListDto"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:Yi.Framework.ApiMicroservice.Utility.CustomHostingStartup">
|
|
||||||
<summary>
|
|
||||||
必须实现IHostingStartup接口
|
|
||||||
必须标记HostingStartup特性
|
|
||||||
|
|
||||||
就像木马一样
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
</members>
|
</members>
|
||||||
</doc>
|
</doc>
|
||||||
|
|||||||
Binary file not shown.
@@ -9,17 +9,6 @@
|
|||||||
<NoWarn>1701;1702;CS1591</NoWarn>
|
<NoWarn>1701;1702;CS1591</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Autofac" Version="6.3.0" />
|
|
||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
|
||||||
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.10">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj" />
|
<ProjectReference Include="..\Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj" />
|
||||||
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
|
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
|
||||||
|
|||||||
@@ -6,8 +6,49 @@
|
|||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"Apollo": {
|
||||||
|
"AppId": "Yi-ApiMicroservice",
|
||||||
|
"Env": "DEV",
|
||||||
|
"MetaServer": "http://192.168.2.168:8080",
|
||||||
|
"ConfigServer": [ "http://192.168.2.168:8080" ]
|
||||||
|
},
|
||||||
"SqliteConn": {
|
"SqliteConn": {
|
||||||
"Url": "Filename=YIDB.db"
|
"Url": "Filename=YIDB.db"
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"MysqlConn": {
|
||||||
|
"Url": "server=192.168.2.128;port=3306;database=ECDB;user id=root;password=123456"
|
||||||
|
},
|
||||||
|
|
||||||
|
"JWTTokenOptions": {
|
||||||
|
"Audience": "http://localhost:7000",
|
||||||
|
"Issuer": "http://localhost:7000",
|
||||||
|
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
|
||||||
|
},
|
||||||
|
"RedisConn": {
|
||||||
|
"Host": "192.168.2.128",
|
||||||
|
"Prot": 6379,
|
||||||
|
"DB": 0,
|
||||||
|
"Password": "123456"
|
||||||
|
},
|
||||||
|
"KafkaOptions": {
|
||||||
|
"BrokerList": "192.168.3.230:9092",
|
||||||
|
"TopicName": "kafkalog"
|
||||||
|
},
|
||||||
|
"ConsulClientOption": {
|
||||||
|
"IP": "192.168.2.128",
|
||||||
|
"Port": "8500",
|
||||||
|
"Datacenter": "dc1"
|
||||||
|
},
|
||||||
|
"ConsulRegisterOption": {
|
||||||
|
"IP": "192.168.1.104",
|
||||||
|
"Port": "7001",
|
||||||
|
"GroupName": "ApiMicroservice",
|
||||||
|
"HealthCheckUrl": "/Health",
|
||||||
|
"Interval": 10,
|
||||||
|
"Timeout": 5,
|
||||||
|
"DeregisterCriticalServiceAfter": 60,
|
||||||
|
"Tag": "13"
|
||||||
|
},
|
||||||
|
"IPLibraryServiceUrl": "http://gRPCIPLibraryService"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ namespace Yi.Framework.Common.Models
|
|||||||
{
|
{
|
||||||
return new Result() { status = true, code = 200, msg = msg };
|
return new Result() { status = true, code = 200, msg = msg };
|
||||||
}
|
}
|
||||||
|
public static Result UnAuthorize(string msg = "unAuthorize")
|
||||||
|
{
|
||||||
|
return new Result() { status = false, code = 401, msg = msg };
|
||||||
|
}
|
||||||
|
|
||||||
public Result SetData(object obj)
|
public Result SetData(object obj)
|
||||||
{
|
{
|
||||||
this.data = obj;
|
this.data = obj;
|
||||||
@@ -56,6 +61,12 @@ namespace Yi.Framework.Common.Models
|
|||||||
{
|
{
|
||||||
return new Result<T> { status = true, code = 200, msg = msg };
|
return new Result<T> { status = true, code = 200, msg = msg };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Result<T> UnAuthorize(string msg = "unAuthorize")
|
||||||
|
{
|
||||||
|
return new Result<T>{ status = false, code = 401, msg = msg };
|
||||||
|
}
|
||||||
|
|
||||||
public Result<T> SetData(T TValue)
|
public Result<T> SetData(T TValue)
|
||||||
{
|
{
|
||||||
this.data = TValue;
|
this.data = TValue;
|
||||||
|
|||||||
@@ -10,6 +10,13 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.10" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.11" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.11">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Oracle.EntityFrameworkCore" Version="5.21.3" />
|
||||||
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
using Com.Ctrip.Framework.Apollo;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Com.Ctrip.Framework.Apollo.Enums;
|
||||||
|
using Com.Ctrip.Framework.Apollo.Logging;
|
||||||
|
using Microsoft.Extensions.Primitives;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Yi.Framework.WebCore.BuilderExtend
|
||||||
|
{
|
||||||
|
public static class ApolloExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 接入Apollo
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="builder"></param>
|
||||||
|
/// <param name="jsonPath">apollo配置文件路径 如果写入appsettings.json中 则jsonPath传null即可</param>
|
||||||
|
public static void AddApolloService(this IConfigurationBuilder builder, params string[] NameSpace)
|
||||||
|
{
|
||||||
|
//阿波罗的日志级别调整
|
||||||
|
LogManager.UseConsoleLogging(LogLevel.Warn);
|
||||||
|
var root = builder.Build();
|
||||||
|
var apolloBuilder = builder.AddApollo(root.GetSection("apollo")).AddDefault();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var item in NameSpace)
|
||||||
|
{
|
||||||
|
apolloBuilder.AddNamespace(item, ConfigFileFormat.Json);
|
||||||
|
}
|
||||||
|
//监听apollo配置
|
||||||
|
Monitor(builder.Build());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
#region private
|
||||||
|
/// <summary>
|
||||||
|
/// 监听配置
|
||||||
|
/// </summary>
|
||||||
|
private static void Monitor(IConfigurationRoot root)
|
||||||
|
{
|
||||||
|
//TODO 需要根据改变执行特定的操作 如 mq redis 等其他跟配置相关的中间件
|
||||||
|
//TODO 初步思路:将需要执行特定的操作key和value放入内存字典中,在赋值操作时通过标准事件来执行特定的操作。
|
||||||
|
|
||||||
|
//要重新Build 此时才将Apollo provider加入到ConfigurationBuilder中
|
||||||
|
ChangeToken.OnChange(() => root.GetReloadToken(), () =>
|
||||||
|
{
|
||||||
|
foreach (var apolloProvider in root.Providers.Where(p => p is ApolloConfigurationProvider))
|
||||||
|
{
|
||||||
|
var property = apolloProvider.GetType().BaseType.GetProperty("Data", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
|
var data = property.GetValue(apolloProvider) as IDictionary<string, string>;
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"key {item.Key} value {item.Value}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,12 +43,10 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
|||||||
|
|
||||||
switch (statusCode)
|
switch (statusCode)
|
||||||
{
|
{
|
||||||
|
|
||||||
case 401: msg = "未授权";break;
|
case 401: msg = "未授权";break;
|
||||||
case 403: msg = "未授权"; break;
|
case 403: msg = "未授权"; break;
|
||||||
case 404: msg = "未找到服务"; break;
|
case 404: msg = "未找到服务"; break;
|
||||||
case 502: msg = "请求错误"; break;
|
case 502: msg = "请求错误"; break;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(msg))
|
if (!string.IsNullOrWhiteSpace(msg))
|
||||||
{
|
{
|
||||||
@@ -59,7 +57,16 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
|||||||
//异常错误信息捕获,将错误信息用Json方式返回
|
//异常错误信息捕获,将错误信息用Json方式返回
|
||||||
private static Task HandleExceptionAsync(HttpContext context, int statusCode, string msg)
|
private static Task HandleExceptionAsync(HttpContext context, int statusCode, string msg)
|
||||||
{
|
{
|
||||||
var result = JsonConvert.SerializeObject( Result.Error(msg).SetCode(statusCode));
|
Result resp;
|
||||||
|
if (statusCode == 401)
|
||||||
|
{
|
||||||
|
resp = Result.UnAuthorize(msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resp = Result.Error(msg);
|
||||||
|
}
|
||||||
|
var result = JsonConvert.SerializeObject(resp);
|
||||||
context.Response.ContentType = "application/json;charset=utf-8";
|
context.Response.ContentType = "application/json;charset=utf-8";
|
||||||
return context.Response.WriteAsync(result);
|
return context.Response.WriteAsync(result);
|
||||||
}
|
}
|
||||||
@@ -67,7 +74,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
|||||||
//扩展方法
|
//扩展方法
|
||||||
public static class ErrorHandlingExtensions
|
public static class ErrorHandlingExtensions
|
||||||
{
|
{
|
||||||
public static IApplicationBuilder UseErrorHandling(this IApplicationBuilder builder)
|
public static IApplicationBuilder UseErrorHandlingService(this IApplicationBuilder builder)
|
||||||
{
|
{
|
||||||
return builder.UseMiddleware<ErrorHandExtension>();
|
return builder.UseMiddleware<ErrorHandExtension>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Yi.Framework.ApiMicroservice.Utility
|
namespace Yi.Framework.WebCore.Utility
|
||||||
{
|
{
|
||||||
public class CustomAutofacAop : IInterceptor
|
public class CustomAutofacAop : IInterceptor
|
||||||
{
|
{
|
||||||
@@ -10,13 +10,10 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Yi.Framework.ApiMicroservice.Utility;
|
using Yi.Framework.WebCore.Utility;
|
||||||
using Yi.Framework.Interface;
|
|
||||||
using Yi.Framework.Model;
|
|
||||||
using Yi.Framework.Service;
|
|
||||||
using Module = Autofac.Module;
|
using Module = Autofac.Module;
|
||||||
|
|
||||||
namespace Yi.Framework.ApiMicroservice.Utility
|
namespace Yi.Framework.WebCore.Utility
|
||||||
{
|
{
|
||||||
public class CustomAutofacModule : Module
|
public class CustomAutofacModule : Module
|
||||||
{
|
{
|
||||||
@@ -7,8 +7,8 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
[assembly: HostingStartup(typeof(Yi.Framework.ApiMicroservice.Utility.CustomHostingStartup))]
|
[assembly: HostingStartup(typeof(Yi.Framework.WebCore.Utility.CustomHostingStartup))]
|
||||||
namespace Yi.Framework.ApiMicroservice.Utility
|
namespace Yi.Framework.WebCore.Utility
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 必须实现IHostingStartup接口
|
/// 必须实现IHostingStartup接口
|
||||||
@@ -5,11 +5,16 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Autofac" Version="6.3.0" />
|
||||||
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||||
|
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Com.Ctrip.Framework.Apollo.Configuration" Version="2.4.1.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.11" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.11" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="5.0.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
<default-notifications />
|
<default-notifications />
|
||||||
|
|
||||||
<default-account />
|
<default-account />
|
||||||
|
|
||||||
</v-app-bar>
|
</v-app-bar>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-main>
|
<v-main>
|
||||||
<v-container fluid>
|
<v-container fluid>
|
||||||
|
<v-progress-linear
|
||||||
|
:active="this.$store.state.loader.load"
|
||||||
|
:indeterminate="this.$store.state.loader.load"
|
||||||
|
background-color="primary lighten-4"
|
||||||
|
color="primary lighten-1"
|
||||||
|
striped
|
||||||
|
></v-progress-linear>
|
||||||
<router-view :key="$route.path" />
|
<router-view :key="$route.path" />
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-main>
|
</v-main>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import vuetify from './plugins/vuetify'
|
|||||||
import VuetifyDialog from 'vuetify-dialog'
|
import VuetifyDialog from 'vuetify-dialog'
|
||||||
import 'vuetify-dialog/dist/vuetify-dialog.css'
|
import 'vuetify-dialog/dist/vuetify-dialog.css'
|
||||||
import './plugins'
|
import './plugins'
|
||||||
|
import "./permission"
|
||||||
import store from './store/index'
|
import store from './store/index'
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
@@ -13,9 +14,11 @@ Vue.use(VuetifyDialog, {
|
|||||||
vuetify
|
vuetify
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
new Vue({
|
let vm = new Vue({
|
||||||
router,
|
router,
|
||||||
store,
|
store,
|
||||||
vuetify,
|
vuetify,
|
||||||
render: function(h) { return h(App) }
|
render: function(h) { return h(App) }
|
||||||
}).$mount('#app')
|
}).$mount('#app')
|
||||||
|
|
||||||
|
export default vm;
|
||||||
19
Yi.Vue/src/permission.js
Normal file
19
Yi.Vue/src/permission.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import router from './router/index'
|
||||||
|
import store from './store/index'
|
||||||
|
// import accountApi from '@/api/accountApi'
|
||||||
|
|
||||||
|
|
||||||
|
router.beforeEach((to, from, next) => {
|
||||||
|
const user = store.state.user.user; //获取是有user
|
||||||
|
console.log(user)
|
||||||
|
if (!user) { //如果没有登入
|
||||||
|
if (to.path == '/login/' || to.path == '/register/' || to.path == '/reset_password/' || to.path == '/qq/') {
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
next({ path: '/login/' });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import store from '../store/index'
|
import store from '../store/index'
|
||||||
|
import vm from '../main'
|
||||||
// import VuetifyDialogPlugin from 'vuetify-dialog/nuxt/index';
|
// import VuetifyDialogPlugin from 'vuetify-dialog/nuxt/index';
|
||||||
const myaxios = axios.create({
|
const myaxios = axios.create({
|
||||||
// baseURL:'/'//
|
// baseURL:'/'//
|
||||||
@@ -12,25 +13,44 @@ const myaxios = axios.create({
|
|||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
myaxios.interceptors.request.use(function(config) {
|
myaxios.interceptors.request.use(function(config) {
|
||||||
config.headers.Authorization = 'Bearer ' + store.state.user.token;
|
config.headers.Authorization = 'Bearer ' + store.state.user.token;
|
||||||
// store.dispatch("openLoad");
|
store.dispatch("openLoad");
|
||||||
return config;
|
return config;
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
myaxios.interceptors.response.use(function(response) {
|
myaxios.interceptors.response.use(async function(response) {
|
||||||
const resp = response.data
|
const resp = response.data
|
||||||
// store.dispatch("closeLoad");
|
if (resp.code == undefined && resp.msg == undefined) {
|
||||||
|
vm.$dialog.notify.error("错误代码:无,原因:与服务器失去连接", {
|
||||||
|
position: "top-right",
|
||||||
|
timeout: 5000,
|
||||||
|
});
|
||||||
|
} else if (resp.code == 401) {
|
||||||
|
const res = await vm.$dialog.error({
|
||||||
|
text: `错误代码:${resp.code},原因:${resp.msg}<br>是否重新进行登录?`,
|
||||||
|
title: '错误',
|
||||||
|
actions: {
|
||||||
|
'false': '取消',
|
||||||
|
'true': '跳转'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (res) {
|
||||||
|
vm.$router.push({ path: "/login" });
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (resp.code !== 200) {
|
||||||
|
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.msg}`, {
|
||||||
|
position: "top-right",
|
||||||
|
timeout: 5000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
store.dispatch("closeLoad");
|
||||||
return resp;
|
return resp;
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
const resp = error.response.data
|
store.dispatch("closeLoad");
|
||||||
// if (resp.code == undefined && resp.msg == undefined) {
|
|
||||||
// alert(`错误代码:无,原因:与服务器失去连接`)
|
|
||||||
// } else if (resp.code != 200) {
|
|
||||||
// alert(`错误代码:${resp.code},原因:${resp.msg}`)
|
|
||||||
// }
|
|
||||||
// store.dispatch("closeLoad");
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
});
|
});
|
||||||
export default myaxios
|
export default myaxios
|
||||||
@@ -55,8 +55,7 @@ export function redirect(
|
|||||||
|
|
||||||
export function route(name, component, path = '') {
|
export function route(name, component, path = '') {
|
||||||
component = Object(component) === component ?
|
component = Object(component) === component ?
|
||||||
component :
|
component : { default: name.replace(' ', '') }
|
||||||
{ default: name.replace(' ', '') }
|
|
||||||
|
|
||||||
const components = {}
|
const components = {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,25 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<MaterialCard
|
||||||
<MaterialCard title="首页卡片" subtitle="微软(Microsoft)是一家美国跨国科技企业,由比尔·盖茨和保罗·艾伦于1975年4月4日创立。" heading="头部" color='#E91E63' :fullHeader='false' icon='mdi-view-dashboard'></MaterialCard>
|
title="首页卡片"
|
||||||
<MaterialCharCard></MaterialCharCard>
|
subtitle="微软(Microsoft)是一家美国跨国科技企业,由比尔·盖茨和保罗·艾伦于1975年4月4日创立。"
|
||||||
<MaterialSnackbar></MaterialSnackbar>
|
heading="头部"
|
||||||
<MaterialStatCard value="微软(Microsoft)是一家美国跨国科技企业,由比尔·盖茨和保罗·艾伦于1975年4月4日创立。">
|
color="#E91E63"
|
||||||
<template v-slot>
|
:fullHeader="false"
|
||||||
还有什么呢?
|
icon="mdi-view-dashboard"
|
||||||
</template>
|
></MaterialCard>
|
||||||
</MaterialStatCard>
|
<MaterialCharCard></MaterialCharCard>
|
||||||
</div>
|
<MaterialSnackbar></MaterialSnackbar>
|
||||||
|
<MaterialStatCard
|
||||||
|
value="微软(Microsoft)是一家美国跨国科技企业,由比尔·盖茨和保罗·艾伦于1975年4月4日创立。"
|
||||||
|
>
|
||||||
|
<template v-slot> 还有什么呢? </template>
|
||||||
|
</MaterialStatCard>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data: () => ({}),
|
||||||
|
created() {},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user