Filter settings sections at build time instead of run time (#5040)

This commit is contained in:
absidue 2024-04-30 12:58:14 +02:00 committed by GitHub
parent 4c511869fc
commit a5f3410378
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 40 additions and 34 deletions

View File

@ -23,19 +23,24 @@ export default defineComponent({
'general-settings': GeneralSettings, 'general-settings': GeneralSettings,
'theme-settings': ThemeSettings, 'theme-settings': ThemeSettings,
'player-settings': PlayerSettings, 'player-settings': PlayerSettings,
'external-player-settings': ExternalPlayerSettings,
'subscription-settings': SubscriptionSettings, 'subscription-settings': SubscriptionSettings,
'privacy-settings': PrivacySettings, 'privacy-settings': PrivacySettings,
'data-settings': DataSettings, 'data-settings': DataSettings,
'distraction-settings': DistractionSettings, 'distraction-settings': DistractionSettings,
'proxy-settings': ProxySettings,
'sponsor-block-settings': SponsorBlockSettings, 'sponsor-block-settings': SponsorBlockSettings,
'download-settings': DownloadSettings,
'parental-control-settings': ParentControlSettings, 'parental-control-settings': ParentControlSettings,
'experimental-settings': ExperimentalSettings,
'password-settings': PasswordSettings, 'password-settings': PasswordSettings,
'password-dialog': PasswordDialog, 'password-dialog': PasswordDialog,
'ft-toggle-switch': FtToggleSwitch 'ft-toggle-switch': FtToggleSwitch,
...(process.env.IS_ELECTRON
? {
'proxy-settings': ProxySettings,
'download-settings': DownloadSettings,
'external-player-settings': ExternalPlayerSettings,
'experimental-settings': ExperimentalSettings
}
: {})
}, },
data: function () { data: function () {
return { return {
@ -53,11 +58,14 @@ export default defineComponent({
type: 'player-settings', type: 'player-settings',
title: this.$t('Settings.Player Settings.Player Settings') title: this.$t('Settings.Player Settings.Player Settings')
}, },
{ ...(process.env.IS_ELECTRON
type: 'external-player-settings', ? [
title: this.$t('Settings.External Player Settings.External Player Settings'), {
usingElectron: true type: 'external-player-settings',
}, title: this.$t('Settings.External Player Settings.External Player Settings')
}
]
: []),
{ {
type: 'subscription-settings', type: 'subscription-settings',
title: this.$t('Settings.Subscription Settings.Subscription Settings') title: this.$t('Settings.Subscription Settings.Subscription Settings')
@ -74,16 +82,18 @@ export default defineComponent({
type: 'data-settings', type: 'data-settings',
title: this.$t('Settings.Data Settings.Data Settings') title: this.$t('Settings.Data Settings.Data Settings')
}, },
{ ...(process.env.IS_ELECTRON
type: 'proxy-settings', ? [
title: this.$t('Settings.Proxy Settings.Proxy Settings'), {
usingElectron: true type: 'proxy-settings',
}, title: this.$t('Settings.Proxy Settings.Proxy Settings')
{ },
type: 'download-settings', {
title: this.$t('Settings.Download Settings.Download Settings'), type: 'download-settings',
usingElectron: true title: this.$t('Settings.Download Settings.Download Settings')
}, }
]
: []),
{ {
type: 'parental-control-settings', type: 'parental-control-settings',
title: this.$t('Settings.Parental Control Settings.Parental Control Settings') title: this.$t('Settings.Parental Control Settings.Parental Control Settings')
@ -92,11 +102,14 @@ export default defineComponent({
type: 'sponsor-block-settings', type: 'sponsor-block-settings',
title: this.$t('Settings.SponsorBlock Settings.SponsorBlock Settings'), title: this.$t('Settings.SponsorBlock Settings.SponsorBlock Settings'),
}, },
{ ...(process.env.IS_ELECTRON
type: 'experimental-settings', ? [
title: this.$t('Settings.Experimental Settings.Experimental Settings'), {
usingElectron: true type: 'experimental-settings',
}, title: this.$t('Settings.Experimental Settings.Experimental Settings')
},
]
: []),
{ {
type: 'password-settings', type: 'password-settings',
title: this.$t('Settings.Password Settings.Password Settings') title: this.$t('Settings.Password Settings.Password Settings')
@ -122,20 +135,13 @@ export default defineComponent({
}, },
settingsSectionComponents: function () { settingsSectionComponents: function () {
let settingsSections
if (!process.env.IS_ELECTRON) {
settingsSections = this.settingsComponentsData.filter((settingsComponent) => !settingsComponent.usingElectron)
} else {
settingsSections = this.settingsComponentsData
}
if (this.settingsSectionSortEnabled) { if (this.settingsSectionSortEnabled) {
return settingsSections.toSorted((a, b) => return this.settingsComponentsData.toSorted((a, b) =>
a.title.toLowerCase().localeCompare(b.title.toLowerCase(), this.locale) a.title.toLowerCase().localeCompare(b.title.toLowerCase(), this.locale)
) )
} }
return settingsSections return this.settingsComponentsData
}, },
}, },
created: function () { created: function () {