修改复制的问题

This commit is contained in:
2026-07-15 10:11:53 +08:00
parent b4166ecadb
commit a9190ba4e1
5 changed files with 55 additions and 19 deletions
@@ -1,6 +1,7 @@
import React, { useEffect, useMemo, useState } from 'react';
import { Alert, Button, Empty, Image, Space, Typography, message } from 'antd';
import { CopyOutlined, LinkOutlined } from '@ant-design/icons';
import { copyToClipboard } from '../../../utils/clipboard';
const RAW_API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
const RESOURCE_BASE = RAW_API_BASE.replace(/\/api\/?$/i, '').replace(/\/$/, '');
@@ -37,12 +38,8 @@ const MediaPreview: React.FC<MediaPreviewProps> = ({
const copyUrl = async () => {
if (!resolvedUrl) return;
try {
await navigator.clipboard.writeText(resolvedUrl);
message.success('资源地址已复制');
} catch {
message.error('复制失败,请手动复制');
}
const ok = await copyToClipboard(resolvedUrl);
message.success(ok ? '资源地址已复制' : '复制失败,请手动复制');
};
const tools = resolvedUrl ? (