Skip to content

Commit 7af0592

Browse files
rtugeekyee338024
authored andcommitted
Refactor widget configurations for sit reminder and labor progres s, add widget package management view, and enhance app language handling
1 parent b83e9e8 commit 7af0592

File tree

9 files changed

+138
-44
lines changed

9 files changed

+138
-44
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"@vueuse/motion": "2.0.0-beta.12",
2323
"@vueuse/router": "^9.9.0",
2424
"@vueuse/shared": "^13.5.0",
25-
"@widget-js/core": "workspace:*",
26-
"@widget-js/vue3": "workspace:*",
25+
"@widget-js/core": "^24.1.1-beta.75",
26+
"@widget-js/vue3": "^24.1.1-beta.74",
2727
"@widget-js/web-api": "24.1.1-beta.45",
2828
"animate.css": "^4.1.1",
2929
"axios": "^1.6.0",
@@ -59,7 +59,7 @@
5959
"@vue/cli-plugin-typescript": "~5.0.0",
6060
"@vue/cli-service": "~5.0.0",
6161
"@vue/compiler-sfc": "^3.2.45",
62-
"@widget-js/vite-plugin-widget": "^24.1.1-beta.41",
62+
"@widget-js/vite-plugin-widget": "^24.1.1-beta.71",
6363
"autoprefixer": "^10.4.13",
6464
"eslint": "8.48.0",
6565
"lint-staged": "^13.0.3",
@@ -83,4 +83,4 @@
8383
"eslint --cache --fix"
8484
]
8585
}
86-
}
86+
}

public/widget.json

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -96,38 +96,38 @@
9696
]
9797
},
9898
{
99-
"name": "cn.widgetjs.widgets.labor_progress",
99+
"name": "cn.widgetjs.widgets.sit_reminder",
100100
"title": {
101-
"zh-CN": "打工进度"
101+
"zh-CN": "久坐提醒"
102102
},
103103
"description": {
104-
"zh-CN": "打工人,打工魂"
104+
"zh-CN": "设置间隔,定时提醒,适合长期久坐的人群"
105105
},
106106
"keywords": [
107107
"recommend"
108108
],
109109
"security": false,
110110
"permissions": [],
111111
"lang": "zh-CN",
112-
"width": 4,
112+
"width": 1,
113113
"height": 1,
114-
"maxWidth": 6,
114+
"maxWidth": 1,
115115
"webviewTag": false,
116-
"maxHeight": 2,
117-
"minWidth": 3,
116+
"maxHeight": 1,
117+
"minWidth": 1,
118118
"minHeight": 1,
119119
"movable": true,
120120
"singleton": false,
121121
"resizable": true,
122-
"path": "/widget/labor_progress",
122+
"path": "/widget/sit_reminder",
123123
"meta": {},
124-
"backgroundThrottling": true,
125-
"previewImage": "/images/preview_labor_progress.png",
124+
"backgroundThrottling": false,
125+
"previewImage": "/images/preview_sit_reminder.png",
126126
"categories": [
127-
"fun"
127+
"utilities"
128128
],
129-
"supportDeployMode": 17,
130-
"configPagePath": "/widget/config/labor_progress?frame=true&transparent=false",
129+
"supportDeployMode": 65536,
130+
"configPagePath": "/widget/config/sit_reminder?frame=true&transparent=false",
131131
"routes": [],
132132
"socialLinks": [
133133
{
@@ -178,38 +178,38 @@
178178
]
179179
},
180180
{
181-
"name": "cn.widgetjs.widgets.dynamic_island",
181+
"name": "cn.widgetjs.widgets.labor_progress",
182182
"title": {
183-
"zh-CN": "久坐提醒"
183+
"zh-CN": "打工进度"
184184
},
185185
"description": {
186-
"zh-CN": "设置间隔,定时提醒,适合长期久坐的人群"
186+
"zh-CN": "打工人,打工魂"
187187
},
188188
"keywords": [
189189
"recommend"
190190
],
191191
"security": false,
192192
"permissions": [],
193193
"lang": "zh-CN",
194-
"width": 6,
195-
"height": 4,
194+
"width": 4,
195+
"height": 1,
196196
"maxWidth": 6,
197197
"webviewTag": false,
198-
"maxHeight": 4,
199-
"minWidth": 6,
200-
"minHeight": 4,
198+
"maxHeight": 2,
199+
"minWidth": 3,
200+
"minHeight": 1,
201201
"movable": true,
202202
"singleton": false,
203203
"resizable": true,
204-
"path": "/widget/dynamic_island",
204+
"path": "/widget/labor_progress",
205205
"meta": {},
206206
"backgroundThrottling": true,
207-
"previewImage": "/images/preview_sit_reminder.png",
207+
"previewImage": "/images/preview_labor_progress.png",
208208
"categories": [
209-
"utilities"
209+
"fun"
210210
],
211-
"supportDeployMode": 65536,
212-
"configPagePath": "/widget/config/dynamic_island?frame=true&transparent=false",
211+
"supportDeployMode": 17,
212+
"configPagePath": "/widget/config/labor_progress?frame=true&transparent=false",
213213
"routes": [],
214214
"socialLinks": [
215215
{
@@ -219,7 +219,7 @@
219219
]
220220
},
221221
{
222-
"name": "cn.widgetjs.widgets.sit_reminder",
222+
"name": "cn.widgetjs.widgets.dynamic_island",
223223
"title": {
224224
"zh-CN": "久坐提醒"
225225
},
@@ -232,25 +232,25 @@
232232
"security": false,
233233
"permissions": [],
234234
"lang": "zh-CN",
235-
"width": 1,
236-
"height": 1,
237-
"maxWidth": 1,
235+
"width": 6,
236+
"height": 4,
237+
"maxWidth": 6,
238238
"webviewTag": false,
239-
"maxHeight": 1,
240-
"minWidth": 1,
241-
"minHeight": 1,
239+
"maxHeight": 4,
240+
"minWidth": 6,
241+
"minHeight": 4,
242242
"movable": true,
243243
"singleton": false,
244244
"resizable": true,
245-
"path": "/widget/sit_reminder",
245+
"path": "/widget/dynamic_island",
246246
"meta": {},
247-
"backgroundThrottling": false,
247+
"backgroundThrottling": true,
248248
"previewImage": "/images/preview_sit_reminder.png",
249249
"categories": [
250250
"utilities"
251251
],
252252
"supportDeployMode": 65536,
253-
"configPagePath": "/widget/config/sit_reminder?frame=true&transparent=false",
253+
"configPagePath": "/widget/config/dynamic_island?frame=true&transparent=false",
254254
"routes": [],
255255
"socialLinks": [
256256
{

src/App.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<script setup>
22
import { useAppLanguage } from '@widget-js/vue3'
3+
import consola from 'consola'
34
import { i18n } from '@/i18n/i18n'
45
56
useAppLanguage({
67
onLoad: (lang) => {
7-
i18n.global.locale.value = lang
8+
consola.log('App language loaded:', lang)
9+
i18n.global.locale = lang
810
},
911
onChange: (lang) => {
10-
i18n.global.locale.value = lang
12+
consola.log('App language onChange:', lang)
13+
i18n.global.locale = lang
1114
},
1215
})
1316
</script>

src/i18n/i18n.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import trayEn from '@/i18n/tray/en.json'
77
import trayZh from '@/i18n/tray/zh.json'
88

99
export const i18n = createI18n({
10-
legacy: false,
1110
locale: 'zh',
1211
messages: {
1312
'zh': {

src/router/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ const routes: RouteRecordRaw[] = [
3737
name: 'manager',
3838
component: () => import('@/views/manager/ManagerView.vue'),
3939
},
40+
{
41+
path: '/package/manager',
42+
name: 'package-manager',
43+
component: () => import('@/views/manager/WidgetPackageManagerView.vue'),
44+
},
4045
{
4146
path: '/add',
4247
name: 'add',

src/views/add/AddWidgetView.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" setup>
22
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
3-
import { Code, Search } from '@icon-park/vue-next'
3+
import { Code, Install, Search } from '@icon-park/vue-next'
44
import type { Category, Widget } from '@widget-js/core'
55
import { AppApi, BrowserWindowApi, ElectronUtils, NotificationApi, WidgetApi, WidgetPackageApi } from '@widget-js/core'
66
@@ -151,6 +151,11 @@ const isShowMask = computed(() => {
151151
<Search />
152152
</template>
153153
</el-input>
154+
<el-button size="large" @click="AppApi.openWidgetPackageManagerWindow()">
155+
<template #icon>
156+
<Install />
157+
</template>已安装管理
158+
</el-button>
154159
</div>
155160
<WidgetTags v-model="selectedCategory" class="px-4 pt-2" @change="search" />
156161
<el-scrollbar :height="height - 140">
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<script setup lang="ts">
2+
import type { PropType } from 'vue'
3+
import type { WidgetPackage } from '@widget-js/core'
4+
5+
defineProps(
6+
{
7+
widgetPackage: {
8+
type: Object as PropType<WidgetPackage>,
9+
required: true,
10+
},
11+
},
12+
)
13+
14+
const emits = defineEmits(['uninstall'])
15+
</script>
16+
17+
<template>
18+
<ElCard shadow="hover" body-style="padding:12px">
19+
<div class="flex">
20+
<div class="flex flex-col gap-2">
21+
<div class="flex flex-col text-start">
22+
<div v-if="widgetPackage">
23+
<b>组件包标题:</b>{{ widgetPackage.getTitle() }}
24+
</div>
25+
<div class="flex gap-6">
26+
<span><b>组件包名:</b>{{ widgetPackage.name }}</span>
27+
</div>
28+
</div>
29+
</div>
30+
<div class="ml-auto flex items-center">
31+
<el-popconfirm cancel-button-text="取消" width="200" confirm-button-text="确认" title="确认卸载该组件包吗?" @confirm="emits('uninstall', widgetPackage)">
32+
<template #reference>
33+
<el-button type="danger" size="small">
34+
卸载
35+
</el-button>
36+
</template>
37+
</el-popconfirm>
38+
</div>
39+
</div>
40+
</ElCard>
41+
</template>
42+
43+
<style scoped lang="scss">
44+
45+
</style>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<script setup lang="ts">
2+
import { WidgetBaseDialog } from '@widget-js/vue3'
3+
import { useWindowSize } from '@vueuse/core'
4+
import { WidgetPackage, WidgetPackageApi } from '@widget-js/core'
5+
import { ref } from 'vue'
6+
import WidgetPackageItem from '@/views/manager/WidgetPackageItem.vue'
7+
8+
const { height } = useWindowSize()
9+
const packages = ref<WidgetPackage[]>([])
10+
WidgetPackageApi.getPackages().then((list) => {
11+
packages.value = list.map(it => WidgetPackage.parseObject(it))
12+
})
13+
14+
async function uninstallPackage(pkg: WidgetPackage) {
15+
await WidgetPackageApi.uninstall(pkg.name)
16+
packages.value = packages.value.filter(it => it.name !== pkg.name)
17+
}
18+
</script>
19+
20+
<template>
21+
<WidgetBaseDialog :body-padding="0" title="已安装管理">
22+
<template #body>
23+
<el-scrollbar :height="height - 48">
24+
<div class="p-4 flex flex-col gap-2">
25+
<WidgetPackageItem v-for="item in packages" v-show="item.name != 'cn.widgetjs.widgets'" :key="item.name" :widget-package="item" @uninstall="uninstallPackage" />
26+
</div>
27+
</el-scrollbar>
28+
</template>
29+
</WidgetBaseDialog>
30+
</template>
31+
32+
<style scoped lang="scss">
33+
34+
</style>

src/views/tray/TrayMenuView.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const { t } = useI18n()
1111
1212
const { simpleInfo } = useAppRuntimeInfo()
1313
const appVersion = ref<string>()
14+
1415
AppApi.getVersion('app').then((it) => {
1516
appVersion.value = it
1617
})
@@ -19,12 +20,14 @@ function shareApp() {
1920
navigator.clipboard.writeText('https://widgetjs.cn')
2021
NotificationApi.success(t('tray.downloadLinkCopied')) // 使用国际化
2122
}
23+
2224
function copyAndReport() {
2325
const text = JSON.stringify(simpleInfo.value, null, 2)
2426
navigator.clipboard.writeText(text)
2527
NotificationApi.success(t('tray.infoCopied'))
2628
BrowserWindowApi.openUrl('https://faq.widgetjs.cn', { external: true })
2729
}
30+
2831
function restartWidgets() {
2932
WidgetApi.restartWidgets()
3033
}

0 commit comments

Comments
 (0)