Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/standalone-pages-smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test.describe("独立扩展页面加载冒烟", () => {
const page = await context.newPage();
const errors = collectPageErrors(page);

await page.goto(`chrome-extension://${extensionId}/src/batchupdate.html?site=example.com&autoclose=30`, {
await page.goto(`chrome-extension://${extensionId}/src/batchupdate.html?site=example.com`, {
waitUntil: "domcontentloaded",
});

Expand Down
4 changes: 1 addition & 3 deletions src/app/service/service_worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,7 @@ export default class ServiceWorkerManager {
// 如该网域没有任何有效脚本则忽略
const domain = newDomain;
const anyOpened = await script.openBatchUpdatePage({
// https://github.com/scriptscat/scriptcat/issues/1087
// 关于 autoclose,日后再检讨 UI/UX 设计
q: domain ? `autoclose=30&site=${domain}` : "autoclose=30",
q: domain ? `site=${domain}` : "",
dontCheckNow: true,
});
if (anyOpened) {
Expand Down
3 changes: 0 additions & 3 deletions src/locales/de-DE/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
"restore_all_confirm": "{{count}} ignorierte Updates werden sofort installiert. Das lässt sich nicht rückgängig machen.",
"restore_all_confirm_connect": "{{count}} davon fordern neue @connect-Berechtigungen an.",
"ignored_section": "Ignorierte Updates",
"auto_close": "Schließt automatisch in {{count}} s",
"auto_close_cancel_hint": "Zum Abbrechen klicken",
"auto_close_cancelled": "Automatisches Schließen abgebrochen",
"col_script": "Skript",
"col_version": "Version",
"col_change": "Änderungen",
Expand Down
3 changes: 0 additions & 3 deletions src/locales/en-US/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
"restore_all_confirm": "{{count}} ignored updates will be installed right away. This cannot be undone.",
"restore_all_confirm_connect": "{{count}} of them request new @connect permissions.",
"ignored_section": "Ignored Updates",
"auto_close": "Auto-closing in {{count}}s",
"auto_close_cancel_hint": "Click to cancel",
"auto_close_cancelled": "Auto-close cancelled",
"col_script": "Script",
"col_version": "Version",
"col_change": "Changes",
Expand Down
3 changes: 0 additions & 3 deletions src/locales/ja-JP/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
"restore_all_confirm": "無視した更新 {{count}} 件を今すぐインストールします。この操作は取り消せません。",
"restore_all_confirm_connect": "そのうち {{count}} 件が新しい @connect 権限を要求します。",
"ignored_section": "無視した更新",
"auto_close": "{{count}} 秒後に自動で閉じます",
"auto_close_cancel_hint": "クリックでキャンセル",
"auto_close_cancelled": "自動で閉じるのをキャンセルしました",
"col_script": "スクリプト",
"col_version": "バージョン",
"col_change": "変更",
Expand Down
3 changes: 0 additions & 3 deletions src/locales/ko-KR/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
"restore_all_confirm": "무시한 업데이트 {{count}}개를 즉시 설치합니다. 되돌릴 수 없습니다.",
"restore_all_confirm_connect": "그중 {{count}}개가 새로운 @connect 권한을 요청합니다.",
"ignored_section": "무시된 업데이트",
"auto_close": "{{count}}초 후 자동으로 닫힘",
"auto_close_cancel_hint": "클릭하여 취소",
"auto_close_cancelled": "자동 닫기를 취소했습니다",
"col_script": "스크립트",
"col_version": "버전",
"col_change": "변경 사항",
Expand Down
3 changes: 0 additions & 3 deletions src/locales/pt-BR/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
"restore_all_confirm": "{{count}} atualizações ignoradas serão instaladas agora. Não é possível desfazer.",
"restore_all_confirm_connect": "{{count}} delas solicitam novas permissões @connect.",
"ignored_section": "Atualizações ignoradas",
"auto_close": "Fechando automaticamente em {{count}} s",
"auto_close_cancel_hint": "Clique para cancelar",
"auto_close_cancelled": "Fechamento automático cancelado",
"col_script": "Script",
"col_version": "Versão",
"col_change": "Alterações",
Expand Down
3 changes: 0 additions & 3 deletions src/locales/ru-RU/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
"restore_all_confirm": "Игнорируемые обновления ({{count}}) будут установлены сразу. Отменить это нельзя.",
"restore_all_confirm_connect": "Из них {{count}} запрашивают новые разрешения @connect.",
"ignored_section": "Игнорируемые обновления",
"auto_close": "Автозакрытие через {{count}} с",
"auto_close_cancel_hint": "Нажмите, чтобы отменить",
"auto_close_cancelled": "Автозакрытие отменено",
"col_script": "Скрипт",
"col_version": "Версия",
"col_change": "Изменения",
Expand Down
3 changes: 0 additions & 3 deletions src/locales/tr-TR/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
"restore_all_confirm": "Yok sayılan {{count}} güncelleme hemen kurulacak. Bu işlem geri alınamaz.",
"restore_all_confirm_connect": "Bunlardan {{count}} tanesi yeni @connect izni istiyor.",
"ignored_section": "Yoksayılan Güncellemeler",
"auto_close": "{{count}} sn içinde otomatik kapanıyor",
"auto_close_cancel_hint": "İptal etmek için tıklayın",
"auto_close_cancelled": "Otomatik kapatma iptal edildi",
"col_script": "Betik",
"col_version": "Sürüm",
"col_change": "Değişiklikler",
Expand Down
3 changes: 0 additions & 3 deletions src/locales/vi-VN/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
"restore_all_confirm": "{{count}} bản cập nhật đã bỏ qua sẽ được cài đặt ngay. Không thể hoàn tác.",
"restore_all_confirm_connect": "Trong đó {{count}} tập lệnh yêu cầu quyền @connect mới.",
"ignored_section": "Cập nhật đã bỏ qua",
"auto_close": "Tự đóng sau {{count}} giây",
"auto_close_cancel_hint": "Nhấn để hủy",
"auto_close_cancelled": "Đã hủy tự đóng",
"col_script": "Tập lệnh",
"col_version": "Phiên bản",
"col_change": "Thay đổi",
Expand Down
3 changes: 0 additions & 3 deletions src/locales/zh-CN/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
"restore_all_confirm": "将立即安装 {{count}} 个已忽略的更新,安装后无法撤销。",
"restore_all_confirm_connect": "其中 {{count}} 个脚本新增了 @connect 权限。",
"ignored_section": "已忽略的更新",
"auto_close": "{{count}} 秒后自动关闭",
"auto_close_cancel_hint": "点击取消",
"auto_close_cancelled": "已取消自动关闭",
"col_script": "脚本",
"col_version": "版本",
"col_change": "变更",
Expand Down
3 changes: 0 additions & 3 deletions src/locales/zh-TW/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
"restore_all_confirm": "將立即安裝 {{count}} 個已忽略的更新,安裝後無法撤銷。",
"restore_all_confirm_connect": "其中 {{count}} 個腳本新增了 @connect 權限。",
"ignored_section": "已忽略的更新",
"auto_close": "{{count}} 秒後自動關閉",
"auto_close_cancel_hint": "點擊取消",
"auto_close_cancelled": "已取消自動關閉",
"col_script": "腳本",
"col_version": "版本",
"col_change": "變更",
Expand Down
41 changes: 0 additions & 41 deletions src/pages/batchupdate/components.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ function mkView(p: Partial<BatchUpdateViewProps> = {}): BatchUpdateViewProps {
checking: false,
loading: false,
selected: new Set(),
autoClose: null,
autoCloseCancelled: false,
rowStates: {},
batchProgress: null,
recordExpired: false,
Expand All @@ -50,7 +48,6 @@ function mkView(p: Partial<BatchUpdateViewProps> = {}): BatchUpdateViewProps {
onIgnoreSelected: () => {},
onRestoreAll: () => {},
onCheckNow: () => {},
onCancelAutoClose: () => {},
onOpen: () => {},
onOpenScriptList: () => {},
...p,
Expand Down Expand Up @@ -280,44 +277,6 @@ describe("批量更新 更新数据过期提示", () => {
});
});

describe("批量更新 自动关闭药丸", () => {
it("倒计时中可点击取消", () => {
const onCancelAutoClose = vi.fn();
renderDesktop({ autoClose: 12, onCancelAutoClose });
const chip = screen.getByTestId("auto-close-chip");
expect(chip.tagName).toBe("BUTTON");
expect(chip).toHaveAttribute("data-state", "counting");
expect(chip).toHaveTextContent(t("install:updatepage.auto_close_cancel_hint"));
fireEvent.click(chip);
expect(onCancelAutoClose).toHaveBeenCalledTimes(1);
});

it("已取消时切成不可点击的已取消态", () => {
renderDesktop({ autoClose: null, autoCloseCancelled: true });
const chip = screen.getByTestId("auto-close-chip");
expect(chip.tagName).not.toBe("BUTTON");
expect(chip).toHaveAttribute("data-state", "cancelled");
expect(chip).toHaveTextContent(t("install:updatepage.auto_close_cancelled"));
});

it("未要求自动关闭时不显示药丸", () => {
renderDesktop({ autoClose: null, autoCloseCancelled: false });
expect(screen.queryByTestId("auto-close-chip")).toBeNull();
});

it("移动视图的药丸同样可点击取消", () => {
const onCancelAutoClose = vi.fn();
renderMobile({ updates: [mkItem()], autoClose: 2, onCancelAutoClose });
fireEvent.click(screen.getByTestId("auto-close-chip"));
expect(onCancelAutoClose).toHaveBeenCalledTimes(1);
});

it("移动视图在已取消后仍显示已取消态", () => {
renderMobile({ updates: [mkItem()], autoClose: null, autoCloseCancelled: true });
expect(screen.getByTestId("auto-close-chip")).toHaveAttribute("data-state", "cancelled");
});
});

describe("批量更新 全部恢复并更新的确认", () => {
it("桌面视图点击后先确认,取消则不发起", () => {
const onRestoreAll = vi.fn();
Expand Down
57 changes: 0 additions & 57 deletions src/pages/batchupdate/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
PackageCheck,
RefreshCw,
ShieldAlert,
Timer,
TriangleAlert,
X,
} from "lucide-react";
Expand Down Expand Up @@ -39,10 +38,6 @@ export interface BatchUpdateViewProps {
checking: boolean;
loading: boolean;
selected: Set<string>;
/** 自动关闭剩余秒数;为 null 表示不再倒计时 */
autoClose: number | null;
/** 倒计时曾存在但已被取消(显式点击或隐式操作都算);用于把药丸切成「已取消」而不是直接消失 */
autoCloseCancelled: boolean;
/** 按 uuid 索引的行内更新状态;不在表内即为初始态 */
rowStates: Record<string, RowState>;
/** 批量操作进度;为 null 表示当前没有批量操作 */
Expand All @@ -58,7 +53,6 @@ export interface BatchUpdateViewProps {
onIgnoreSelected: () => void;
onRestoreAll: () => void;
onCheckNow: () => void;
onCancelAutoClose: () => void;
/** 打开单个脚本的更新详情页 */
onOpen: (uuid: string) => void;
/** 打开 options 脚本列表,便于事后核对刚更新了哪些脚本 */
Expand Down Expand Up @@ -659,52 +653,6 @@ function HeaderStatus({ view }: { view: BatchUpdateViewProps }) {
);
}

const CHIP = "inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs";

/**
* 自动关闭倒计时小药丸:可点击刹车。
* 倒计时结束前的最后几秒转警示色并轻微脉冲,避免"一晃神页面没了";
* 隐式取消(勾选/更新/忽略等)也会走到已取消态,不让取消这件事无声发生。
*/
export function AutoCloseChip({
seconds,
cancelled,
onCancel,
}: {
seconds: number | null;
cancelled: boolean;
onCancel: () => void;
}) {
const { t } = useTranslation();
if (seconds === null) {
if (!cancelled) return null;
return (
<span data-testid="auto-close-chip" data-state="cancelled" className={cn(CHIP, "bg-muted text-muted-foreground")}>
<Timer className="size-3.5" />
{t("install:updatepage.auto_close_cancelled")}
</span>
);
}
const urgent = seconds <= 3;
return (
<button
type="button"
data-testid="auto-close-chip"
data-state="counting"
onClick={onCancel}
className={cn(
CHIP,
"group hover:bg-accent hover:text-accent-foreground",
urgent ? "bg-warning-bg text-warning-fg animate-pulse" : "bg-muted text-muted-foreground"
)}
>
<Timer className="size-3.5" />
<span className="group-hover:hidden">{t("install:updatepage.auto_close", { count: seconds })}</span>
<span className="hidden group-hover:inline">{t("install:updatepage.auto_close_cancel_hint")}</span>
</button>
);
}

/** 桌面端整页视图 */
export function DesktopView({ view }: { view: BatchUpdateViewProps }) {
const { t } = useTranslation();
Expand All @@ -727,11 +675,6 @@ export function DesktopView({ view }: { view: BatchUpdateViewProps }) {
<RefreshCw className={cn(view.checking && "animate-spin")} />
{t("install:updatepage.main_header")}
</Button>
<AutoCloseChip
seconds={view.autoClose}
cancelled={view.autoCloseCancelled}
onCancel={view.onCancelAutoClose}
/>
<Button
variant="ghost"
size="icon-sm"
Expand Down
Loading
Loading