Skip to content

media

NPM version

Platform Support

Platform Support

介绍:

媒体插件

Reference

Method

  • savePictures

    保存图片到相册

ts
import { 
mediaPlugin
} from "@plaoc/plugins";
await
mediaPlugin
.
savePictures
({
file
:
File
,
saveLocation
: "dwebbrowser") });

Parameter

  • MediaOption

    媒体参数

ts
import type { MediaOption } from "@plaoc/plugins";
const 
options
: MediaOption = {
file
:
File
,
saveLocation
: "" };

Usage Plugins

vue
<script setup lang="ts">
import { 
mediaPlugin
} from "@plaoc/plugins";
const
fileChange
= (
$event
: Event) => {
const
target
=
$event
.
target
as HTMLInputElement;
if (
target
&&
target
.
files
?.[0]) {
mediaPlugin
.
savePictures
({
file
:
target
.
files
[0] });
} }; </script> <template> <
input
type
="file"
accept
="image/*" @
change
="
fileChange
(
$event
)" />
</template>

Usage WebComponent

vue
<script setup lang="ts">
import { 
ref
,
onMounted
} from "vue";
import {
HTMLDwebMediaElement
} from "@plaoc/plugins";
const
$mediaPlugin
=
ref
<
HTMLDwebMediaElement
>();
let
media
:
HTMLDwebMediaElement
;
onMounted
(async () => {
media
=
$mediaPlugin
.
value
!;
}); const
fileChange
= (
$event
: Event) => {
const
target
=
$event
.
target
as HTMLInputElement;
if (
target
&&
target
.
files
?.[0]) {
mediaPlugin.savePictures({
file
:
target
.
files
[0] });
} }; </script> <template> <
dweb-media
ref
="
$mediaPlugin
"></
dweb-media
>
<
input
type
="file"
accept
="image/*" @
change
="
fileChange
(
$event
)" />
</template>

基于 MIT 许可发布