Skip to content

Commit 22eada5

Browse files
committed
🚧 Updated components after system date change
1 parent 4709e1a commit 22eada5

12 files changed

+96
-78
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
"@vueuse/integrations": "^10.5.0",
2222
"@vueuse/motion": "2.0.0-beta.12",
2323
"@vueuse/router": "^9.9.0",
24-
"@widget-js/core": "^0.11.22-beta.2",
24+
"@widget-js/core": "^0.11.22-beta.3",
2525
"@widget-js/vue3": "^0.11.21-rc.6",
2626
"animate.css": "^4.1.1",
2727
"axios": "^1.6.0",
2828
"color": "^4.2.3",
29-
"consola": "^2.15.3",
29+
"consola": "^3.2.3",
3030
"core-js": "^3.26.1",
3131
"dayjs": "^1.11.6",
3232
"driver.js": "^0.9.8",
@@ -83,7 +83,7 @@
8383
"webpack-cli": "^4.10.0"
8484
},
8585
"simple-git-hooks": {
86-
"pre-commit": "npm run remote && npx lint-staged"
86+
"pre-commit": "npx lint-staged"
8787
},
8888
"lint-staged": {
8989
"*.{js,ts,tsx,vue,md}": [

public/widget.json

+59-59
Original file line numberDiff line numberDiff line change
@@ -46,67 +46,67 @@
4646
"routes": []
4747
},
4848
{
49-
"name": "cn.widgetjs.widgets.water_reminder",
49+
"name": "cn.widgetjs.widgets.todo_list",
5050
"title": {
51-
"zh-CN": "喝水提醒"
51+
"zh-CN": "待办事项"
5252
},
5353
"description": {
54-
"zh-CN": "每天N杯水,养成好习惯"
54+
"zh-CN": "TODO待办事项"
5555
},
5656
"keywords": [
5757
"recommend"
5858
],
5959
"security": false,
6060
"permissions": [],
6161
"lang": "zh-CN",
62-
"width": 2,
63-
"height": 2,
64-
"maxWidth": 2,
62+
"width": 4,
63+
"height": 4,
64+
"maxWidth": 6,
6565
"webviewTag": false,
66-
"maxHeight": 2,
67-
"minWidth": 2,
68-
"minHeight": 2,
66+
"maxHeight": 6,
67+
"minWidth": 3,
68+
"minHeight": 3,
6969
"movable": true,
7070
"singleton": false,
7171
"resizable": true,
72-
"path": "/widget/water_reminder",
72+
"path": "/widget/todo_list",
7373
"meta": {},
74-
"backgroundThrottling": false,
75-
"previewImage": "/images/preview_water_reminder.png",
74+
"backgroundThrottling": true,
75+
"previewImage": "/images/preview_todo_list.png",
7676
"supportDeployMode": 17,
77-
"configPagePath": "/widget/config/water_reminder",
77+
"configPagePath": "/widget/config/todo_list",
7878
"routes": []
7979
},
8080
{
81-
"name": "cn.widgetjs.widgets.todo_list",
81+
"name": "cn.widgetjs.widgets.water_reminder",
8282
"title": {
83-
"zh-CN": "待办事项"
83+
"zh-CN": "喝水提醒"
8484
},
8585
"description": {
86-
"zh-CN": "TODO待办事项"
86+
"zh-CN": "每天N杯水,养成好习惯"
8787
},
8888
"keywords": [
8989
"recommend"
9090
],
9191
"security": false,
9292
"permissions": [],
9393
"lang": "zh-CN",
94-
"width": 4,
95-
"height": 4,
96-
"maxWidth": 6,
94+
"width": 2,
95+
"height": 2,
96+
"maxWidth": 2,
9797
"webviewTag": false,
98-
"maxHeight": 6,
99-
"minWidth": 3,
100-
"minHeight": 3,
98+
"maxHeight": 2,
99+
"minWidth": 2,
100+
"minHeight": 2,
101101
"movable": true,
102102
"singleton": false,
103103
"resizable": true,
104-
"path": "/widget/todo_list",
104+
"path": "/widget/water_reminder",
105105
"meta": {},
106-
"backgroundThrottling": true,
107-
"previewImage": "/images/preview_todo_list.png",
106+
"backgroundThrottling": false,
107+
"previewImage": "/images/preview_water_reminder.png",
108108
"supportDeployMode": 17,
109-
"configPagePath": "/widget/config/todo_list",
109+
"configPagePath": "/widget/config/water_reminder",
110110
"routes": []
111111
},
112112
{
@@ -237,6 +237,38 @@
237237
"configPagePath": "/widget/config/phone_reminder",
238238
"routes": []
239239
},
240+
{
241+
"name": "cn.widgetjs.widgets.labor_progress",
242+
"title": {
243+
"zh-CN": "打工进度"
244+
},
245+
"description": {
246+
"zh-CN": "打工人,打工魂"
247+
},
248+
"keywords": [
249+
"recommend"
250+
],
251+
"security": false,
252+
"permissions": [],
253+
"lang": "zh-CN",
254+
"width": 4,
255+
"height": 1,
256+
"maxWidth": 6,
257+
"webviewTag": false,
258+
"maxHeight": 2,
259+
"minWidth": 3,
260+
"minHeight": 1,
261+
"movable": true,
262+
"singleton": false,
263+
"resizable": true,
264+
"path": "/widget/labor_progress",
265+
"meta": {},
266+
"backgroundThrottling": true,
267+
"previewImage": "/images/preview_labor_progress.png",
268+
"supportDeployMode": 17,
269+
"configPagePath": "/widget/config/labor_progress",
270+
"routes": []
271+
},
240272
{
241273
"name": "cn.widgetjs.widgets.key_stroke",
242274
"title": {
@@ -366,38 +398,6 @@
366398
"configPagePath": "/widget/config/countdown",
367399
"routes": []
368400
},
369-
{
370-
"name": "cn.widgetjs.widgets.labor_progress",
371-
"title": {
372-
"zh-CN": "打工进度"
373-
},
374-
"description": {
375-
"zh-CN": "打工人,打工魂"
376-
},
377-
"keywords": [
378-
"recommend"
379-
],
380-
"security": false,
381-
"permissions": [],
382-
"lang": "zh-CN",
383-
"width": 4,
384-
"height": 1,
385-
"maxWidth": 6,
386-
"webviewTag": false,
387-
"maxHeight": 2,
388-
"minWidth": 3,
389-
"minHeight": 1,
390-
"movable": true,
391-
"singleton": false,
392-
"resizable": true,
393-
"path": "/widget/labor_progress",
394-
"meta": {},
395-
"backgroundThrottling": true,
396-
"previewImage": "/images/preview_labor_progress.png",
397-
"supportDeployMode": 17,
398-
"configPagePath": "/widget/config/labor_progress",
399-
"routes": []
400-
},
401401
{
402402
"name": "cn.widgetjs.widgets.clipboard",
403403
"title": {
@@ -466,4 +466,4 @@
466466
}
467467
],
468468
"pages": []
469-
}
469+
}

src/widgets/birthday-list/BirthdayListWidgetView.vue

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
useWidget,
55
} from '@widget-js/vue3'
66
import {
7-
BrowserWindowApi,
87
WidgetApi,
98
} from '@widget-js/core'
109
import BirthdayListWidget from './BirthdayListWidget.vue'
@@ -16,10 +15,7 @@ const {
1615
} = useWidget(BirthdayListData, { loadDataByWidgetName: true })
1716
1817
async function add() {
19-
const url = await WidgetApi.getWidgetConfigUrl(widgetData.value.name, widgetParams)
20-
if (url) {
21-
await BrowserWindowApi.openUrl(url)
22-
}
18+
await WidgetApi.openConfigPage(widgetParams.id!)
2319
}
2420
</script>
2521

src/widgets/countdown/CountdownWidget.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { computed } from 'vue'
33
import dayjs from 'dayjs'
44
import '@/common/dayjs-extend'
55
import Color from 'color'
6+
import { useAppBroadcast } from '@widget-js/vue3'
7+
import { SystemApiEvent } from '@widget-js/core'
68
79
export default {
810
name: 'CountdownWidget',
@@ -27,7 +29,9 @@ export default {
2729
const now = dayjs()
2830
return dayjs(props.date).diff(now, 'day')
2931
})
30-
32+
useAppBroadcast([SystemApiEvent.DATE_CHANGED], () => {
33+
days.effect.run()
34+
})
3135
const daysColor = computed(() => {
3236
const color = new Color(props.backgroundColor)
3337
return color.alpha(1).darken(0.7).toString()
@@ -128,7 +132,6 @@ export default {
128132
justify-items: center;
129133
display: flex;
130134
flex-direction: column;
131-
align-items: center;
132135
133136
.still {
134137
color: #878D9C;

src/widgets/countdown2/Countdown2.widget.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const name = 'cn.widgetjs.widgets.countdown2'
77
// 组件标题
88
const title = { 'zh-CN': '倒计时' }
99
// 组件描述
10-
const description = { 'zh-CN': '简单的倒计时组件,支持农历' }
10+
const description = { 'zh-CN': '日历样式的倒计时组件' }
1111
// 组件关键词
1212
const keywords = [WidgetKeyword.RECOMMEND]
1313
// 组件路由地址

src/widgets/countdown2/Countdown2Widget.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import dayjs from 'dayjs'
44
import '@/common/dayjs-extend'
55
import Color from 'color'
66
import { Lunar } from 'lunar-typescript'
7+
import { useAppBroadcast } from '@widget-js/vue3'
8+
import { SystemApiEvent } from '@widget-js/core'
79
810
export default {
911
name: 'Countdown2Widget',
@@ -28,7 +30,9 @@ export default {
2830
const now = dayjs()
2931
return dayjs(props.date).diff(now, 'day')
3032
})
31-
33+
useAppBroadcast([SystemApiEvent.DATE_CHANGED], () => {
34+
days.effect.run()
35+
})
3236
const titleBgColor = computed(() => {
3337
const color = new Color(props.primaryColor)
3438
return `linear-gradient(180deg,${color.toString()} 0%, ${color.darken(0.2).toString()} 100%)`
@@ -133,7 +137,6 @@ $border-radius: var(--widget-border-radius);
133137
justify-items: center;
134138
display: flex;
135139
flex-direction: column;
136-
align-items: center;
137140
138141
.days {
139142
font-size: var(--widget-font-size);

src/widgets/countdown2/Countdown2WidgetView.vue

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const {
2424
:primary-color="widgetData.theme.primaryColor"
2525
:background-color="widgetData.theme.backgroundColor"
2626
:is-lunar="widgetData.dateType === DateType.LUNAR"
27-
:font-size="fontSize"
2827
/>
2928
</WidgetWrapper>
3029
</template>

src/widgets/labor-progress/LaborProgressWidget.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ $progressHeight: 56px;
207207
.outline {
208208
box-sizing: border-box;
209209
height: calc($progressHeight / 2);
210-
border: 4px solid #422e26;
210+
border: 2px solid #422e26;
211211
border-radius: 39px;
212212
position: absolute;
213213
width: 100%;
214214
215215
.progress {
216-
height: calc($progressHeight / 2 - 6px);
216+
height: calc($progressHeight / 2 - 2.2px);
217217
left: 0;
218218
width: 0;
219219
transition-property: width;
@@ -225,7 +225,7 @@ $progressHeight: 56px;
225225
226226
.percent {
227227
position: absolute;
228-
top: 0px;
228+
top: 0;
229229
color: #453840;
230230
font-weight: bold;
231231
}

src/widgets/labor-progress/LaborProgressWidgetView.vue

+7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<script lang="ts" setup>
22
import {
33
WidgetWrapper,
4+
useAppBroadcast,
45
useWidget,
56
} from '@widget-js/vue3'
67
import { ref } from 'vue'
8+
import { SystemApiEvent } from '@widget-js/core'
79
import LaborProgressWidget from './LaborProgressWidget.vue'
810
import LaborProgressData from '@/widgets/labor-progress/model/LaborProgressData'
911
@@ -17,6 +19,11 @@ const { widgetData } = useWidget(LaborProgressData, {
1719
}
1820
},
1921
})
22+
23+
useAppBroadcast([SystemApiEvent.DATE_CHANGED], () => {
24+
startTime.value = widgetData.value.getStartTime()
25+
endTime.value = widgetData.value.getEndTime()
26+
})
2027
</script>
2128

2229
<template>

src/widgets/phone-reminder/PhoneReminderWidgetView.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
import {
33
BrowserWindowApi,
44
NotificationApi,
5+
SystemApiEvent,
56
} from '@widget-js/core'
67
import {
78
computed,
89
ref,
910
} from 'vue'
1011
import { useIntervalFn } from '@vueuse/core'
11-
import { useWidget } from '@widget-js/vue3'
12+
import { useAppBroadcast, useWidget } from '@widget-js/vue3'
1213
import dayjs from 'dayjs'
1314
import duration from 'dayjs/plugin/duration'
1415
import { PhoneReminderData } from '@/widgets/phone-reminder/model/PhoneReminder'
@@ -38,6 +39,10 @@ useIntervalFn(async () => {
3839
}
3940
}
4041
}, 1000)
42+
43+
useAppBroadcast([SystemApiEvent.DATE_CHANGED], () => {
44+
enableReminders.effect.run()
45+
})
4146
</script>
4247

4348
<template>

src/widgets/water-reminder/WaterReminderConfigView.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ BrowserWindowApi.setup({
1515
})
1616
1717
const cup = ref(0)
18-
18+
const defaultData = new WaterReminderModel()
19+
defaultData.theme.backgroundColor = '#fff'
20+
defaultData.theme.color = '#092239'
21+
defaultData.theme.primaryColor = '#2596FF'
1922
const {
2023
widgetData,
2124
widgetParams,
2225
save,
2326
} = useWidget(WaterReminderModel, {
27+
defaultData,
2428
loadDataByWidgetName: true,
2529
onDataLoaded: (data) => {
2630
cup.value = data?.getTodayHistory() ?? 0

src/widgets/water-reminder/WaterReminderWidgetView.vue

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const cup = ref(0)
2727
const defaultData = new WaterReminderModel()
2828
defaultData.theme.backgroundColor = '#fff'
2929
defaultData.theme.color = '#092239'
30+
defaultData.theme.primaryColor = '#2596FF'
3031
const { widgetData } = useWidget(WaterReminderModel, {
3132
defaultData,
3233
onDataLoaded: (data) => {

0 commit comments

Comments
 (0)