feat:修改使用mysql
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import useUserStore from '@/stores/user'
|
import useUserStore from '@/stores/user'
|
||||||
import { reactive, watch, onMounted, computed } from 'vue';
|
import { reactive, watch, onMounted, computed, ref } from 'vue';
|
||||||
//userInfo
|
//userInfo
|
||||||
//{icon,name,role,id},根据判断userInfo是否等于未定义,来觉得是当前登录用户信息,还是其他人信息
|
//{icon,name,role,id},根据判断userInfo是否等于未定义,来觉得是当前登录用户信息,还是其他人信息
|
||||||
const props = defineProps(['size', 'showWatching', 'time', 'userInfo', 'isSelf'])
|
const props = defineProps(['size', 'showWatching', 'time', 'userInfo', 'isSelf'])
|
||||||
@@ -39,20 +39,14 @@ const userInfo = reactive({
|
|||||||
role: [],
|
role: [],
|
||||||
id: ""
|
id: ""
|
||||||
});
|
});
|
||||||
|
const iconUrl=ref('/src/assets/logo.ico');
|
||||||
const iconUrl = computed(() => {
|
const iconUrlHandler = () => {
|
||||||
if (userInfo.icon == null || userInfo.icon == undefined || userInfo.icon == '') {
|
if (userInfo.icon == null || userInfo.icon == undefined || userInfo.icon == '') {
|
||||||
|
|
||||||
return '/src/assets/logo.ico';
|
return '/src/assets/logo.ico';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userInfo.icon.includes(import.meta.env.VITE_APP_BASEAPI)) {
|
|
||||||
return userInfo.icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return `${import.meta.env.VITE_APP_BASEAPI}/file/${userInfo.icon}`;
|
return `${import.meta.env.VITE_APP_BASEAPI}/file/${userInfo.icon}`;
|
||||||
})
|
}
|
||||||
|
|
||||||
watch(userStore, (n) => {
|
watch(userStore, (n) => {
|
||||||
if (props.userInfo == undefined) {
|
if (props.userInfo == undefined) {
|
||||||
@@ -76,14 +70,18 @@ const Init = () => {
|
|||||||
userInfo.nick = props.userInfo.nick;
|
userInfo.nick = props.userInfo.nick;
|
||||||
userInfo.role = props.userInfo.role;
|
userInfo.role = props.userInfo.role;
|
||||||
userInfo.id = props.userInfo.id;
|
userInfo.id = props.userInfo.id;
|
||||||
|
iconUrl.value=iconUrlHandler(userInfo.icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
//使用当前登录用户
|
//使用当前登录用户
|
||||||
else {
|
else {
|
||||||
|
|
||||||
userInfo.icon = userStore.icon;
|
userInfo.icon = userStore.icon;
|
||||||
userInfo.nick = userStore.name;
|
userInfo.nick = userStore.name;
|
||||||
userInfo.role = userStore.role;
|
userInfo.role = userStore.role;
|
||||||
userInfo.id = userStore.id;
|
userInfo.id = userStore.id;
|
||||||
|
iconUrl.value=userInfo.icon;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ const useUserStore = defineStore('user',
|
|||||||
// this.permissions=["*:*:*"]
|
// this.permissions=["*:*:*"]
|
||||||
this.name = user.nick
|
this.name = user.nick
|
||||||
this.icon = avatar;
|
this.icon = avatar;
|
||||||
|
|
||||||
this.userName=user.userName;
|
this.userName=user.userName;
|
||||||
this.id=user.id;
|
this.id=user.id;
|
||||||
resolve(res)
|
resolve(res)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace Yi.Framework.Core.Sqlsugar
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
SqlSugarClient = new SqlSugarScope(new ConnectionConfig()
|
SqlSugarClient = new SqlSugarClient(new ConnectionConfig()
|
||||||
{
|
{
|
||||||
//准备添加分表分库
|
//准备添加分表分库
|
||||||
DbType = dbConnOptions.DbType ?? DbType.Sqlite,
|
DbType = dbConnOptions.DbType ?? DbType.Sqlite,
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ namespace Yi.Framework.Data.DataSeeds
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual async Task<bool> IsInvoker()
|
public virtual async Task<bool> IsInvoker()
|
||||||
{
|
{
|
||||||
|
var p = await _repository.IsAnyAsync(x=>true);
|
||||||
|
var p2 = await _repository.CountAsync(x => true);
|
||||||
if (await _repository.CountAsync(u => true) > 0)
|
if (await _repository.CountAsync(u => true) > 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using Yi.Framework.Core.Attributes;
|
|||||||
using Yi.Framework.Core.Sqlsugar;
|
using Yi.Framework.Core.Sqlsugar;
|
||||||
using Yi.BBS.Domain;
|
using Yi.BBS.Domain;
|
||||||
using Yi.RBAC.Sqlsugar;
|
using Yi.RBAC.Sqlsugar;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
namespace Yi.BBS.Sqlsugar
|
namespace Yi.BBS.Sqlsugar
|
||||||
{
|
{
|
||||||
@@ -20,6 +21,7 @@ namespace Yi.BBS.Sqlsugar
|
|||||||
{
|
{
|
||||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Yi.BBS.Web;
|
|||||||
using Yi.Framework.Core.Module;
|
using Yi.Framework.Core.Module;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Services.AddLogging(builder => { builder.ClearProviders().AddNLog("nlog.config").SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); });
|
builder.Services.AddLogging(builder => { builder.ClearProviders().AddNLog("nlog.config").SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); });
|
||||||
@@ -23,7 +24,8 @@ builder.Host.ConfigureAutoFacContainer(container =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
var db = app.Services.GetService<ISqlSugarClient>();
|
||||||
|
db.DbMaintenance.CreateDatabase();
|
||||||
app.UseErrorHandlingServer();
|
app.UseErrorHandlingServer();
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
||||||
|
|
||||||
"DbConnOptions": {
|
"DbConnOptions": {
|
||||||
"Url": "DataSource=yi-sqlsugar-dev.db",
|
//"Url": "DataSource=yi-sqlsugar-dev.db",
|
||||||
//"Url": "server=106.52.94.217;port=3306;database=yi-bbs-dev;user id=root;password=Qz52013142020.",
|
"Url": "server=106.52.94.217;port=3306;database=yi-bbs-dev;user id=root;password=Qz52013142020.",
|
||||||
"DbType": "Sqlite",
|
"DbType": "Mysql",
|
||||||
"EnabledDbSeed": true,
|
"EnabledDbSeed": true,
|
||||||
"EnabledReadWrite": false,
|
"EnabledReadWrite": false,
|
||||||
"EnabledCodeFirst": true,
|
"EnabledCodeFirst": true,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using Yi.Framework.Core.Attributes;
|
|||||||
using Yi.Framework.Core.Sqlsugar;
|
using Yi.Framework.Core.Sqlsugar;
|
||||||
using Yi.BBS.Domain;
|
using Yi.BBS.Domain;
|
||||||
using Yi.RBAC.Sqlsugar;
|
using Yi.RBAC.Sqlsugar;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
namespace Yi.BBS.Sqlsugar
|
namespace Yi.BBS.Sqlsugar
|
||||||
{
|
{
|
||||||
@@ -20,6 +21,7 @@ namespace Yi.BBS.Sqlsugar
|
|||||||
{
|
{
|
||||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Yi.BBS.Web;
|
|||||||
using Yi.Framework.Core.Module;
|
using Yi.Framework.Core.Module;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Services.AddLogging(builder => { builder.ClearProviders().AddNLog("nlog.config").SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); });
|
builder.Services.AddLogging(builder => { builder.ClearProviders().AddNLog("nlog.config").SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); });
|
||||||
@@ -23,7 +24,8 @@ builder.Host.ConfigureAutoFacContainer(container =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
var db = app.Services.GetService<ISqlSugarClient>();
|
||||||
|
db.DbMaintenance.CreateDatabase();
|
||||||
app.UseErrorHandlingServer();
|
app.UseErrorHandlingServer();
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
||||||
|
|
||||||
"DbConnOptions": {
|
"DbConnOptions": {
|
||||||
"Url": "DataSource=yi-sqlsugar-dev.db",
|
//"Url": "DataSource=yi-sqlsugar-dev.db",
|
||||||
//"Url": "server=106.52.94.217;port=3306;database=yi-bbs-dev;user id=root;password=Qz52013142020.",
|
"Url": "server=106.52.94.217;port=3306;database=yi-bbs-dev;user id=root;password=Qz52013142020.",
|
||||||
"DbType": "Sqlite",
|
"DbType": "Mysql",
|
||||||
"EnabledDbSeed": true,
|
"EnabledDbSeed": true,
|
||||||
"EnabledReadWrite": false,
|
"EnabledReadWrite": false,
|
||||||
"EnabledCodeFirst": true,
|
"EnabledCodeFirst": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user