Skip to content

Commit 30891f7

Browse files
committed
Fix the limit mask not displaying on Reddit (#423)
1 parent 0983489 commit 30891f7

File tree

4 files changed

+35
-69
lines changed

4 files changed

+35
-69
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
"@babel/preset-env": "^7.26.9",
3232
"@crowdin/crowdin-api-client": "^1.41.2",
3333
"@rsdoctor/webpack-plugin": "^1.0.0",
34-
"@swc/core": "^1.11.9",
34+
"@swc/core": "^1.11.11",
3535
"@swc/jest": "^0.2.37",
36-
"@types/chrome": "0.0.309",
36+
"@types/chrome": "0.0.310",
3737
"@types/decompress": "^4.2.7",
3838
"@types/echarts": "^5.0.0",
3939
"@types/generate-json-webpack-plugin": "^0.3.7",
@@ -58,15 +58,15 @@
5858
"postcss-loader": "^8.1.1",
5959
"postcss-rtlcss": "^5.6.0",
6060
"puppeteer": "^24.4.0",
61-
"sass": "^1.85.1",
61+
"sass": "^1.86.0",
6262
"sass-loader": "^16.0.5",
6363
"style-loader": "^4.0.0",
6464
"ts-loader": "^9.5.2",
6565
"ts-node": "^10.9.2",
6666
"tsconfig-paths": "^4.2.0",
6767
"typescript": "5.8.2",
6868
"url-loader": "^4.1.1",
69-
"web-ext": "^8.4.0",
69+
"web-ext": "^8.5.0",
7070
"webpack": "^5.98.0",
7171
"webpack-cli": "^6.0.1"
7272
},

src/content-script/limit/modal/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,14 @@ class ModalInstance implements MaskModal {
178178
pauseAllVideo()
179179
pauseAllAudio()
180180

181+
this.rootElement && (this.rootElement.style.visibility = 'visible')
181182
this.reason.value = reason
182183
this.screenLocker.lock()
183184
this.body.style.display = 'block'
184185
}
185186

186187
private hide() {
188+
this.rootElement && (this.rootElement.style.visibility = 'hidden')
187189
this.screenLocker.unlock()
188190
this.body && (this.body.style.display = 'none')
189191
this.reason && (this.reason.value = null)

src/pages/app/components/Limit/LimitTable/column/LimitEnabledColumn.tsx

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/pages/app/components/Limit/LimitTable/index.tsx

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import weekHelper from "@service/components/week-helper"
1212
import limitService from "@service/limit-service"
1313
import { isEffective } from "@util/limit"
1414
import { useDocumentVisibility, useLocalStorage } from "@vueuse/core"
15-
import { ElMessage, ElTable, ElTableColumn, ElTag, type Sort, type TableInstance } from "element-plus"
16-
import { defineComponent, ref, watch } from "vue"
15+
import { ElMessage, ElSwitch, ElTable, ElTableColumn, ElTag, type Sort, type TableInstance } from "element-plus"
16+
import { defineComponent, ref, toRaw, watch } from "vue"
17+
import { verifyCanModify } from "../common"
1718
import { useLimitFilter } from "../context"
1819
import LimitDelayColumn from "./column/LimitDelayColumn"
19-
import LimitEnabledColumn from "./column/LimitEnabledColumn"
2020
import LimitOperationColumn from "./column/LimitOperationColumn"
2121
import RuleContent from "./RuleContent"
2222
import Waste from "./Waste"
@@ -37,6 +37,8 @@ const sortMethodByNumVal = (key: keyof timer.limit.Item & 'waste' | 'weeklyWaste
3737

3838
const sortByEffectiveDays = ({ weekdays: a }: timer.limit.Item, { weekdays: b }: timer.limit.Item) => (a?.length ?? 0) - (b?.length ?? 0)
3939

40+
const sortByEnabled: CompareFn<timer.limit.Item> = (a, b): number => (a.enabled ? 1 : 0) - (b.enabled ? 1 : 0)
41+
4042
const _default = defineComponent({
4143
emits: {
4244
delayChange: (_row: timer.limit.Item) => true,
@@ -76,12 +78,21 @@ const _default = defineComponent({
7678

7779
const historySort = useLocalStorage<Sort>('__limit_sort_default__', { prop: DEFAULT_SORT_COL, order: 'descending' })
7880

81+
const onEnabledChange = async (row: timer.limit.Item, newVal: boolean | string | number) => {
82+
const enabled = !!newVal
83+
try {
84+
!enabled && await verifyCanModify(row)
85+
row.enabled = enabled
86+
ctx.emit("enabledChange", toRaw(row))
87+
} catch (e) {
88+
console.log(e)
89+
}
90+
}
91+
7992
return () => (
8093
<ElTable
8194
ref={tableInstance}
82-
border
83-
fit
84-
highlightCurrentRow
95+
border fit highlightCurrentRow
8596
style={{ width: "100%" }}
8697
data={data.value}
8798
defaultSort={historySort.value}
@@ -174,7 +185,18 @@ const _default = defineComponent({
174185
}}
175186
/>
176187
<LimitDelayColumn onRowChange={row => ctx.emit("delayChange", row)} />
177-
<LimitEnabledColumn onRowChange={row => ctx.emit("enabledChange", row)} />
188+
<ElTableColumn
189+
label={t(msg => msg.limit.item.enabled)}
190+
minWidth={100}
191+
align="center"
192+
fixed="right"
193+
sortable
194+
sortMethod={sortByEnabled}
195+
>
196+
{({ row }: ElTableRowScope<timer.limit.Item>) => (
197+
<ElSwitch size="small" modelValue={row.enabled} onChange={v => onEnabledChange(row, v)} />
198+
)}
199+
</ElTableColumn>
178200
<LimitOperationColumn
179201
onRowDelete={deleteRow}
180202
onRowModify={row => ctx.emit("modify", row)}

0 commit comments

Comments
 (0)