Skip to content

Commit dd4e1c9

Browse files
committed
Merge from master
2 parents bcf0096 + 8caa515 commit dd4e1c9

File tree

31 files changed

+530
-234
lines changed

31 files changed

+530
-234
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 ZHY
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
[![Chrome](https://img.shields.io/chrome-web-store/v/dkdhhcbjijekmneelocdllcldcpmekmm?label=Google%20Chrome)](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?hl=zh-CN)
2424
[![Firefox](https://img.shields.io/amo/v/2690100?color=green&label=Mozilla%20Firefox)](https://addons.mozilla.org/zh-CN/firefox/addon/web%E6%99%82%E9%96%93%E7%B5%B1%E8%A8%88/)
25-
[![Edge](https://img.shields.io/badge/dynamic/json?label=Microsoft%20Edge&query=%24.version&url=https%3A%2F%2Fmicrosoftedge.microsoft.com%2Faddons%2Fgetproductdetailsbycrxid%2Ffepjgblalcnepokjblgbgmapmlkgfahc)](https://microsoftedge.microsoft.com/addons/detail/timer-running-browsin/fepjgblalcnepokjblgbgmapmlkgfahc)
25+
[![Edge](https://img.shields.io/badge/dynamic/json?label=Microsoft%20Edge&prefix=v&query=%24.version&url=https%3A%2F%2Fmicrosoftedge.microsoft.com%2Faddons%2Fgetproductdetailsbycrxid%2Ffepjgblalcnepokjblgbgmapmlkgfahc)](https://microsoftedge.microsoft.com/addons/detail/timer-running-browsin/fepjgblalcnepokjblgbgmapmlkgfahc)
2626

2727
## 开发
2828

@@ -38,16 +38,7 @@
3838

3939
- 欢迎大家 PR, PR 之前请先创建 ISSUE
4040

41-
## DEBUG
41+
## TODO
4242

43-
- 在控制台下可以开启数据存取日志
43+
请查看 [功能迭代 RoadMap](https://github.com/sheepzh/timer/projects/1) 项目
4444

45-
```JavaScript
46-
window.timer.openLog()
47-
```
48-
49-
- 关闭日志
50-
51-
```JavaScript
52-
window.timer.closeLog()
53-
```

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "timer",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "Web timer",
55
"homepage": "https://github.com/sheepzh/timer",
66
"scripts": {
@@ -26,6 +26,7 @@
2626
"eslint": "^7.28.0",
2727
"filemanager-webpack-plugin": "^5.0.0",
2828
"generate-json-webpack-plugin": "^2.0.0",
29+
"jest": "^27.0.6",
2930
"node-sass": "^6.0.0",
3031
"sass-loader": "^12.1.0",
3132
"style-loader": "^2.0.0",

src/app/components/clear/filter/date-filter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const basePickerProps = {
3333
size: 'mini',
3434
style: 'width:250px;',
3535
startPlaceholder: '1994/12/15',
36+
format: "YYYY/MM/DD",
3637
endPlaceholder: yesterdayMsg,
3738
type: 'daterange',
3839
disabledDate(date: Date) { return date.getTime() > yesterday },

src/app/components/report/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import filter, { FilterProps } from "./filter"
1010
import pagination, { PaginationProps } from "./pagination"
1111
import { renderContentContainer } from '../common/content-container'
1212
import { QueryData, PaginationInfo } from '../common/constants'
13+
import { useRouter } from 'vue-router'
1314

1415
const hostRef: Ref<string> = ref('')
1516
const now = new Date()
@@ -80,7 +81,8 @@ const tableProps: TableProps = {
8081
whitelistRef,
8182
dateRangeRef,
8283
dataRef,
83-
sortRef
84+
sortRef,
85+
router: undefined
8486
}
8587

8688
const filterProps: FilterProps = {
@@ -101,4 +103,9 @@ const paginationProps: PaginationProps = {
101103

102104
const childNodes = () => [filter(filterProps), table(tableProps), pagination(paginationProps)]
103105

104-
export default defineComponent(() => renderContentContainer(childNodes))
106+
export default defineComponent(() => {
107+
const router = useRouter()
108+
tableProps.router = router
109+
console.log(router)
110+
return renderContentContainer(() => childNodes())
111+
})

src/app/components/report/table-column/date.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { dateFormatter } from "../formatter"
1111
const dateColProp = {
1212
prop: 'date',
1313
label: t(msg => msg.item.date),
14-
minWidth: 200,
14+
minWidth: 135,
1515
align: 'center',
1616
sortable: 'custom'
1717
}

src/app/components/report/table-column/host.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,15 @@ const host2ElLink = (host: string, iconUrl: string) => {
1414
)
1515
const icon = h('span',
1616
{ style: 'height:23px;line-height:23px;padding-left:2px;' },
17-
h('img',
18-
{
19-
src: iconUrl,
20-
width: 12,
21-
height: 12
22-
}
23-
)
17+
h('img', { src: iconUrl, width: 12, height: 12 })
2418
)
2519
return [link, icon]
2620
}
2721

2822
const hostColProp = {
2923
prop: 'host',
3024
label: t(msg => msg.item.host),
31-
minWidth: 300,
25+
minWidth: 210,
3226
sortable: 'custom',
3327
align: 'center'
3428
}

src/app/components/report/table-column/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const columns = (props: ColumnProps) => {
1010
props.mergeDateRef.value || result.push(dateCol())
1111
result.push(hostCol(props))
1212
result.push(...itemColumns(props))
13-
!props.mergeDomainRef.value && result.push(operationButtons(props))
13+
result.push(operationButtons(props))
1414
return result
1515
}
1616

src/app/components/report/table-column/item-columns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const dataCol = (itemKey: keyof ItemMessage, propName: keyof SiteItemVal, fomatt
1414
h(ElTableColumn, {
1515
prop: propName,
1616
label: t(msg => msg.item[itemKey]),
17-
minWidth: 220,
17+
minWidth: 130,
1818
align: 'center',
1919
sortable: 'custom'
2020
}, { default: ({ row }: { row: SiteInfo }) => fomatter(row[propName]) })

src/app/components/report/table-column/operation.ts

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Generate operation butons
2+
* Generate operation buttons
33
*/
44
import { h, ref, Ref } from 'vue'
55
import { ElButton, ElMessage, ElPopconfirm, ElTableColumn } from "element-plus"
@@ -12,6 +12,8 @@ import { formatTime } from '../../../../util/time'
1212
import { dateFormatter } from '../formatter'
1313
import { ReportMessage } from '../../../locale/components/report'
1414
import { QueryData } from '../../common/constants'
15+
import { LocationQueryRaw, Router } from 'vue-router'
16+
import { TRENDER_ROUTE } from '../../../router/constants'
1517

1618
const timerDatabase = new TimerDatabase(chrome.storage.local)
1719

@@ -23,7 +25,9 @@ type Props = {
2325
queryData: QueryData
2426
whitelistRef: Ref<string[]>
2527
mergeDateRef: Ref<boolean>
28+
mergeDomainRef: Ref<boolean>
2629
dateRangeRef: Ref<Array<Date>>
30+
router: Router
2731
}
2832

2933
export type OperationButtonColumnProps = Props
@@ -116,7 +120,6 @@ const add2WhitelistButton = (props: Props, { host }: SiteInfo) => operationButto
116120
})
117121

118122
// Remove from whitelist
119-
120123
const removeFromWhitelistButton = (props: Props, { host }: SiteInfo) => operationButton({
121124
confirmTitle: t(msg => msg.setting.whitelist.removeConfirmMsg, { url: host }),
122125
buttonType: 'primary',
@@ -125,24 +128,44 @@ const removeFromWhitelistButton = (props: Props, { host }: SiteInfo) => operatio
125128
onConfirm: () => operateTheWhitelist(whitelistService.remove(host), props, 'removeFromWhitelist')
126129
})
127130

131+
function handleClickJump(props: Props, { host }: SiteInfo) {
132+
const query: LocationQueryRaw = {
133+
host,
134+
merge: props.mergeDomainRef.value ? '1' : '0',
135+
}
136+
props.router.push({ path: TRENDER_ROUTE, query })
137+
}
138+
139+
// Jump to the trender
140+
const jumpTowardTheTrender = (props: Props, row: SiteInfo) => h(ElButton, {
141+
icon: 'el-icon-stopwatch',
142+
size: 'mini',
143+
type: 'primary',
144+
onClick: () => handleClickJump(props, row)
145+
}, () => t(msg => msg.item.operation.jumpToTrender))
146+
128147
const operationContainer = (props: Props, row: SiteInfo) => {
129148
const operationButtons = []
130-
const { host, date } = row
131-
// Delete button
132-
operationButtons.push(deleteButton(props, row))
133-
134-
const existsInWhitelist = props.whitelistRef.value.includes(host)
135-
const whitelistButton = existsInWhitelist ? removeFromWhitelistButton(props, row) : add2WhitelistButton(props, row)
136-
operationButtons.push(whitelistButton)
149+
const { host } = row
150+
operationButtons.push(jumpTowardTheTrender(props, row))
151+
if (!props.mergeDomainRef.value) {
152+
// Delete button
153+
operationButtons.push(deleteButton(props, row))
154+
155+
const existsInWhitelist = props.whitelistRef.value.includes(host)
156+
const whitelistButton = existsInWhitelist ? removeFromWhitelistButton(props, row) : add2WhitelistButton(props, row)
157+
operationButtons.push(whitelistButton)
158+
}
137159
return operationButtons
138160
}
139161

140162
const tableColumnProps = {
141163
label: t(msg => msg.item.operation.label),
142-
minWidth: 240,
143-
align: 'center'
164+
align: 'center',
165+
fixed: 'right'
144166
}
145-
const _default = (props: Props) => h(ElTableColumn, tableColumnProps,
167+
const _default = (props: Props) => h(ElTableColumn,
168+
{ minWidth: props.mergeDomainRef.value ? 100 : 280, ...tableColumnProps },
146169
{
147170
default: (data: { row: SiteInfo }) => operationContainer(props, data.row)
148171
}

0 commit comments

Comments
 (0)