Browse Source

Change some API names and logic

pull/230/head
cKey 5 years ago
parent
commit
2842718b81
  1. 8
      vueJs/src/App.vue
  2. 58
      vueJs/src/api/dynamic-api.ts
  3. 2
      vueJs/src/components/LangSelect/index.vue
  4. 2
      vueJs/src/components/TenantBox/index.vue
  5. 1
      vueJs/src/main.ts
  6. 61
      vueJs/src/mixins/HttpProxyMiXin.ts
  7. 2
      vueJs/src/store/modules/abp.ts
  8. 19
      vueJs/src/store/modules/http-proxy.ts
  9. 2
      vueJs/src/store/modules/user.ts
  10. 18
      vueJs/src/views/admin/identityServer/persisted-grants/index.vue

8
vueJs/src/App.vue

@ -17,14 +17,14 @@ import ServiceWorkerUpdatePopup from '@/pwa/components/ServiceWorkerUpdatePopup.
ServiceWorkerUpdatePopup
}
})
export default class extends Vue {
export default class App extends Vue {
created() {
this.initializeAbpConfiguration()
this.initialize()
}
private async initializeAbpConfiguration() {
private async initialize() {
await HttpProxyModule.Initialize()
await AbpModule.LoadAbpConfiguration()
await AbpModule.Initialize()
}
}
</script>

58
vueJs/src/api/dynamic-api.ts

@ -207,44 +207,12 @@ export class ControllerApiDescriptionModel {
type!: string
interfaces = new Array<ControllerInterfaceApiDescriptionModel>()
actions: {[key: string]: ActionApiDescriptionModel} = {}
public static getAction(
actionName: string,
actions: {[key: string]: ActionApiDescriptionModel}) {
const actionKeys = Object.keys(actions)
const index = actionKeys.findIndex(key => {
const a = actions[key]
if (a.name.toLowerCase() === actionName.toLowerCase()) {
return a
}
})
if (index < 0) {
throw new Error(`没有找到名为 ${actionName} 的方法定义!`)
}
return actions[actionKeys[index]]
}
}
export class ModuleApiDescriptionModel {
rootPath = 'app'
remoteServiceName = 'Default'
controllers: {[key: string]: ControllerApiDescriptionModel} = {}
public static getController(
controllerName: string,
controllers: {[key: string]: ControllerApiDescriptionModel}) {
const controllerKeys = Object.keys(controllers)
const index = controllerKeys.findIndex(key => {
const c = controllers[key]
if (c.controllerName.toLowerCase() === controllerName.toLowerCase()) {
return c
}
})
if (index < 0) {
throw new Error(`没有找到名为 ${controllerName} 的接口定义!`)
}
return controllers[controllerKeys[index]]
}
}
export class TypeApiDescriptionModel {
@ -259,30 +227,4 @@ export class TypeApiDescriptionModel {
export class ApplicationApiDescriptionModel {
modules: {[key: string]: ModuleApiDescriptionModel} = {}
types: {[key: string]: TypeApiDescriptionModel} = {}
public static getAction(
remoteService: string,
controllerName: string,
actionName: string,
modules: {[key: string]: ModuleApiDescriptionModel}) {
const module = this.getModule(remoteService, modules)
const controller = ModuleApiDescriptionModel.getController(controllerName, module.controllers)
return ControllerApiDescriptionModel.getAction(actionName, controller.actions)
}
private static getModule(
remoteService: string,
modules: {[key: string]: ModuleApiDescriptionModel}) {
const moduleKeys = Object.keys(modules)
const index = moduleKeys.findIndex(key => {
const m = modules[key]
if (m.remoteServiceName.toLowerCase() === remoteService.toLowerCase()) {
return m
}
})
if (index < 0) {
throw new Error(`没有找到名为 ${remoteService} 的服务定义!`)
}
return modules[moduleKeys[index]]
}
}

2
vueJs/src/components/LangSelect/index.vue

@ -40,7 +40,7 @@ export default class extends Vue {
AppModule.SetLanguage(lang)
this.$i18n.locale = lang
this.localization.currentCulture.cultureName = lang
AbpModule.LoadAbpConfiguration().then(() => {
AbpModule.Initialize().then(() => {
this.$message({
message: 'Switch Language Success',
type: 'success'

2
vueJs/src/components/TenantBox/index.vue

@ -49,7 +49,7 @@ export default class extends Vue {
})
} else {
AbpModule.configuration.currentTenant.isAvailable = false
AbpModule.LoadAbpConfiguration().finally(() => {
AbpModule.Initialize().finally(() => {
this.$emit('input', '')
})
}

1
vueJs/src/main.ts

@ -59,6 +59,7 @@ Object.keys(filters).forEach(key => {
})
Vue.config.productionTip = false
Vue.prototype.$r = {}
new Vue({
router,

61
vueJs/src/mixins/HttpProxyMiXin.ts

@ -7,7 +7,9 @@ import {
ApiVersionInfo,
ParameterBindingSources,
UrlBuilder,
ApplicationApiDescriptionModel
ApplicationApiDescriptionModel,
ModuleApiDescriptionModel,
ControllerApiDescriptionModel
} from '@/api/dynamic-api'
/**
* Http代理组件
@ -16,6 +18,8 @@ import {
name: 'HttpProxyMiXin'
})
export default class HttpProxyMiXin extends Vue {
private apiDescriptor = HttpProxyModule.applicationApiDescriptionModel
protected pagedRequest<TResult>(options: {
service: string,
controller: string,
@ -32,10 +36,9 @@ export default class HttpProxyMiXin extends Vue {
action: string,
data?: any
}) {
const action = ApplicationApiDescriptionModel
.getAction(
options.service, options.controller, options.action,
HttpProxyModule.applicationApiDescriptionModel.modules)
const module = this.getModule(options.service, this.apiDescriptor.modules)
const controller = this.getController(options.controller, module.controllers)
const action = this.getAction(options.action, controller.actions)
const apiVersion = this.getApiVersionInfo(action)
let url = process.env.REMOTE_SERVICE_BASE_URL || ''
url = this.ensureEndsWith(url, '/') + UrlBuilder.generateUrlWithParameters(action, options.data, apiVersion)
@ -47,6 +50,54 @@ export default class HttpProxyMiXin extends Vue {
})
}
private getModule(
remoteService: string,
modules: {[key: string]: ModuleApiDescriptionModel}) {
const moduleKeys = Object.keys(modules)
const index = moduleKeys.findIndex(key => {
const m = modules[key]
if (m.remoteServiceName.toLowerCase() === remoteService.toLowerCase()) {
return m
}
})
if (index < 0) {
throw new Error(`没有找到名为 ${remoteService} 的服务定义!`)
}
return modules[moduleKeys[index]]
}
private getController(
controllerName: string,
controllers: {[key: string]: ControllerApiDescriptionModel}) {
const controllerKeys = Object.keys(controllers)
const index = controllerKeys.findIndex(key => {
const c = controllers[key]
if (c.controllerName.toLowerCase() === controllerName.toLowerCase()) {
return c
}
})
if (index < 0) {
throw new Error(`没有找到名为 ${controllerName} 的接口定义!`)
}
return controllers[controllerKeys[index]]
}
private getAction(
actionName: string,
actions: {[key: string]: ActionApiDescriptionModel}) {
const actionKeys = Object.keys(actions)
const index = actionKeys.findIndex(key => {
const a = actions[key]
if (a.name.toLowerCase() === actionName.toLowerCase()) {
return a
}
})
if (index < 0) {
throw new Error(`没有找到名为 ${actionName} 的方法定义!`)
}
return actions[actionKeys[index]]
}
private getApiVersionInfo(action: ActionApiDescriptionModel) {
const apiVersion = this.findBestApiVersion(action)
const versionParam =

2
vueJs/src/store/modules/abp.ts

@ -27,7 +27,7 @@ class AbpConfiguration extends VuexModule implements IAbpState {
}
@Action({ rawError: true })
public LoadAbpConfiguration() {
public Initialize() {
return new Promise<AbpConfig>((resolve, reject) => {
AbpConfigurationService.getAbpConfiguration().then(config => {
this.SET_ABPCONFIGURATION(config)

19
vueJs/src/store/modules/http-proxy.ts

@ -22,25 +22,16 @@ class HttpProxy extends VuexModule implements IHttpProxy {
public async Initialize() {
const dynamicApiJson = getItem(dynamicApiKey)
if (dynamicApiJson) {
this.SET_API_DESCRIPTOR(JSON.parse(dynamicApiJson))
return
const apiDescriptor = JSON.parse(dynamicApiJson) as ApplicationApiDescriptionModel
if (apiDescriptor) {
this.SET_API_DESCRIPTOR(apiDescriptor)
return
}
}
const dynamicApi = await DynamicApiService.get()
this.SET_API_DESCRIPTOR(dynamicApi)
setItem(dynamicApiKey, JSON.stringify(dynamicApi))
}
@Action({ rawError: true })
public findAction(service: {
name: string,
controller: string,
action: string
}) {
return ApplicationApiDescriptionModel
.getAction(
service.name, service.controller, service.action,
this.applicationApiDescriptionModel.modules)
}
}
export const HttpProxyModule = getModule(HttpProxy)

2
vueJs/src/store/modules/user.ts

@ -136,7 +136,7 @@ class User extends VuexModule implements IUserState {
@Action
private async PostLogin() {
const abpConfig = await AbpModule.LoadAbpConfiguration()
const abpConfig = await AbpModule.Initialize()
this.SET_CURRENTUSERINFO(abpConfig.currentUser)
}
}

18
vueJs/src/views/admin/identityServer/persisted-grants/index.vue

@ -35,7 +35,7 @@
:label="$t('AbpIdentityServer.Client:Id')"
prop="clientId"
sortable
width="150px"
width="180px"
>
<template slot-scope="{row}">
<span>{{ row.clientId }}</span>
@ -45,7 +45,7 @@
:label="$t('AbpIdentityServer.Grants:Key')"
prop="key"
sortable
width="150px"
width="300px"
>
<template slot-scope="{row}">
<span>{{ row.key }}</span>
@ -65,7 +65,7 @@
:label="$t('AbpIdentityServer.Grants:SessionId')"
prop="sessionId"
sortable
width="140px"
width="180px"
>
<template slot-scope="{row}">
<span>{{ row.sessionId }}</span>
@ -75,7 +75,7 @@
:label="$t('AbpIdentityServer.Description')"
prop="description"
sortable
width="140px"
width="200px"
>
<template slot-scope="{row}">
<span>{{ row.description }}</span>
@ -84,7 +84,7 @@
<el-table-column
:label="$t('global.operaActions')"
align="center"
width="250px"
width="150px"
>
<template slot-scope="{row}">
<el-button
@ -92,18 +92,14 @@
type="success"
icon="el-icon-tickets"
@click="onShowProfile(row.id)"
>
{{ $t('AbpIdentityServer.Grants:Profile') }}
</el-button>
/>
<el-button
:disabled="!checkPermission(['AbpIdentityServer.Grants.Delete'])"
size="mini"
type="danger"
icon="el-icon-delete"
@click="onDeleted(row.id, row.key)"
>
{{ $t('AbpIdentityServer.Grants:Delete') }}
</el-button>
/>
</template>
</el-table-column>
</el-table>

Loading…
Cancel
Save