UNPKG

press-plus

Version:
45 lines (35 loc) 736 B
import { isNotH5 } from '../utils/env'; // #ifndef H5 import { copyText as copyTextMp } from './copy-mp'; // #endif // #ifdef H5 import { copyText as copyTextWeb } from './copy-web'; // #endif import type { ICopyText } from './types'; /** * 复制到剪切板 * @param text 待复制的文本 * @param showToast 复制成功是否弹提示,默认 true 弹"内容已复制" * @example * ```ts * copyText('hello world'); * * copyText('hello world', true); * * copyText('hello world', true).then(() => { * console.log('copy success') * }) * ``` */ let copyText: ICopyText; // #ifdef H5 copyText = copyTextWeb; // #endif // #ifndef H5 if (isNotH5()) { copyText = copyTextMp; } // #endif export { copyText, };