Skip to content

Commit c4e7079

Browse files
committed
增加灵动岛
1 parent 536be76 commit c4e7079

26 files changed

+753
-557
lines changed

components.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export {}
77

88
declare module '@vue/runtime-core' {
99
export interface GlobalComponents {
10+
ElAlert: typeof import('element-plus/es')['ElAlert']
1011
ElButton: typeof import('element-plus/es')['ElButton']
1112
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
1213
ElForm: typeof import('element-plus/es')['ElForm']

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
"dependencies": {
2929
"@vueuse/core": "^9.4.0",
3030
"@vueuse/integrations": "^9.6.0",
31-
"@widget-js/core": "^0.1.15",
32-
"@widget-js/vue3": "^0.0.11",
31+
"@vueuse/motion": "2.0.0-beta.12",
32+
"@widget-js/core": "^0.1.16",
33+
"@widget-js/vue3": "^0.1.18",
3334
"animate.css": "^4.1.1",
3435
"axios": "^1.1.3",
3536
"color": "^4.2.3",
@@ -72,8 +73,8 @@
7273
"@vue/cli-service": "~5.0.0",
7374
"@vue/compiler-sfc": "^3.2.45",
7475
"@vue/eslint-config-typescript": "^9.1.0",
75-
"@widget-js/cli": "^1.0.5",
76-
"@widget-js/webpack-plugin": "^1.0.1",
76+
"@widget-js/cli": "^1.0.7",
77+
"@widget-js/webpack-plugin": "^1.0.5",
7778
"archiver": "^5.3.1",
7879
"babel-loader": "^8.3.0",
7980
"css-loader": "^6.7.2",

src/main.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {WidgetJsPlugin} from "@widget-js/vue3";
66
import '@widget-js/vue3/dist/style.css'
77
import '@widget-js/vue3/dist/mingcute_icon/font/Mingcute.css'
88
import {createPinia} from "pinia";
9+
import {MotionPlugin} from '@vueuse/motion'
910

10-
createApp(App).use(WidgetJsPlugin).use(router).use(createPinia()).mount('#app')
11+
createApp(App).use(WidgetJsPlugin).use(MotionPlugin)
12+
.use(router).use(createPinia()).mount('#app')
1113

src/widgets/birthday-list/BirthdayListWidget.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import dayjs, {Dayjs} from "dayjs";
4646
import {Lunar, LunarMonth, Solar, SolarMonth} from 'lunar-typescript';
4747
import BirthdayListData, {BirthdayPeople} from "@/widgets/birthday-list/model/BirthdayListData";
48-
import {WidgetApi} from "../../../../core";
48+
import {WidgetApi} from "@widget-js/core";
4949
// import {delay} from "lodash";
5050
//import BirthdayListData from './model/BirthdayListData';
5151

src/widgets/birthday-list/BirthdayListWidgetView.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {Solar} from 'lunar-typescript';
99
import BirthdayListWidget from "./BirthdayListWidget.vue";
1010
import BirthdayListData from "@/widgets/birthday-list/model/BirthdayListData";
1111
import {useWidget} from "@widget-js/vue3";
12-
import {BrowserWindowApi, WidgetApi} from "../../../../core";
12+
import {BrowserWindowApi, WidgetApi} from "@widget-js/core";
1313
1414
//默认数据
1515
const previewData = new BirthdayListData("");

src/widgets/dynamic-island/DynamicIsland.widget.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const name = "cn.widgetjs.widgets.dynamic_island";
44
//组件标题
55
const title = {"zh": "灵动岛"};
66
//组件描述
7-
const description = {"zh": ""};
7+
const description = {"zh": "丝般顺滑的灵动通知组件"};
88
//组件关键词
99
const keywords = [WidgetKeyword.RECOMMEND];
1010
//组件路由地址
@@ -20,12 +20,12 @@ const DynamicIslandWidgetDefine = new Widget({
2020
lang: "zh",
2121
url: url,
2222
configUrl: configUrl,
23-
width: 4,
23+
width: 6,
2424
height: 4,
25-
minWidth: 4,
26-
maxWidth: 4,
25+
minWidth: 6,
26+
maxWidth: 6,
2727
minHeight: 4,
28-
maxHeight: 4
28+
maxHeight: 4,
2929
})
3030

3131
export default DynamicIslandWidgetDefine;

src/widgets/dynamic-island/DynamicIslandConfigView.vue

+27-20
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,53 @@
11
<template>
22

3-
<widget-edit-dialog :widget-params="widgetParams" :option="widgetConfigOption"
4-
:widget-data="widgetData"
5-
@confirm="onSaveClick()">
6-
<template v-slot:widget>
7-
<!-- 组件配置内容 -->
8-
<dynamic-island-widget :style="{
9-
width:`${widgetParams.widthPx}px`,
10-
height:`${widgetParams.heightPx}px`
11-
}" :background-color="widgetData.backgroundColor"></dynamic-island-widget>
12-
</template>
13-
<template v-slot:form>
14-
<!-- TODO 这里写自定义表单内容 -->
15-
</template>
16-
</widget-edit-dialog>
3+
<widget-edit-dialog :widget-params="widgetParams" :option="widgetConfigOption"
4+
:widget-data="widgetData"
5+
@confirm="onSaveClick()">
6+
<template v-slot:form>
7+
<widget-checkbox-field v-model:checked="widgetData.enable" label="启用久坐提醒"/>
8+
<widget-slider-field v-model:value="widgetData.sitInterval" label="久坐时长(分钟)" :min="5" :max="120"/>
9+
<widget-slider-field v-model:value="widgetData.breakInterval" label="休息时长(分钟)" :min="1" :max="60"/>
10+
<widget-slider-field v-model:value="widgetData.usageInterval" label="检测阈值(分钟)" :min="1" :max="120"/>
11+
<el-alert type="info" :closable="false">
12+
<p>检测阈值:多久没使用鼠标视为离开电脑</p>
13+
</el-alert>
14+
</template>
15+
</widget-edit-dialog>
1716
</template>
1817

1918
<script lang="ts">
2019
2120
import DynamicIslandWidget from "./DynamicIslandWidget.vue";
2221
import {useWidget, WidgetConfigOption, WidgetEditDialog} from "@widget-js/vue3";
23-
import {WidgetData, WidgetDataRepository} from "@widget-js/core";
22+
import {NotificationApi, WidgetApi} from "@widget-js/core";
2423
import {reactive} from "vue";
24+
import {SitReminder} from "@/widgets/dynamic-island/model/SitReminder";
2525
2626
export default {
2727
name: "",
2828
components: {DynamicIslandWidget, WidgetEditDialog},
2929
setup() {
30-
const {widgetData, widgetParams} = useWidget(WidgetData)
31-
30+
const name = "cn.widgetjs.widget.dynamic_island.sit_reminder";
31+
const sitReminder = new SitReminder(name);
32+
const {widgetData, widgetParams} = useWidget(SitReminder, {
33+
defaultData: sitReminder,
34+
loadDataByWidgetName: true,
35+
widgetName: name
36+
})
3237
//修改成需要设置组件参数配置
3338
const widgetConfigOption = reactive(new WidgetConfigOption({
3439
custom: true,
35-
backgroundColor: true,
36-
borderRadius: true
40+
backgroundColor: false,
41+
borderRadius: false,
42+
preview: false
3743
}));
3844
3945
return {widgetData, widgetParams, widgetConfigOption}
4046
},
4147
methods: {
4248
async onSaveClick() {
43-
await WidgetDataRepository.save(this.widgetData);
49+
await WidgetApi.saveDataByName(this.widgetData);
50+
NotificationApi.info(this.widgetData.breakInterval)
4451
window.close();
4552
}
4653
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import DynamicIslandWidget from './DynamicIslandWidget.vue';
22
import dayjs from "dayjs";
3+
import {NotificationState} from "@/widgets/dynamic-island/model/NotificationState";
4+
import {NotificationType} from "@widget-js/core";
35

46
export default {
57
title: 'Widget/DynamicIsland',
68
component: DynamicIslandWidget,
79
argTypes: {
8-
size: {control: 'select', options: ['small', 'default', 'large']},
9-
targetTime: {control: 'date'},
10-
type: {
10+
// size: {control: 'select', options: ['small', 'default', 'large']},
11+
state: {
1112
control: 'select',
12-
options: ['call', 'countdown', 'advance-countdown', 'error', 'success', 'warning', 'info'],
13-
}
13+
options: [NotificationState.HIDE, NotificationState.SMALL, NotificationState.NORMAL, NotificationState.LARGE]
14+
},
1415
},
1516
};
1617

@@ -25,77 +26,81 @@ const Template = (args: any) => ({
2526
export const MessageError = Template.bind({})
2627
// @ts-ignore
2728
MessageError.args = {
28-
show: true,
29-
type: 'error',
30-
size: 'small',
31-
message: "错误信息"
29+
notification: {
30+
type: 'error',
31+
message: "错误信息",
32+
},
33+
state: NotificationState.SMALL
3234
}
3335
export const MessageInfo = Template.bind({})
3436
// @ts-ignore
3537
MessageInfo.args = {
36-
show: true,
37-
type: 'info',
38-
size: 'small',
39-
message: "Hello World"
38+
notification: {
39+
type: 'info',
40+
message: "Hello World",
41+
},
42+
state: NotificationState.SMALL
4043
}
4144
export const MessageSuccess = Template.bind({})
4245
// @ts-ignore
4346
MessageSuccess.args = {
44-
show: true,
45-
type: 'success',
46-
size: 'small',
47-
message: "Hello World"
47+
notification: {
48+
type: 'success',
49+
message: "Hello World",
50+
},
51+
state: NotificationState.SMALL,
4852
}
4953

5054
export const MessageWarning = Template.bind({})
5155
// @ts-ignore
5256
MessageWarning.args = {
53-
show: true,
54-
type: 'warning',
55-
size: 'small',
56-
message: "警告信息"
57+
notification: {
58+
type: 'warning',
59+
message: "警告信息",
60+
},
61+
state: NotificationState.SMALL,
5762
}
5863

5964
export const Countdown = Template.bind({})
6065
const date = dayjs('2023-01-01');
6166

6267
// @ts-ignore
6368
Countdown.args = {
64-
show: true,
65-
type: 'countdown',
66-
size: 'small',
67-
message: '新年倒计时',
68-
targetTime: date.toISOString(),
69+
notification: {
70+
type: 'countdown',
71+
message: "新年倒计时",
72+
backgroundColor: "rgba(0,0,0,0.5)",
73+
targetTime: date.toISOString(),
74+
},
75+
state: NotificationState.SMALL,
6976
}
7077

7178
export const CountdownAdvance = Template.bind({})
7279
// @ts-ignore
7380
CountdownAdvance.args = {
74-
show: true,
75-
type: 'advance-countdown',
76-
size: 'default',
77-
message: '恭喜发财',
78-
title: '新年倒计时',
79-
targetTime: date.toISOString(),
80-
}
81-
82-
export const Call = Template.bind({})
83-
// @ts-ignore
84-
Call.args = {
85-
show: true,
86-
type: 'call',
87-
size: 'default',
88-
message: '下班提醒',
89-
title: '章鱼哥',
81+
notification: {
82+
type: 'advance-countdown',
83+
title: "新年倒计时",
84+
message: '恭喜发财',
85+
backgroundColor: "rgba(0,0,0,0.5)",
86+
targetTime: date.toISOString(),
87+
},
88+
state: NotificationState.NORMAL,
9089
}
9190

9291

93-
export const Alert = Template.bind({})
92+
export const Reminder = Template.bind({})
9493
// @ts-ignore
95-
Alert.args = {
96-
show: true,
97-
type: 'alert',
98-
size: 'large',
99-
message: '您已经连续使用电脑45分钟',
100-
title: '久坐提醒',
94+
Reminder.args = {
95+
state: NotificationState.LARGE,
96+
notification: {
97+
type: "reminder",
98+
message: '您已经连续使用电脑45分钟',
99+
state: NotificationState.LARGE,
100+
title: '久坐提醒',
101+
icon: 'computer_line',
102+
color: '#5D8AC8',
103+
cancelButtonText:"知道了",
104+
confirmButtonText:"休息一下",
105+
}
101106
}

0 commit comments

Comments
 (0)