fix: 修复客服权限与收件箱配置问题

This commit is contained in:
Rogee
2026-08-08 19:52:18 +08:00
parent dc2a6577bf
commit 518f9c5d6b
20 changed files with 385 additions and 70 deletions
@@ -33,6 +33,7 @@ export const copyTextToClipboard = async data => {
document.body.appendChild(textarea);
try {
textarea.focus({ preventScroll: true });
textarea.select();
textarea.setSelectionRange(0, textarea.value.length);
@@ -2,6 +2,7 @@ import { copyTextToClipboard, handleOtpPaste } from '../clipboard';
const mockWriteText = vi.fn();
const mockExecCommand = vi.fn();
const originalCreateElement = document.createElement.bind(document);
const setClipboard = clipboard => {
Object.defineProperty(navigator, 'clipboard', {
@@ -148,9 +149,16 @@ describe('copyTextToClipboard', () => {
it('falls back when clipboard API is not available', async () => {
setClipboard(undefined);
const focus = vi.fn();
vi.spyOn(document, 'createElement').mockImplementation(tagName => {
const element = originalCreateElement(tagName);
if (tagName === 'textarea') element.focus = focus;
return element;
});
await copyTextToClipboard('test');
expect(focus).toHaveBeenCalledWith({ preventScroll: true });
expect(mockExecCommand).toHaveBeenCalledWith('copy');
expect(document.querySelector('textarea')).toBeNull();
});