mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Fix orders of login-required items (fix #5099)
This commit is contained in:
parent
f0b40d4da1
commit
1ce2da6a62
@ -10,7 +10,6 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { addComponentListener } from '@/core/settings'
|
||||
import { getUID } from '@/core/utils'
|
||||
import { ascendingSort } from '@/core/utils/sort'
|
||||
import { registerAndGetData } from '@/plugins/data'
|
||||
import { getBuiltInItems } from './built-in-items'
|
||||
@ -28,14 +27,7 @@ const [renderedItems] = registerAndGetData(CustomNavbarRenderedItems, {
|
||||
items: [] as CustomNavbarItem[],
|
||||
})
|
||||
const getItems = () => {
|
||||
const isLogin = Boolean(getUID())
|
||||
const items = (initItems as CustomNavbarItemInit[])
|
||||
.filter(it => {
|
||||
if (it.loginRequired && !isLogin) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
.map(it => new CustomNavbarItem(it))
|
||||
.sort(ascendingSort(it => it.order))
|
||||
renderedItems.items = items
|
||||
|
||||
@ -2,6 +2,7 @@ import { createPopper, Instance as Popper } from '@popperjs/core'
|
||||
import { VueModule, Executable } from '@/core/common-types'
|
||||
import { getComponentSettings, addComponentListener } from '@/core/settings'
|
||||
import type { CustomNavbarOptions } from '.'
|
||||
import { getUID } from '@/core/utils'
|
||||
|
||||
export const CustomNavbarItems = 'customNavbar.items'
|
||||
export const CustomNavbarRenderedItems = 'customNavbar.renderedItems'
|
||||
@ -90,7 +91,8 @@ export class CustomNavbarItem implements Required<CustomNavbarItemInit> {
|
||||
},
|
||||
true,
|
||||
)
|
||||
this.hidden = CustomNavbarItem.navbarOptions.hidden.includes(this.name)
|
||||
this.hidden =
|
||||
CustomNavbarItem.navbarOptions.hidden.includes(this.name) || (!getUID() && init.loginRequired)
|
||||
const orderMap = CustomNavbarItem.navbarOptions.order
|
||||
this.order = orderMap[this.name] || 0
|
||||
this.requestedPopup = !this.lazy
|
||||
|
||||
@ -118,6 +118,7 @@ export default Vue.extend({
|
||||
}
|
||||
})
|
||||
const list: HTMLElement = this.$refs.navbarSortList
|
||||
if (list) {
|
||||
const Sortable = await SortableJSLibrary
|
||||
Sortable.create(list, {
|
||||
delay: 100,
|
||||
@ -127,11 +128,8 @@ export default Vue.extend({
|
||||
},
|
||||
})
|
||||
checkSequentialOrder(rendered.items)
|
||||
}
|
||||
this.loaded = true
|
||||
// unsafeWindow.nsTest = {
|
||||
// list,
|
||||
// Sortable,
|
||||
// }
|
||||
},
|
||||
methods: {
|
||||
toggle() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user