Browse Source

add user avatar field

pull/216/head
cKey 5 years ago
parent
commit
2b95c9ff2f
  1. 2
      aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Validation/LINGYUN.Abp.AspNetCore.Mvc.Validation.csproj
  2. 22
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN/Abp/Identity/AbpIdentityApplicationModule.cs
  3. 14
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/ExtensionIdentityUserConsts.cs
  4. 18
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreModule.cs
  5. 1774
      aspnet-core/services/account/AuthServer.Host/Migrations/20210302035805_Add-IdentityUser-AvatarUrl.Designer.cs
  6. 24
      aspnet-core/services/account/AuthServer.Host/Migrations/20210302035805_Add-IdentityUser-AvatarUrl.cs
  7. 6
      aspnet-core/services/account/AuthServer.Host/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs
  8. 18
      vueJs/src/router/index.ts
  9. 0
      vueJs/src/views/profile/components/MyNotifier.vue
  10. 53
      vueJs/src/views/profile/components/MyProfile.vue
  11. 0
      vueJs/src/views/profile/components/MySecurity.vue
  12. 0
      vueJs/src/views/profile/setting.vue

2
aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Validation/LINGYUN.Abp.AspNetCore.Mvc.Validation.csproj

@ -3,7 +3,7 @@
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace />
</PropertyGroup>

22
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN/Abp/Identity/AbpIdentityApplicationModule.cs

@ -1,6 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading;
namespace LINGYUN.Abp.Identity
{
@ -10,6 +13,7 @@ namespace LINGYUN.Abp.Identity
typeof(AbpIdentityDomainModule))]
public class AbpIdentityApplicationModule : AbpModule
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<AbpIdentityApplicationModule>();
@ -19,5 +23,23 @@ namespace LINGYUN.Abp.Identity
options.AddProfile<AbpIdentityApplicationModuleAutoMapperProfile>(validate: true);
});
}
public override void PostConfigureServices(ServiceConfigurationContext context)
{
OneTimeRunner.Run(() =>
{
ObjectExtensionManager.Instance
.AddOrUpdateProperty<string>(
new[]
{
typeof(IdentityUserDto),
typeof(IdentityUserCreateDto),
typeof(IdentityUserUpdateDto),
typeof(ProfileDto),
typeof(UpdateProfileDto)
},
ExtensionIdentityUserConsts.AvatarUrlField);
});
}
}
}

14
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/ExtensionIdentityUserConsts.cs

@ -0,0 +1,14 @@
namespace LINGYUN.Abp.Identity
{
public static class ExtensionIdentityUserConsts
{
/// <summary>
/// 头像字段
/// </summary>
public static string AvatarUrlField { get; set; } = "AvatarUrl";
/// <summary>
/// 头像字段最大长度
/// </summary>
public static int MaxAvatarUrlLength { get; set; } = 128;
}
}

18
aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreModule.cs

@ -2,6 +2,8 @@
using Volo.Abp.Identity;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.Modularity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading;
namespace LINGYUN.Abp.Identity.EntityFrameworkCore
{
@ -9,6 +11,8 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore
[DependsOn(typeof(Volo.Abp.Identity.EntityFrameworkCore.AbpIdentityEntityFrameworkCoreModule))]
public class AbpIdentityEntityFrameworkCoreModule : AbpModule
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<IdentityDbContext>(options =>
@ -17,5 +21,19 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore
options.AddRepository<IdentityUser, EfCoreIdentityUserRepository>();
});
}
public override void PostConfigureServices(ServiceConfigurationContext context)
{
OneTimeRunner.Run(() =>
{
ObjectExtensionManager.Instance
.MapEfCoreProperty<IdentityUser, string>(
ExtensionIdentityUserConsts.AvatarUrlField,
(etb, prop) =>
{
prop.HasMaxLength(ExtensionIdentityUserConsts.MaxAvatarUrlLength);
});
});
}
}
}

1774
aspnet-core/services/account/AuthServer.Host/Migrations/20210302035805_Add-IdentityUser-AvatarUrl.Designer.cs

File diff suppressed because it is too large

24
aspnet-core/services/account/AuthServer.Host/Migrations/20210302035805_Add-IdentityUser-AvatarUrl.cs

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace AuthServer.Host.Migrations
{
public partial class AddIdentityUserAvatarUrl : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "AvatarUrl",
table: "AbpUsers",
type: "varchar(128) CHARACTER SET utf8mb4",
maxLength: 128,
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AvatarUrl",
table: "AbpUsers");
}
}
}

6
aspnet-core/services/account/AuthServer.Host/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs

@ -17,7 +17,7 @@ namespace AuthServer.Migrations
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.0");
.HasAnnotation("ProductVersion", "5.0.2");
modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b =>
{
@ -256,6 +256,10 @@ namespace AuthServer.Migrations
.HasDefaultValue(0)
.HasColumnName("AccessFailedCount");
b.Property<string>("AvatarUrl")
.HasMaxLength(128)
.HasColumnType("varchar(128) CHARACTER SET utf8mb4");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)

18
vueJs/src/router/index.ts

@ -142,21 +142,13 @@ export const asyncRoutes: RouteConfig[] = [
icon: 'user',
noCache: true
}
}
]
},
{
path: '/profile-setting',
component: Layout,
redirect: '/profile-setting/index',
meta: { hidden: true },
children: [
},
{
path: 'index',
component: () => import(/* webpackChunkName: "profile" */ '@/views/profile-setting/index.vue'),
name: '个人设置',
path: 'setting',
component: () => import(/* webpackChunkName: "profile" */ '@/views/profile/setting.vue'),
name: 'setting',
meta: {
title: '个人设置',
title: 'setting',
icon: 'setting',
noCache: true
}

0
vueJs/src/views/profile-setting/components/MyNotifier.vue → vueJs/src/views/profile/components/MyNotifier.vue

53
vueJs/src/views/profile-setting/components/MyProfile.vue → vueJs/src/views/profile/components/MyProfile.vue

@ -39,10 +39,25 @@
/>
</el-row>
<el-row>
<el-button>
<el-button
@click="handleShowImageUpload"
>
<i class="el-icon-upload2" />
更换头像
</el-button>
<avatar-upload
v-model="showImageUpload"
field="avatar"
:width="300"
:height="300"
:params="params"
:headers="headers"
:url="uploadUrl"
@close="showImageUpload=false"
@src-file-set="handleSrcFileSet"
@crop-upload-fail="handleUploadFail"
@crop-upload-success="onCropUploadSuccess"
/>
</el-row>
</div>
</div>
@ -74,18 +89,27 @@
<script lang="ts">
import MyProfileService, { MyProfile, UpdateMyProfile } from '@/api/profile'
import { FileUploadUrl } from '@/api/filemanagement'
import { Component, Vue } from 'vue-property-decorator'
import { UserModule } from '@/store/modules/user'
import AvatarUpload from '@/components/AvatarUpload/index.vue'
import PanThumb from '@/components/PanThumb/index.vue'
@Component({
name: 'MyProfile',
components: {
PanThumb
PanThumb,
AvatarUpload
}
})
export default class extends Vue {
private myProfile = new MyProfile()
private showImageUpload = false
private headers: any = {}
private params: any = {}
private uploadUrl = FileUploadUrl
get myAvatar() {
if (this.myProfile.extraProperties) {
const avatar = this.myProfile.extraProperties.avatar
@ -108,6 +132,31 @@ export default class extends Vue {
})
}
private handleShowImageUpload() {
this.showImageUpload = true
this.headers.Authorization = UserModule.token
}
private handleSrcFileSet(fileName: string, fileType: any, fileSize: any) {
this.params.FileName = fileName
this.params.ChunkSize = fileSize
this.params.CurrentChunkSize = fileSize
this.params.ChunkNumber = 1
this.params.TotalChunks = 1
this.params.TotalSize = fileSize
}
private handleUploadFail(status: any, field: any) {
console.log(status)
console.log(field)
}
private onCropUploadSuccess(jsonData: any, field: string) {
this.showImageUpload = false
console.log(jsonData)
console.log(field)
}
private handleUpdateMyProfile() {
this.$confirm(this.$t('AbpAccount.ManageYourProfile').toString(),
this.$t('AbpAccount.AreYouSure').toString(), {

0
vueJs/src/views/profile-setting/components/MySecurity.vue → vueJs/src/views/profile/components/MySecurity.vue

0
vueJs/src/views/profile-setting/index.vue → vueJs/src/views/profile/setting.vue

Loading…
Cancel
Save