Skip to content

Commit 1bdd12e

Browse files
committed
feat: support site blocking for mobile (#579)
1 parent 6dce672 commit 1bdd12e

File tree

42 files changed

+897
-554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+897
-554
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
"@rsdoctor/rspack-plugin": "^1.5.2",
3535
"@rspack/cli": "^1.7.6",
3636
"@rspack/core": "^1.7.6",
37-
"@swc/core": "^1.15.13",
37+
"@swc/core": "^1.15.17",
3838
"@swc/jest": "^0.2.39",
3939
"@types/chrome": "0.1.37",
4040
"@types/decompress": "^4.2.7",
4141
"@types/jest": "^30.0.0",
42-
"@types/node": "^25.3.1",
42+
"@types/node": "^25.3.2",
4343
"@types/punycode": "^2.1.4",
4444
"@vue/babel-plugin-jsx": "^2.0.1",
4545
"babel-loader": "^10.0.0",
@@ -64,7 +64,7 @@
6464
"dependencies": {
6565
"@element-plus/icons-vue": "^2.3.2",
6666
"echarts": "^6.0.0",
67-
"element-plus": "2.13.2",
67+
"element-plus": "2.13.3",
6868
"punycode": "^2.3.1",
6969
"typescript-guard": "^0.2.1",
7070
"vue": "^3.5.29",

src/content-script/limit/modal/components/Alert.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getUrl } from "@api/chrome/runtime"
22
import { t } from "@cs/locale"
3+
import { useXsState } from '@hooks/useMediaSize'
34
import { useRequest } from "@hooks/useRequest"
45
import Box from '@pages/components/Box'
56
import Flex from '@pages/components/Flex'
@@ -21,13 +22,19 @@ const _default = defineComponent(() => {
2122
return option?.limitPrompt || defaultPrompt
2223
}, { defaultValue: defaultPrompt })
2324

25+
const isXs = useXsState()
26+
2427
return () => (
2528
<Flex marginBottom={80} column align='center'>
2629
<Flex as='h2' align='center' lineHeight='2em'>
2730
<img src={ICON_URL} style={IMG_STYLE} />
2831
<span>{t(msg => msg.meta.name)?.toUpperCase()}</span>
2932
</Flex>
30-
<Box fontSize='2.7em' maxWidth='50vw' marginBlock='0.67em'>
33+
<Box
34+
fontSize={`${isXs.value ? 1 : 2.7}em`}
35+
maxWidth={`${isXs.value ? 80 : 50}vw`}
36+
marginBlock={`${isXs.value ? .3 : .67}em`}
37+
>
3138
{prompt.value}
3239
</Box>
3340
</Flex>

src/content-script/limit/modal/components/Reason.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { t } from "@cs/locale"
2+
import { useXsState } from '@hooks/index'
23
import { useRequest } from "@hooks/useRequest"
34
import Flex from "@pages/components/Flex"
45
import { matchCond, meetLimit, meetTimeLimit, period2Str } from "@util/limit"
@@ -7,8 +8,13 @@ import { ElDescriptions, ElDescriptionsItem, ElTag } from 'element-plus'
78
import { computed, defineComponent, type StyleValue } from "vue"
89
import { useGlobalParam, useReason, useRule } from "../context"
910

10-
const DESCRIPTIONS_STYLE: StyleValue = {
11-
width: '400px',
11+
const useDescriptions = () => {
12+
const isXs = useXsState()
13+
const style = computed(() => ({
14+
width: isXs.value ? '90vw' : '400px',
15+
} satisfies StyleValue))
16+
const size = computed(() => isXs.value ? 'small' : undefined)
17+
return { style, size }
1218
}
1319

1420
const renderBaseItems = (rule: timer.limit.Rule | null, url: string) => <>
@@ -35,12 +41,13 @@ const TimeDescriptions = defineComponent({
3541
const rule = useRule()
3642
const reason = useReason()
3743
const { url } = useGlobalParam()
44+
const { style, size } = useDescriptions()
3845

3946
const timeLimited = computed(() => meetTimeLimit(props.time ?? 0, props.waste ?? 0, !!reason.value?.allowDelay, reason.value?.delayCount ?? 0))
4047
const visitLimited = computed(() => meetLimit(props.count ?? 0, props.visit ?? 0))
4148

4249
return () => (
43-
<ElDescriptions border column={1} labelWidth={130} style={DESCRIPTIONS_STYLE}>
50+
<ElDescriptions border column={1} size={size.value} style={style.value}>
4451
{renderBaseItems(rule.value, url)}
4552
<ElDescriptionsItem label={props.ruleLabel} labelAlign="right">
4653
<Flex gap={5} width={200}>
@@ -90,6 +97,8 @@ const _default = defineComponent(() => {
9097

9198
setInterval(refreshBrowsingTime, 1000)
9299

100+
const { style, size } = useDescriptions()
101+
93102
return () => (
94103
<Flex justify='center' marginBottom={30}>
95104
<TimeDescriptions
@@ -110,7 +119,7 @@ const _default = defineComponent(() => {
110119
ruleLabel={t(msg => msg.limit.item.weekly)}
111120
dataLabel={t(msg => msg.calendar.range.thisWeek)}
112121
/>
113-
<ElDescriptions v-show={type.value === 'VISIT'} border column={1} style={DESCRIPTIONS_STYLE}>
122+
<ElDescriptions v-show={type.value === 'VISIT'} border column={1} style={style.value} size={size.value}>
114123
{renderBaseItems(rule.value, url)}
115124
<ElDescriptionsItem label={t(msg => msg.limit.item.visitTime)} labelAlign="right">
116125
{formatPeriodCommon((rule.value?.visitTime ?? 0) * MILL_PER_SECOND) || '-'}
@@ -124,7 +133,7 @@ const _default = defineComponent(() => {
124133
{reason.value?.delayCount ?? 0}
125134
</ElDescriptionsItem>
126135
</ElDescriptions>
127-
<ElDescriptions v-show={type.value === 'PERIOD'} border column={1} style={DESCRIPTIONS_STYLE}>
136+
<ElDescriptions v-show={type.value === 'PERIOD'} border column={1} style={style.value} size={size.value}>
128137
{renderBaseItems(rule.value, url)}
129138
<ElDescriptionsItem label={t(msg => msg.limit.item.period)} labelAlign="right">
130139
{rule.value?.periods?.length

src/pages/app/Layout/menu/item.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export const menuGroups = (): MenuGroup[] => [{
7676
}, {
7777
title: msg => msg.menu.limit,
7878
route: '/behavior/limit',
79-
icon: Timer
79+
icon: Timer,
80+
mobile: true,
8081
}]
8182
}, {
8283
title: msg => msg.menu.additional,

src/pages/app/components/Dashboard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Flex from "@pages/components/Flex"
1212
import { recommendRate, saveFlag } from "@service/meta-service"
1313
import { REVIEW_PAGE } from "@util/constant/url"
1414
import { ElRow, ElScrollbar } from "element-plus"
15-
import { computed, defineComponent, FunctionalComponent } from "vue"
15+
import { computed, defineComponent, type FunctionalComponent } from "vue"
1616
import { useRouter } from "vue-router"
1717
import ContentContainer from "../common/ContentContainer"
1818
import Calendar from "./components/Calendar"

src/pages/app/components/Limit/LimitModify/Sop/Step3/TimeInput.tsx

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

0 commit comments

Comments
 (0)