perf: 优化应用菜单

This commit is contained in:
kuaifan 2025-07-30 08:32:19 +08:00
parent a562bfdb08
commit a3649c04e2
4 changed files with 21 additions and 26 deletions

View File

@ -288,10 +288,10 @@ export default {
this.userSelectOptions.value = params.value this.userSelectOptions.value = params.value
delete params.value delete params.value
this.userSelectOptions.config = params this.userSelectOptions.config = params
return await new Promise(resolve => { return await new Promise((resolve, reject) => {
this.$refs.userSelect.onSelection((res) => { this.$refs.userSelect.onSelection((res) => {
return resolve(res) resolve(res)
}) }, reject)
}) })
}, },
nextZIndex: () => { nextZIndex: () => {

View File

@ -328,6 +328,7 @@ export default {
values: [], values: [],
selects: [], selects: [],
callback: null, callback: null,
closeCallback: null,
recents: [], recents: [],
contacts: [], contacts: [],
@ -373,6 +374,7 @@ export default {
this.upTitleWidth() this.upTitleWidth()
} else { } else {
this.searchKey = "" this.searchKey = ""
this.closeCallback && this.closeCallback()
} }
this.$emit("on-show-change", v) this.$emit("on-show-change", v)
// //
@ -764,13 +766,14 @@ export default {
}, this.searchCache.length > 0 ? 300 : 0) }, this.searchCache.length > 0 ? 300 : 0)
}, },
onSelection(callback = null) { onSelection(callback = null, closeCallback = null) {
if (this.disabled) { if (this.disabled) {
return return
} }
this.$nextTick(_ => { this.$nextTick(_ => {
this.selects = $A.cloneJSON(this.values) this.selects = $A.cloneJSON(this.values)
this.callback = typeof callback === 'function' ? callback : null this.callback = typeof callback === 'function' ? callback : null
this.closeCallback = typeof closeCallback === 'function' ? closeCallback : null
this.showModal = true this.showModal = true
}) })
}, },

View File

@ -287,9 +287,6 @@ export default {
*/ */
filterMicroAppsMenus: (state) => { filterMicroAppsMenus: (state) => {
return state.microAppsMenus.filter(item => { return state.microAppsMenus.filter(item => {
if (item.only_admin === true && !state.userIsAdmin) {
return false
}
return item.location === 'application' return item.location === 'application'
}) })
}, },
@ -303,9 +300,6 @@ export default {
*/ */
filterMicroAppsMenusAdmin: (state) => { filterMicroAppsMenusAdmin: (state) => {
return state.microAppsMenus.filter(item => { return state.microAppsMenus.filter(item => {
if (item.only_admin === true && !state.userIsAdmin) {
return false
}
return item.location === 'application/admin' return item.location === 'application/admin'
}) })
}, },
@ -319,9 +313,6 @@ export default {
*/ */
filterMicroAppsMenusMain: (state) => { filterMicroAppsMenusMain: (state) => {
return state.microAppsMenus.filter(item => { return state.microAppsMenus.filter(item => {
if (item.only_admin === true && !state.userIsAdmin) {
return false
}
return item.location === 'main/menu' return item.location === 'main/menu'
}) })
} }

View File

@ -337,19 +337,20 @@ export default {
'microApps/data': function(state, data) { 'microApps/data': function(state, data) {
// 添加应用商店 // 添加应用商店
data.unshift({ if (state.userIsAdmin) {
id: 'appstore', data.unshift({
version: '1.0.0', id: 'appstore',
menu_items: [{ version: '1.0.0',
location: "application/admin", menu_items: [{
label: $A.L("应用商店"), location: "application/admin",
icon: $A.mainUrl("images/application/appstore.svg"), label: $A.L("应用商店"),
url: 'appstore/internal?language={system_lang}&theme={system_theme}', icon: $A.mainUrl("images/application/appstore.svg"),
only_admin: true, url: 'appstore/internal?language={system_lang}&theme={system_theme}',
disable_scope_css: true, disable_scope_css: true,
auto_dark_theme: false, auto_dark_theme: false,
}] }]
}) })
}
// 找出已卸载的应用和版本更新的应用 // 找出已卸载的应用和版本更新的应用
const updatedOrUninstalledApps = state.microAppsInstalled const updatedOrUninstalledApps = state.microAppsInstalled
.filter((oldApp) => !data.some((newApp) => newApp.id === oldApp.id)) .filter((oldApp) => !data.some((newApp) => newApp.id === oldApp.id))