Skip to content

Commit 92f8d7b

Browse files
author
sheepzh
committed
v1.8.0.mv3
2 parents 4386f35 + bbe7902 commit 92f8d7b

Some content is hidden

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

88 files changed

+2537
-841
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Timer can
2020
- support to set the maximum time for browsing a specific website each day to help you keey away from time wasting.
2121
- support to export files formatted _.csv_ and _.json_.
2222
- support dark mode.
23-
- support to sync data with Github Gist across serveral browser clients.
23+
- support to sync data with GitHub Gist across serveral browser clients.
2424

2525
## Install
2626

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "timer",
3-
"version": "1.7.1",
3+
"version": "1.8.0",
44
"description": "Web timer",
55
"homepage": "https://github.com/sheepzh/timer",
66
"scripts": {
@@ -12,7 +12,11 @@
1212
"test": "jest --env=jsdom",
1313
"test-c": "jest --coverage --env=jsdom"
1414
},
15-
"author": "zhy",
15+
"author": {
16+
"name": "zhy",
17+
"email": "returnzhy1996@outlook.com",
18+
"url": "https://www.github.com/sheepzh"
19+
},
1620
"license": "MIT",
1721
"devDependencies": {
1822
"@crowdin/crowdin-api-client": "^1.22.1",
@@ -37,7 +41,7 @@
3741
"node-sass": "^8.0.0",
3842
"sass-loader": "^13.2.1",
3943
"style-loader": "^3.3.2",
40-
"ts-jest": "^29.0.5",
44+
"ts-jest": "^29.1.0",
4145
"ts-loader": "^9.4.2",
4246
"ts-node": "^10.9.1",
4347
"tsconfig-paths": "^4.1.2",
@@ -63,4 +67,4 @@
6367
"engines": {
6468
"node": ">=16"
6569
}
66-
}
70+
}

public/images/guide/beating.gif

12.8 KB
Loading

public/images/guide/home.png

17.9 KB
Loading

public/images/guide/pin.png

18.6 KB
Loading

src/api/chrome/runtime.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,13 @@ export function getVersion(): string {
3838

3939
export function setUninstallURL(url: string): Promise<void> {
4040
return new Promise(resolve => chrome.runtime.setUninstallURL(url, resolve))
41+
}
42+
43+
/**
44+
* Get the url of this extension
45+
*
46+
* @param path The path relative to the root directory of this extension
47+
*/
48+
export function getUrl(path: string): string {
49+
return chrome.runtime.getURL(path)
4150
}

src/api/chrome/tab.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* Copyright (c) 2023-present Hengyang Zhang
3+
*
4+
* This software is released under the MIT License.
5+
* https://opensource.org/licenses/MIT
6+
*/
7+
18
import { handleError } from "./common"
29

310
export function getTab(id: number): Promise<ChromeTab> {
@@ -7,6 +14,13 @@ export function getTab(id: number): Promise<ChromeTab> {
714
}))
815
}
916

17+
export function getCurrentTab(): Promise<ChromeTab> {
18+
return new Promise(resolve => chrome.tabs.getCurrent(tab => {
19+
handleError("getCurrentTab")
20+
resolve(tab)
21+
}))
22+
}
23+
1024
export function createTab(param: chrome.tabs.CreateProperties | string): Promise<ChromeTab> {
1125
const prop: chrome.tabs.CreateProperties = typeof param === 'string' ? { url: param } : param
1226
return new Promise(resolve => chrome.tabs.create(prop, tab => {
@@ -15,6 +29,26 @@ export function createTab(param: chrome.tabs.CreateProperties | string): Promise
1529
}))
1630
}
1731

32+
/**
33+
* Create one tab after current tab.
34+
*
35+
* Must not be invocked in background.js
36+
*/
37+
export async function createTabAfterCurrent(url: string): Promise<ChromeTab> {
38+
const tab = await getCurrentTab()
39+
if (!tab) {
40+
// Current tab not found
41+
return createTab(url)
42+
} else {
43+
const { windowId, index: currentIndex } = tab
44+
return createTab({
45+
url,
46+
windowId,
47+
index: (currentIndex ?? -1) + 1
48+
})
49+
}
50+
}
51+
1852
export function listTabs(query?: chrome.tabs.QueryInfo): Promise<ChromeTab[]> {
1953
query = query || {}
2054
return new Promise(resolve => chrome.tabs.query(query, tabs => {

src/api/chrome/window.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ export function getFocusedNormalWindow(): Promise<chrome.windows.Window> {
2828
}
2929

3030
export function getWindow(id: number): Promise<chrome.windows.Window> {
31-
return new Promise(resolve =>
32-
chrome.windows.get(id)
33-
.then(win => resolve(win))
34-
.catch(_ => resolve(undefined))
35-
)
31+
return new Promise(resolve => chrome.windows.get(id, win => resolve(win)))
3632
}
3733

3834
type _Handler = (windowId: number) => void
@@ -41,5 +37,5 @@ export function onNormalWindowFocusChanged(handler: _Handler) {
4137
chrome.windows.onFocusChanged.addListener(windowId => {
4238
handleError('onWindowFocusChanged')
4339
handler(windowId)
44-
}, { windowTypes: ['normal'] })
40+
})
4541
}

src/app/components/analysis/components/summary/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function computeSummary(site: timer.site.SiteKey, rows: timer.stat.Row[]): Summa
2828

2929
const summary: Summary = { focus: 0, visit: 0, day: 0 }
3030
summary.firstDay = rows?.[0]?.date
31-
rows.forEach(({ focus, time: visit }) => {
31+
rows?.forEach(({ focus, time: visit }) => {
3232
summary.focus += focus
3333
summary.visit += visit
3434
focus && (summary.day += 1)

src/app/components/common/content-container.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
2-
* Copyright (c) 2021 Hengyang Zhang
2+
* Copyright (c) 2021-present Hengyang Zhang
33
*
44
* This software is released under the MIT License.
55
* https://opensource.org/licenses/MIT
66
*/
77

8-
import { ElCard } from "element-plus"
8+
import { ElCard, ElScrollbar } from "element-plus"
99
import ContentCard from "./content-card"
1010
import { defineComponent, h, useSlots } from "vue"
1111

@@ -19,7 +19,7 @@ const _default = defineComponent(() => {
1919
} else {
2020
content && children.push(h(ContentCard, () => h(content)))
2121
}
22-
return () => h("div", { class: "content-container" }, children)
22+
return () => h(ElScrollbar, () => h("div", { class: "content-container" }, children))
2323
})
2424

2525
export default _default

0 commit comments

Comments
 (0)