Skip to content

Commit d631ff6

Browse files
committed
Add feedback link while in zh_CN
1 parent 2ccf891 commit d631ff6

File tree

6 files changed

+37
-9
lines changed

6 files changed

+37
-9
lines changed

src/background/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ setInterval(() => {
1414
const now = Date.now()
1515
const realInterval = now - lastLoopTime
1616
lastLoopTime = now
17-
let focusHost = ''
1817
chrome.windows.getAll(windows => {
1918
const hostSet: Set<string> = new Set()
19+
let focusHost = ''
2020
Promise.all(
2121
windows.map(w => {
2222
const isFocusWindow = !!w.focused

src/locale/components/popup.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type PopupMessage = {
99
totalTime: string
1010
totalCount: string
1111
otherLabel: string
12+
feedback: string
1213
}
1314
const _default: Messages<PopupMessage> = {
1415
zh_CN: {
@@ -19,7 +20,8 @@ const _default: Messages<PopupMessage> = {
1920
saveAsImageTitle: '保存',
2021
totalTime: '共 {totalTime}',
2122
totalCount: '共 {totalCount} 次',
22-
otherLabel: '其他'
23+
otherLabel: '其他',
24+
feedback: '使用反馈'
2325
},
2426
en: {
2527
title: 'Today\'s Data',
@@ -29,7 +31,8 @@ const _default: Messages<PopupMessage> = {
2931
saveAsImageTitle: 'Save',
3032
totalTime: 'Total {totalTime}',
3133
totalCount: 'Total {totalCount} times',
32-
otherLabel: 'Others'
34+
otherLabel: 'Others',
35+
feedback: 'Feedback'
3336
},
3437
ja: {
3538
title: '今日のデータ',
@@ -39,7 +42,8 @@ const _default: Messages<PopupMessage> = {
3942
saveAsImageTitle: 'ダウンロード',
4043
totalTime: '合計 {totalTime}',
4144
totalCount: '合計 {totalCount} 回',
42-
otherLabel: 'その他'
45+
otherLabel: 'その他',
46+
feedback: 'フィードバック'
4347
}
4448
}
4549

src/popup/app.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ use([TitleComponent, ToolboxComponent, TooltipComponent, LegendComponent, Canvas
1010

1111
import { ElLink, ElOption, ElSelect, ElSwitch, ElTooltip } from "element-plus"
1212
import { computed, ComputedRef, defineComponent, h, onMounted, Ref, ref, watch } from "vue"
13-
import { t } from "../common/vue-i18n"
13+
import { locale, t } from "../common/vue-i18n"
1414
import SiteInfo, { ALL_SITE_ITEMS, SiteItem } from "../entity/dto/site-info"
1515
import timerService, { SortDirect, TimerQueryParam } from "../service/timer-service"
1616
import { IS_FIREFOX } from "../util/constant/environment"
17-
import { FAVICON } from "../util/constant/url"
17+
import { FAVICON, ZH_FEEDBACK_PAGE } from "../util/constant/url"
1818
import { formatPeriodCommon, formatTime } from "../util/time"
19+
import { Locale } from "../locale/constant"
1920

2021

2122
const DEFAULT_DATE_TYPE: SiteItem = 'focus'
@@ -232,8 +233,21 @@ export default defineComponent(() => {
232233
},
233234
() => t('popup.viewMore')
234235
)
236+
const feedback = () => h(ElLink,
237+
{
238+
icon: 'el-icon-edit',
239+
class: 'option-right',
240+
onClick: () => chrome.tabs.create({ url: ZH_FEEDBACK_PAGE })
241+
},
242+
() => t('popup.feedback'))
243+
244+
const footerItems = () => {
245+
const result = [versionAndTotalInfo(), typeSelect(), mergeDomainSwitch(), link()]
246+
locale === Locale.ZH_CN && result.push(feedback())
247+
return result
248+
}
235249

236-
const footer = () => h('div', { class: 'option-container' }, [versionAndTotalInfo(), typeSelect(), mergeDomainSwitch(), link()])
250+
const footer = () => h('div', { class: 'option-container' }, footerItems())
237251

238252
return () => h('div',
239253
{ style: `width:${width}; height:${height};` },

src/util/constant/url.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,11 @@ export const HOME_PAGE = homePage
2525
/**
2626
* @since 0.0.6
2727
*/
28-
export const GITHUB_ISSUE_ADD = 'https://github.com/sheepzh/timer/issues/new'
28+
export const GITHUB_ISSUE_ADD = 'https://github.com/sheepzh/timer/issues/new'
29+
30+
/**
31+
* Feedback powered by www.wjx.cn
32+
*
33+
* @since 0.1.6
34+
*/
35+
export const ZH_FEEDBACK_PAGE = 'https://www.wjx.cn/vj/YFWwHUy.aspx'

src/util/pattern.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
* @param url
55
*/
66
export function isBrowserUrl(url: string) {
7-
return /^([(chrome)|(edge)].*?):\/\/.*$/g.test(url) || /^about(-.+)?:/.test(url)
7+
return /^chrome.*?:\/\/.*$/.test(url)
8+
|| /^about(-.+)?:/.test(url)
9+
|| /^edge.*?:\/\/.*$/.test(url)
810
}
911

1012
const isNotValidPort = (portStr: string) => {

test/util/pattern.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ test('browser url', () => {
88
expect(isBrowserUrl('about:addons')).toBeTruthy()
99
// edge
1010
expect(isBrowserUrl('edge://extensions/')).toBeTruthy()
11+
expect(isBrowserUrl('https://www.jss.com.cn/')).toBeFalsy()
1112
})
1213

1314
test('ip and port', () => {

0 commit comments

Comments
 (0)