Skip to content

Commit c13d6aa

Browse files
author
sheepzh
committed
Support to open the option page in popup (#151)
1 parent 3f1a1b9 commit c13d6aa

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/popup/components/chart/option.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { formatPeriodCommon, formatTime } from "@util/time"
1818
import { t } from "@popup/locale"
1919
import { getPrimaryTextColor, getSecondaryTextColor } from "@util/style"
2020
import { generateSiteLabel } from "@util/site"
21+
import { OPTION_ROUTE } from "@app/router/constants"
22+
import { getAppPageUrl } from "@util/constant/url"
23+
import { optionIcon } from "./toolbox-icon"
2124

2225
type EcOption = ComposeOption<
2326
| PieSeriesOption
@@ -114,6 +117,15 @@ const staticOptions: EcOption = {
114117
}),
115118
excludeComponents: ['toolbox'],
116119
pixelRatio: 1
120+
},
121+
// Customized tool's name must start with 'my'
122+
myOptions: {
123+
show: true,
124+
title: t(msg => msg.options),
125+
icon: optionIcon,
126+
onclick() {
127+
chrome.tabs.create({ url: getAppPageUrl(false, OPTION_ROUTE, { i: 'popup' }) })
128+
}
117129
}
118130
}
119131
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const optionIcon = 'path://' +
2+
'M499.612903 68.789677L134.35871 279.667613a24.774194 24.774194 0 0 0-12.387097 21.470968v421.739354a24.774194 24.774194 0 0 0 12.387097 21.454452L499.612903 955.210323a24.774194 24.774194 0 0 0 24.774194 0l365.254193-210.877936a24.774194 24.774194 0 0 0 12.387097-21.470968V301.138581a24.774194 24.774194 0 0 0-12.387097-21.454452L524.387097 68.789677a24.774194 24.774194 0 0 0-24.774194 0z m414.802581 167.969033a74.322581 74.322581 0 0 1 37.16129 64.363355v421.75587a74.322581 74.322581 0 0 1-37.16129 64.363355L549.16129 998.119226a74.322581 74.322581 0 0 1-74.32258 0L109.584516 787.24129a74.322581 74.322581 0 0 1-37.16129-64.363355V301.122065a74.322581 74.322581 0 0 1 37.16129-64.363355L474.83871 25.880774a74.322581 74.322581 0 0 1 74.32258 0l365.254194 210.877936zM512 685.419355c-95.777032 0-173.419355-77.642323-173.419355-173.419355S416.222968 338.580645 512 338.580645 685.419355 416.222968 685.419355 512 607.777032 685.419355 512 685.419355z m0-49.548387a123.870968 123.870968 0 1 0 0-247.741936 123.870968 123.870968 0 0 0 0 247.741936z'

src/popup/locale/messages.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type PopupMessage = {
1717
fileName: string
1818
saveAsImageTitle: string
1919
restoreTitle: string
20+
options: string
2021
totalTime: string
2122
totalCount: string
2223
averageTime: string
@@ -43,6 +44,7 @@ const _default: Messages<PopupMessage> = {
4344
fileName: '上网时长清单_{today}_by_{app}',
4445
saveAsImageTitle: '保存',
4546
restoreTitle: '刷新',
47+
options: '设置',
4648
totalTime: '共 {totalTime}',
4749
totalCount: '共 {totalCount} 次',
4850
averageTime: '平均每天 {value}',
@@ -67,6 +69,7 @@ const _default: Messages<PopupMessage> = {
6769
fileName: '上網時長清單_{today}_by_{app}',
6870
saveAsImageTitle: '保存',
6971
restoreTitle: '刷新',
72+
options: '設置',
7073
totalTime: '共 {totalTime}',
7174
totalCount: '共 {totalCount} 次',
7275
averageCount: '平均每天 {value} 次',
@@ -91,6 +94,7 @@ const _default: Messages<PopupMessage> = {
9194
fileName: 'Web_Time_List_{today}_By_{app}',
9295
saveAsImageTitle: 'Snapshot',
9396
restoreTitle: 'Restore',
97+
options: 'Options',
9498
totalTime: 'Total {totalTime}',
9599
totalCount: 'Total {totalCount} times',
96100
averageCount: '{value} times per day on average',
@@ -115,6 +119,7 @@ const _default: Messages<PopupMessage> = {
115119
fileName: 'オンライン時間_{today}_by_{app}',
116120
saveAsImageTitle: 'ダウンロード',
117121
restoreTitle: '刷新',
122+
options: '設定',
118123
totalTime: '合計 {totalTime}',
119124
totalCount: '合計 {totalCount} 回',
120125
averageTime: '1日平均 {value}',

0 commit comments

Comments
 (0)