From 7a28ae4a7ebb9498f59c7eafce879345cc8c395a Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 26 May 2020 10:52:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Vuex=20AbpConfiguration?= =?UTF-8?q?=E6=A8=A1=E5=9D=97;=E6=9C=AC=E5=9C=B0=E5=8C=96=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=90=8E=E7=AB=AF=E6=9C=AC=E5=9C=B0=E5=8C=96=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E7=9A=84=E9=9B=86=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs | 13 +- .../PermissionAppService.cs | 10 + .../LINGYUN.Platform.HttpApi.Host.csproj | 2 +- .../PlatformHttpApiHostModule.cs | 3 +- aspnet-core/services/start-all-service.bat | 4 +- vueJs/src/api/abpconfiguration.ts | 99 ++++ vueJs/src/api/users.ts | 67 ++- vueJs/src/assets/login-images/login.jpg | Bin 0 -> 29266 bytes vueJs/src/components/LangSelect/index.vue | 48 +- vueJs/src/lang/es.ts | 175 ------- vueJs/src/lang/index.ts | 18 - vueJs/src/lang/ja.ts | 175 ------- vueJs/src/lang/ko.ts | 175 ------- vueJs/src/lang/zh.ts | 15 +- vueJs/src/permission.ts | 3 - vueJs/src/store/index.ts | 2 + vueJs/src/store/modules/abp.ts | 27 + vueJs/src/store/modules/user.ts | 85 +++- vueJs/src/utils/cookies.ts | 12 - vueJs/src/utils/localStorage.ts | 26 + vueJs/src/utils/request.ts | 140 +++-- .../admin/users/components/UserCreateForm.vue | 2 +- .../admin/users/components/UserEditForm.vue | 2 +- .../dashboard/admin/components/BoxCard.vue | 8 - vueJs/src/views/login/index.vue | 481 ++++++++++-------- vueJs/src/views/profile/index.vue | 7 - 26 files changed, 701 insertions(+), 898 deletions(-) create mode 100644 vueJs/src/api/abpconfiguration.ts create mode 100644 vueJs/src/assets/login-images/login.jpg delete mode 100644 vueJs/src/lang/es.ts delete mode 100644 vueJs/src/lang/ja.ts delete mode 100644 vueJs/src/lang/ko.ts create mode 100644 vueJs/src/store/modules/abp.ts create mode 100644 vueJs/src/utils/localStorage.ts diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs index 0a3ef9982..5ee48c601 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs @@ -49,9 +49,7 @@ namespace LINYUN.Abp.Sms.Aliyun TryAddTemplateCode(request, smsMessage); TryAddSignName(request, smsMessage); TryAddSendPhone(request, smsMessage); - - var queryParamJson = JsonSerializer.Serialize(smsMessage.Properties); - request.AddQueryParameters("TemplateParam", queryParamJson); + TryAddTemplateParam(request, smsMessage); try { @@ -125,5 +123,14 @@ namespace LINYUN.Abp.Sms.Aliyun request.AddQueryParameters("PhoneNumbers", smsMessage.PhoneNumber); } } + + private void TryAddTemplateParam(CommonRequest request, SmsMessage smsMessage) + { + if (smsMessage.Properties.Count > 0) + { + var queryParamJson = JsonSerializer.Serialize(smsMessage.Properties); + request.AddQueryParameters("TemplateParam", queryParamJson); + } + } } } diff --git a/aspnet-core/modules/permissions/LINGYUN.Abp.PermissionManagement.Application/LINGYUN/Abp/PermissionManagement/PermissionAppService.cs b/aspnet-core/modules/permissions/LINGYUN.Abp.PermissionManagement.Application/LINGYUN/Abp/PermissionManagement/PermissionAppService.cs index c100c9030..a19a33bad 100644 --- a/aspnet-core/modules/permissions/LINGYUN.Abp.PermissionManagement.Application/LINGYUN/Abp/PermissionManagement/PermissionAppService.cs +++ b/aspnet-core/modules/permissions/LINGYUN.Abp.PermissionManagement.Application/LINGYUN/Abp/PermissionManagement/PermissionAppService.cs @@ -9,6 +9,7 @@ using Volo.Abp; using Volo.Abp.Application.Services; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Caching; +using Volo.Abp.Clients; using Volo.Abp.DependencyInjection; using Volo.Abp.MultiTenancy; using Volo.Abp.PermissionManagement; @@ -22,10 +23,12 @@ namespace LINGYUN.Abp.PermissionManagement public class PermissionAppService : ApplicationService, IPermissionAppService { protected PermissionManagementOptions Options { get; } + protected ICurrentClient CurrentClient { get; } protected IDistributedCache Cache { get; } protected IPermissionGrantRepository PermissionGrantRepository { get; } protected IPermissionDefinitionManager PermissionDefinitionManager { get; } public PermissionAppService( + ICurrentClient currentClient, IDistributedCache cache, IPermissionGrantRepository permissionGrantRepository, IPermissionDefinitionManager permissionDefinitionManager, @@ -33,6 +36,7 @@ namespace LINGYUN.Abp.PermissionManagement { Cache = cache; Options = options.Value; + CurrentClient = currentClient; PermissionGrantRepository = permissionGrantRepository; PermissionDefinitionManager = permissionDefinitionManager; } @@ -62,6 +66,12 @@ namespace LINGYUN.Abp.PermissionManagement } } } + if (!CurrentClient.Id.IsNullOrWhiteSpace()) + { + var clientPermissions = await PermissionGrantRepository + .GetListAsync(ClientPermissionValueProvider.ProviderName, CurrentClient.Id); + permissions = permissions.Union(clientPermissions); + } foreach (var permissionGroup in permissionGroups) { var groupDto = new PermissionGroupDto diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj index 1cda942b4..ca1f77f73 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj @@ -22,7 +22,7 @@ - + diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs index 0cd0722c6..a669d0cb0 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs @@ -23,6 +23,7 @@ using Volo.Abp; using Volo.Abp.Account; using Volo.Abp.AspNetCore.Authentication.JwtBearer; using Volo.Abp.AspNetCore.MultiTenancy; +using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; using Volo.Abp.Autofac; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.MySQL; @@ -44,7 +45,7 @@ using AbpPermissionManagementApplicationModule = LINGYUN.Abp.PermissionManagemen namespace LINGYUN.Platform { [DependsOn( - typeof(AbpAspNetCoreMultiTenancyModule), + typeof(AbpAspNetCoreMvcUiMultiTenancyModule), typeof(AbpPermissionManagementDomainIdentityModule), typeof(AbpPermissionManagementDomainIdentityServerModule), typeof(ApiGatewayApplicationContractsModule), diff --git a/aspnet-core/services/start-all-service.bat b/aspnet-core/services/start-all-service.bat index c891b0b8c..c7641f6ff 100644 --- a/aspnet-core/services/start-all-service.bat +++ b/aspnet-core/services/start-all-service.bat @@ -3,4 +3,6 @@ cls start .\start-identity-server.bat --run start .\start-apigateway-admin.bat --run -start .\start-platform.bat --run \ No newline at end of file +start .\start-platform.bat --run +ping -n 10 127.1 >nul +start .\start-apigateway-host.bat --run \ No newline at end of file diff --git a/vueJs/src/api/abpconfiguration.ts b/vueJs/src/api/abpconfiguration.ts new file mode 100644 index 000000000..697026231 --- /dev/null +++ b/vueJs/src/api/abpconfiguration.ts @@ -0,0 +1,99 @@ +import ApiService from './serviceBase' + +const serviceUrl = process.env.VUE_APP_BASE_API + +export default class AbpConfigurationService { + public static getAbpConfiguration() { + const _url = '/api/abp/application-configuration' + return ApiService.Get(_url, serviceUrl) + } +} + +export class Auth { + policies?: { [key: string]: boolean} + grantedPolicies?: { [key: string]: boolean} +} + +export class CurrentTenant { + id?: string + name?: string + isAvailable!: boolean +} + +export class CurrentUser { + id?: string + email?: string + userName?: string + tenantId?: string + isAuthenticated!: boolean +} + +export class Feature { + values?: { [key: string]: string} +} + +export class DateTimeFormat { + calendarAlgorithmType!: string + dateSeparator!: string + dateTimeFormatLong!: string + fullDateTimePattern!: string + longTimePattern!: string + shortDatePattern!: string + shortTimePattern!: string +} + +export class CurrentCulture { + cultureName!: string + displayName!: string + englishName!: string + isRightToLeft!: boolean + name!: string + nativeName!: string + threeLetterIsoLanguageName!: string + twoLetterIsoLanguageName!: string + dateTimeFormat!: DateTimeFormat +} + +export class Language { + cultureName!: string + displayName!: string + flagIcon?: string + uiCultureName!: string +} + +export class Localization { + currentCulture!: CurrentCulture + defaultResourceName?: string + languages!: Language[] + values!: {[key:string]: {[key:string]: string}} +} + +export class MultiTenancy { + isEnabled!: boolean +} + +export class Setting { + values?: {[key:string]: string} +} + +export interface IAbpConfiguration { + auth: Auth + currentTenant: CurrentTenant + currentUser: CurrentUser + features: Feature + localization: Localization + multiTenancy: MultiTenancy + objectExtensions: any + setting: Setting +} + +export class AbpConfiguration implements IAbpConfiguration { + auth!: Auth + currentTenant!: CurrentTenant + currentUser!: CurrentUser + features!: Feature + localization!: Localization + multiTenancy!: MultiTenancy + objectExtensions!: any + setting!: Setting +} \ No newline at end of file diff --git a/vueJs/src/api/users.ts b/vueJs/src/api/users.ts index 9444d7fe6..d57b913d3 100644 --- a/vueJs/src/api/users.ts +++ b/vueJs/src/api/users.ts @@ -118,8 +118,53 @@ export default class UserApiService { }) } - public static refreshToken() { - + public static sendPhoneVerifyCode(phoneVerify: PhoneVerify) { + const _url = '/api/account/phone/verify' + return ApiService.HttpRequest({ + baseURL: IdentityServiceUrl, + url: _url, + method: 'POST', + data: phoneVerify + }) + } + + public static userLoginWithPhone(loginData: UserLoginPhoneData) { + const _url = '/connect/token' + const login = { + grant_type: 'phone_verify', + phone_number: loginData.phoneNumber, + phone_verify_code: loginData.verifyCode, + client_id: process.env.VUE_APP_CLIENT_ID, + client_secret: process.env.VUE_APP_CLIENT_SECRET + } + return ApiService.HttpRequest({ + baseURL: IdentityServerUrl, + url: _url, + method: 'POST', + data: qs.stringify(login), + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }) + } + + public static refreshToken(token: string) { + const _url = '/connect/token' + const refresh = { + grant_type: 'refresh_token', + refresh_token: token, + client_id: process.env.VUE_APP_CLIENT_ID, + client_secret: process.env.VUE_APP_CLIENT_SECRET + } + return ApiService.HttpRequest({ + baseURL: IdentityServerUrl, + url: _url, + method: 'POST', + data: qs.stringify(refresh), + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }) } public static userLogout(token: string | undefined) { @@ -174,6 +219,24 @@ export class UserLoginData { password!: string } +export enum VerifyType { + register = 0, + signin = 10 +} + +export class PhoneVerify { + phoneNumber!: string + verifyType!:VerifyType +} + +/** 用户手机登录对象 */ +export class UserLoginPhoneData { + /** 手机号码 */ + phoneNumber!: string + /** 手机验证码 */ + verifyCode!: string +} + /** 用户信息对象 由IdentityServer提供 */ export class UserInfo { /** 标识 */ diff --git a/vueJs/src/assets/login-images/login.jpg b/vueJs/src/assets/login-images/login.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0569144945a58cb73dd12d8fa043d1f72e59d0c2 GIT binary patch literal 29266 zcmeHQUx*V&7@yrFce9&BHYUCHMB-+XTbFdfkUurpmR`2!agn2G6-y+O$w2t+)LU<)qPvrc)|W6G&%2%O(Jfm> z6Cr;n@xMRK?}>-nYs0#YkqGNyY#ye0i@e&pRfe>G7aX0_*gUs=}-glWjm(6#lRU~zC3k4{WUuy zU+3b>MyP&F$D*asP&6Xwc9Ee31%~qN*1#e%d(T_e#MQNALyRS76V%lz+h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Q1<5lOL*(JPW0B|wXU_6!M#adA~ zpp_s34Fb`eH0vlRdDDlAu0i6ARPG7~3uZ|*a}y)ENEIrwj>@!>UzL5SBVJxy;fi=c ozu English - - Español - - - 日本語 - - - 한국어 - - + diff --git a/vueJs/src/views/profile/index.vue b/vueJs/src/views/profile/index.vue index 090e67fbc..3bdae36f5 100644 --- a/vueJs/src/views/profile/index.vue +++ b/vueJs/src/views/profile/index.vue @@ -51,14 +51,12 @@ import UserCard from './components/UserCard.vue' export interface IProfile { name: string email: string - avatar: string roles: string } const defaultProfile: IProfile = { name: 'Loading...', email: 'Loading...', - avatar: 'Loading...', roles: 'Loading...' } @@ -83,10 +81,6 @@ export default class extends Vue { return UserModule.email } - get avatar() { - return UserModule.avatar - } - get roles() { return UserModule.roles } @@ -99,7 +93,6 @@ export default class extends Vue { this.user = { name: this.name, email: this.email, - avatar: this.avatar, roles: this.roles.join(' | ') } }