mirror of
https://github.com/jumpserver/lina.git
synced 2025-07-13 15:04:43 +00:00
perf: 修改平台选择
This commit is contained in:
parent
c491fb6c40
commit
d7dedf15f1
@ -12,7 +12,7 @@
|
|||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-collapse v-model="activeType" accordion>
|
<el-collapse v-model="activeType" accordion>
|
||||||
<el-collapse-item
|
<el-collapse-item
|
||||||
v-for="(ps, categoryName) in sortedPlatforms"
|
v-for="(ps, categoryName) in iPlatforms"
|
||||||
:key="categoryName"
|
:key="categoryName"
|
||||||
:title="categoryName"
|
:title="categoryName"
|
||||||
:name="categoryName"
|
:name="categoryName"
|
||||||
@ -60,6 +60,7 @@ export default {
|
|||||||
platforms: [],
|
platforms: [],
|
||||||
recentPlatformIds: [],
|
recentPlatformIds: [],
|
||||||
activeType: 'host',
|
activeType: 'host',
|
||||||
|
recentUsedLabel: this.$t('assets.RecentlyUsed'),
|
||||||
typeIconMapper: {
|
typeIconMapper: {
|
||||||
linux: 'fa-linux',
|
linux: 'fa-linux',
|
||||||
windows: 'fa-windows',
|
windows: 'fa-windows',
|
||||||
@ -79,15 +80,21 @@ export default {
|
|||||||
},
|
},
|
||||||
get() { return this.visible }
|
get() { return this.visible }
|
||||||
},
|
},
|
||||||
sortedPlatforms() {
|
iPlatforms() {
|
||||||
const recentPlatforms = {}
|
let recentPlatforms = {}
|
||||||
|
let platforms = {}
|
||||||
if (this.category === 'all') {
|
if (this.category === 'all') {
|
||||||
recentPlatforms[this.$t('assets.RecentlyUsed')] = this.allRecentPlatforms
|
recentPlatforms[this.recentUsedLabel] = this.allRecentPlatforms
|
||||||
return { ...recentPlatforms, ...this.allSortedPlatforms }
|
platforms = this.allSortedPlatforms
|
||||||
} else {
|
} else {
|
||||||
recentPlatforms[this.$t('assets.RecentlyUsed')] = this.recentPlatforms
|
recentPlatforms[this.recentUsedLabel] = this.typeRecentPlatforms
|
||||||
return { ...recentPlatforms, ...this.typeSortedPlatforms }
|
platforms = this.typeSortedPlatforms
|
||||||
}
|
}
|
||||||
|
// 最近使用为空就不用了
|
||||||
|
if (recentPlatforms[this.recentUsedLabel].length === 0) {
|
||||||
|
recentPlatforms = {}
|
||||||
|
}
|
||||||
|
return { ...recentPlatforms, ...platforms }
|
||||||
},
|
},
|
||||||
allSortedPlatforms() {
|
allSortedPlatforms() {
|
||||||
return _.groupBy(this.platforms, (item) => item.category.label)
|
return _.groupBy(this.platforms, (item) => item.category.label)
|
||||||
@ -96,9 +103,6 @@ export default {
|
|||||||
const typedPlatforms = this.platforms.filter(item => item.category.value === this.category)
|
const typedPlatforms = this.platforms.filter(item => item.category.value === this.category)
|
||||||
return _.groupBy(typedPlatforms, (item) => item.type.label)
|
return _.groupBy(typedPlatforms, (item) => item.type.label)
|
||||||
},
|
},
|
||||||
recentPlatforms() {
|
|
||||||
return this.category === 'all' ? this.allRecentPlatforms : this.typeRecentPlatforms
|
|
||||||
},
|
|
||||||
allRecentPlatforms() {
|
allRecentPlatforms() {
|
||||||
return this.recentPlatformIds
|
return this.recentPlatformIds
|
||||||
.map(i => this.platforms.find(p => p.id === i))
|
.map(i => this.platforms.find(p => p.id === i))
|
||||||
@ -112,7 +116,7 @@ export default {
|
|||||||
this.$axios.get('/api/v1/assets/platforms/').then(data => {
|
this.$axios.get('/api/v1/assets/platforms/').then(data => {
|
||||||
this.platforms = data
|
this.platforms = data
|
||||||
this.loadRecentPlatformIds()
|
this.loadRecentPlatformIds()
|
||||||
this.activeType = Object.keys(this.sortedPlatforms)[0]
|
this.activeType = Object.keys(this.iPlatforms)[0]
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
Loading…
Reference in New Issue
Block a user