接入填码原生剪贴板读取

邀请码填写和兑换码弹窗在宿主声明 clipboard.readText 时显示粘贴入口

粘贴动作只读取宿主纯文本并填入现有受控输入框,不自动提交或伪造兑换成功

补充填码粘贴回归测试和 profile 剪贴板 helper

更新 Expo/Tauri 宿主壳方案、HostBridge 协议和共享决策记录
This commit is contained in:
2026-06-18 06:48:46 +08:00
parent a0497cb39d
commit e8c2e8d532
8 changed files with 176 additions and 5 deletions
@@ -1,6 +1,12 @@
import { ClipboardPaste } from 'lucide-react';
import { PlatformActionButton } from '../common/PlatformActionButton';
import { PlatformStatusMessage } from '../common/PlatformStatusMessage';
import { PlatformTextField } from '../common/PlatformTextField';
import {
canPasteFromNativeHostClipboard,
readNativeHostClipboardText,
} from './platformProfileHostClipboard';
import { PlatformProfileModalShell } from './PlatformProfileModalShell';
export type PlatformProfileRewardCodeRedeemModalProps = {
@@ -26,6 +32,15 @@ export function PlatformProfileRewardCodeRedeemModal({
onSubmit,
onClose,
}: PlatformProfileRewardCodeRedeemModalProps) {
const canPasteRewardCode = canPasteFromNativeHostClipboard();
const pasteRewardCode = () => {
void readNativeHostClipboardText().then((text) => {
if (text) {
onChange(text);
}
});
};
return (
<PlatformProfileModalShell
title="兑换码"
@@ -62,6 +77,20 @@ export function PlatformProfileRewardCodeRedeemModal({
aria-label="兑换码"
autoFocus
/>
{canPasteRewardCode ? (
<PlatformActionButton
type="button"
surface="profile"
tone="ghost"
size="xs"
shape="pill"
fullWidth
onClick={pasteRewardCode}
>
<ClipboardPaste className="h-3.5 w-3.5" />
</PlatformActionButton>
) : null}
{error ? (
<PlatformStatusMessage
tone="error"