Skip to content

Commit 637bf37

Browse files
authored
v3.4.0
* feat: lock limit rule (#338, #407) * i18n(zh_TW): optimize the texts by deepseek * test: fix e2e cases * test: fix e2e cases * feat: support caching filter value for the report page (#449) (#451) * refactor: refactor with provider (#453) * test: use localhost for example pages * ci: fix end-to-end tests * feat: simplify URL configuration for time limit rules (#424) (#455)
1 parent 4e2aefb commit 637bf37

File tree

147 files changed

+3352
-3621
lines changed

Some content is hidden

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

147 files changed

+3352
-3621
lines changed

.commitlintrc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export default {
4040
"revert",
4141
"style",
4242
"test",
43+
"i18n",
4344
],
4445
] satisfies [RuleConfigSeverity, RuleConfigCondition, string[]],
4546
},

.github/workflows/end-to-end-tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@ jobs:
99
uses: actions/setup-node@v1
1010
with:
1111
node-version: "v20.11.0"
12-
- run: npm install
12+
- name: Install dependencies
13+
run: npm install
14+
- name: Install http-server
15+
run: npm install -g http-server pm2
1316
- name: Build e2e outputs
1417
run: npm run dev:e2e
1518
- name: Build production outputs
1619
run: npm run build
1720

21+
- name: Start up mock server
22+
run: |
23+
pm2 start 'http-server ./test-e2e/example -p 12345'
24+
pm2 start 'http-server ./test-e2e/example -p 12346'
25+
1826
- name: Run tests
1927
env:
2028
USE_HEADLESS_PUPPETEER: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ package-lock.json
2929
aaa
3030

3131
user-chart.svg
32+
test.log

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"COPYFILE",
2020
"countup",
2121
"daterange",
22+
"delayable",
2223
"domcontentloaded",
2324
"dont",
2425
"echarts",
@@ -29,6 +30,7 @@
2930
"Kanban",
3031
"MKCOL",
3132
"newtab",
33+
"nohup",
3234
"okey",
3335
"Openeds",
3436
"Popconfirm",
@@ -38,6 +40,7 @@
3840
"rtlcss",
3941
"selectchanged",
4042
"sheepzh",
43+
"subpages",
4144
"Treemap",
4245
"Vnode",
4346
"vueuse",

package.json

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@
3030
"devDependencies": {
3131
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
3232
"@babel/preset-env": "^7.26.9",
33-
"@crowdin/crowdin-api-client": "^1.41.2",
34-
"@rsdoctor/webpack-plugin": "^1.0.0",
35-
"@swc/core": "^1.11.11",
33+
"@crowdin/crowdin-api-client": "^1.42.0",
34+
"@rsdoctor/webpack-plugin": "^1.0.2",
35+
"@swc/core": "^1.11.21",
3636
"@swc/jest": "^0.2.37",
37-
"@types/chrome": "0.0.313",
37+
"@types/chrome": "0.0.315",
3838
"@types/decompress": "^4.2.7",
39-
"@types/echarts": "^5.0.0",
4039
"@types/generate-json-webpack-plugin": "^0.3.7",
4140
"@types/jest": "^29.5.14",
42-
"@types/node": "^22.13.10",
41+
"@types/node": "^22.14.1",
4342
"@types/punycode": "^2.1.4",
4443
"@types/webpack": "^5.28.5",
4544
"@vue/babel-plugin-jsx": "^1.4.0",
@@ -48,7 +47,7 @@
4847
"copy-webpack-plugin": "^13.0.0",
4948
"css-loader": "^7.1.2",
5049
"decompress": "^4.2.1",
51-
"eslint": "^9.22.0",
50+
"eslint": "^9.25.0",
5251
"filemanager-webpack-plugin": "^8.0.0",
5352
"generate-json-webpack-plugin": "^2.0.0",
5453
"html-webpack-plugin": "^5.6.3",
@@ -59,26 +58,26 @@
5958
"mini-css-extract-plugin": "^2.9.2",
6059
"postcss": "^8.5.3",
6160
"postcss-loader": "^8.1.1",
62-
"postcss-rtlcss": "^5.6.0",
63-
"puppeteer": "^24.4.0",
64-
"sass": "^1.86.0",
61+
"postcss-rtlcss": "^5.7.0",
62+
"puppeteer": "^24.6.1",
63+
"sass": "^1.86.3",
6564
"sass-loader": "^16.0.5",
6665
"style-loader": "^4.0.0",
6766
"ts-loader": "^9.5.2",
6867
"ts-node": "^10.9.2",
6968
"tsconfig-paths": "^4.2.0",
70-
"typescript": "5.8.2",
69+
"typescript": "5.8.3",
7170
"url-loader": "^4.1.1",
7271
"web-ext": "^8.5.0",
73-
"webpack": "^5.98.0",
72+
"webpack": "^5.99.6",
7473
"webpack-cli": "^6.0.1"
7574
},
7675
"dependencies": {
7776
"@element-plus/icons-vue": "^2.3.1",
78-
"@vueuse/core": "^13.0.0",
77+
"@vueuse/core": "^13.1.0",
7978
"countup.js": "^2.8.0",
8079
"echarts": "^5.6.0",
81-
"element-plus": "2.9.7",
80+
"element-plus": "2.9.8",
8281
"js-base64": "^3.7.7",
8382
"punycode": "^2.3.1",
8483
"stream-browserify": "^3.0.0",

src/background/migrator/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { type Migrator } from "./common"
1111
import HostMergeInitializer from "./host-merge-initializer"
1212
import LocalFileInitializer from "./local-file-initializer"
1313
import WhitelistInitializer from "./whitelist-initializer"
14+
import LimitRuleMigrator from "./limit-rule-migrator"
1415

1516
/**
1617
* Version manager
@@ -26,6 +27,7 @@ class VersionManager {
2627
new LocalFileInitializer(),
2728
new WhitelistInitializer(),
2829
new CateInitializer(),
30+
new LimitRuleMigrator(),
2931
)
3032
}
3133

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import limitService from "@service/limit-service"
2+
import { cleanCond } from "@util/limit"
3+
import type { Migrator } from "./common"
4+
5+
export default class LimitRuleMigrator implements Migrator {
6+
onInstall(): void {
7+
}
8+
9+
async onUpdate(_version: string): Promise<void> {
10+
const rules = await limitService.select()
11+
if (!rules?.length) return
12+
const needUpdate: timer.limit.Rule[] = []
13+
const needRemoved: timer.limit.Rule[] = []
14+
rules.forEach(async rule => {
15+
const { cond } = rule
16+
let changed = false
17+
const newCond: string[] = []
18+
cond?.forEach(url => {
19+
const clean = cleanCond(url)
20+
changed = changed || clean !== url
21+
clean && newCond.push(clean)
22+
})
23+
if (!changed) return
24+
if (rule.cond.length) {
25+
rule.cond = newCond
26+
needUpdate.push(rule)
27+
} else {
28+
needRemoved.push(rule)
29+
}
30+
31+
})
32+
needRemoved.length && await limitService.remove(...needRemoved)
33+
needUpdate.length && await limitService.update(...needUpdate)
34+
}
35+
}

src/database/limit-database.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ type ItemValue = {
6464
* Enabled flag
6565
*/
6666
e: boolean
67+
/**
68+
* Locked flag
69+
*/
70+
l: boolean
6771
/**
6872
* Allow to delay
6973
*/
@@ -94,7 +98,7 @@ type ItemValue = {
9498
}
9599

96100
const cvtItem2Rec = (item: ItemValue): LimitRecord => {
97-
const { i, n, c, t, v, p, e, ad, wd, wt, r, ct, wct, } = item
101+
const { i, n, c, t, v, p, e, l, ad, wd, wt, r, ct, wct, } = item
98102
const records: DateRecords = {}
99103
Object.entries(r || {}).forEach?.(([date, { m, d, c }]) => records[date] = { mill: m, delay: d, visit: c })
100104
return {
@@ -111,6 +115,7 @@ const cvtItem2Rec = (item: ItemValue): LimitRecord => {
111115
allowDelay: !!ad,
112116
weekdays: wd,
113117
records: records,
118+
locked: l,
114119
}
115120
}
116121

@@ -121,9 +126,9 @@ function migrate(exist: Items, toMigrate: any) {
121126
Object.values(toMigrate).forEach((value, idx) => {
122127
const id = idBase + idx
123128
const itemValue: ItemValue = value as ItemValue
124-
const { c, n, t, e, ad, v, p } = itemValue
129+
const { c, n, t, e, l, ad, v, p } = itemValue
125130
exist[id] = {
126-
i: id, c, n, t, e: !!e, ad: !!ad, v, p,
131+
i: id, c, n, t, e: !!e, l: !!l, ad: !!ad, v, p,
127132
r: {},
128133
}
129134
})
@@ -162,7 +167,7 @@ class LimitDatabase extends BaseDatabase {
162167
const items = await this.getItems()
163168
let {
164169
id, name, weekdays,
165-
enabled, allowDelay,
170+
enabled, locked, allowDelay,
166171
cond,
167172
time, count,
168173
weekly, weeklyCount,
@@ -181,7 +186,7 @@ class LimitDatabase extends BaseDatabase {
181186
// Can be overridden by existing
182187
...(existItem || {}),
183188
i: id, n: name, c: cond, wd: weekdays,
184-
e: !!enabled, ad: !!allowDelay,
189+
e: !!enabled, l: locked, ad: !!allowDelay,
185190
t: time, ct: count,
186191
wt: weekly, wct: weeklyCount,
187192
v: visitTime, p: periods,
@@ -247,6 +252,13 @@ class LimitDatabase extends BaseDatabase {
247252
await this.update(items)
248253
}
249254

255+
async updateLocked(id: number, locked: boolean) {
256+
const items = await this.getItems()
257+
if (!items[id]) return
258+
items[id].l = !!locked
259+
await this.update(items)
260+
}
261+
250262
async importData(data: any): Promise<void> {
251263
let toImport = data[KEY] as Items
252264
// Not import

src/database/memory-detector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import StoragePromise from "./common/storage-promise"
1010
/**
1111
* User memory of this extension
1212
*/
13-
type MemoryInfo = {
13+
export type MemoryInfo = {
1414
/**
1515
* Used bytes
1616
*/

src/database/site-database.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ function cvt2Entry({ alias, iconUrl, cate, run }: timer.site.SiteInfo): _Entry {
8181
return entry
8282
}
8383

84-
function cvt2SiteInfo(key: timer.site.SiteKey, entry: _Entry): timer.site.SiteInfo {
85-
const { a, i, c, r } = entry
84+
function cvt2SiteInfo(key: timer.site.SiteKey, entry: _Entry | undefined): timer.site.SiteInfo {
85+
const { a, i, c, r } = entry || {}
8686
const siteInfo: timer.site.SiteInfo = { ...key }
8787
siteInfo.alias = a
8888
siteInfo.cate = c

0 commit comments

Comments
 (0)