尝试修复mac复制异常

This commit is contained in:
目棃
2025-01-16 11:49:07 +08:00
parent b6ea50a597
commit e8a79fb409
3 changed files with 11 additions and 4 deletions

View File

@@ -1 +0,0 @@
<!-- todo 时间轴 -->

View File

@@ -1,6 +1,5 @@
<template>
<div class="tp-video-box" v-if="videoData">
<!-- todo https://socialsisteryi.github.io/bilibili-API-collect/docs/video/videostream_url.html#%E8%A7%86%E9%A2%91%E4%BC%B4%E9%9F%B3%E9%9F%B3%E8%B4%A8%E4%BB%A3%E7%A0%81 -->
<iframe
class="tp-video-container"
:src="props.data.insert.video"

View File

@@ -1,13 +1,14 @@
/**
* @file utils/TGShare.ts
* @description 生成分享截图并保存到本地
* @since Beta v0.6.7
* @since Beta v0.6.8
*/
import showSnackbar from "@comp/func/snackbar.js";
import { path } from "@tauri-apps/api";
import { save } from "@tauri-apps/plugin-dialog";
import { writeFile } from "@tauri-apps/plugin-fs";
import { platform } from "@tauri-apps/plugin-os";
import html2canvas from "html2canvas";
import { storeToRefs } from "pinia";
@@ -148,7 +149,7 @@ export async function generateShareImg(
/**
* @description 复制到剪贴板
* @since Beta v0.6.2
* @since Beta v0.6.8
* @param {Uint8Array} buffer - 图片数据
* @returns {Promise<void>} 无返回值
*/
@@ -156,6 +157,14 @@ export async function copyToClipboard(buffer: Uint8Array): Promise<void> {
const blob = new Blob([buffer], { type: "image/png" });
const url = URL.createObjectURL(blob);
// todo mac 会报错: https://bugs.webkit.org/show_bug.cgi?id=222262
if (platform() === "macos") {
// todo 待测试
navigator.clipboard.write([new ClipboardItem({ [blob.type]: blob })]).then(
() => URL.revokeObjectURL(url),
(err) => TGLogger.Error(`[copyToClipboard] 复制到剪贴板失败: ${err}`),
);
return;
}
await navigator.clipboard.write([new ClipboardItem({ [blob.type]: blob })]);
URL.revokeObjectURL(url);
}