Skip to content

Commit b7c3316

Browse files
committed
Merge branch 'main' of https://github.com/sheepzh/timer
2 parents a6c90cc + 6c5b075 commit b7c3316

File tree

112 files changed

+1915
-1485
lines changed

Some content is hidden

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

112 files changed

+1915
-1485
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The technology stack used is:
66

77
- [rspack](https://rspack.dev) + [TypeScript](https://github.com/microsoft/TypeScript)
88
- [Vue3 (Composition API + JSX)](<https://vuejs.org/api/#:~:text=defineCustomElement()-,Composition%20API,-setup()>)
9-
- [sass](https://github.com/sass/sass)
9+
- [emotion](https://github.com/emotion-js/emotion)
1010
- [Element Plus](https://element-plus.gitee.io/)
1111
- [Echarts](https://github.com/apache/echarts)
1212

@@ -44,7 +44,7 @@ Create a new branch for your changes
4444
# Chrome/Edge development
4545
npm run dev
4646

47-
# Firefox development
47+
# Firefox development
4848
npm run dev:firefox
4949

5050
# Safari development
@@ -53,7 +53,7 @@ npm run dev:safari
5353

5454
This will create output directories:
5555
- `dist_dev` - Chrome/Edge extension
56-
- `dist_dev_firefox` - Firefox extension
56+
- `dist_dev_firefox` - Firefox extension
5757
- `dist_dev_safari` - Safari extension
5858

5959
#### Mobile Development (Android)

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@
2929
"license": "MIT",
3030
"devDependencies": {
3131
"@crowdin/crowdin-api-client": "^1.48.3",
32-
"@rsdoctor/rspack-plugin": "^1.3.4",
33-
"@rspack/cli": "^1.5.8",
34-
"@rspack/core": "^1.5.8",
35-
"@swc/core": "^1.13.21",
32+
"@emotion/babel-plugin": "^11.13.5",
33+
"@emotion/css": "^11.13.5",
34+
"@rsdoctor/rspack-plugin": "^1.3.7",
35+
"@rspack/cli": "^1.6.0",
36+
"@rspack/core": "^1.6.0",
37+
"@swc/core": "^1.14.0",
3638
"@swc/jest": "^0.2.39",
37-
"@types/chrome": "0.1.24",
39+
"@types/chrome": "0.1.27",
3840
"@types/decompress": "^4.2.7",
3941
"@types/jest": "^30.0.0",
40-
"@types/node": "^24.9.1",
42+
"@types/node": "^24.9.2",
4143
"@types/punycode": "^2.1.4",
4244
"@vue/babel-plugin-jsx": "^2.0.1",
4345
"babel-loader": "^10.0.0",
@@ -52,9 +54,7 @@
5254
"postcss": "^8.5.6",
5355
"postcss-loader": "^8.2.0",
5456
"postcss-rtlcss": "^5.7.1",
55-
"puppeteer": "^24.26.1",
56-
"sass": "^1.93.2",
57-
"sass-loader": "^16.0.6",
57+
"puppeteer": "^24.27.0",
5858
"ts-loader": "^9.5.4",
5959
"ts-node": "^10.9.2",
6060
"tsconfig-paths": "^4.2.0",
@@ -64,7 +64,7 @@
6464
"@element-plus/icons-vue": "^2.3.2",
6565
"countup.js": "^2.9.0",
6666
"echarts": "^6.0.0",
67-
"element-plus": "2.11.5",
67+
"element-plus": "2.11.7",
6868
"js-base64": "^3.7.8",
6969
"punycode": "^2.3.1",
7070
"vue": "^3.5.22",

rspack/rspack.common.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,21 @@ const staticOptions: Configuration = {
8484
},
8585
plugins: [
8686
"@vue/babel-plugin-jsx",
87+
"@emotion/babel-plugin",
8788
],
8889
},
8990
}, 'ts-loader'],
9091
}, {
9192
test: /\.css$/,
9293
use: [CssExtractRspackPlugin.loader, 'css-loader', POSTCSS_LOADER_CONF],
93-
}, {
94-
test: /\.s[ac]ss$/,
95-
use: [CssExtractRspackPlugin.loader, 'css-loader', POSTCSS_LOADER_CONF, 'sass-loader']
9694
}, {
9795
test: /\.(jpg|jpeg|png|woff|woff2|eot|ttf|svg)$/,
9896
type: 'asset/resource'
9997
}
10098
]
10199
},
102100
resolve: {
103-
extensions: ['.ts', '.tsx', '.js', '.css', '.scss', '.sass'],
101+
extensions: ['.ts', '.tsx', '.js', '.css'],
104102
tsConfig: join(__dirname, '..', 'tsconfig.json'),
105103
},
106104
optimization: {

src/content-script/limit/modal/Main.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import "@pages/element-ui/dark-theme.css"
2+
import "element-plus/theme-chalk/el-button-group.css"
3+
import "element-plus/theme-chalk/el-button.css"
4+
import "element-plus/theme-chalk/el-descriptions-item.css"
5+
import "element-plus/theme-chalk/el-descriptions.css"
6+
import "element-plus/theme-chalk/el-input.css"
7+
import "element-plus/theme-chalk/el-message-box.css"
8+
import "element-plus/theme-chalk/el-message.css"
9+
import "element-plus/theme-chalk/el-tag.css"
110
import { defineComponent } from "vue"
211
import Alert from "./components/Alert"
312
import Footer from "./components/Footer"
413
import Reason from "./components/Reason"
514
import { provideRule } from "./context"
6-
import "./style/index.sass"
15+
import "./style/element-base.css"
16+
import "./style/modal.css"
717

818
const _default = defineComponent(() => {
919
provideRule()

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
import { getUrl } from "@api/chrome/runtime"
22
import { t } from "@cs/locale"
33
import { useRequest } from "@hooks/useRequest"
4+
import Box from '@pages/components/Box'
5+
import Flex from '@pages/components/Flex'
46
import optionHolder from "@service/components/option-holder"
5-
import { defineComponent } from "vue"
7+
import { defineComponent, type StyleValue } from "vue"
68

79
const ICON_URL = getUrl('static/images/icon.png')
810

11+
const IMG_STYLE: StyleValue = {
12+
width: '1.4em',
13+
height: '1.4em',
14+
marginInlineEnd: '.4em',
15+
}
16+
917
const _default = defineComponent(() => {
1018
const defaultPrompt = t(msg => msg.modal.defaultPrompt)
1119
const { data: prompt } = useRequest(async () => {
1220
const option = await optionHolder.get()
1321
return option?.limitPrompt || defaultPrompt
1422
}, { defaultValue: defaultPrompt })
23+
1524
return () => (
16-
<div class='alert-container'>
17-
<h2 class='name-line'>
18-
<img src={ICON_URL} />
19-
<span> {t(msg => msg.meta.name)?.toUpperCase()}</span>
20-
</h2>
21-
<h1>{prompt.value}</h1>
22-
</div>
25+
<Flex marginBottom={80} column align='center'>
26+
<Flex as='h2' align='center' lineHeight='2em'>
27+
<img src={ICON_URL} style={IMG_STYLE} />
28+
<span>{t(msg => msg.meta.name)?.toUpperCase()}</span>
29+
</Flex>
30+
<Box fontSize='2.7em' maxWidth='50vw' marginBlock='0.67em'>
31+
{prompt.value}
32+
</Box>
33+
</Flex>
2334
)
2435
})
2536

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { judgeVerificationRequired, processVerification } from "@app/util/limit"
44
import { TAG_NAME } from "@cs/limit/element"
55
import { t } from "@cs/locale"
66
import { Plus, Timer } from "@element-plus/icons-vue"
7+
import Flex from '@pages/components/Flex'
78
import optionHolder from "@service/components/option-holder"
89
import { meetTimeLimit } from '@util/limit'
910
import { ElButton } from "element-plus"
@@ -49,7 +50,7 @@ const _default = defineComponent(() => {
4950
const delayHandler = useDelayHandler()
5051

5152
return () => (
52-
<div class='footer-container'>
53+
<Flex gap={10} marginBottom={60} justify='center'>
5354
<ElButton
5455
round
5556
icon={Trend}
@@ -74,7 +75,7 @@ const _default = defineComponent(() => {
7475
>
7576
{t(msg => msg.modal.ruleDetail)}
7677
</ElButton>
77-
</div>
78+
</Flex>
7879
)
7980
})
8081

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ import Flex from "@pages/components/Flex"
44
import { matchCond, meetLimit, meetTimeLimit, period2Str } from "@util/limit"
55
import { formatPeriodCommon, MILL_PER_SECOND } from "@util/time"
66
import { ElDescriptions, ElDescriptionsItem, ElTag } from 'element-plus'
7-
import { computed, defineComponent } from "vue"
7+
import { computed, defineComponent, type StyleValue } from "vue"
88
import { useGlobalParam, useReason, useRule } from "../context"
99

10+
const DESCRIPTIONS_STYLE: StyleValue = {
11+
width: '400px',
12+
}
13+
1014
const renderBaseItems = (rule: timer.limit.Rule | null, url: string) => <>
1115
<ElDescriptionsItem label={t(msg => msg.limit.item.name)} labelAlign="right">
1216
{rule?.name ?? '-'}
@@ -36,7 +40,7 @@ const TimeDescriptions = defineComponent({
3640
const visitLimited = computed(() => meetLimit(props.count ?? 0, props.visit ?? 0))
3741

3842
return () => (
39-
<ElDescriptions border column={1} labelWidth={130}>
43+
<ElDescriptions border column={1} labelWidth={130} style={DESCRIPTIONS_STYLE}>
4044
{renderBaseItems(rule.value, url)}
4145
<ElDescriptionsItem label={props.ruleLabel} labelAlign="right">
4246
<Flex gap={5} width={200}>
@@ -67,7 +71,7 @@ const TimeDescriptions = defineComponent({
6771
>
6872
{reason.value?.delayCount ?? 0}
6973
</ElDescriptionsItem>
70-
</ElDescriptions>
74+
</ElDescriptions >
7175
)
7276
},
7377
})
@@ -87,7 +91,7 @@ const _default = defineComponent(() => {
8791
setInterval(refreshBrowsingTime, 1000)
8892

8993
return () => (
90-
<div class="reason-container">
94+
<Flex justify='center' marginBottom={30}>
9195
<TimeDescriptions
9296
v-show={type.value === 'DAILY'}
9397
time={rule.value?.time}
@@ -106,7 +110,7 @@ const _default = defineComponent(() => {
106110
ruleLabel={t(msg => msg.limit.item.weekly)}
107111
dataLabel={t(msg => msg.calendar.range.thisWeek)}
108112
/>
109-
<ElDescriptions border column={1} v-show={type.value === 'VISIT'}>
113+
<ElDescriptions v-show={type.value === 'VISIT'} border column={1} style={DESCRIPTIONS_STYLE}>
110114
{renderBaseItems(rule.value, url)}
111115
<ElDescriptionsItem label={t(msg => msg.limit.item.visitTime)} labelAlign="right">
112116
{formatPeriodCommon((rule.value?.visitTime ?? 0) * MILL_PER_SECOND) || '-'}
@@ -120,19 +124,18 @@ const _default = defineComponent(() => {
120124
{reason.value?.delayCount ?? 0}
121125
</ElDescriptionsItem>
122126
</ElDescriptions>
123-
<ElDescriptions border column={1} v-show={type.value === 'PERIOD'}>
127+
<ElDescriptions v-show={type.value === 'PERIOD'} border column={1} style={DESCRIPTIONS_STYLE}>
124128
{renderBaseItems(rule.value, url)}
125129
<ElDescriptionsItem label={t(msg => msg.limit.item.period)} labelAlign="right">
126-
{
127-
rule.value?.periods?.length
128-
? <div>
129-
{rule.value?.periods.map(p => <span style={{ display: "block" }}>{period2Str(p)}</span>)}
130-
</div>
131-
: '-'
130+
{rule.value?.periods?.length
131+
? <div>
132+
{rule.value.periods.map(p => <span style={{ display: "block" }}>{period2Str(p)}</span>)}
133+
</div>
134+
: '-'
132135
}
133136
</ElDescriptionsItem>
134137
</ElDescriptions>
135-
</div>
138+
</Flex>
136139
)
137140
})
138141

src/content-script/limit/modal/style/index.sass

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#app {
2+
width: 100vw;
3+
height: 100vh;
4+
display: flex;
5+
justify-content: space-around;
6+
flex-direction: column;
7+
align-items: center;
8+
color: var(--el-text-color-primary);
9+
}
10+
11+
body {
12+
height: 100vh;
13+
width: 100vw;
14+
padding: 0;
15+
margin: 0;
16+
position: absolute;
17+
top: 0;
18+
left: 0;
19+
z-index: 999999;
20+
min-height: 600px;
21+
background-color: var(--el-fill-color-blank);
22+
}
23+
24+
html[data-theme=dark] body {
25+
background-color: var(--el-fill-color-dark);
26+
}

0 commit comments

Comments
 (0)