diff --git a/src/api/settings.js b/src/api/settings.js index 1365b2475..673601969 100644 --- a/src/api/settings.js +++ b/src/api/settings.js @@ -15,6 +15,7 @@ export function testEmailSetting(data) { data: data }) } + export function importLicense(formData) { return request({ url: '/api/v1/xpack/license/import', @@ -25,6 +26,7 @@ export function importLicense(formData) { data: formData }) } + export function testLdapSetting(data, refresh = true) { let url = '/api/v1/settings/ldap/testing/config/' if (refresh) { @@ -96,9 +98,17 @@ export function getPublicSettings(isOpen) { method: 'get' }) } + export function getLogo() { return request({ url: '/api/v1/xpack/interface/setting/', method: 'get' }) } + +export function getPreference() { + return request({ + url: 'api/v1/users/preference/?category=luna', + method: 'get' + }) +} diff --git a/src/utils/common.js b/src/utils/common.js index 388fef90f..67c4bc8fb 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -310,4 +310,26 @@ export function toSentenceCase(string) { }).join(' ') return s[0].toUpperCase() + s.slice(1) } + export { BASE_URL } + +export function openNewWindow(url) { + let count + let top = 50 + count = parseInt(window.sessionStorage.getItem('newWindowCount'), 10) + if (isNaN(count)) { + count = 0 + } + let left = 100 + count * 100 + top = 50 + count * 50 + if (left + screen.width / 3 > screen.width) { + // 支持两排足以 + top = screen.height / 3 + count = 1 + left = 100 + } + let params = 'toolbar=yes,scrollbars=yes,resizable=yes' + params = params + `,top=${top},left=${left},width=${screen.width / 3},height=${screen.height / 3}` + window.sessionStorage.setItem('newWindowCount', `${count + 1}`) + window.open(url, '_blank', params) +} diff --git a/src/views/workbench/myassets/index.vue b/src/views/workbench/myassets/index.vue index 7fa878bbb..75134d516 100644 --- a/src/views/workbench/myassets/index.vue +++ b/src/views/workbench/myassets/index.vue @@ -15,6 +15,8 @@ import GrantedAssets from '@/components/Apps/GrantedAssets/index.vue' import Page from '@/layout/components/Page/index.vue' import { EditableInputFormatter } from '@/components/Table/TableFormatters' +import { getPreference } from '@/api/settings' +import { openNewWindow } from '@/utils/common' export default { components: { @@ -25,6 +27,7 @@ export default { return { treeUrl: `/api/v1/perms/users/self/nodes/children/tree/`, tableUrl: `/api/v1/perms/users/self/assets/`, + preference: {}, actions: { width: '88px', align: 'center', @@ -41,8 +44,13 @@ export default { can: ({ row }) => row.is_active, callback: ({ row }) => { const oid = this.$store.getters.currentOrg ? this.$store.getters.currentOrg.id : '' - const url = `/luna/?login_to=${row.id}${oid ? `&oid=${oid}` : ''}` - window.open(url, '_blank') + const url = `/luna/connect?login_to=${row.id}` + if (this.preference?.basic?.connect_default_open_method === 'new') { + openNewWindow(url) + } else { + const url = `/luna/?login_to=${row.id}${oid ? `&oid=${oid}` : ''}` + window.open(url, '_blank') + } } }, { @@ -81,6 +89,9 @@ export default { }, mounted() { this.refreshAllFavorites() + this.preference = getPreference().then((resp) => { + this.preference = resp + }) }, methods: { refreshAllFavorites() { diff --git a/src/views/workbench/myhome/components/Session.vue b/src/views/workbench/myhome/components/Session.vue index de5f275a9..bd9e9774c 100644 --- a/src/views/workbench/myhome/components/Session.vue +++ b/src/views/workbench/myhome/components/Session.vue @@ -4,6 +4,8 @@