feat: 修复雪花id问题
This commit is contained in:
@@ -5,4 +5,11 @@ export function getList(data){
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
};
|
||||
|
||||
export function getListByPlateId(plateId){
|
||||
return myaxios({
|
||||
url: `/discuss/plate-id/${plateId}`,
|
||||
method: 'get'
|
||||
})
|
||||
};
|
||||
@@ -11,7 +11,7 @@
|
||||
<span>{{props.name}}</span>
|
||||
<div class="bottom">
|
||||
<time class="remarks">{{ props.introduction }}</time>
|
||||
<RouterLink to="/discuss"> <el-button text class="button" type="primary">进入<el-icon><CaretRight /></el-icon></el-button> </RouterLink>
|
||||
<RouterLink :to="`/discuss/${props.id}`"> <el-button text class="button" type="primary">进入<el-icon><CaretRight /></el-icon></el-button> </RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
@@ -20,7 +20,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props = defineProps(['name','introduction'])
|
||||
import { onMounted } from 'vue';
|
||||
|
||||
const props = defineProps(['name','introduction','id'])
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -22,7 +22,7 @@ const router = createRouter({
|
||||
},
|
||||
{
|
||||
name:'discuss',
|
||||
path: '/discuss',
|
||||
path: '/discuss/:plateId',
|
||||
component: () => import('../views/Discuss.vue')
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
// import JsonBig from 'json-bigint'
|
||||
const myaxios = axios.create({
|
||||
baseURL:import.meta.env.VITE_APP_BASEAPI,
|
||||
timeout: 50000,
|
||||
// transformResponse: [data => {
|
||||
// const json = JsonBig({
|
||||
// storeAsString: true
|
||||
// })
|
||||
// return json.parse(data)
|
||||
// try {
|
||||
// const json = JsonBig({
|
||||
// storeAsString: true
|
||||
// })
|
||||
// return json.parse(data)
|
||||
// } catch (err) {
|
||||
// // 如果转换失败,则包装为统一数据格式并返回
|
||||
// return {
|
||||
// data
|
||||
// }
|
||||
// }
|
||||
// }],
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + ""
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
<el-form :inline="true" >
|
||||
<el-form-item label="标签:" >
|
||||
<el-input placeholder="请输入标签"
|
||||
:suffix-icon="Calendar"></el-input>
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="内容:">
|
||||
<el-input
|
||||
placeholder="搜索当下分类下的内容"
|
||||
:suffix-icon="Calendar"
|
||||
|
||||
/>
|
||||
</el-form-item>
|
||||
<div class="form-right">
|
||||
@@ -46,19 +46,30 @@
|
||||
<el-tab-pane label="最新" name="second"> </el-tab-pane>
|
||||
<el-tab-pane label="最热" name="third"> </el-tab-pane>
|
||||
</el-tabs>
|
||||
<div class="div-item" v-for="i in 10" >
|
||||
<DisscussCard/>
|
||||
<div class="div-item" v-for="i in discussList" >
|
||||
<DisscussCard :title="i.title" :introduction="i.introduction" :createTime="i.createTime"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import DisscussCard from '@/components/DisscussCard.vue'
|
||||
import { ref } from 'vue'
|
||||
import {getListByPlateId} from '@/apis/discussApi.js'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRouter,useRoute } from 'vue-router'
|
||||
const router = useRouter()
|
||||
const route=useRoute()
|
||||
const activeName = ref('first')
|
||||
|
||||
const discussList=ref([]);
|
||||
|
||||
const handleClick = (tab, event) => {
|
||||
console.log(tab, event)
|
||||
}
|
||||
|
||||
onMounted(async()=>{
|
||||
const response= await getListByPlateId(route.params.plateId);
|
||||
discussList.value=response.items;
|
||||
})
|
||||
</script>
|
||||
<style scoped>
|
||||
.body-div{
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
|
||||
|
||||
<el-row class="left-div">
|
||||
|
||||
<el-col :span="8" v-for="i in plateList" class="plate" :style="{ 'padding-left': i%3==1?0:0.2+'rem','padding-right': i%3==0?0:0.2+'rem'}" >
|
||||
<PlateCard :name="i.name" :introduction="i.introduction"/>
|
||||
<PlateCard :name="i.name" :introduction="i.introduction" :id="i.id"/>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" v-for="i in discussList">
|
||||
@@ -103,10 +102,10 @@ var discussList=ref([]);
|
||||
onMounted(async()=>{
|
||||
const response= await getList();
|
||||
plateList.value= response.items;
|
||||
|
||||
const discussReponse=await discussGetList();
|
||||
discussList.value= discussReponse.items;
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Autofac;
|
||||
using Autofac.Core.Registration;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -20,10 +21,11 @@ namespace Yi.Framework.Core.Autofac.Extensions
|
||||
|
||||
public static void RegisterYiModule(this ContainerBuilder builder, AutoFacModuleEnum autoFacModuleEnum, params Assembly[] assemblies)
|
||||
{
|
||||
Logger? _logger = LogManager.Setup().LoadConfigurationFromAssemblyResource(typeof(AutoFacModuleExtensions).Assembly).GetCurrentClassLogger();
|
||||
switch (autoFacModuleEnum)
|
||||
{
|
||||
case AutoFacModuleEnum.PropertiesAutowiredModule:
|
||||
Console.WriteLine($"意框架添加AutoFac模块:{nameof(PropertiesAutowiredModule)}-属性注入模块");
|
||||
_logger.Info($"意框架添加AutoFac模块:{nameof(PropertiesAutowiredModule)}-属性注入模块");
|
||||
new PropertiesAutowiredModule().Load(builder, assemblies);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Buffers.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Data.Json
|
||||
{
|
||||
public class LongToStringConverter : JsonConverter<long>
|
||||
{
|
||||
public override long Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
{
|
||||
ReadOnlySpan<byte> span = reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan;
|
||||
if (Utf8Parser.TryParse(span, out long number, out int bytesConsumed) && span.Length == bytesConsumed)
|
||||
{
|
||||
return number;
|
||||
}
|
||||
|
||||
if (long.TryParse(reader.GetString(), out number))
|
||||
{
|
||||
return number;
|
||||
}
|
||||
}
|
||||
|
||||
return reader.GetInt64();
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, long value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,22 @@
|
||||
using AspNetCore.Microsoft.AspNetCore.Hosting;
|
||||
using AspNetCore.Microsoft.AspNetCore.Hosting;
|
||||
using Yi.Framework.Core.Autofac.Extensions;
|
||||
using Yi.Framework.Core.Autofac.Modules;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
using Yi.BBS.Web;
|
||||
using Yi.Framework.Core.Module;
|
||||
using NLog.Extensions.Logging;
|
||||
using NLog;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddLogging(builder => { builder.ClearProviders().AddNLog("nlog.config").SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); });
|
||||
Logger? _logger = LogManager.Setup().LoadConfigurationFromAssemblyResource(typeof(Program).Assembly).GetCurrentClassLogger();
|
||||
_logger.Info("-----( ¯ □ ¯ )YiFrameowrk框架启动-----");
|
||||
|
||||
builder.WebHost.UseStartUrlsServer(builder.Configuration);
|
||||
|
||||
builder.UseYiModules(typeof(YiBBSWebModule));
|
||||
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>autofacģ<EFBFBD><EFBFBD>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
//添加autofac模块,需要添加模块
|
||||
builder.Host.ConfigureAutoFacContainer(container =>
|
||||
{
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, ModuleAssembly.Assemblies);
|
||||
|
||||
@@ -15,6 +15,12 @@
|
||||
<ProjectReference Include="..\Yi.BBS.Sqlsugar\Yi.BBS.Sqlsugar.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="nlog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="key.pem">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
|
||||
@@ -12,6 +12,7 @@ using Yi.Framework.AspNetCore;
|
||||
using Yi.Framework.Data.Json;
|
||||
using Yi.Framework.OperLogManager;
|
||||
using Yi.Framework.Core.Module;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Yi.BBS.Web
|
||||
{
|
||||
@@ -28,7 +29,8 @@ namespace Yi.BBS.Web
|
||||
//添加控制器与动态api
|
||||
services.AddControllers().AddJsonOptions(opt => {
|
||||
opt.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
|
||||
});
|
||||
opt.JsonSerializerOptions.Converters.Add(new LongToStringConverter());
|
||||
});
|
||||
|
||||
services.AddAutoApiService(opt =>
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
|
||||
51
Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/nlog.config
Normal file
51
Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/nlog.config
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true"
|
||||
throwExceptions="false"
|
||||
internalLogLevel="Off">
|
||||
|
||||
<variable name="archiveAboveSize" value="10485760"/>
|
||||
<variable name="maxArchiveFiles" value="50"/>
|
||||
<variable name="layout" value="${date:format=HH\:mm\:ss.fff}|${level}|${threadId:format=threadId}|${logger}${newline}>>${message} ${exception:format=tostring}"/>
|
||||
<variable name="logsRootPath" value="${basedir}/logs/${shortdate}" />
|
||||
|
||||
<targets>
|
||||
<target xsi:type="File"
|
||||
name="AllFile"
|
||||
fileName="${logsRootPath}/AllFile/log.log"
|
||||
layout="${layout}${newline}"
|
||||
archiveAboveSize="${archiveAboveSize}"
|
||||
maxArchiveFiles="${maxArchiveFiles}" />
|
||||
|
||||
<target xsi:type="ColoredConsole"
|
||||
name="ColoredConsole"
|
||||
layout="${layout}${newline}">
|
||||
<highlight-row condition="level == LogLevel.Info" foregroundColor="White" />
|
||||
<highlight-row condition="level == LogLevel.Debug" foregroundColor="Green" />
|
||||
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
|
||||
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
|
||||
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" backgroundColor="White" />
|
||||
</target>
|
||||
|
||||
<target xsi:type="File" name="OwnFile"
|
||||
fileName="${logsRootPath}/OwnFile/log.log"
|
||||
layout="${layout}|Url: ${aspnet-request-url}|Action: ${aspnet-mvc-action}${newline}"
|
||||
archiveAboveSize="${archiveAboveSize}"
|
||||
maxArchiveFiles="${maxArchiveFiles}" />
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="Quartz.*" maxlevel="Warn" final="true" />
|
||||
<logger name="Grpc.*" maxlevel="Debug" final="true" />
|
||||
<logger name="Grpc.*" maxlevel="Trace" final="true" />
|
||||
<logger name="Microsoft.EntityFrameworkCore.*" maxlevel="Warn" final="true" />
|
||||
<logger name="Microsoft.AspNetCore.*" maxlevel="Warn" final="true" />
|
||||
<logger name="Microsoft.AspNetCore.SignalR.*" maxlevel="Warn" final="true" />
|
||||
<logger name="*" minlevel="Information" maxlevel="Fatal" writeTo="AllFile,ColoredConsole"/>
|
||||
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="ColoredConsole,OwnFile" final="true" />
|
||||
<logger name="Microsoft.*" maxlevel="Info" final="true" />
|
||||
<logger name="*" minlevel="Trace" writeTo="OwnFile" />
|
||||
|
||||
</rules>
|
||||
</nlog>
|
||||
Binary file not shown.
@@ -1,16 +1,22 @@
|
||||
using AspNetCore.Microsoft.AspNetCore.Hosting;
|
||||
using AspNetCore.Microsoft.AspNetCore.Hosting;
|
||||
using Yi.Framework.Core.Autofac.Extensions;
|
||||
using Yi.Framework.Core.Autofac.Modules;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
using Yi.BBS.Web;
|
||||
using Yi.Framework.Core.Module;
|
||||
using NLog.Extensions.Logging;
|
||||
using NLog;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddLogging(builder => { builder.ClearProviders().AddNLog("nlog.config").SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); });
|
||||
Logger? _logger = LogManager.Setup().LoadConfigurationFromAssemblyResource(typeof(Program).Assembly).GetCurrentClassLogger();
|
||||
_logger.Info("-----( ¯ □ ¯ )YiFrameowrk框架启动-----");
|
||||
|
||||
builder.WebHost.UseStartUrlsServer(builder.Configuration);
|
||||
|
||||
builder.UseYiModules(typeof(YiBBSWebModule));
|
||||
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>autofacģ<EFBFBD><EFBFBD>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
//添加autofac模块,需要添加模块
|
||||
builder.Host.ConfigureAutoFacContainer(container =>
|
||||
{
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, ModuleAssembly.Assemblies);
|
||||
|
||||
@@ -15,6 +15,12 @@
|
||||
<ProjectReference Include="..\Yi.BBS.Sqlsugar\Yi.BBS.Sqlsugar.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="nlog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="key.pem">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
|
||||
@@ -12,6 +12,7 @@ using Yi.Framework.AspNetCore;
|
||||
using Yi.Framework.Data.Json;
|
||||
using Yi.Framework.OperLogManager;
|
||||
using Yi.Framework.Core.Module;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Yi.BBS.Web
|
||||
{
|
||||
@@ -28,7 +29,8 @@ namespace Yi.BBS.Web
|
||||
//添加控制器与动态api
|
||||
services.AddControllers().AddJsonOptions(opt => {
|
||||
opt.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
|
||||
});
|
||||
opt.JsonSerializerOptions.Converters.Add(new LongToStringConverter());
|
||||
});
|
||||
|
||||
services.AddAutoApiService(opt =>
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user