Skip to content

Commit ea408f5

Browse files
committed
Support TSX
1 parent 3fc3138 commit ea408f5

Some content is hidden

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

54 files changed

+916
-987
lines changed

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
88
"cSpell.words": [
99
"Auths",
10+
"clipboardy",
11+
"countup",
1012
"echarts",
13+
"filemanager",
1114
"Hengyang",
12-
"Kanban"
15+
"Kanban",
16+
"zrender"
1317
],
1418
"cSpell.ignorePaths": [
1519
"package-lock.json",

package.json

Lines changed: 73 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,74 @@
11
{
2-
"name": "timer",
3-
"version": "2.1.1",
4-
"description": "Web timer",
5-
"homepage": "https://github.com/sheepzh/timer",
6-
"scripts": {
7-
"dev": "webpack --config=webpack/webpack.dev.ts --watch",
8-
"dev:safari": "webpack --config=webpack/webpack.dev.safari.ts --watch",
9-
"build": "webpack --config=webpack/webpack.prod.ts",
10-
"build:safari": "webpack --config=webpack/webpack.prod.safari.ts",
11-
"analyze": "webpack --config=webpack/webpack.analyze.ts",
12-
"test": "jest --env=jsdom",
13-
"test-c": "jest --coverage --env=jsdom"
14-
},
15-
"author": {
16-
"name": "zhy",
17-
"email": "returnzhy1996@outlook.com",
18-
"url": "https://www.github.com/sheepzh"
19-
},
20-
"license": "MIT",
21-
"devDependencies": {
22-
"@crowdin/crowdin-api-client": "^1.28.2",
23-
"@types/chrome": "0.0.254",
24-
"@types/copy-webpack-plugin": "^8.0.1",
25-
"@types/echarts": "^4.9.22",
26-
"@types/generate-json-webpack-plugin": "^0.3.7",
27-
"@types/jest": "^29.5.11",
28-
"@types/node": "^20.10.5",
29-
"@types/psl": "^1.1.3",
30-
"@types/webpack": "^5.28.5",
31-
"@types/webpack-bundle-analyzer": "^4.6.3",
32-
"babel-loader": "^9.1.3",
33-
"copy-webpack-plugin": "^11.0.0",
34-
"css-loader": "^6.8.1",
35-
"eslint": "^8.56.0",
36-
"filemanager-webpack-plugin": "^8.0.0",
37-
"generate-json-webpack-plugin": "^2.0.0",
38-
"html-webpack-plugin": "^5.5.4",
39-
"jest": "^29.7.0",
40-
"jest-environment-jsdom": "^29.7.0",
41-
"mini-css-extract-plugin": "^2.7.6",
42-
"node-sass": "^9.0.0",
43-
"sass-loader": "^13.3.2",
44-
"style-loader": "^3.3.3",
45-
"ts-jest": "^29.1.1",
46-
"ts-loader": "^9.5.1",
47-
"ts-node": "^10.9.2",
48-
"tsconfig-paths": "^4.2.0",
49-
"tslib": "^2.6.2",
50-
"typescript": "5.3.3",
51-
"url-loader": "^4.1.1",
52-
"webpack": "^5.89.0",
53-
"webpack-bundle-analyzer": "^4.10.1",
54-
"webpack-cli": "^5.1.4"
55-
},
56-
"dependencies": {
57-
"@element-plus/icons-vue": "^2.3.1",
58-
"axios": "^1.6.2",
59-
"clipboardy": "^4.0.0",
60-
"countup.js": "^2.8.0",
61-
"echarts": "^5.4.3",
62-
"element-plus": "2.4.4",
63-
"psl": "^1.9.0",
64-
"stream-browserify": "^3.0.0",
65-
"vue": "^3.3.12",
66-
"vue-router": "^4.2.5"
67-
},
68-
"engines": {
69-
"node": ">=18"
70-
}
71-
}
2+
"name": "timer",
3+
"version": "2.1.1",
4+
"description": "Web timer",
5+
"homepage": "https://github.com/sheepzh/timer",
6+
"scripts": {
7+
"dev": "webpack --config=webpack/webpack.dev.ts --watch",
8+
"dev:safari": "webpack --config=webpack/webpack.dev.safari.ts --watch",
9+
"build": "webpack --config=webpack/webpack.prod.ts",
10+
"build:safari": "webpack --config=webpack/webpack.prod.safari.ts",
11+
"analyze": "webpack --config=webpack/webpack.analyze.ts",
12+
"test": "jest --env=jsdom",
13+
"test-c": "jest --coverage --env=jsdom"
14+
},
15+
"author": {
16+
"name": "zhy",
17+
"email": "returnzhy1996@outlook.com",
18+
"url": "https://www.github.com/sheepzh"
19+
},
20+
"license": "MIT",
21+
"devDependencies": {
22+
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
23+
"@babel/preset-env": "^7.23.8",
24+
"@crowdin/crowdin-api-client": "^1.29.5",
25+
"@types/chrome": "0.0.256",
26+
"@types/copy-webpack-plugin": "^8.0.1",
27+
"@types/echarts": "^4.9.22",
28+
"@types/generate-json-webpack-plugin": "^0.3.7",
29+
"@types/jest": "^29.5.11",
30+
"@types/node": "^20.11.3",
31+
"@types/psl": "^1.1.3",
32+
"@types/webpack": "^5.28.5",
33+
"@types/webpack-bundle-analyzer": "^4.6.3",
34+
"@vue/babel-plugin-jsx": "^1.1.6",
35+
"babel-loader": "^9.1.3",
36+
"copy-webpack-plugin": "^12.0.1",
37+
"css-loader": "^6.9.0",
38+
"eslint": "^8.56.0",
39+
"filemanager-webpack-plugin": "^8.0.0",
40+
"generate-json-webpack-plugin": "^2.0.0",
41+
"html-webpack-plugin": "^5.6.0",
42+
"jest": "^29.7.0",
43+
"jest-environment-jsdom": "^29.7.0",
44+
"mini-css-extract-plugin": "^2.7.7",
45+
"node-sass": "^9.0.0",
46+
"sass-loader": "^14.0.0",
47+
"style-loader": "^3.3.4",
48+
"ts-jest": "^29.1.1",
49+
"ts-loader": "^9.5.1",
50+
"ts-node": "^10.9.2",
51+
"tsconfig-paths": "^4.2.0",
52+
"tslib": "^2.6.2",
53+
"typescript": "5.3.3",
54+
"url-loader": "^4.1.1",
55+
"webpack": "^5.89.0",
56+
"webpack-bundle-analyzer": "^4.10.1",
57+
"webpack-cli": "^5.1.4"
58+
},
59+
"dependencies": {
60+
"@element-plus/icons-vue": "^2.3.1",
61+
"axios": "^1.6.5",
62+
"clipboardy": "^4.0.0",
63+
"countup.js": "^2.8.0",
64+
"echarts": "^5.4.3",
65+
"element-plus": "2.4.4",
66+
"psl": "^1.9.0",
67+
"stream-browserify": "^3.0.0",
68+
"vue": "^3.4.14",
69+
"vue-router": "^4.2.5"
70+
},
71+
"engines": {
72+
"node": ">=18"
73+
}
74+
}

src/api/chrome/runtime.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export function setUninstallURL(url: string): Promise<void> {
4242

4343
/**
4444
* Get the url of this extension
45-
*
46-
* @param path The path relative to the root directory of this extension
45+
*
46+
* @param path The path relative to the root directory of this extension
4747
*/
4848
export function getUrl(path: string): string {
4949
return chrome.runtime.getURL(path)

src/app/components/dashboard/card.ts renamed to src/app/components/Dashboard/DashboardCard.tsx

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

88
import { ElCard, ElCol } from "element-plus"
9-
import { defineComponent, h } from "vue"
9+
import { defineComponent } from "vue"
1010

1111
const _default = defineComponent({
12-
name: "DashboardCard",
1312
props: {
1413
span: {
1514
type: Number,
1615
required: true
1716
}
1817
},
1918
setup(props, ctx) {
20-
return () => h(ElCol, {
21-
span: props.span
22-
}, () => h(ElCard, {
23-
style: { height: "100%" }
24-
}, () => h(ctx.slots.default)))
19+
return () => (
20+
<ElCol span={props.span}>
21+
<ElCard style={{ height: "100%" }} v-slots={ctx.slots} />
22+
</ElCol>
23+
)
2524
}
2625
})
2726

src/app/components/dashboard/components/calendar-heat-map.ts renamed to src/app/components/Dashboard/components/CalendarHeatMap.tsx

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ 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"
35-
import { defineComponent, h, onMounted, ref, Ref } from "vue"
35+
import { defineComponent, onMounted, ref, Ref } from "vue"
3636
import { groupBy, rotate } from "@util/array"
3737
import { BASE_TITLE_OPTION } from "../common"
3838
import { getPrimaryTextColor } from "@util/style"
@@ -243,45 +243,38 @@ class ChartWrapper {
243243
}
244244
}
245245

246-
const _default = defineComponent({
247-
name: "CalendarHeatMap",
248-
setup() {
249-
const isChinese = locale === "zh_CN"
250-
const now = new Date()
251-
const startTime: Date = getWeeksAgo(now, isChinese, WEEK_NUM)
246+
const _default = defineComponent(() => {
247+
const isChinese = locale === "zh_CN"
248+
const now = new Date()
249+
const startTime: Date = getWeeksAgo(now, isChinese, WEEK_NUM)
252250

253-
const chart: Ref<HTMLDivElement> = ref()
254-
const chartWrapper: ChartWrapper = new ChartWrapper(startTime, now)
251+
const chart: Ref<HTMLDivElement> = ref()
252+
const chartWrapper: ChartWrapper = new ChartWrapper(startTime, now)
255253

256-
onMounted(async () => {
257-
// 1. loading
258-
const loading = ElLoading.service({
259-
target: `#${CONTAINER_ID}`,
260-
})
261-
// 2. init chart
262-
chartWrapper.init(chart.value)
263-
// 3. query data
264-
const query: StatQueryParam = { date: [startTime, now], sort: "date" }
265-
const items = await statService.select(query)
266-
const result = {}
267-
items.forEach(({ date, focus }) => result[date] = (result[date] || 0) + focus)
268-
// 4. set weekdays
269-
// Sunday to Monday
270-
const weekDays = (t(msg => msg.calendar.weekDays)?.split?.('|') || []).reverse()
271-
if (!isChinese) {
272-
// Let Sunday last
273-
// Saturday to Sunday
274-
rotate(weekDays, 1)
275-
}
276-
// 5. render
277-
chartWrapper.render(result, weekDays, loading)
278-
})
279-
return () => h('div', {
280-
id: CONTAINER_ID,
281-
class: 'chart-container',
282-
ref: chart,
254+
onMounted(async () => {
255+
// 1. loading
256+
const loading = ElLoading.service({
257+
target: `#${CONTAINER_ID}`,
283258
})
284-
}
259+
// 2. init chart
260+
chartWrapper.init(chart.value)
261+
// 3. query data
262+
const query: StatQueryParam = { date: [startTime, now], sort: "date" }
263+
const items = await statService.select(query)
264+
const result = {}
265+
items.forEach(({ date, focus }) => result[date] = (result[date] || 0) + focus)
266+
// 4. set weekdays
267+
// Sunday to Monday
268+
const weekDays = (t(msg => msg.calendar.weekDays)?.split?.('|') || []).reverse()
269+
if (!isChinese) {
270+
// Let Sunday last
271+
// Saturday to Sunday
272+
rotate(weekDays, 1)
273+
}
274+
// 5. render
275+
chartWrapper.render(result, weekDays, loading)
276+
})
277+
return () => <div id={CONTAINER_ID} class="chart-container" ref={chart} />
285278
})
286279

287280
export default _default

0 commit comments

Comments
 (0)