diff --git a/src/app/components/Option/components/LimitOption/index.tsx b/src/app/components/Option/components/LimitOption/index.tsx index 1540dce8..d7e391e0 100644 --- a/src/app/components/Option/components/LimitOption/index.tsx +++ b/src/app/components/Option/components/LimitOption/index.tsx @@ -9,7 +9,7 @@ import { t } from "@app/locale" import { locale } from "@i18n" import optionService from "@service/option-service" import { defaultDailyLimit } from "@util/constant/option" -import { ElInput, ElOption, ElSelect } from "element-plus" +import { ElInput, ElMessageBox, ElOption, ElSelect } from "element-plus" import { defineComponent, reactive, unref, UnwrapRef, ref, Ref, watch } from "vue" import { OptionItem } from "../../common" import "./limit-option.sass" @@ -25,6 +25,7 @@ const ALL_LEVEL: timer.limit.RestrictionLevel[] = [ 'nothing', 'verification', 'password', + 'strict', ] const ALL_DIFF: timer.limit.VerificationDifficulty[] = [ @@ -61,6 +62,16 @@ function reset(target: timer.option.DailyLimitOption) { Object.entries(defaultValue).forEach(([key, val]) => target[key] = val) } +const confirm4Strict = async (): Promise => { + const title = t(msg => msg.option.dailyLimit.level.strictTitle) + const content = t(msg => msg.option.dailyLimit.level.strictContent) + await ElMessageBox.confirm(content, title, { + type: "warning", + confirmButtonText: t(msg => msg.button.confirm), + cancelButtonText: t(msg => msg.button.cancel), + }) +} + const _default = defineComponent((_, ctx) => { const option: UnwrapRef = reactive(defaultDailyLimit()) const verified = ref(false) @@ -93,6 +104,7 @@ const _default = defineComponent((_, ctx) => { size="small" class={`option-daily-limit-level-select ${locale}`} onChange={(val: timer.limit.RestrictionLevel) => verifyTriggered(option, verified) + .then(() => val === "strict" ? confirm4Strict() : Promise.resolve()) .then(() => option.limitLevel = val) .catch(console.log) } diff --git a/src/app/util/limit.tsx b/src/app/util/limit.tsx index 7e98b1ad..95df1831 100644 --- a/src/app/util/limit.tsx +++ b/src/app/util/limit.tsx @@ -82,6 +82,16 @@ const AnswerCanvas = defineComponent({ */ export async function processVerification(option: timer.option.DailyLimitOption): Promise { const { limitLevel, limitPassword, limitVerifyDifficulty } = option + if (limitLevel === "strict") { + return new Promise( + (_, reject) => ElMessageBox({ + boxType: 'alert', + type: 'warning', + title: '', + message:
{t(msg => msg.limit.verification.strictTip)}
, + }).then(reject).catch(reject) + ) + } let answerValue: string let messageNode: VNode | string | Element let incorrectMessage: string diff --git a/src/content-script/limit/modal.ts b/src/content-script/limit/modal.ts index 38169f32..1143eb93 100644 --- a/src/content-script/limit/modal.ts +++ b/src/content-script/limit/modal.ts @@ -71,7 +71,9 @@ function isSameReason(a: LimitReason, b: LimitReason): boolean { return same } -const canDelay = ({ allowDelay, type }: LimitReason) => allowDelay && (type === "DAILY" || type === "VISIT") +const canDelay = ({ allowDelay, type }: LimitReason, options: timer.option.DailyLimitOption) => allowDelay + && (type === "DAILY" || type === "VISIT") + && options.limitLevel !== "strict" class ModalInstance implements MaskModal { url: string @@ -164,7 +166,7 @@ class ModalInstance implements MaskModal { this.mask.append(document.createElement("br")) this.mask.append(link2Setup(url)) - if (canDelay(reason)) { + if (canDelay(reason, this.options)) { const delayConfirm = new DelayConfirm(this.options) const delayButton = new DelayButton( () => delayConfirm.doConfirm().then(() => this.delayHandlers?.forEach?.(h => h?.())) diff --git a/src/i18n/message/app/limit-resource.json b/src/i18n/message/app/limit-resource.json index 6895787c..51a78d12 100644 --- a/src/i18n/message/app/limit-resource.json +++ b/src/i18n/message/app/limit-resource.json @@ -34,9 +34,10 @@ }, "urlPlaceholder": "请直接粘贴网址 ➡️", "verification": { - "inputTip": "该规则已超时,如要继续操作,请输入以下问题的答案:{prompt}", - "inputTip2": "该规则已超时,如要继续操作,请在下列输入框中原样输入:{answer}", - "pswInputTip": "该规则已超时,如要继续操作,所以请在下列输入框中输入您的解锁密码", + "inputTip": "时限规则已触发,如要继续操作,请输入以下问题的答案:{prompt}", + "inputTip2": "时限规则已触发,如要继续操作,请在下列输入框中原样输入:{answer}", + "pswInputTip": "时限规则已触发,如要继续操作,所以请在下列输入框中输入您的解锁密码", + "strictTip": "时限规则已触发,不允许手动解锁!", "incorrectPsw": "密码错误", "incorrectAnswer": "回答错误", "pi": "圆周率 π 的小数部分第 {startIndex} 位到第 {endIndex} 位的共 {digitCount} 位数字", @@ -76,9 +77,10 @@ }, "urlPlaceholder": "請直接粘貼網址 ➡️", "verification": { - "inputTip": "此規則已逾時,如要繼續操作,請輸入以下問題的答案:{prompt}", - "inputTip2": "此規則已逾時,如要繼續操作,請在下列輸入框中原樣輸入:{answer}", - "pswInputTip": "此規則已逾時,如要繼續操作,所以請在下列輸入框中輸入您的解鎖密碼", + "inputTip": "時限規則已觸發,如要繼續操作,請輸入以下問題的答案:{prompt}", + "inputTip2": "時限規則已觸發,如要繼續操作,請在下列輸入框中原樣輸入:{answer}", + "pswInputTip": "時限規則已觸發,如要繼續操作,所以請在下列輸入框中輸入您的解鎖密碼", + "strictTip": "時限規則已觸發,不允許手動解鎖!", "incorrectPsw": "密碼錯誤", "incorrectAnswer": "答案不正確", "pi": "圓周率 π 的小數部分第 {startIndex} 位到第 {endIndex} 位的共 {digitCount} 位數字", @@ -122,9 +124,10 @@ }, "urlPlaceholder": "Please paste the URL directly ➡️", "verification": { - "inputTip": "This rule has already been triggered. To continue, please enter the answer to the following prompt: {prompt}", - "inputTip2": "This rule has already been triggered. To continue, please enter it as it is: {answer}", - "pswInputTip": "This rule has already been triggered. To continue, please enter your unlock password", + "inputTip": "Limit rule has already been triggered. To continue, please enter the answer to the following prompt: {prompt}", + "inputTip2": "Limit rule has already been triggered. To continue, please enter it as it is: {answer}", + "pswInputTip": "Limit rule has already been triggered. To continue, please enter your unlock password", + "strictTip": "Limit rule has already been triggered and manual unlocking is not allowed!", "incorrectPsw": "Incorrect password", "incorrectAnswer": "Incorrect answer", "pi": "{digitCount} digits from {startIndex} to {endIndex} of the decimal part of π", diff --git a/src/i18n/message/app/limit.ts b/src/i18n/message/app/limit.ts index ad202765..ad1d13cb 100644 --- a/src/i18n/message/app/limit.ts +++ b/src/i18n/message/app/limit.ts @@ -45,6 +45,7 @@ export type LimitMessage = { inputTip: string inputTip2: string pswInputTip: string + strictTip: string incorrectPsw: string incorrectAnswer: string pi: string diff --git a/src/i18n/message/app/option-resource.json b/src/i18n/message/app/option-resource.json index d5af74cd..5b03e1ba 100644 --- a/src/i18n/message/app/option-resource.json +++ b/src/i18n/message/app/option-resource.json @@ -69,7 +69,10 @@ "easy": "简单", "hard": "困难", "disgusting": "折磨" - } + }, + "strict": "不允许手动解锁", + "strictTitle": "危险操作", + "strictContent": "当您选择这个选项之后,如果某个站点触发了每日限制,除了等到第二天自动解锁以外,不允许您手动解锁。如果规则设置不当,很有可能会阻碍您的日常工作!" } }, "backup": { @@ -189,7 +192,10 @@ "easy": "簡單", "hard": "困難", "disgusting": "噁心" - } + }, + "strict": "不允許手動解鎖", + "strictTitle": "危險操作", + "strictContent": "當您選擇這個選項之後,如果某個網站觸發了每日限制,除了等到第二天自動解鎖以外,不允許您手動解鎖。 如果規則設定不當,很有可能會阻礙您的日常工作!" } }, "backup": { @@ -309,7 +315,10 @@ "easy": "Easy", "hard": "Hard", "disgusting": "Disgusting" - } + }, + "strict": "Not allow unlocking anyway", + "strictTitle": "Operation confirm", + "strictContent": "When you select this option, if a site triggers daily limit, you will not be allowed to manually unblock it other than waiting until the next day. If rules are not set up properly, they can very well hinder your routines!" } }, "backup": { diff --git a/src/i18n/message/app/option.ts b/src/i18n/message/app/option.ts index 56f07b4e..9995865c 100644 --- a/src/i18n/message/app/option.ts +++ b/src/i18n/message/app/option.ts @@ -69,6 +69,8 @@ export type OptionMessage = { verificationDifficulty: { [diff in timer.limit.VerificationDifficulty]: string } + strictTitle: string + strictContent: string } } backup: { diff --git a/types/timer/limit.d.ts b/types/timer/limit.d.ts index dcfcf4dc..663d1a6b 100644 --- a/types/timer/limit.d.ts +++ b/types/timer/limit.d.ts @@ -67,6 +67,8 @@ declare namespace timer.limit { | 'password' // Verification code input required to lock or modify restricted rule | 'verification' + // Not allowed to unlock manually + | 'strict' /** * @since 1.9.0 */