Merge pull request #3598 from snowraincloud/preview-features

修复命名错误,添加使用描述
This commit is contained in:
Grant Howard 2022-08-19 23:02:16 +08:00 committed by GitHub
commit 1fd518dcb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 43 deletions

View File

@ -2,12 +2,12 @@
<VPopup
ref="popup"
v-model="open"
class="custom-block-list-settings"
class="custom-black-list-settings"
fixed
:lazy="false"
:trigger-element="triggerElement"
>
<div class="block-list-settings-header">
<div class="black-list-settings-header">
<VIcon class="title-icon" icon="mdi-sort" :size="24"></VIcon>
<div class="title">
{{ titleName }}黑名单设置
@ -17,35 +17,35 @@
<VIcon icon="close" :size="18"></VIcon>
</div>
</div>
<div class="block-list-settings-content">
<div class="block-list-settings-section">
<div class="block-list-settings-section-title">
<div class="black-list-settings-content">
<div class="black-list-settings-section">
<div class="black-list-settings-section-title">
添加到黑名单
</div>
<div class="block-list-settings-section-input">
<div class="black-list-settings-section-input">
<TextBox :text="name" @change="changeName" />
<VButton @click="add">添加</VButton>
</div>
</div>
<div class="block-list-settings-section">
<div class="block-list-settings-section-title">
<div class="black-list-settings-section">
<div class="black-list-settings-section-title">
黑名单列表
</div>
<div
class="block-list-settings-section-description"
class="black-list-settings-section-description"
>
点击×图标可以删除名单.
</div>
<VLoading v-if="!loaded" />
<div
v-show="loaded"
ref="block-listSortList"
class="block-list-settings-section-content block-list-sort-list"
ref="black-listSortList"
class="black-list-settings-section-content black-list-sort-list"
>
<div
v-for="item of list"
:key="item"
class="block-list-sort-item"
class="black-list-sort-item"
:data-name="item"
>
<div class="item-name">
@ -137,7 +137,7 @@ export default Vue.extend({
</script>
<style lang="scss">
@import "common";
.custom-block-list-settings {
.custom-black-list-settings {
@include popup();
width: 400px;
font-size: 14px;
@ -150,7 +150,7 @@ export default Vue.extend({
&.open {
transform: translateX(-50%) translateY(-50%) scale(1);
}
.block-list-settings-header {
.black-list-settings-header {
@include h-center();
justify-content: space-between;
.title {
@ -170,8 +170,8 @@ export default Vue.extend({
}
}
}
.block-list-settings-content {
.block-list-settings-section {
.black-list-settings-content {
.black-list-settings-section {
margin-top: 12px;
> :not(:last-child) {
margin-bottom: 6px;
@ -202,7 +202,7 @@ export default Vue.extend({
width: 50px;
text-align: end;
}
.block-list-sort-item {
.black-list-sort-item {
@include card();
@include h-center();
transition: none;
@ -214,7 +214,7 @@ export default Vue.extend({
&:hover {
border-color: var(--theme-color);
}
&.block-list-hidden {
&.black-list-hidden {
opacity: 0.5;
}
&.sortable-ghost {
@ -227,7 +227,7 @@ export default Vue.extend({
&.sortable-drag {
opacity: 1;
}
&.sortable-drag.block-list-hidden {
&.sortable-drag.black-list-hidden {
opacity: 0.5;
}
.toggle-visible {

View File

@ -1,20 +1,20 @@
<template>
<div>
<div class="custom-block-list-extra-options">
<div class="custom-black-list-extra-options">
<VButton
v-if="login"
ref="button"
@mouseover="loadNameBlockListSettings()"
@mouseover="loadNameBlackListSettings()"
@click="toggleNameSettings()"
>
精确匹配列表<VIcon icon="right-arrow" :size="16"></VIcon>
</VButton>
</div>
<div class="custom-block-list-extra-options">
<div class="custom-black-list-extra-options">
<VButton
v-if="login"
ref="button"
@mouseover="loadRegexBlockListSettings()"
@mouseover="loadRegexBlackListSettings()"
@click="toggleRegexSettings()"
>
正则匹配列表<VIcon icon="right-arrow" :size="16"></VIcon>
@ -38,7 +38,7 @@ export default Vue.extend({
}
},
methods: {
async loadNameBlockListSettings() {
async loadNameBlackListSettings() {
const isFirstLoad = await loadNameSettings()
if (isFirstLoad) {
const triggerButton = this.$refs.button.$el as HTMLElement
@ -46,7 +46,7 @@ export default Vue.extend({
}
},
toggleNameSettings,
async loadRegexBlockListSettings() {
async loadRegexBlackListSettings() {
const isFirstLoad = await loadRegexSettings()
if (isFirstLoad) {
const triggerButton = this.$refs.button.$el as HTMLElement
@ -58,7 +58,7 @@ export default Vue.extend({
})
</script>
<style lang="scss">
.custom-block-list-extra-options {
.custom-black-list-extra-options {
display: flex;
align-items: center;
justify-content: center;

View File

@ -1 +1 @@
export const BlockListDataKey = 'blokList.data'
export const BlackListDataKey = 'blackList.data'

View File

@ -3,24 +3,24 @@ import { mainSiteUrls } from '@/core/utils/urls'
import { allMutationsOn } from '@/core/observer'
import { selectAll } from '@/core/spin-query'
import { registerData, getData } from '@/plugins/data'
import { BlockListDataKey } from './common'
import { BlackListDataKey } from './common'
const name = 'blackList'
const entry = async ({ settings: { options } }) => {
const blockListData = {
const blackListData = {
up: options.up,
upRegex: options.upRegex,
}
registerData(BlockListDataKey, blockListData)
registerData(BlackListDataKey, blackListData)
const billGrid = await selectAll('.bili-grid')
allMutationsOn(billGrid, async () => {
const videos = await selectAll('.bili-video-card')
if (!videos) {
return
}
const blockList = getData(BlockListDataKey)
const blockList = getData(BlackListDataKey)
const upRegex = blockList[0].upRegex.map(e => new RegExp(e))
videos.forEach(video => {
const authorElement = (video as unknown as HTMLElement).querySelector('.bili-video-card__info--author')
@ -70,7 +70,7 @@ export const component: ComponentMetadata = {
componentsTags.utils,
],
description: {
'zh-CN': '屏蔽黑名单up主',
'zh-CN': '屏蔽黑名单up主, 根据up主的名称进行匹配支持精确匹配和正则匹配',
},
author: {
name: 'snowraincloud',

View File

@ -1,7 +1,7 @@
import { getComponentSettings } from '@/core/settings'
import { mountVueComponent } from '@/core/utils'
import { addData, getData } from '@/plugins/data'
import { BlockListDataKey } from './common'
import { BlackListDataKey } from './common'
type SettingsVmType = Vue & {
toggle: () => void
@ -23,10 +23,10 @@ export const setNameProps = (element: HTMLElement) => {
return
}
nameSettingsVM.triggerElement = element
const blockList = getData(BlockListDataKey)
nameSettingsVM.list = lodash.cloneDeep(blockList[0].up)
const blackList = getData(BlackListDataKey)
nameSettingsVM.list = lodash.cloneDeep(blackList[0].up)
nameSettingsVM.save = (items:string[]) => {
addData(BlockListDataKey, data => {
addData(BlackListDataKey, data => {
data.up = items
})
blackListOptions.up = items
@ -38,10 +38,10 @@ export const setRegexProps = (element: HTMLElement) => {
return
}
regexSettingsVm.triggerElement = element
const blockList = getData(BlockListDataKey)
regexSettingsVm.list = lodash.cloneDeep(blockList[0].upRegex)
const blackList = getData(BlackListDataKey)
regexSettingsVm.list = lodash.cloneDeep(blackList[0].upRegex)
regexSettingsVm.save = (items:string[]) => {
addData(BlockListDataKey, data => {
addData(BlackListDataKey, data => {
data.upRegex = items
})
blackListOptions.upRegex = items
@ -53,8 +53,8 @@ export const loadNameSettings = async () => {
if (nameSettingsVM) {
return false
}
const blockListSettings = await import('./BlockListSettings.vue').then(m => m.default)
nameSettingsVM = mountVueComponent(blockListSettings)
const blackListSettings = await import('./BlackListSettings.vue').then(m => m.default)
nameSettingsVM = mountVueComponent(blackListSettings)
document.body.insertAdjacentElement('beforeend', nameSettingsVM.$el)
return true
}
@ -63,8 +63,8 @@ export const loadRegexSettings = async () => {
if (regexSettingsVm) {
return false
}
const blockListSettings = await import('./BlockListSettings.vue').then(m => m.default)
regexSettingsVm = mountVueComponent(blockListSettings)
const blackListSettings = await import('./BlackListSettings.vue').then(m => m.default)
regexSettingsVm = mountVueComponent(blackListSettings)
document.body.insertAdjacentElement('beforeend', regexSettingsVm.$el)
return true
}