-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'download cover' option in 'downloadVideo' component
- add a plugin in utils/view-cover components for downloadVideo - reconstruct codes for getting video cover url.
- Loading branch information
Showing
5 changed files
with
124 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template> | ||
<div class="download-cover-config download-video-config-section"> | ||
<div class="download-video-config-item"> | ||
<div class="download-video-config-title">封面:</div> | ||
<VDropdown v-model="type" :items="items"> | ||
<template #item="{ item }"> | ||
{{ item }} | ||
</template> | ||
</VDropdown> | ||
</div> | ||
</div> | ||
</template> | ||
<script lang="ts"> | ||
import { getComponentSettings } from '@/core/settings' | ||
import { VDropdown } from '@/ui' | ||
import { CoverDownloadType } from './utils' | ||
interface Options { | ||
CoverType: CoverDownloadType | '无' | ||
} | ||
const options = getComponentSettings('downloadVideo').options as Options | ||
export default Vue.extend({ | ||
components: { | ||
VDropdown, | ||
}, | ||
data() { | ||
return { | ||
type: options.CoverType ?? '无', | ||
items: ['无', 'jpg'], | ||
} | ||
}, | ||
computed: { | ||
enabled() { | ||
return this.type !== '无' | ||
}, | ||
}, | ||
watch: { | ||
type(newValue: CoverDownloadType) { | ||
options.CoverType = newValue | ||
}, | ||
}, | ||
}) | ||
</script> | ||
<style lang="scss"> | ||
.download-cover-config.download-video-config-section { | ||
.be-dropdown { | ||
text-transform: uppercase; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { logError } from '@/core/utils/log' | ||
import { VideoInfo } from '@/components/video/video-info' | ||
|
||
export type CoverDownloadType = 'jpg' | ||
|
||
export const getVideoCoverUrlByAid = async (aid: string) => { | ||
const videoInfo = new VideoInfo(aid) | ||
try { | ||
await videoInfo.fetchInfo() | ||
} catch (error) { | ||
logError(error) | ||
throw error | ||
} | ||
return videoInfo.coverUrl.replace('http:', 'https:') | ||
} | ||
|
||
export const getBlobByAid = async (aid: string) => { | ||
const url = await getVideoCoverUrlByAid(aid) | ||
const response = await fetch(url) | ||
const blob = await response.blob() | ||
return blob | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters