Browse Source

Merge pull request #81 from colinin/3.1

backlog commits
pull/115/head
cKey 5 years ago
committed by GitHub
parent
commit
7e0197d012
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs
  2. BIN
      aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/event-bus-cap.db
  3. 1
      aspnet-core/services/cleanup-logs.bat
  4. 2
      aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs
  5. 2
      aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/LINGYUN.Abp.IdentityServer4.HttpApi.Host.csproj
  6. 6
      vueJs/package-lock.json
  7. 1
      vueJs/package.json
  8. 21
      vueJs/src/components/EventBus/events.d.ts
  9. 10
      vueJs/src/components/EventBus/index.d.ts
  10. 83
      vueJs/src/components/EventBus/index.js
  11. 7
      vueJs/src/components/EventBus/vue.d.ts
  12. 9
      vueJs/src/components/Notification/index.vue
  13. 2
      vueJs/src/main.ts
  14. 8
      vueJs/src/mixins/DataListMiXin.ts
  15. 59
      vueJs/src/mixins/EventBusMiXin.ts
  16. 40
      vueJs/src/utils/request.ts

2
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs

@ -191,7 +191,7 @@ namespace LINGYUN.Abp.Account
verifyCacheItem.VerifyCode = phoneVerifyCode.ToString();
var templateCode = await SettingProvider.GetOrDefaultAsync(AccountSettingNames.SmsRegisterTemplateCode, ServiceProvider);
await SendPhoneVerifyMessageAsync(templateCode, input.PhoneNumber, phoneVerifyCode.ToString());
return;
break;
case PhoneNumberVerifyType.Signin:
var phoneSigninCode = await SendSigninVerifyCodeAsync(input.PhoneNumber);
verifyCacheItem.VerifyCode = phoneSigninCode;

BIN
aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/event-bus-cap.db

Binary file not shown.

1
aspnet-core/services/cleanup-logs.bat

@ -8,6 +8,7 @@ del .\platform\LINGYUN.Platform.HttpApi.Host\Logs /Q
del .\apigateway\LINGYUN.ApiGateway.Host\Logs /Q
del .\apigateway\LINGYUN.ApiGateway.HttpApi.Host\Logs /Q
del .\account\AuthServer.Host\Logs /Q
del .\identity-server\LINGYUN.Abp.IdentityServer4.HttpApi.Host\Logs /Q
del .\messages\LINGYUN.Abp.MessageService.HttpApi.Host\Logs /Q
del .\admin\LINGYUN.Abp.BackendAdmin.HttpApi.Host\Logs /Q

2
aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs

@ -1,4 +1,4 @@
using DotNetCore.CAP;
using DotNetCore.CAP;
using IdentityModel;
using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.Abp.ExceptionHandling;

2
aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/LINGYUN.Abp.IdentityServer4.HttpApi.Host.csproj

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

6
vueJs/package-lock.json

@ -21314,12 +21314,6 @@
}
}
},
"vue-events": {
"version": "3.1.0",
"resolved": "https://registry.npm.taobao.org/vue-events/download/vue-events-3.1.0.tgz",
"integrity": "sha1-jiMSHDRbT/Mu4FT5eVmV8+NEsn0=",
"dev": true
},
"vue-hot-reload-api": {
"version": "2.3.4",
"resolved": "https://registry.npm.taobao.org/vue-hot-reload-api/download/vue-hot-reload-api-2.3.4.tgz",

1
vueJs/package.json

@ -117,7 +117,6 @@
"typescript": "^3.8.3",
"vue-cli-plugin-element": "^1.0.1",
"vue-cli-plugin-style-resources-loader": "^0.1.4",
"vue-events": "^3.1.0",
"vue-template-compiler": "^2.6.11",
"vue-virtual-scroll-list": "^2.1.8",
"webpack": "^4.42.1"

21
vueJs/src/components/EventBus/events.d.ts

@ -0,0 +1,21 @@
import { PluginFunction } from 'vue'
export declare class VueEvents {
static install: PluginFunction<never>
emit(event: string, ...args: any[]): void
fire(event: string, ...args: any[]): void
on(event: string, callback: (eventData: any) => void): void
listen(event: string, callback: (eventData: any) => void): void
once(event: string, callback: (eventData: any) => void): void
off(event:string, callback?: (eventData: any) => void): void
unlisten (event:string, callback?: (eventData: any) => void): void
removeAll(): void
}

10
vueJs/src/components/EventBus/index.d.ts

@ -0,0 +1,10 @@
import './vue';
import * as E from './events'
declare namespace VueEvents {
export type VueEvents = E.VueEvents;
}
declare class VueEvents extends E.VueEvents {}
export default VueEvents

83
vueJs/src/components/EventBus/index.js

@ -0,0 +1,83 @@
/**
* vue-event-handler typescript adapter
* src: https://github.com/sandeepk01/vue-event-handler
* reference: https://github.com/cklmercer/vue-events
*/
function plugin(Vue) {
if (plugin.installed) {
return
}
const evmap = {}
const events = new Vue({
methods: {
fire(name, data = null) {
this.emit(name, data)
},
emit(name, data = null) {
this.$emit(name, data)
},
listen(name, cb) {
this.on(name, cb)
},
listenOnce(name, cb) {
this.once(name, cb)
},
on(name, cb) {
evmap[name] = cb
this.$on(name, cb)
},
once(name, cb) {
evmap[name] = cb
this.$once(name, cb)
},
off(name, cb) {
if (!cb) {
cb = evmap[name]
}
this.$off(name, cb)
},
unlisten(name, cb) {
this.off(name, cb)
},
removeAll() {
this.$off()
}
}
})
Vue.mixin({
beforeCreate() {
if (typeof this.$options.events !== 'object') return
let eventMap = {}
for (const key in this.$options.events) {
eventMap[key] = this.$options.events[key].bind(this)
}
this.$once('hook:beforeMount', () => {
for (const key in eventMap) {
events.$on(key, eventMap[key])
}
})
this.$once('hook:beforeDestroy', () => {
for (const key in eventMap) {
events.$off(key, eventMap[key])
}
eventMap = null
})
}
})
Vue.events = events
Object.defineProperty(Vue.prototype, '$events', {
get() {
return events
}
})
}
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(plugin)
}
export default plugin

7
vueJs/src/components/EventBus/vue.d.ts

@ -0,0 +1,7 @@
import VueEvents from './index';
declare module 'vue/types/vue' {
interface Vue {
$events: VueEvents
}
}

9
vueJs/src/components/Notification/index.vue

@ -33,7 +33,8 @@
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import Component, { mixins } from 'vue-class-component'
import EventBusMiXin from '@/mixins/EventBusMiXin'
import UserNofitications from './components/UserNofitications.vue'
@Component({
@ -42,14 +43,14 @@ import UserNofitications from './components/UserNofitications.vue'
UserNofitications
}
})
export default class extends Vue {
export default class extends mixins(EventBusMiXin) {
private notificationCount = 0
created() {
this.$events.on('onNotificationReceived', () => {
this.subscribe('onNotificationReceived', () => {
this.notificationCount += 1
})
this.$events.on('onNotificationReadChanged', () => {
this.subscribe('onNotificationReadChanged', () => {
this.notificationCount -= 1
})
}

2
vueJs/src/main.ts

@ -7,7 +7,7 @@ import SvgIcon from 'vue-svgicon'
import uploader from 'vue-simple-uploader'
import contextMenu from 'vue-contextmenujs'
import VueEvents from 'vue-events'
import VueEvents from '@/components/EventBus'
import '@/styles/element-variables.scss'
import 'view-design/dist/styles/iview.css'

8
vueJs/src/mixins/DataListMiXin.ts

@ -37,6 +37,8 @@ export default class DataListMiXin extends Vue {
*/
protected refreshPagedData() {
this.dataLoading = true
// 这里还可以处理对于过滤器的变动
// 例如 abp 框架的skipCount区别于常见的pageNumber
this.getPagedList(this.dataFilter)
.then(res => {
this.dataList = res.items
@ -52,9 +54,7 @@ export default class DataListMiXin extends Vue {
*/
protected getList(filter: any): Promise<ListResultDto<any>> {
console.log(filter)
return new Promise<ListResultDto<any>>((resolve) => {
return resolve(new ListResultDto<any>())
})
return this.getEmptyList()
}
/** 获取空数据 */
@ -96,4 +96,6 @@ export default class DataListMiXin extends Vue {
protected l(name: string, values?: any[] | { [key: string]: any }) {
return this.$t(name, values).toString()
}
/** 还可以添加 eventbus 的通用处理器 */
}

59
vueJs/src/mixins/EventBusMiXin.ts

@ -0,0 +1,59 @@
import { Component, Vue } from 'vue-property-decorator'
/**
*
*
*/
@Component
export default class EventBusMiXin extends Vue {
protected eventMap = new Array<string>()
/**
*
*
*/
destroyed() {
this.$events.removeAll()
this.eventMap.length = 0
}
/**
*
* @param name
* @param callback
*/
protected subscribe(name: string, callback: (eventData: any) => void) {
if (this.eventMap.includes(name)) {
return
}
this.eventMap.push(name)
this.$events.on(name, callback)
}
/**
*
* @param name
* @param callback
*/
protected subscribeOne(name: string, callback: (eventData: any) => void) {
this.$events.once(name, callback)
}
/**
*
* @param name
* @param callback
*/
protected unSubscribe(name: string, callback: (eventData: any) => void | undefined) {
this.$events.off(name, callback)
}
/**
*
* @param name
* @param args
*/
protected trigger(name: string, ...args: any[]) {
this.$events.emit(name, args)
}
}

40
vueJs/src/utils/request.ts

@ -18,20 +18,21 @@ service.interceptors.request.use(
if (tenantId) {
config.headers.__tenant = tenantId
}
if (config.url === '/connect/token') {
return config
}
// Add X-Access-Token header to every request, you can add other custom headers here
if (UserModule.token) {
config.headers.Authorization = UserModule.token
}
// abp官方类库用的 zh-Hans 的简体中文包 这里直接粗暴一点
// 顺序调整到token之前
const language = getLanguage()
if (language?.indexOf('zh') !== -1) {
config.headers['Accept-Language'] = 'zh-Hans'
} else {
config.headers['Accept-Language'] = language
}
if (config.url === '/connect/token') {
return config
}
// Add X-Access-Token header to every request, you can add other custom headers here
if (UserModule.token) {
config.headers.Authorization = UserModule.token
}
return config
},
(error) => {
@ -43,21 +44,21 @@ function l(name: string) {
return i18n.tc(name)
}
function showError(error: any, status: number) {
function showError(response: any) {
let message = ''
let title = ''
if (error && error.error) {
if (error.error.details) {
message = error.error.details
title = error.error.message
} else if (error.error.message) {
message = error.error.message
if (response.data && response.data.error) {
if (response.data.error.details) {
message = response.data.error.details
title = response.data.error.message
} else if (response.data.error.message) {
message = response.data.error.message
}
} else {
switch (status) {
switch (response.status) {
case 400:
title = error.error
message = error.error_description
title = response.data.error
message = response.data.error_description
break
case 401:
title = l('AbpUi.DefaultErrorMessage401')
@ -79,6 +80,9 @@ function showError(error: any, status: number) {
message = l('AbpUi.InternalServerErrorMessage')
break
default:
// 从响应中返回原始状态说明
title = response.statusText
message = response.status + ' ' + response.statusText
break
}
}
@ -116,7 +120,7 @@ service.interceptors.response.use(
})
})
} else {
showError(error.response.data, error.response.status)
showError(error.response)
}
return Promise.reject(error)
}

Loading…
Cancel
Save