mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Add online registry branch switcher
This commit is contained in:
parent
88820ff0b5
commit
7ad515c2f6
@ -13,11 +13,6 @@ export enum SettingsPanelDockSide {
|
||||
Right = '右侧',
|
||||
}
|
||||
|
||||
export enum Branch {
|
||||
Master = 'master',
|
||||
Preview = 'preview'
|
||||
}
|
||||
|
||||
const entry: ComponentEntry = async ({ metadata }) => {
|
||||
const { isIframe } = await import('@/core/utils')
|
||||
if (isIframe()) {
|
||||
@ -69,11 +64,6 @@ export const component: ComponentMetadata = {
|
||||
displayName: '更新源',
|
||||
dropdownEnum: CdnTypes,
|
||||
},
|
||||
branch: {
|
||||
defaultValue: Branch.Preview,
|
||||
displayName: '更新分支',
|
||||
dropdownEnum: Branch,
|
||||
},
|
||||
dockSide: {
|
||||
defaultValue: SettingsPanelDockSide.Left,
|
||||
displayName: '设置面板停靠',
|
||||
|
||||
@ -5,13 +5,6 @@
|
||||
<div class="online-registry-header-title">
|
||||
在线仓库
|
||||
</div>
|
||||
<div class="online-registry-header-search">
|
||||
<VIcon icon="search" :size="18" />
|
||||
<TextBox
|
||||
v-model="searchKeyword"
|
||||
placeholder="搜索功能"
|
||||
/>
|
||||
</div>
|
||||
<VIcon
|
||||
icon="mdi-refresh"
|
||||
:size="22"
|
||||
@ -27,6 +20,23 @@
|
||||
@click="popupOpen = false"
|
||||
/>
|
||||
</div>
|
||||
<div class="online-registry-header">
|
||||
<div class="online-registry-header-search">
|
||||
<VIcon icon="search" :size="18" />
|
||||
<TextBox
|
||||
v-model="searchKeyword"
|
||||
placeholder="搜索功能"
|
||||
/>
|
||||
</div>
|
||||
<div class="online-registry-header-branch">
|
||||
分支:
|
||||
<VDropdown v-model="selectedBranch" :items="registryBranches">
|
||||
<template #item="{ item }">
|
||||
{{ item }}
|
||||
</template>
|
||||
</VDropdown>
|
||||
</div>
|
||||
</div>
|
||||
<div class="online-registry-separator"></div>
|
||||
<div ref="content" class="online-registry-content">
|
||||
<VLoading v-if="loading" />
|
||||
@ -47,10 +57,12 @@
|
||||
<script lang="ts">
|
||||
import { monkey } from '@/core/ajax'
|
||||
import { cdnRoots } from '@/core/cdn-types'
|
||||
import { meta } from '@/core/meta'
|
||||
import { getGeneralSettings } from '@/core/settings'
|
||||
import { logError } from '@/core/utils/log'
|
||||
import {
|
||||
VIcon,
|
||||
VDropdown,
|
||||
TextBox,
|
||||
VPopup,
|
||||
VLoading,
|
||||
@ -59,10 +71,13 @@ import {
|
||||
import Fuse from 'fuse.js'
|
||||
import { DocSourceItem } from 'registry/lib/docs'
|
||||
import RegistryItem from './RegistryItem.vue'
|
||||
import { registryBranches } from './third-party'
|
||||
|
||||
const general = getGeneralSettings()
|
||||
export default Vue.extend({
|
||||
components: {
|
||||
VIcon,
|
||||
VDropdown,
|
||||
TextBox,
|
||||
VPopup,
|
||||
RegistryItem,
|
||||
@ -76,6 +91,11 @@ export default Vue.extend({
|
||||
},
|
||||
},
|
||||
data() {
|
||||
const branches = [
|
||||
general.registryBranch,
|
||||
meta.compilationInfo.branch,
|
||||
registryBranches[0],
|
||||
].filter(it => registryBranches.includes(it) && Boolean(it))
|
||||
return {
|
||||
searchKeyword: '',
|
||||
popupOpen: false,
|
||||
@ -84,6 +104,8 @@ export default Vue.extend({
|
||||
filteredList: [],
|
||||
// packList: [],
|
||||
fuse: null,
|
||||
registryBranches,
|
||||
selectedBranch: branches[0],
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -97,6 +119,10 @@ export default Vue.extend({
|
||||
this.filteredList = fuseResult.map(it => it.item)
|
||||
this.$nextTick().then(() => this.$refs.content.scrollTo(0, 0))
|
||||
}, 200),
|
||||
selectedBranch(newBranch: string) {
|
||||
general.registryBranch = newBranch
|
||||
this.fetchFeatures()
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.fetchFeatures()
|
||||
@ -106,7 +132,7 @@ export default Vue.extend({
|
||||
if (this.loading) {
|
||||
return
|
||||
}
|
||||
const fetchPath = cdnRoots[getGeneralSettings().cdnRoot](getGeneralSettings().branch)
|
||||
const fetchPath = cdnRoots[general.cdnRoot](general.branch)
|
||||
try {
|
||||
this.loading = true
|
||||
const featureListUrl = `${fetchPath}doc/features/features.json`
|
||||
@ -157,14 +183,17 @@ export default Vue.extend({
|
||||
}
|
||||
&-header {
|
||||
padding: 12px;
|
||||
@include h-center(6px);
|
||||
@include h-center(12px);
|
||||
& + & {
|
||||
padding-top: 0;
|
||||
}
|
||||
&-title {
|
||||
flex: 1;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
&-search {
|
||||
flex: 1;
|
||||
margin: 0 12px;
|
||||
justify-content: center;
|
||||
@include h-center(6px);
|
||||
.be-textbox {
|
||||
@ -173,6 +202,10 @@ export default Vue.extend({
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
&-branch {
|
||||
@include h-center(6px);
|
||||
font-size: 12px;
|
||||
}
|
||||
&-refresh-icon,
|
||||
&-close-icon {
|
||||
padding: 4px;
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
// import { ComponentMetadata } from '../types'
|
||||
|
||||
// export const component: ComponentMetadata = {
|
||||
// name: 'onlineRegistry',
|
||||
// displayName: '在线功能仓库',
|
||||
// entry: () => {
|
||||
|
||||
// },
|
||||
// tags: [componentsTags.general],
|
||||
// description: {
|
||||
// 'zh-CN': '浏览在线功能仓库, 为脚本挑选并安装需要的功能.',
|
||||
// },
|
||||
// }
|
||||
@ -0,0 +1,4 @@
|
||||
import { registerAndGetData } from '@/plugins/data'
|
||||
|
||||
const defaultRegistryBranches = ['master', 'preview']
|
||||
export const [registryBranches] = registerAndGetData('settingsPanel.registryBranches', [...defaultRegistryBranches])
|
||||
Loading…
Reference in New Issue
Block a user