fix: 修复Dropdown Menu的回调异常 (#642)

* fix: 修复Dropdown Menu的回调异常

* perf: 优化创建

Co-authored-by: Orange <orangemtony@gmail.com>
Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
fit2bot 2021-03-09 12:35:44 +08:00 committed by GitHub
parent 1d008330a1
commit 5d973944ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 21 deletions

View File

@ -5,7 +5,9 @@ export function cleanActions(actions, canDefaults, { selectedRows, reloadTable }
cloneActions.forEach((action) => { cloneActions.forEach((action) => {
action.has = cleanBoolean(action, 'has', true, { selectedRows, reloadTable }) action.has = cleanBoolean(action, 'has', true, { selectedRows, reloadTable })
action.can = cleanBoolean(action, 'can', true, { selectedRows, reloadTable }) action.can = cleanBoolean(action, 'can', true, { selectedRows, reloadTable })
if (!action.dropdown) {
action.callback = cleanCallback(action, { selectedRows, reloadTable }) action.callback = cleanCallback(action, { selectedRows, reloadTable })
}
cleanedActions.push(action) cleanedActions.push(action)
}) })
return cleanedActions return cleanedActions

View File

@ -56,7 +56,7 @@ export default {
createRoute: 'SystemUserCreate', createRoute: 'SystemUserCreate',
moreCreates: { moreCreates: {
callback: (option) => { callback: (option) => {
vm.$router.push({ name: 'SystemUserCreate', query: { protocol: option.type }}) vm.$router.push({ name: 'SystemUserCreate', query: { protocol: option.title.toLowerCase() }})
}, },
dropdown: [ dropdown: [
{ {

View File

@ -1,5 +1,4 @@
import i18n from '@/i18n/i18n' import i18n from '@/i18n/i18n'
import router from '@/router'
import store from '@/store' import store from '@/store'
export const CHROME = 'chrome' export const CHROME = 'chrome'
export const MYSQL_WORKBENCH = 'mysql_workbench' export const MYSQL_WORKBENCH = 'mysql_workbench'
@ -20,29 +19,25 @@ export const REMOTE_APP = [
title: i18n.t(`applications.applicationsType.${CHROME}`), title: i18n.t(`applications.applicationsType.${CHROME}`),
type: 'primary', type: 'primary',
group: i18n.t('applications.RemoteApp'), group: i18n.t('applications.RemoteApp'),
has: hasValidLicense, has: hasValidLicense
callback: function() { router.push({ name: 'ApplicationPermissionCreate', query: { type: CHROME, category: REMOTEAPP_CATEGORY }}) }
}, },
{ {
name: MYSQL_WORKBENCH, name: MYSQL_WORKBENCH,
title: i18n.t(`applications.applicationsType.${MYSQL_WORKBENCH}`), title: i18n.t(`applications.applicationsType.${MYSQL_WORKBENCH}`),
type: 'primary', type: 'primary',
has: hasValidLicense, has: hasValidLicense
callback: function() { router.push({ name: 'ApplicationPermissionCreate', query: { type: MYSQL_WORKBENCH, category: REMOTEAPP_CATEGORY }}) }
}, },
{ {
name: VMWARE_CLIENT, name: VMWARE_CLIENT,
title: i18n.t(`applications.applicationsType.${VMWARE_CLIENT}`), title: i18n.t(`applications.applicationsType.${VMWARE_CLIENT}`),
type: 'primary', type: 'primary',
has: hasValidLicense, has: hasValidLicense
callback: function() { router.push({ name: 'ApplicationPermissionCreate', query: { type: VMWARE_CLIENT, category: REMOTEAPP_CATEGORY }}) }
}, },
{ {
name: CUSTOM, name: CUSTOM,
title: i18n.t(`applications.applicationsType.${CUSTOM}`), title: i18n.t(`applications.applicationsType.${CUSTOM}`),
type: 'primary', type: 'primary',
has: hasValidLicense, has: hasValidLicense
callback: function() { router.push({ name: 'ApplicationPermissionCreate', query: { type: CUSTOM, category: REMOTEAPP_CATEGORY }}) }
} }
] ]
@ -58,29 +53,25 @@ export const DATABASE = [
title: i18n.t(`applications.applicationsType.${MYSQL}`), title: i18n.t(`applications.applicationsType.${MYSQL}`),
type: 'primary', type: 'primary',
has: true, has: true,
group: i18n.t('applications.Database'), group: i18n.t('applications.Database')
callback: function() { router.push({ name: 'ApplicationPermissionCreate', query: { type: MYSQL, category: DATABASE_CATEGORY }}) }
}, },
{ {
name: ORACLE, name: ORACLE,
title: i18n.t(`applications.applicationsType.${ORACLE}`), title: i18n.t(`applications.applicationsType.${ORACLE}`),
type: 'primary', type: 'primary',
has: hasValidLicense, has: hasValidLicense
callback: function() { router.push({ name: 'ApplicationPermissionCreate', query: { type: ORACLE, category: DATABASE_CATEGORY }}) }
}, },
{ {
name: POSTGRESQL, name: POSTGRESQL,
title: i18n.t(`applications.applicationsType.${POSTGRESQL}`), title: i18n.t(`applications.applicationsType.${POSTGRESQL}`),
type: 'primary', type: 'primary',
has: hasValidLicense, has: hasValidLicense
callback: function() { router.push({ name: 'ApplicationPermissionCreate', query: { type: POSTGRESQL, category: DATABASE_CATEGORY }}) }
}, },
{ {
name: MARIADB, name: MARIADB,
title: i18n.t(`applications.applicationsType.${MARIADB}`), title: i18n.t(`applications.applicationsType.${MARIADB}`),
type: 'primary', type: 'primary',
has: hasValidLicense, has: hasValidLicense
callback: function() { router.push({ name: 'ApplicationPermissionCreate', query: { type: MARIADB, category: DATABASE_CATEGORY }}) }
} }
] ]
@ -93,8 +84,7 @@ export const CLOUD = [
title: i18n.t(`applications.applicationsType.${KUBERNETES}`), title: i18n.t(`applications.applicationsType.${KUBERNETES}`),
group: i18n.t('applications.Cloud'), group: i18n.t('applications.Cloud'),
type: 'primary', type: 'primary',
has: true, has: true
callback: function() { router.push({ name: 'ApplicationPermissionCreate', query: { type: KUBERNETES, category: CLOUD_CATEGORY }}) }
} }
] ]