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 ServiceWorkerUpdatePopup
} }
}) })
export default class extends Vue { export default class App extends Vue {
created() { created() {
this.initializeAbpConfiguration() this.initialize()
} }
private async initializeAbpConfiguration() { private async initialize() {
await HttpProxyModule.Initialize() await HttpProxyModule.Initialize()
await AbpModule.LoadAbpConfiguration() await AbpModule.Initialize()
} }
} }
</script> </script>

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

@ -207,44 +207,12 @@ export class ControllerApiDescriptionModel {
type!: string type!: string
interfaces = new Array<ControllerInterfaceApiDescriptionModel>() interfaces = new Array<ControllerInterfaceApiDescriptionModel>()
actions: {[key: string]: ActionApiDescriptionModel} = {} 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 { export class ModuleApiDescriptionModel {
rootPath = 'app' rootPath = 'app'
remoteServiceName = 'Default' remoteServiceName = 'Default'
controllers: {[key: string]: ControllerApiDescriptionModel} = {} 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 { export class TypeApiDescriptionModel {
@ -259,30 +227,4 @@ export class TypeApiDescriptionModel {
export class ApplicationApiDescriptionModel { export class ApplicationApiDescriptionModel {
modules: {[key: string]: ModuleApiDescriptionModel} = {} modules: {[key: string]: ModuleApiDescriptionModel} = {}
types: {[key: string]: TypeApiDescriptionModel} = {} 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) AppModule.SetLanguage(lang)
this.$i18n.locale = lang this.$i18n.locale = lang
this.localization.currentCulture.cultureName = lang this.localization.currentCulture.cultureName = lang
AbpModule.LoadAbpConfiguration().then(() => { AbpModule.Initialize().then(() => {
this.$message({ this.$message({
message: 'Switch Language Success', message: 'Switch Language Success',
type: 'success' type: 'success'

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

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

1
vueJs/src/main.ts

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

61
vueJs/src/mixins/HttpProxyMiXin.ts

@ -7,7 +7,9 @@ import {
ApiVersionInfo, ApiVersionInfo,
ParameterBindingSources, ParameterBindingSources,
UrlBuilder, UrlBuilder,
ApplicationApiDescriptionModel ApplicationApiDescriptionModel,
ModuleApiDescriptionModel,
ControllerApiDescriptionModel
} from '@/api/dynamic-api' } from '@/api/dynamic-api'
/** /**
* Http代理组件 * Http代理组件
@ -16,6 +18,8 @@ import {
name: 'HttpProxyMiXin' name: 'HttpProxyMiXin'
}) })
export default class HttpProxyMiXin extends Vue { export default class HttpProxyMiXin extends Vue {
private apiDescriptor = HttpProxyModule.applicationApiDescriptionModel
protected pagedRequest<TResult>(options: { protected pagedRequest<TResult>(options: {
service: string, service: string,
controller: string, controller: string,
@ -32,10 +36,9 @@ export default class HttpProxyMiXin extends Vue {
action: string, action: string,
data?: any data?: any
}) { }) {
const action = ApplicationApiDescriptionModel const module = this.getModule(options.service, this.apiDescriptor.modules)
.getAction( const controller = this.getController(options.controller, module.controllers)
options.service, options.controller, options.action, const action = this.getAction(options.action, controller.actions)
HttpProxyModule.applicationApiDescriptionModel.modules)
const apiVersion = this.getApiVersionInfo(action) const apiVersion = this.getApiVersionInfo(action)
let url = process.env.REMOTE_SERVICE_BASE_URL || '' let url = process.env.REMOTE_SERVICE_BASE_URL || ''
url = this.ensureEndsWith(url, '/') + UrlBuilder.generateUrlWithParameters(action, options.data, apiVersion) 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) { private getApiVersionInfo(action: ActionApiDescriptionModel) {
const apiVersion = this.findBestApiVersion(action) const apiVersion = this.findBestApiVersion(action)
const versionParam = const versionParam =

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

@ -27,7 +27,7 @@ class AbpConfiguration extends VuexModule implements IAbpState {
} }
@Action({ rawError: true }) @Action({ rawError: true })
public LoadAbpConfiguration() { public Initialize() {
return new Promise<AbpConfig>((resolve, reject) => { return new Promise<AbpConfig>((resolve, reject) => {
AbpConfigurationService.getAbpConfiguration().then(config => { AbpConfigurationService.getAbpConfiguration().then(config => {
this.SET_ABPCONFIGURATION(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() { public async Initialize() {
const dynamicApiJson = getItem(dynamicApiKey) const dynamicApiJson = getItem(dynamicApiKey)
if (dynamicApiJson) { if (dynamicApiJson) {
this.SET_API_DESCRIPTOR(JSON.parse(dynamicApiJson)) const apiDescriptor = JSON.parse(dynamicApiJson) as ApplicationApiDescriptionModel
return if (apiDescriptor) {
this.SET_API_DESCRIPTOR(apiDescriptor)
return
}
} }
const dynamicApi = await DynamicApiService.get() const dynamicApi = await DynamicApiService.get()
this.SET_API_DESCRIPTOR(dynamicApi) this.SET_API_DESCRIPTOR(dynamicApi)
setItem(dynamicApiKey, JSON.stringify(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) export const HttpProxyModule = getModule(HttpProxy)

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

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

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

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

Loading…
Cancel
Save