mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Support copy with title (#2557)
This commit is contained in:
parent
f43b3a4f4b
commit
7fce59dab1
@ -19,11 +19,15 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { videoChange } from '@/core/observer'
|
import { videoChange } from '@/core/observer'
|
||||||
|
import { getComponentSettings } from '@/core/settings'
|
||||||
import { select } from '@/core/spin-query'
|
import { select } from '@/core/spin-query'
|
||||||
import { matchUrlPattern } from '@/core/utils'
|
import { matchUrlPattern } from '@/core/utils'
|
||||||
|
import { getFriendlyTitle } from '@/core/utils/title'
|
||||||
import { bangumiUrls } from '@/core/utils/urls'
|
import { bangumiUrls } from '@/core/utils/urls'
|
||||||
import { VIcon } from '@/ui'
|
import { VIcon } from '@/ui'
|
||||||
|
import { BvidConvertOptions } from '.'
|
||||||
|
|
||||||
|
const { options } = getComponentSettings<BvidConvertOptions>('bvidConvert')
|
||||||
enum CopyIdType {
|
enum CopyIdType {
|
||||||
Aid = 'aid',
|
Aid = 'aid',
|
||||||
Bvid = 'bvid',
|
Bvid = 'bvid',
|
||||||
@ -82,7 +86,11 @@ export default Vue.extend({
|
|||||||
id: this[data],
|
id: this[data],
|
||||||
}
|
}
|
||||||
const link = linkProviders.map(p => p(context)).filter(it => it !== null)[0]
|
const link = linkProviders.map(p => p(context)).filter(it => it !== null)[0]
|
||||||
|
if (options.copyWithTitle) {
|
||||||
|
await navigator.clipboard.writeText(`${getFriendlyTitle()} ${link}`)
|
||||||
|
} else {
|
||||||
await navigator.clipboard.writeText(link)
|
await navigator.clipboard.writeText(link)
|
||||||
|
}
|
||||||
this[`${data}Copied`] = true
|
this[`${data}Copied`] = true
|
||||||
setTimeout(() => (this[`${data}Copied`] = false), 1000)
|
setTimeout(() => (this[`${data}Copied`] = false), 1000)
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,10 +1,17 @@
|
|||||||
import { ComponentMetadata } from '@/components/types'
|
import { defineComponentMetadata, defineOptionsMetadata, OptionsOfMetadata } from '@/components/define'
|
||||||
import { hasVideo } from '@/core/spin-query'
|
import { hasVideo } from '@/core/spin-query'
|
||||||
import { videoAndBangumiUrls } from '@/core/utils/urls'
|
import { videoAndBangumiUrls } from '@/core/utils/urls'
|
||||||
|
|
||||||
export const component: ComponentMetadata = {
|
const options = defineOptionsMetadata({
|
||||||
|
copyWithTitle: {
|
||||||
|
defaultValue: false,
|
||||||
|
displayName: '复制链接时带上标题',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
export const component = defineComponentMetadata({
|
||||||
name: 'bvidConvert',
|
name: 'bvidConvert',
|
||||||
displayName: 'BV 号转换',
|
displayName: 'BV 号转换',
|
||||||
|
options,
|
||||||
entry: none,
|
entry: none,
|
||||||
description: {
|
description: {
|
||||||
'zh-CN': '在功能面板中显示视频的 AV 号和 BV 号.',
|
'zh-CN': '在功能面板中显示视频的 AV 号和 BV 号.',
|
||||||
@ -18,4 +25,5 @@ export const component: ComponentMetadata = {
|
|||||||
condition: hasVideo,
|
condition: hasVideo,
|
||||||
},
|
},
|
||||||
urlInclude: videoAndBangumiUrls,
|
urlInclude: videoAndBangumiUrls,
|
||||||
}
|
})
|
||||||
|
export type BvidConvertOptions = OptionsOfMetadata<typeof options>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user