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">
|
<script lang="ts">
|
||||||
import { addComponentListener } from '@/core/settings'
|
import { addComponentListener } from '@/core/settings'
|
||||||
import { getUID } from '@/core/utils'
|
|
||||||
import { ascendingSort } from '@/core/utils/sort'
|
import { ascendingSort } from '@/core/utils/sort'
|
||||||
import { registerAndGetData } from '@/plugins/data'
|
import { registerAndGetData } from '@/plugins/data'
|
||||||
import { getBuiltInItems } from './built-in-items'
|
import { getBuiltInItems } from './built-in-items'
|
||||||
@ -28,14 +27,7 @@ const [renderedItems] = registerAndGetData(CustomNavbarRenderedItems, {
|
|||||||
items: [] as CustomNavbarItem[],
|
items: [] as CustomNavbarItem[],
|
||||||
})
|
})
|
||||||
const getItems = () => {
|
const getItems = () => {
|
||||||
const isLogin = Boolean(getUID())
|
|
||||||
const items = (initItems as CustomNavbarItemInit[])
|
const items = (initItems as CustomNavbarItemInit[])
|
||||||
.filter(it => {
|
|
||||||
if (it.loginRequired && !isLogin) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
.map(it => new CustomNavbarItem(it))
|
.map(it => new CustomNavbarItem(it))
|
||||||
.sort(ascendingSort(it => it.order))
|
.sort(ascendingSort(it => it.order))
|
||||||
renderedItems.items = items
|
renderedItems.items = items
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { createPopper, Instance as Popper } from '@popperjs/core'
|
|||||||
import { VueModule, Executable } from '@/core/common-types'
|
import { VueModule, Executable } from '@/core/common-types'
|
||||||
import { getComponentSettings, addComponentListener } from '@/core/settings'
|
import { getComponentSettings, addComponentListener } from '@/core/settings'
|
||||||
import type { CustomNavbarOptions } from '.'
|
import type { CustomNavbarOptions } from '.'
|
||||||
|
import { getUID } from '@/core/utils'
|
||||||
|
|
||||||
export const CustomNavbarItems = 'customNavbar.items'
|
export const CustomNavbarItems = 'customNavbar.items'
|
||||||
export const CustomNavbarRenderedItems = 'customNavbar.renderedItems'
|
export const CustomNavbarRenderedItems = 'customNavbar.renderedItems'
|
||||||
@ -90,7 +91,8 @@ export class CustomNavbarItem implements Required<CustomNavbarItemInit> {
|
|||||||
},
|
},
|
||||||
true,
|
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
|
const orderMap = CustomNavbarItem.navbarOptions.order
|
||||||
this.order = orderMap[this.name] || 0
|
this.order = orderMap[this.name] || 0
|
||||||
this.requestedPopup = !this.lazy
|
this.requestedPopup = !this.lazy
|
||||||
|
|||||||
@ -118,6 +118,7 @@ export default Vue.extend({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const list: HTMLElement = this.$refs.navbarSortList
|
const list: HTMLElement = this.$refs.navbarSortList
|
||||||
|
if (list) {
|
||||||
const Sortable = await SortableJSLibrary
|
const Sortable = await SortableJSLibrary
|
||||||
Sortable.create(list, {
|
Sortable.create(list, {
|
||||||
delay: 100,
|
delay: 100,
|
||||||
@ -127,11 +128,8 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
checkSequentialOrder(rendered.items)
|
checkSequentialOrder(rendered.items)
|
||||||
|
}
|
||||||
this.loaded = true
|
this.loaded = true
|
||||||
// unsafeWindow.nsTest = {
|
|
||||||
// list,
|
|
||||||
// Sortable,
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggle() {
|
toggle() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user