Skip to content

Commit a0f2b16

Browse files
committed
Merge from main
2 parents ad08f4b + afdaacb commit a0f2b16

File tree

10 files changed

+101
-83
lines changed

10 files changed

+101
-83
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: Translation Issue / 翻译改善建议
3+
about: Improve the translation of this extension
4+
title: 'Report translation mistakes'
5+
labels: 'locale'
6+
assignees: ''
7+
---
8+
9+
## Any Snapshot?
10+
11+

README.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
[![](https://img.shields.io/amo/rating/2690100?color=green)](https://addons.mozilla.org/en-US/firefox/addon/2690100)
3535
[![Mozilla Add-on](https://img.shields.io/amo/users/2690100?color=green)](https://addons.mozilla.org/en-US/firefox/addon/2690100)
3636

37-
3837
## 截图
3938

4039
> 弹窗页展示今日数据
@@ -53,23 +52,30 @@
5352

5453
详细展示图文:[douban.com](https://www.douban.com/group/topic/213888429/)
5554

56-
## 开发
55+
## 贡献指南
56+
57+
如果你想参与到该项目的开源建设,可以考虑以下几种方式
58+
59+
#### 提交 Issue
60+
61+
如果您有一些好的想法,或者 bug 反馈,可以新建一条 [issue](https://github.com/sheepzh/timer/issues) 。作者会在第一时间进行回复。
62+
63+
#### 参与开发
64+
65+
如果你知道如何开发浏览器扩展,并且熟悉该项目的技术栈 ( TypeScript + vue3 + ElementPlus ),也可以贡献代码:
66+
67+
1. Fork 自己的仓库
68+
2. 开发完成后请直接 PR 到 main 分支,并在 message 里关联指定的 issue
69+
70+
当然也欢迎新手同学使用该项目作为学习项目自己练手
5771

58-
```
59-
git clone https://github.com/sheepzh/timer.git
60-
cd timer
61-
npm install
62-
# 开发编译,输出目录为 dist_dev
63-
npm run dev
64-
# 生产编译,输出目录为 dist_prod 和 market_packages
65-
npm run build
66-
```
72+
#### 完善翻译
6773

68-
- 欢迎大家 PR, PR 之前请先创建 ISSUE
74+
除了简体中文外,该扩展另外的本地化语言都依赖机翻。所以也非常欢迎您在 [issue](https://github.com/sheepzh/timer/issues/new?assignees=&labels=locale&template=translation-------.md&title=Report+translation+mistakes) 里提交翻译建议。
6975

70-
## TODO
76+
#### 好评鼓励
7177

72-
请查看 [功能迭代 RoadMap](https://github.com/sheepzh/timer/projects/1) 项目
78+
至于最简单粗暴的贡献方式,当然是在 [Firefox](https://addons.mozilla.org/zh-CN/firefox/addon/web%E6%99%82%E9%96%93%E7%B5%B1%E8%A8%88/) / [Chrome](https://chrome.google.com/webstore/detail/%E7%BD%91%E8%B4%B9%E5%BE%88%E8%B4%B5-%E4%B8%8A%E7%BD%91%E6%97%B6%E9%97%B4%E7%BB%9F%E8%AE%A1/dkdhhcbjijekmneelocdllcldcpmekmm) / [Edge](https://microsoftedge.microsoft.com/addons/detail/timer-the-web-time-is-e/fepjgblalcnepokjblgbgmapmlkgfahc) 好评三连啦 XXD
7379

7480
## 致谢
7581

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "timer",
3-
"version": "0.9.3",
3+
"version": "0.9.4",
44
"description": "Web timer",
55
"homepage": "https://github.com/sheepzh/timer",
66
"scripts": {
@@ -54,4 +54,4 @@
5454
"vue": "^3.2.33",
5555
"vue-router": "^4.0.14"
5656
}
57-
}
57+
}

src/app/components/common/input-filter-item.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const _default = defineComponent({
1313
props: {
1414
placeholder: String
1515
},
16-
emits: ["clear", "enter"],
16+
emits: ["search"],
1717
setup(props, ctx) {
1818
const modelValue: Ref<string> = ref("")
1919
return () => h(ElInput, {
@@ -23,10 +23,11 @@ const _default = defineComponent({
2323
clearable: true,
2424
onClear() {
2525
modelValue.value = ''
26-
ctx.emit("clear")
26+
ctx.emit("search", "")
2727
},
2828
onInput: (val: string) => modelValue.value = val.trim(),
29-
onKeyup: (event: KeyboardEvent) => event.key === 'Enter' && ctx.emit("enter", modelValue.value)
29+
onKeyup: (event: KeyboardEvent) => event.key === 'Enter' && ctx.emit("search", modelValue.value),
30+
onBlur: (_event: FocusEvent) => ctx.emit("search", modelValue.value),
3031
})
3132
}
3233
})

src/app/components/limit/filter.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,10 @@ const _default = defineComponent({
3838
return () => [
3939
h(InputFilterItem, {
4040
placeholder: urlPlaceholder,
41-
onClear() {
42-
url.value = ""
41+
onSearch(searchVal: string) {
42+
url.value = searchVal
4343
handleChange()
4444
},
45-
onEnter(newVal: string) {
46-
url.value = newVal
47-
handleChange()
48-
}
4945
}),
5046
h(SwitchFilterItem, {
5147
label: onlyEnabledLabel,

src/app/components/report/filter/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,10 @@ const _default = defineComponent({
7272
return () => [
7373
h(InputFilterItem, {
7474
placeholder: hostPlaceholder,
75-
onClear() {
76-
host.value = ""
75+
onSearch(searchVal: string) {
76+
host.value = searchVal
7777
handleChange()
7878
},
79-
onEnter(newVal: string) {
80-
host.value = newVal
81-
handleChange()
82-
}
8379
}),
8480
h(DateRangeFilterItem, {
8581
startPlaceholder: dateStartPlaceholder,

src/app/components/site-manage/filter.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,15 @@ const _default = defineComponent({
4343
return () => [
4444
h(InputFilterItem, {
4545
placeholder: hostPlaceholder,
46-
onClear() {
47-
host.value = ""
46+
onSearch(searchVal: string) {
47+
host.value = searchVal
4848
handleChange()
4949
},
50-
onEnter(newVal: string) {
51-
host.value = newVal
52-
handleChange()
53-
}
5450
}),
5551
h(InputFilterItem, {
5652
placeholder: aliasPlaceholder,
57-
onClear() {
58-
alias.value = ""
59-
handleChange()
60-
},
61-
onEnter(newVal: string) {
62-
alias.value = newVal
53+
onSearch(searchVal: string) {
54+
alias.value = searchVal
6355
handleChange()
6456
}
6557
}),

src/app/layout/menu.ts

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ElIcon, ElMenu, ElMenuItem, ElMenuItemGroup, MenuItemRegistered } from
1010
import { RouteLocationNormalizedLoaded, Router, useRoute, useRouter } from "vue-router"
1111
import { I18nKey, t } from "@app/locale"
1212
import { MenuMessage } from "@app/locale/components/menu"
13-
import { GITHUB_ISSUE_ADD, HOME_PAGE, MEAT_URL, TU_CAO_PAGE } from "@util/constant/url"
13+
import { HOME_PAGE, MEAT_URL, TU_CAO_PAGE } from "@util/constant/url"
1414
import { Aim, Calendar, ChatSquare, Folder, Food, HotWater, Rank, SetUp, Stopwatch, Sugar, Tickets, Timer, TrendCharts } from "@element-plus/icons-vue"
1515
import ElementIcon from "../element-ui/icon"
1616
import { locale } from "@util/i18n"
@@ -34,37 +34,46 @@ type _RouteProps = {
3434
}
3535

3636
/**
37-
* Use TU_CAO_PAGE, if the locale is Chinese
38-
*
39-
* @since 0.9.0
37+
* Generate menu items after locale initialized
4038
*/
41-
let realFeedbackLink: string = GITHUB_ISSUE_ADD
42-
if (locale === 'zh_CN') {
43-
realFeedbackLink = TU_CAO_PAGE
44-
}
45-
46-
const OTHER_MENU_ITEMS: _MenuItem[] = [{
47-
title: 'feedback',
48-
href: realFeedbackLink,
49-
icon: ChatSquare,
50-
index: '_feedback'
51-
}]
52-
HOME_PAGE && OTHER_MENU_ITEMS.push({
53-
title: 'rate',
54-
href: HOME_PAGE,
55-
icon: Sugar,
56-
index: '_rate'
57-
})
58-
OTHER_MENU_ITEMS.push({
59-
title: 'meat',
60-
href: MEAT_URL,
61-
icon: Food,
62-
index: '_meat'
63-
})
39+
function generateMenus(): _MenuGroup[] {
40+
/**
41+
* Use TU_CAO_PAGE, if the locale is Chinese
42+
*
43+
* @since 0.9.0
44+
*/
45+
const isZhCn = locale === "zh_CN"
46+
47+
const otherMenuItems: _MenuItem[] = []
48+
HOME_PAGE && otherMenuItems.push({
49+
title: 'rate',
50+
href: HOME_PAGE,
51+
icon: Sugar,
52+
index: '_rate'
53+
})
54+
if (isZhCn) {
55+
otherMenuItems.push({
56+
title: 'feedback',
57+
href: TU_CAO_PAGE,
58+
icon: ChatSquare,
59+
index: '_feedback'
60+
}, {
61+
title: 'meat',
62+
href: MEAT_URL,
63+
icon: Food,
64+
index: '_meat'
65+
})
66+
} else {
67+
otherMenuItems.push({
68+
title: 'translationMistake',
69+
href: 'https://github.com/sheepzh/timer/issues/new?assignees=&labels=locale&template=translation-------.md&title=Report+translation+mistakes',
70+
icon: ChatSquare,
71+
index: '_i18n'
72+
})
73+
}
6474

65-
// All menu items
66-
const ALL_MENU: _MenuGroup[] = [
67-
{
75+
// All menu items
76+
return [{
6877
title: 'data',
6978
children: [{
7079
title: 'dashboard',
@@ -115,9 +124,9 @@ const ALL_MENU: _MenuGroup[] = [
115124
}]
116125
}, {
117126
title: 'other',
118-
children: OTHER_MENU_ITEMS
119-
}
120-
]
127+
children: otherMenuItems
128+
}]
129+
}
121130

122131
function openMenu(route: string, title: I18nKey, routeProps: UnwrapRef<_RouteProps>) {
123132
const routerVal = routeProps.router
@@ -178,7 +187,7 @@ const _default = defineComponent({
178187

179188
return () => h(ElMenu,
180189
{ defaultActive: routeProps.current.path },
181-
() => ALL_MENU.map(menu => renderMenu(menu, routeProps))
190+
() => generateMenus().map(menu => renderMenu(menu, routeProps))
182191
)
183192
}
184193
})

src/app/locale/components/menu.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type MenuMessage = {
2525
feedback: string
2626
rate: string
2727
meat: string
28+
translationMistake: string
2829
}
2930
const _default: Messages<MenuMessage> = {
3031
zh_CN: {
@@ -44,7 +45,8 @@ const _default: Messages<MenuMessage> = {
4445
other: '其他',
4546
feedback: '有什么反馈吗?',
4647
rate: '打个分吧!',
47-
meat: '请作者吃饭~'
48+
meat: '请作者吃饭~',
49+
translationMistake: '提交翻译错误'
4850
},
4951
zh_TW: {
5052
dashboard: '儀錶盤',
@@ -63,7 +65,8 @@ const _default: Messages<MenuMessage> = {
6365
other: '其他',
6466
feedback: '有什麼反饋嗎?',
6567
rate: '打個分吧!',
66-
meat: '請作者吃飯~'
68+
meat: '請作者吃飯~',
69+
translationMistake: '改善翻译~'
6770
},
6871
en: {
6972
dashboard: "Dashboard",
@@ -82,7 +85,8 @@ const _default: Messages<MenuMessage> = {
8285
option: 'Options',
8386
feedback: 'Feedback',
8487
rate: 'Rate It',
85-
meat: 'Invite the author to dinner'
88+
meat: 'Invite the author to dinner',
89+
translationMistake: 'Improve translation'
8690
},
8791
ja: {
8892
dashboard: 'ダッシュボード',
@@ -101,7 +105,8 @@ const _default: Messages<MenuMessage> = {
101105
option: '拡張設定',
102106
feedback: 'フィードバック',
103107
rate: 'それを評価',
104-
meat: '著者を夕食に招待する'
108+
meat: '著者を夕食に招待する',
109+
translationMistake: '翻訳を改善する'
105110
}
106111
}
107112

src/service/components/host-merge-ruler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ export default class CustomizedHostMergeRuler implements IHostMergeRuler {
8181
matchResult && (merged = matchResult.result)
8282
if (merged === undefined) {
8383
// No rule matched
84-
return isIpAndPort(origin) ? origin : psl.get(origin)
84+
return isIpAndPort(origin)
85+
? origin
86+
: psl.get(origin) || this.merge0(2, origin)
8587
} else {
8688
return this.merge0(merged, origin)
8789
}
@@ -90,4 +92,4 @@ export default class CustomizedHostMergeRuler implements IHostMergeRuler {
9092
private merge0(merged: string | number, origin: string): string {
9193
return typeof merged === 'string' ? (merged === '' ? origin : merged) : getTheSuffix(origin, merged)
9294
}
93-
}
95+
}

0 commit comments

Comments
 (0)