Skip to content

Commit 60623b0

Browse files
author
sheepzh
committed
Support virtual sites (sheepzh#194, sheepzh#191)
1 parent a9ee07b commit 60623b0

File tree

85 files changed

+1904
-1529
lines changed

Some content is hidden

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

85 files changed

+1904
-1529
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@
6060
"vue": "^3.2.45",
6161
"vue-router": "^4.1.6"
6262
}
63-
}
63+
}

script/crowdin/common.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,3 @@ export async function checkMainBranch(client: CrowdinClient) {
223223
}
224224
return branch
225225
}
226-
227-
// function main() {
228-
// const file = fs.readFileSync(path.join(MSG_BASE, 'app', 'habit.ts'), { encoding: 'utf-8' })
229-
// const result = /(const|let|var) _default(.*)=\s*\{\s*(\n?.*\n)+\}/.exec(file)
230-
// const origin = result[0]
231-
// console.log(origin)
232-
// console.log(file.indexOf(origin))
233-
// }
234-
235-
// main()

src/app/components/report/table/columns/alias-info.ts renamed to src/app/components/common/editable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ function render(data: _Data, ctx: SetupContext<_Emits>) {
8585
* @since 0.7.1
8686
*/
8787
const _default = defineComponent({
88-
name: "ReportAliasInfo",
88+
name: "Editable",
8989
props: {
9090
modelValue: {
9191
type: String
9292
}
9393
},
9494
emits: {
95-
change: (_newAlias: string) => true
95+
change: (_newVal: string) => true
9696
},
9797
setup(props, ctx) {
9898
const editing = ref(false)

src/app/components/common/host-alert.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,21 @@ const _default = defineComponent({
4747
underline: props.clickable,
4848
style: { cursor: cursor.value }
4949
}, () => props.host)
50-
: () => h('div', [
51-
h(ElLink,
52-
{
50+
: () => {
51+
const children = [
52+
h(ElLink, {
5353
href: href.value,
5454
target: target.value,
5555
underline: props.clickable,
5656
style: { cursor: cursor.value }
57-
},
58-
() => props.host
59-
), h('span',
57+
}, () => props.host)
58+
]
59+
props.iconUrl && children.push(h('span',
6060
{ style: HOST_ICON_STYLE },
6161
h('img', { src: props.iconUrl, width: 12, height: 12 })
62-
)
63-
])
62+
))
63+
return h('div', children)
64+
}
6465
}
6566
})
6667

src/app/components/dashboard/components/calendar-heat-map.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use([
2828
])
2929

3030
import { t } from "@app/locale"
31-
import timerService, { TimerQueryParam } from "@service/timer-service"
31+
import statService, { StatQueryParam } from "@service/stat-service"
3232
import { locale } from "@i18n"
3333
import { formatTime, getWeeksAgo, MILL_PER_DAY, MILL_PER_MINUTE } from "@util/time"
3434
import { ElLoading } from "element-plus"
@@ -269,8 +269,8 @@ const _default = defineComponent({
269269
// 2. init chart
270270
chartWrapper.init(chart.value)
271271
// 3. query data
272-
const query: TimerQueryParam = { date: [startTime, now], sort: "date" }
273-
const items = await timerService.select(query)
272+
const query: StatQueryParam = { date: [startTime, now], sort: "date" }
273+
const items = await statService.select(query)
274274
const result = {}
275275
items.forEach(({ date, focus }) => result[date] = (result[date] || 0) + focus)
276276
// 4. set weekdays

src/app/components/dashboard/components/indicator/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import PeriodDatabase from "@db/period-database"
9-
import timerService from "@service/timer-service"
9+
import statService from "@service/stat-service"
1010
import { getStartOfDay, MILL_PER_DAY, MILL_PER_MINUTE } from "@util/time"
1111
import { defineComponent, h, ref, Ref } from "vue"
1212
import { groupBy } from "@util/array"
@@ -36,7 +36,7 @@ function calculateInstallDays(installTime: Date, now: Date): number {
3636
}
3737

3838
async function query(): Promise<_Value> {
39-
const allData: timer.stat.Row[] = await timerService.select()
39+
const allData: timer.stat.Row[] = await statService.select()
4040
const hostSet = new Set<string>()
4141
let visits = 0
4242
let browsingTime = 0

src/app/components/dashboard/components/top-k-visit.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { ECharts, ComposeOption } from "echarts/core"
99
import type { PieSeriesOption } from "echarts/charts"
1010
import type { TitleComponentOption, TooltipComponentOption } from "echarts/components"
1111
import type { Ref } from "vue"
12-
import type { TimerQueryParam } from "@service/timer-service"
12+
import type { StatQueryParam } from "@service/stat-service"
1313

1414
import { init, use } from "@echarts/core"
1515
import PieChart from "@echarts/chart/pie"
@@ -18,7 +18,7 @@ import TooltipComponent from "@echarts/component/tooltip"
1818

1919
use([PieChart, TitleComponent, TooltipComponent])
2020

21-
import timerService from "@service/timer-service"
21+
import statService from "@service/stat-service"
2222
import { MILL_PER_DAY } from "@util/time"
2323
import { ElLoading } from "element-plus"
2424
import { defineComponent, h, onMounted, ref } from "vue"
@@ -110,13 +110,13 @@ const _default = defineComponent({
110110
target: `#${CONTAINER_ID}`,
111111
})
112112
chartWrapper.init(chart.value)
113-
const query: TimerQueryParam = {
113+
const query: StatQueryParam = {
114114
date: [startTime, now],
115115
sort: "time",
116116
sortOrder: 'DESC',
117117
mergeDate: true,
118118
}
119-
const top: timer.stat.Row[] = (await timerService.selectByPage(query, { num: 1, size: TOP_NUM }, { alias: true })).list
119+
const top: timer.stat.Row[] = (await statService.selectByPage(query, { num: 1, size: TOP_NUM }, true)).list
120120
const data: _Value[] = top.map(({ time, host, alias }) => ({ name: alias || host, host, alias, value: time }))
121121
for (let realSize = top.length; realSize < TOP_NUM; realSize++) {
122122
data.push({ name: '', host: '', value: 0 })

src/app/components/dashboard/components/week-on-week.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import type { Ref } from "vue"
9-
import type { FillFlagParam, TimerQueryParam } from "@service/timer-service"
9+
import type { StatQueryParam } from "@service/stat-service"
1010
import type { ECharts, ComposeOption } from "echarts/core"
1111
import type { CandlestickSeriesOption } from "echarts/charts"
1212
import type { GridComponentOption, TitleComponentOption, TooltipComponentOption } from "echarts/components"
@@ -22,7 +22,7 @@ use([CandlestickChart, GridComponent, TitleComponent, TooltipComponent])
2222
import { formatPeriodCommon, MILL_PER_DAY } from "@util/time"
2323
import { ElLoading } from "element-plus"
2424
import { defineComponent, h, onMounted, ref } from "vue"
25-
import timerService from "@service/timer-service"
25+
import statService from "@service/stat-service"
2626
import { groupBy, sum } from "@util/array"
2727
import { BASE_TITLE_OPTION } from "../common"
2828
import { t } from "@app/locale"
@@ -197,16 +197,15 @@ const _default = defineComponent({
197197
target: `#${CONTAINER_ID}`,
198198
})
199199
chartWrapper.init(chart.value)
200-
const query: TimerQueryParam = {
200+
const query: StatQueryParam = {
201201
date: [lastPeriodStart, lastPeriodEnd],
202202
mergeDate: true,
203203
}
204204
// Query with alias
205205
// @since 1.1.8
206-
const flagParam: FillFlagParam = { alias: true }
207-
const lastPeriodItems: timer.stat.Row[] = await timerService.select(query, flagParam)
206+
const lastPeriodItems: timer.stat.Row[] = await statService.select(query, true)
208207
query.date = [thisPeriodStart, thisPeriodEnd]
209-
const thisPeriodItems: timer.stat.Row[] = await timerService.select(query, flagParam)
208+
const thisPeriodItems: timer.stat.Row[] = await statService.select(query, true)
210209
const option = optionOf(lastPeriodItems, thisPeriodItems)
211210
chartWrapper.render(option, loading)
212211
})

src/app/components/data-manage/clear/filter/operation-button.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import { ElButton, ElMessage, ElMessageBox, ElTooltip } from "element-plus"
99
import ElementIcon from "@src/element-ui/icon"
1010
import { Ref, h } from "vue"
11-
import TimerDatabase, { TimerCondition } from "@db/timer-database"
11+
import StatDatabase, { StatCondition } from "@db/stat-database"
1212
import { ItemMessage } from "@i18n/message/common/item"
1313
import { t } from "@src/app/locale"
1414
import { DataManageMessage } from "@i18n/message/app/data-manage"
1515
import { MILL_PER_DAY } from "@util/time"
1616
import { ElementButtonType } from "@src/element-ui/button"
1717

18-
const timerDatabase = new TimerDatabase(chrome.storage.local)
18+
const statDatabase = new StatDatabase(chrome.storage.local)
1919

2020
export type BaseFilterProps = {
2121
focusStartRef: Ref<string>
@@ -77,7 +77,7 @@ const str2Range = (startAndEnd: Ref<string>[], numAmplifier?: (origin: number) =
7777

7878
const seconds2Milliseconds = (a: number) => a * 1000
7979

80-
function checkParam(props: _Props): TimerCondition | undefined {
80+
function checkParam(props: _Props): StatCondition | undefined {
8181
const { focusStartRef, focusEndRef, timeStartRef, timeEndRef } = props
8282
let hasError = false
8383
const focusRange = str2Range([focusStartRef, focusEndRef], seconds2Milliseconds)
@@ -87,7 +87,7 @@ function checkParam(props: _Props): TimerCondition | undefined {
8787
if (hasError) {
8888
return undefined
8989
}
90-
const condition: TimerCondition = {}
90+
const condition: StatCondition = {}
9191
condition.focusRange = focusRange
9292
condition.timeRange = timeRange
9393
return condition
@@ -108,7 +108,7 @@ function generateParamAndSelect(props: _Props): Promise<timer.stat.Row[]> | unde
108108
}
109109
condition.date = [dateStart, dateEnd]
110110

111-
return timerDatabase.select(condition)
111+
return statDatabase.select(condition)
112112
}
113113

114114
const operationCancelMsg = t(msg => msg.dataManage.operationCancel)

src/app/components/data-manage/clear/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import { defineComponent, h, Ref, ref, SetupContext } from "vue"
1010
import { t } from "@app/locale"
1111
import { alertProps } from "../common"
1212
import Filter from "./filter"
13-
import TimerDatabase, { TimerCondition } from "@db/timer-database"
13+
import StatDatabase, { StatCondition } from "@db/stat-database"
1414
import { MILL_PER_DAY } from "@util/time"
1515

1616
type _Emits = {
1717
dataDelete: () => true
1818
}
1919

20-
const timerDatabase = new TimerDatabase(chrome.storage.local)
20+
const statDatabase = new StatDatabase(chrome.storage.local)
2121

2222
const operationCancelMsg = t(msg => msg.dataManage.operationCancel)
2323
const operationConfirmMsg = t(msg => msg.dataManage.operationConfirm)
@@ -32,7 +32,7 @@ async function handleClick(filterRef: Ref, ctx: SetupContext<_Emits>) {
3232
cancelButtonText: operationCancelMsg,
3333
confirmButtonText: operationConfirmMsg
3434
}).then(async () => {
35-
await timerDatabase.delete(result)
35+
await statDatabase.delete(result)
3636
ElMessage(t(msg => msg.dataManage.deleteSuccess))
3737
ctx.emit('dataDelete')
3838
}).catch(() => { })
@@ -53,7 +53,7 @@ function generateParamAndSelect(props: DataManageClearFilterOption): Promise<tim
5353
}
5454
condition.date = [dateStart, dateEnd]
5555

56-
return timerDatabase.select(condition)
56+
return statDatabase.select(condition)
5757
}
5858

5959
/**
@@ -77,7 +77,7 @@ function assertQueryParam(range: number[], mustInteger?: boolean): boolean {
7777
const str2Num = (str: string, defaultVal?: number) => (str && str !== '') ? parseInt(str) : defaultVal
7878
const seconds2Milliseconds = (a: number) => a * 1000
7979

80-
function checkParam(filterOption: DataManageClearFilterOption): TimerCondition | undefined {
80+
function checkParam(filterOption: DataManageClearFilterOption): StatCondition | undefined {
8181
const { focusStart, focusEnd, timeStart, timeEnd } = filterOption
8282
let hasError = false
8383
const focusRange = str2Range([focusStart, focusEnd], seconds2Milliseconds)
@@ -87,7 +87,7 @@ function checkParam(filterOption: DataManageClearFilterOption): TimerCondition |
8787
if (hasError) {
8888
return undefined
8989
}
90-
const condition: TimerCondition = {}
90+
const condition: StatCondition = {}
9191
condition.focusRange = focusRange
9292
condition.timeRange = timeRange
9393
return condition

0 commit comments

Comments
 (0)