Skip to content

Commit 6e36eb2

Browse files
committed
Merge remote-tracking branch 'origin/main' into v3.2.0
2 parents 67e7be1 + 612fe6a commit 6e36eb2

File tree

7 files changed

+65
-56
lines changed

7 files changed

+65
-56
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"Popconfirm",
3333
"PROPFIND",
3434
"Qihu",
35+
"Rsdoctor",
3536
"rtlcss",
3637
"selectchanged",
3738
"sheepzh",

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to Time Tracker will be documented in this file.
44

55
It is worth mentioning that the release time of each change refers to the time when the installation package is submitted to the webstore. It is about one week for Edge to moderate packages, while only 1-2 days for Chrome and Firefox.
66

7+
## [3.1.2] - 2025-02-11
8+
9+
- Fixed some bugs
10+
711
## [3.1.1] - 2025-02-07 [For Firefox]
812

913
- Supported sidebar for Firefox

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "timer",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"description": "Time tracker",
55
"homepage": "https://www.wfhg.cc",
66
"scripts": {
@@ -29,6 +29,7 @@
2929
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
3030
"@babel/preset-env": "^7.26.7",
3131
"@crowdin/crowdin-api-client": "^1.41.1",
32+
"@rsdoctor/webpack-plugin": "^0.4.13",
3233
"@swc/core": "^1.10.15",
3334
"@swc/jest": "^0.2.37",
3435
"@types/chrome": "0.0.303",
@@ -40,7 +41,6 @@
4041
"@types/psl": "^1.1.3",
4142
"@types/punycode": "^2.1.4",
4243
"@types/webpack": "^5.28.5",
43-
"@types/webpack-bundle-analyzer": "^4.7.0",
4444
"@vue/babel-plugin-jsx": "^1.2.5",
4545
"babel-loader": "^9.2.1",
4646
"copy-webpack-plugin": "^12.0.2",
@@ -63,11 +63,9 @@
6363
"ts-loader": "^9.5.2",
6464
"ts-node": "^10.9.2",
6565
"tsconfig-paths": "^4.2.0",
66-
"tslib": "^2.8.1",
6766
"typescript": "5.7.3",
6867
"url-loader": "^4.1.1",
6968
"webpack": "^5.97.1",
70-
"webpack-bundle-analyzer": "^4.10.2",
7169
"webpack-cli": "^6.0.1"
7270
},
7371
"dependencies": {
@@ -85,4 +83,4 @@
8583
"engines": {
8684
"node": ">=20"
8785
}
88-
}
86+
}

src/pages/app/components/Analysis/components/AnalysisFilter/TargetSelect.tsx

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { SELECT_WRAPPER_STYLE } from "@app/components/common/filter/common"
22
import { useCategories } from "@app/context"
33
import { t } from "@app/locale"
4-
import { useManualRequest } from "@hooks"
4+
import { useManualRequest, useState } from "@hooks"
55
import Flex from "@pages/components/Flex"
66
import siteService from "@service/site-service"
77
import statService from "@service/stat-service"
@@ -44,32 +44,29 @@ type TargetItem = AnalysisTarget & {
4444
label: string
4545
}
4646

47-
function collectHosts(hosts: Set<string>, siteType: timer.site.Type, collector: SiteMap<timer.site.SiteInfo>) {
48-
hosts?.forEach(host => {
49-
const site: timer.site.SiteInfo = { host, type: siteType }
50-
collector?.put(site, site)
47+
function collectHosts(hosts: Record<timer.site.Type, string[]>, collector: SiteMap<timer.site.SiteInfo>) {
48+
Object.entries(hosts).forEach(([key, arr]) => {
49+
const type = key as timer.site.Type
50+
arr.forEach(host => {
51+
const site: timer.site.SiteInfo = { host, type }
52+
collector?.put(site, site)
53+
})
5154
})
5255
}
5356

54-
const fetchItems = async (query: string, categories: timer.site.Cate[]): Promise<[siteItems: TargetItem[], cateItems: TargetItem[]]> => {
55-
query = query?.trim?.()
57+
const fetchItems = async (categories: timer.site.Cate[]): Promise<[siteItems: TargetItem[], cateItems: TargetItem[]]> => {
5658
// 1. query categories
57-
const cateItems = categories
58-
?.filter(({ name }) => !query || name?.includes(query))
59-
?.map(({ id, name }) => ({ type: 'cate', key: id, label: name } satisfies TargetItem))
59+
const cateItems = categories?.map(({ id, name }) => ({ type: 'cate', key: id, label: name } satisfies TargetItem))
6060

6161
// 2. query sites
6262
const siteSet = new SiteMap<timer.site.SiteInfo>()
6363

6464
// 2.1 sites from hosts
65-
const hosts = await statService.listHosts(query)
66-
const { origin, merged, virtual } = hosts || {}
67-
collectHosts(origin, 'normal', siteSet)
68-
collectHosts(merged, 'merged', siteSet)
69-
collectHosts(virtual, 'virtual', siteSet)
65+
const hosts = await statService.listHosts()
66+
collectHosts(hosts, siteSet)
7067

7168
// 2.2 query sites from sites
72-
const sites = await siteService.selectAll({ fuzzyQuery: query })
69+
const sites = await siteService.selectAll()
7370
sites?.forEach(site => siteSet.put(site, site))
7471

7572
const siteItems = siteSet?.map((_, site) => ({ type: 'site', key: site, label: labelOfHostInfo(site) }) satisfies TargetItem)
@@ -129,19 +126,31 @@ const TargetSelect = defineComponent({
129126
ctx.emit('change', target)
130127
}
131128

132-
const { data: items, refresh, refreshAgain } = useManualRequest(
133-
(query: string) => fetchItems(query, categories.value),
129+
const { data: allItems } = useManualRequest(
130+
() => fetchItems(categories.value),
134131
{ deps: categories },
135132
)
136133

137-
const searchRemote = useDebounceFn(query => {
138-
if (!query && !!selectKey.value) {
139-
// Use last query
140-
refreshAgain()
141-
} else {
142-
refresh(query)
143-
}
144-
}, 200)
134+
const [query, setQuery] = useState<string>()
135+
136+
const items = computed(() => {
137+
const q = query.value?.trim?.()
138+
if (!q) return allItems.value
139+
140+
return allItems.value?.map(itemArr => {
141+
const newItems = itemArr.filter(item => {
142+
if (item.type === 'cate') {
143+
return item.label?.includes?.(q)
144+
} else {
145+
const { host, alias } = item.key || {}
146+
return host?.includes?.(q) || alias?.includes?.(q)
147+
}
148+
})
149+
return newItems
150+
}) ?? []
151+
})
152+
153+
const searchRemote = useDebounceFn(setQuery, 50)
145154

146155
return () => (
147156
<ElSelect

src/pages/app/components/SiteManage/SiteManageModify/HostSelect.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
import { useManualRequest } from "@hooks"
88
import siteService from "@service/site-service"
9-
import statService, { type HostSet } from "@service/stat-service"
9+
import statService from "@service/stat-service"
1010
import { MERGED_HOST, ALL_HOSTS as REMAIN_HOSTS } from "@util/constant/remain-host"
1111
import { isValidVirtualHost, judgeVirtualFast } from "@util/pattern"
1212
import { ElOption, ElSelect, ElTag } from "element-plus"
@@ -32,10 +32,10 @@ function cleanQuery(query: string) {
3232
async function handleRemoteSearch(query: string): Promise<_OptionInfo[]> {
3333
query = cleanQuery(query)
3434
if (!query) return []
35-
const hostSet: HostSet = (await statService.listHosts(query))
35+
const { normal, merged } = (await statService.listHosts(query)) || {}
3636
const allAlias: timer.site.SiteKey[] = [
37-
...Array.from(hostSet.origin || []).map(host => ({ host, type: 'normal' } satisfies timer.site.SiteKey)),
38-
...Array.from(hostSet.merged || []).map(host => ({ host, type: 'merged' } satisfies timer.site.SiteKey)),
37+
...normal?.map(host => ({ host, type: 'normal' } satisfies timer.site.SiteKey)) ?? [],
38+
...merged?.map(host => ({ host, type: 'merged' } satisfies timer.site.SiteKey)) ?? [],
3939
]
4040
// Add local files
4141
REMAIN_HOSTS.forEach(remain => allAlias.push({ host: remain, type: 'normal' }))

src/service/stat-service/index.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ export type StatQueryParam = StatCondition & {
6262
sortOrder?: SortDirect
6363
}
6464

65-
export type HostSet = {
66-
origin: Set<string>
67-
merged: Set<string>
68-
virtual: Set<string>
69-
}
70-
7165
function cvtStatRow2BaseKey(statRow: timer.stat.Row): timer.core.RowKey {
7266
const { siteKey, date } = statRow || {}
7367
if (!date) return undefined
@@ -116,36 +110,39 @@ class StatService {
116110
* @param fuzzyQuery the part of host
117111
* @since 0.0.8
118112
*/
119-
async listHosts(fuzzyQuery: string): Promise<HostSet> {
113+
async listHosts(fuzzyQuery?: string): Promise<Record<timer.site.Type, string[]>> {
120114
const rows = await statDatabase.select()
121115
const allHosts: Set<string> = new Set(rows.map(row => row.host))
122116
// Generate ruler
123117
const mergeRuleItems: timer.merge.Rule[] = await mergeRuleDatabase.selectAll()
124118
const mergeRuler = new CustomizedHostMergeRuler(mergeRuleItems)
125119

126-
const origin: Set<string> = new Set()
127-
const merged: Set<string> = new Set()
128-
const virtual: Set<string> = new Set()
120+
const normalSet: Set<string> = new Set()
121+
const mergedSet: Set<string> = new Set()
122+
const virtualSet: Set<string> = new Set()
129123

130124
const allHostArr = Array.from(allHosts)
131125

132126
allHostArr.forEach(host => {
133127
if (judgeVirtualFast(host)) {
134-
host.includes(fuzzyQuery) && virtual.add(host)
128+
virtualSet.add(host)
135129
return
136130
}
137-
host.includes(fuzzyQuery) && origin.add(host)
131+
normalSet.add(host)
138132
const mergedHost = mergeRuler.merge(host)
139-
mergedHost?.includes(fuzzyQuery) && merged.add(mergedHost)
133+
mergedSet.add(mergedHost)
140134
})
141135

142-
const virtualSites = await siteDatabase.select({ types: 'virtual' })
143-
virtualSites
144-
.map(site => site.host)
145-
.filter(host => host?.includes(fuzzyQuery))
146-
.forEach(host => virtual.add(host))
136+
let normal = Array.from(normalSet)
137+
let merged = Array.from(mergedSet)
138+
let virtual = Array.from(virtualSet)
139+
if (fuzzyQuery) {
140+
normal = normal.filter(host => host?.includes(fuzzyQuery))
141+
merged = merged.filter(host => host?.includes(fuzzyQuery))
142+
virtual = virtual.filter(host => host?.includes(fuzzyQuery))
143+
}
147144

148-
return { origin, merged, virtual }
145+
return { normal, merged, virtual }
149146
}
150147

151148
/**

webpack/webpack.analyze.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import path from 'path'
77
import generateOption from "./webpack.common"
8-
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
8+
import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin'
99
import manifest from '../src/manifest'
1010

1111
const option = generateOption({
@@ -16,6 +16,6 @@ const option = generateOption({
1616

1717
option.optimization.minimize = true
1818
option.optimization.usedExports = true
19-
option.plugins.push(new BundleAnalyzerPlugin())
19+
option.plugins.push(new RsdoctorWebpackPlugin())
2020

2121
export default option

0 commit comments

Comments
 (0)