feat(viewer): remove native share button from share sheet (user request) — copy link only

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-28 09:08:39 +08:00
parent dc8d3ff967
commit a5d71686ff
3 changed files with 12 additions and 62 deletions
+9 -14
View File
@@ -203,25 +203,20 @@ describe('album header info area (UI-02 V02)', () => {
expect(copyBtn.textContent).toContain('复制失败');
});
it('share sheet offers navigator.share when available (native panel self-reports)', async () => {
it('native share button removed (user request 2026-09-24): copy only', async () => {
const share = vi.fn(() => Promise.resolve());
Object.defineProperty(navigator, 'share', { value: share, configurable: true });
const writeText = stubClipboard(() => Promise.resolve());
const wrapper = mountHeader({ album: makeAlbum(), viewCount: null });
await wrapper.find('.share-btn').trigger('click');
await Promise.resolve();
await Promise.resolve();
const nativeBtn = sheetEl()!.querySelector<HTMLButtonElement>('[data-test="share-sheet-native"]')!;
expect(nativeBtn).not.toBeNull();
nativeBtn.click();
await Promise.resolve();
await Promise.resolve();
expect(share).toHaveBeenCalledWith({
title: '2026 公司年会',
url: 'http://localhost:3000/a/tokfixture0000000000aaaa?lang=zh-CN',
});
// 原生分享路径不落剪贴板(面板自反馈,§5.4)。
expect(writeText).not.toHaveBeenCalled();
await flushPromises();
// 仅复制按钮;系统分享不再提供(navigator.share 存在也不显示)。
expect(sheetEl()!.querySelector('[data-test="share-sheet-native"]')).toBeNull();
const copyBtn = sheetEl()!.querySelector<HTMLButtonElement>('[data-test="share-sheet-copy"]')!;
copyBtn.click();
await flushPromises();
expect(writeText).toHaveBeenCalled();
expect(share).not.toHaveBeenCalled();
});
});
+2 -22
View File
@@ -589,28 +589,6 @@ describe('photo lightbox interactions (UI-02 V05)', () => {
return document.querySelector('.share-sheet');
}
it('share opens the sheet with the photo deep link; native share via sheet button', async () => {
const share = vi.fn(() => Promise.resolve());
Object.defineProperty(navigator, 'share', { value: share, configurable: true });
const { wrapper } = mountV05('p1', {
albumTitle: '2026 公司年会',
shareUrl: '/a/tok-lb/p/p1?lang=zh-CN',
});
await flushPromises();
await wrapper.find('button[aria-label="分享照片"]').trigger('click');
await flushPromises();
// 弹层出现并携带照片深链(页面级提示已退役)。
expect(lbSheet()).not.toBeNull();
// 链接文本已隐藏(2026-09-24)。
expect(wrapper.find('.share-status').exists()).toBe(false);
const nativeBtn = lbSheet()!.querySelector<HTMLButtonElement>('[data-test="share-sheet-native"]')!;
nativeBtn.click();
await flushPromises();
expect(share).toHaveBeenCalledWith({ title: '2026 公司年会', url: '/a/tok-lb/p/p1?lang=zh-CN' });
});
it('sheet copy button writes the deep link with on-button feedback', async () => {
const writeText = vi.fn(() => Promise.resolve());
Object.defineProperty(navigator, 'clipboard', { value: { writeText }, configurable: true });
@@ -619,6 +597,8 @@ describe('photo lightbox interactions (UI-02 V05)', () => {
await wrapper.find('button[aria-label="分享照片"]').trigger('click');
await flushPromises();
// 系统分享按钮已移除(2026-09-24):仅复制。
expect(lbSheet()!.querySelector('[data-test="share-sheet-native"]')).toBeNull();
const copyBtn = lbSheet()!.querySelector<HTMLButtonElement>('[data-test="share-sheet-copy"]')!;
copyBtn.click();
await flushPromises();
@@ -12,7 +12,6 @@
import { nextTick, onBeforeUnmount, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import QRCode from 'qrcode';
import { canNativeShare } from '../../support/share';
import { copyText } from '../../support/clipboard';
const props = defineProps<{
@@ -34,7 +33,6 @@ const copyState = ref<'idle' | 'copied' | 'failed'>('idle');
let copyResetTimer: ReturnType<typeof setTimeout> | undefined;
let qrAbort: { cancel: () => void } | null = null;
const showNativeShare = canNativeShare();
/** 二维码绘制(url 变化重绘;弹层打开时按可见尺寸绘制)。 */
async function drawQr(): Promise<void> {
@@ -82,14 +80,6 @@ async function onCopy(): Promise<void> {
}, 2500);
}
async function onNativeShare(): Promise<void> {
try {
await navigator.share({ title: props.title, url: props.url });
} catch {
// 取消(AbortError)或其他失败:静默——弹层仍在,复制路径可用。
}
}
function onKeydown(event: KeyboardEvent): void {
if (event.key === 'Escape') {
event.preventDefault();
@@ -145,15 +135,7 @@ onBeforeUnmount(() => {
<!-- 链接文本已按用户要求隐藏(2026-09-24)——二维码 + 复制按钮保留。 -->
<div class="share-sheet-actions">
<button
v-if="showNativeShare"
type="button"
class="share-sheet-btn is-secondary"
data-test="share-sheet-native"
@click="onNativeShare"
>
{{ t('viewer.share') }}
</button>
<!-- 系统分享按钮已按用户要求移除(2026-09-24)——仅保留复制链接。 -->
<button
type="button"
class="share-sheet-btn is-primary"
@@ -289,13 +271,6 @@ onBeforeUnmount(() => {
.share-sheet-btn.is-primary[data-state='failed'] {
background: #b54a4a;
}
.share-sheet-btn.is-secondary {
flex: 0 0 auto;
padding: 0 18px;
background: #ffffff;
border-color: var(--viewer-divider, #d7dfeb);
color: var(--viewer-text, #172033);
}
.share-sheet-btn:focus-visible {
outline: 2px solid var(--viewer-primary, #1a73e8);
outline-offset: 2px;