-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
674 lines (666 loc) · 25.1 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
const { app, BrowserWindow, webContents, ipcMain, screen, Menu, Tray } = require('electron')
const path = require('path')
const Store = require('electron-store');
const { attach, detach } = require("electron-addtodesktop");
const { config } = require('process');
Store.initRenderer()
const store = new Store();
const appPath = app.isPackaged ? process.execPath : app.getAppPath();
const WM_INITMENU = 0x0116;
// 初始化
let DefaultRightClickData = { a: false, b: false, c: false, d: false, e: false, f: false, g: false, h: false, i: true, j: false, k: false, l: false, }
let mainWindow = null
// let ma nageWindow = null
let childWin = null
let tray = null
// 单例模式
const isFirstInstance = app.requestSingleInstanceLock()
if (!isFirstInstance) {
app.quit()
} else {
app.on('second-instance', () => {
if (mainWindow) {
mainWindow.focus()
}
})
}
app.whenReady().then(() => {
init()
createMainWindow()
// createManageWindow()
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
beforeExit()
app.relaunch() // 崩溃重启
}
})
app.on('before-quit', (event) => {
event.preventDefault()
beforeExit()
})
//////////////////////////////////////////////////////////
// 首选项设置保存 //
// Preferences //
// -Appearance //
// --SaveXYWH //
// ---isSaveXYWH //
// ---X/Y/W/H //
// --Transparency //
// ---value //
// ---percent //
// --Curvature //
// ---value //
// ---percent //
// --FontSize //
// ---isSetSize //
// ---fontSizeTitle //
// ----value //
// ----percent //
// ---fontSizeText //
// ----value //
// ----percent //
// ---fontSizeFrom //
// ----value //
// ----percent //
// -Other //
// --ifMinimize //
// --iFOpenAtStart //
// -RightClick //
// -LastData //
//////////////////////////////////////////////////////////
function createMainWindow () {
if (mainWindow) {
return
}
// 主窗口
mainWindow = new BrowserWindow({
// useContentSize: true,
width: userW,
height: userH,
minWidth: 350,
minHeight: 200,
x: userX,
y: userY,
frame: false,
transparent: true,
show: false,
maximizable: false,
skipTaskbar: true,
webPreferences: {
devTools: false,
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false,
}
})
attach(mainWindow);
mainWindow.loadFile('./src/index.html');
setMainWindow()
}
function setMainWindow () {
mainWindow.setIgnoreMouseEvents(false);
mainWindow.setFullScreenable(false);
// 主窗口准备好后显示
mainWindow.once('ready-to-show', () => {
openListenerWhenShow()
if (store.get('Other.ifMinimize')) {
createTray()
}
mainWindow.show()
})
}
// 显示时开启监听
function openListenerWhenShow () {
// 主窗口大小改变事件
mainWindow.on('resized', () => {
mainWindow.webContents.send('send-H', 'WH')
})
// 右键菜单设置
mainWindow.hookWindowMessage(WM_INITMENU, () => {
mainWindow.setEnabled(false);
mainWindow.setEnabled(true);
rightClickMenu = createRightClickMenu()
rightClickMenu.popup();
});
// 打开设置窗口
ipcMain.on('openSetting', () => {
openSetting()
})
// 更改窗口大小
ipcMain.on('change-H', (event, arg) => {
if (arg[1] !== 'onlyH') {
mainWindow.setSize(arg[0], arg[1])
store.set('Appearance.SaveXYWH.W', arg[0])
store.set('Appearance.SaveXYWH.H', arg[1])
}
else {
mainWindow.setSize(store.get('Appearance.SaveXYWH.W'), arg[0])
store.set('Appearance.SaveXYWH.H', arg[0])
}
})
}
// 设置窗口
function createSetting () {
if (childWin) {
childWin.show()
return
}
childWin = new BrowserWindow({
width: 850,
height: 650,
frame: false,
title: "设置",
icon: iconPath,
show: false,
maximizable: false,
webPreferences: {
devTools: false,
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false,
}
})
childWin.loadFile('./src/setting.html')
childWin.webContents.closeDevTools();
childWin.setFullScreenable(false);
// 设置窗口准备好后显示
childWin.once('ready-to-show', () => {
childWin.show()
})
childWin.on('closed', () => {
childWin = null
})
// 右键菜单设置
childWin.hookWindowMessage(WM_INITMENU, () => {
childWin.setEnabled(false);
childWin.setEnabled(true);
});
}
// 打开设置界面
function openSetting () {
// 创建设置窗口
createSetting()
if (childWin === null) {
return
}
// 事件处理函数:发送WH主窗口大小数据
const sendWH = () => {
childWin.webContents.send('wh', mainWindow.getSize())
}
// 事件处理函数:发送XY主窗口位置数据
const sendXY = () => {
childWin.webContents.send('xy', mainWindow.getPosition())
}
ifOpenXYWHListener()
ifChangeFontSizeListener()
// 记录开始按钮发生变更
ipcMain.on('btn-changed-xywh', () => {
ifOpenXYWHListener()
})
// 透明度滑动条发送变更
ipcMain.on('transparency-changed', (event, arg) => {
transparencyListener(arg[0], arg[1])
})
// 边角弧度滑动条发送变更
ipcMain.on('curvature-changed', (event, arg) => {
curvatureListener(arg[0], arg[1])
})
// 是否改变文字大小按钮发生变更
ipcMain.on('btn-changed-fontSize', () => {
ifChangeFontSizeListener()
})
// 是否最小化按钮发生变更
ipcMain.on('btn-changed-minimize', () => {
ifMinimizeListener()
})
// 关闭设置窗口(隐藏窗口同时,关闭事件监听器
ipcMain.once('setting:close', () => {
if (childWin) {
childWin.close()
}
mainWindow.removeListener('resize', sendWH)
mainWindow.removeListener('move', sendXY)
ipcMain.removeAllListeners('btn-changed-xywh')
ipcMain.removeAllListeners('transparency-changed')
ipcMain.removeAllListeners('curvature-changed')
ipcMain.removeAllListeners('btn-changed-fontSize')
ipcMain.removeAllListeners('btn-changed-minimize')
ipcMain.removeAllListeners('setting:close')
})
// 函数:开启/关闭对主窗口变化的监听
function ifOpenXYWHListener () {
if (store.get('Appearance.SaveXYWH.isSave')) {
// 如果按钮打开,先发送一次数据,否则显示空白
childWin.webContents.send('wh', mainWindow.getSize())
childWin.webContents.send('xy', mainWindow.getPosition())
mainWindow.on('resize', sendWH)
mainWindow.on('move', sendXY)
}
else {
mainWindow.removeListener('resize', sendWH)
mainWindow.removeListener('move', sendXY)
}
}
// 函数:透明度变化
function transparencyListener (value, percent) {
store.set('Appearance.Transparency.value', value);
store.set('Appearance.Transparency.percent', percent);
userTransparency = store.get('Appearance.Transparency.value') / 100
changeTransparency(userTransparency)
}
// 函数:边角弧度变化
function curvatureListener (value, percent) {
store.set('Appearance.Curvature.value', value);
store.set('Appearance.Curvature.percent', percent);
userCurvature = store.get('Appearance.Curvature.value') * 6
changeCurvature(userCurvature)
}
// 函数:标题文字大小变化
function fontSizeTitleListener (value, percent) {
store.set('Appearance.FontSize.fontSizeTitle.value', value);
store.set('Appearance.FontSize.fontSizeTitle.percent', percent);
userFontSizeTitle = store.get('Appearance.FontSize.fontSizeTitle.value')
changeFontSizeTitle(userFontSizeTitle)
}
// 函数:主体文字大小变化
function fontSizeTextListener (value, percent) {
store.set('Appearance.FontSize.fontSizeText.value', value);
store.set('Appearance.FontSize.fontSizeText.percent', percent);
userFontSizeText = store.get('Appearance.FontSize.fontSizeText.value')
changeFontSizeText(userFontSizeText)
}
// 函数:来源文字大小变化
function fontSizeFromListener (value, percent) {
store.set('Appearance.FontSize.fontSizeFrom.value', value);
store.set('Appearance.FontSize.fontSizeFrom.percent', percent);
userFontSizeFrom = store.get('Appearance.FontSize.fontSizeFrom.value')
changeFontSizeFrom(userFontSizeFrom)
}
// 函数:开启/关闭对文字大小改变滑动条的监听
function ifChangeFontSizeListener () {
if (store.get('Appearance.FontSize.isSetSize')) {
ipcMain.on('fontSizeTitle-changed', (event, arg) => {
fontSizeTitleListener(arg[0], arg[1])
})
ipcMain.on('fontSizeText-changed', (event, arg) => {
fontSizeTextListener(arg[0], arg[1])
})
ipcMain.on('fontSizeFrom-changed', (event, arg) => {
fontSizeFromListener(arg[0], arg[1])
})
mainWindow.webContents.send('send-H', 'onlyH')
}
else {
ipcMain.removeAllListeners('fontSizeTitle-changed')
ipcMain.removeAllListeners('fontSizeText-changed')
ipcMain.removeAllListeners('fontSizeFrom-changed')
// 改回默认大小
store.set('Appearance.FontSize.fontSizeTitle.value', store.get('Preferences.Appearance.FontSize.fontSizeTitle.value'))
store.set('Appearance.FontSize.fontSizeTitle.percent', store.get('Preferences.Appearance.FontSize.fontSizeTitle.percent'))
store.set('Appearance.FontSize.fontSizeText.value', store.get('Preferences.Appearance.FontSize.fontSizeText.value'))
store.set('Appearance.FontSize.fontSizeText.percent', store.get('Preferences.Appearance.FontSize.fontSizeText.percent'))
store.set('Appearance.FontSize.fontSizeFrom.value', store.get('Preferences.Appearance.FontSize.fontSizeFrom.value'))
store.set('Appearance.FontSize.fontSizeFrom.percent', store.get('Preferences.Appearance.FontSize.fontSizeFrom.percent'))
userFontSizeTitle = store.get('Appearance.FontSize.fontSizeTitle.value')
changeFontSizeTitle(userFontSizeTitle)
userFontSizeText = store.get('Appearance.FontSize.fontSizeText.value')
changeFontSizeText(userFontSizeText)
userFontSizeFrom = store.get('Appearance.FontSize.fontSizeFrom.value')
changeFontSizeFrom(userFontSizeFrom)
mainWindow.webContents.send('send-H', 'onlyH')
}
}
// 函数:开启/关闭对是否最小化到托盘的监听
function ifMinimizeListener () {
if (store.get('Other.ifMinimize')) {
createTray()
}
else if (tray) {
tray.destroy()
tray = null
}
}
}
// 创建托盘
function createTray () {
if (tray) {
return
}
tray = new Tray(iconPath)
tray.setToolTip('Hitokoto Desktop')
const trayContextMenu = Menu.buildFromTemplate([
{
label: '设置',
click: () => {
openSetting()
}
},
{
label: '显示/隐藏',
// type: 'checkbox',
click: () => {
if (mainWindow.isVisible()) {
mainWindow.hide()
mainWindow.removeAllListeners('resized')
ipcMain.removeAllListeners('openSetting')
ipcMain.removeAllListeners('change-H')
}
else {
openListenerWhenShow()
mainWindow.show();
}
}
},
{
type: 'separator'
},
{
label: '退出',
click: () => {
beforeExit()
}
}
])
tray.on('click', () => {
if (mainWindow.isVisible()) {
mainWindow.hide()
mainWindow.removeAllListeners('resized')
ipcMain.removeAllListeners('openSetting')
ipcMain.removeAllListeners('change-H')
}
else {
openListenerWhenShow()
mainWindow.show();
}
})
tray.on('right-click', () => {
tray.popUpContextMenu(trayContextMenu)
})
}
// 创建右键菜单
function createRightClickMenu () {
var tmpRightClickData = store.get('RightClick')
var rightClickMenu = Menu.buildFromTemplate([
{
label: '动画',
type: 'checkbox',
checked: tmpRightClickData.a,
click: function (menuItem, event) {
tmpRightClickData.a = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
label: '漫画',
type: 'checkbox',
checked: tmpRightClickData.b,
click: function (menuItem, event) {
tmpRightClickData.b = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
label: '游戏',
type: 'checkbox',
checked: tmpRightClickData.c,
click: function (menuItem, event) {
tmpRightClickData.c = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
label: '文学',
type: 'checkbox',
checked: tmpRightClickData.d,
click: function (menuItem, event) {
tmpRightClickData.d = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
label: '原创',
type: 'checkbox',
checked: tmpRightClickData.e,
click: function (menuItem, event) {
tmpRightClickData.e = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
label: '来自网络',
type: 'checkbox',
checked: tmpRightClickData.f,
click: function (menuItem, event) {
tmpRightClickData.f = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
label: '其他',
type: 'checkbox',
checked: tmpRightClickData.g,
click: function (menuItem, event) {
tmpRightClickData.g = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
label: '影视',
type: 'checkbox',
checked: tmpRightClickData.h,
click: function (menuItem, event) {
tmpRightClickData.h = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
label: '诗词',
type: 'checkbox',
checked: tmpRightClickData.i,
click: function (menuItem, event) {
tmpRightClickData.i = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
label: '网易云',
type: 'checkbox',
checked: tmpRightClickData.j,
click: function (menuItem, event) {
tmpRightClickData.j = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
label: '哲学',
type: 'checkbox',
checked: tmpRightClickData.k,
click: function (menuItem, event) {
tmpRightClickData.k = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
label: '抖机灵',
type: 'checkbox',
checked: tmpRightClickData.l,
click: function (menuItem, event) {
tmpRightClickData.l = menuItem.checked
store.set('RightClick', tmpRightClickData)
}
},
{
type: 'separator'
},
{
label: store.get('Other.ifMinimize') ? '最小化' : '退出',
id: 'changeExit',
click: () => {
if (store.get('Other.ifMinimize')) {
mainWindow.hide()
mainWindow.removeAllListeners('resized')
ipcMain.removeAllListeners('openSetting')
ipcMain.removeAllListeners('change-H')
}
else {
beforeExit()
}
}
}
])
return rightClickMenu
}
// 保存窗口位置
function ifSaveXYWH () {
const flagXYWH = store.get('Appearance.SaveXYWH.isSave');
if (flagXYWH) {
let mainsize = mainWindow.getSize()
let mainpos = mainWindow.getPosition()
store.set('Appearance.SaveXYWH.W', mainsize[0])
store.set('Appearance.SaveXYWH.H', mainsize[1])
store.set('Appearance.SaveXYWH.X', mainpos[0])
store.set('Appearance.SaveXYWH.Y', mainpos[1])
}
else {
store.set('Appearance.SaveXYWH.W', store.get('Preferences.Appearance.SaveXYWH.W'))
store.set('Appearance.SaveXYWH.H', store.get('Preferences.Appearance.SaveXYWH.H'))
store.set('Appearance.SaveXYWH.X', store.get('Preferences.Appearance.SaveXYWH.X'))
store.set('Appearance.SaveXYWH.Y', store.get('Preferences.Appearance.SaveXYWH.Y'))
}
}
// 更改主窗口透明度
function changeTransparency (userTransparency) {
mainWindow.webContents.executeJavaScript(`allItems.style.backgroundColor = "rgba(0, 0, 0, ${userTransparency})";`)
}
// 更改主边角弧度
function changeCurvature (userCurvature) {
mainWindow.webContents.executeJavaScript(`allItems.style.borderRadius = "${userCurvature}px";`)
}
// 更改标题文字大小
function changeFontSizeTitle (userFontSizeTitle) {
mainWindow.webContents.executeJavaScript(`title_text.style.fontSize = "${userFontSizeTitle}px";`)
}
// 更改一言文字大小
function changeFontSizeText (userFontSizeText) {
mainWindow.webContents.executeJavaScript(`content.style.fontSize = "${userFontSizeText}px";`)
}
// 更改来源文字大小
function changeFontSizeFrom (userFontSizeFrom) {
mainWindow.webContents.executeJavaScript(`from.style.fontSize = "${userFontSizeFrom}px";`)
}
// 退出前操作
function beforeExit () {
if (!mainWindow.isDestroyed()) {
setIFOpenAtStart()
ifSaveXYWH()
detach(mainWindow);
}
app.exit()
}
// 初始化
function init () {
loadPreferences()
if (!store.has('Appearance.SaveXYWH.isSave')) {
store.set('Appearance.SaveXYWH.isSave', store.get('Preferences.Appearance.SaveXYWH.isSave'))
store.set('Appearance.SaveXYWH.W', store.get('Preferences.Appearance.SaveXYWH.W'))
store.set('Appearance.SaveXYWH.H', store.get('Preferences.Appearance.SaveXYWH.H'))
store.set('Appearance.SaveXYWH.X', store.get('Preferences.Appearance.SaveXYWH.X'))
store.set('Appearance.SaveXYWH.Y', store.get('Preferences.Appearance.SaveXYWH.Y'))
}
userW = store.get('Appearance.SaveXYWH.W')
userH = store.get('Appearance.SaveXYWH.H')
userX = store.get('Appearance.SaveXYWH.X')
userY = store.get('Appearance.SaveXYWH.Y')
if (!store.has('Appearance.Transparency.value')) {
store.set('Appearance.Transparency.value', store.get('Preferences.Appearance.Transparency.value'))
store.set('Appearance.Transparency.percent', store.get('Preferences.Appearance.Transparency.percent'))
}
if (!store.has('Appearance.Curvature.value')) {
store.set('Appearance.Curvature.value', store.get('Preferences.Appearance.Curvature.value'))
store.set('Appearance.Curvature.percent', store.get('Preferences.Appearance.Curvature.percent'))
}
if (!store.has('Appearance.FontSize.isSetSize')) {
store.set('Appearance.FontSize.isSetSize', store.get('Preferences.Appearance.FontSize.isSetSize'))
store.set('Appearance.FontSize.fontSizeTitle.value', store.get('Preferences.Appearance.FontSize.fontSizeTitle.value'))
store.set('Appearance.FontSize.fontSizeTitle.percent', store.get('Preferences.Appearance.FontSize.fontSizeTitle.percent'))
store.set('Appearance.FontSize.fontSizeText.value', store.get('Preferences.Appearance.FontSize.fontSizeText.value'))
store.set('Appearance.FontSize.fontSizeText.percent', store.get('Preferences.Appearance.FontSize.fontSizeText.percent'))
store.set('Appearance.FontSize.fontSizeFrom.value', store.get('Preferences.Appearance.FontSize.fontSizeFrom.value'))
store.set('Appearance.FontSize.fontSizeFrom.percent', store.get('Preferences.Appearance.FontSize.fontSizeFrom.percent'))
}
if (!store.has('Other.ifMinimize')) {
store.set('Other.ifMinimize', store.get('Preferences.Other.ifMinimize'))
}
if (!store.has('Other.ifOpenAtStart')) {
store.set('Other.ifOpenAtStart', store.get('Preferences.Other.ifOpenAtStart'))
}
if (!store.has('Other.ifCustomizationAPI.isAPI')) {
store.set('Other.ifCustomizationAPI.isAPI', store.get('Preferences.Other.ifCustomizationAPI.isAPI'))
store.set('Other.ifCustomizationAPI.https', store.get('Preferences.Other.ifCustomizationAPI.https'))
store.set('Other.ifCustomizationAPI.js', store.get('Preferences.Other.ifCustomizationAPI.js'))
}
if (!store.has('RightClick')) {
store.set('RightClick', store.get('Preferences.RightClick'))
}
if (!store.has('LastData.text')) {
store.set('LastData.text', store.get('Preferences.LastData.text'))
store.set('LastData.from', store.get('Preferences.LastData.from'))
}
iconPath = path.join(__dirname, '/src/icons/icon.ico');
setIFOpenAtStart()
}
// 首选项
function loadPreferences () {
if (!store.has('Preferences.Appearance.SaveXYWH.isSave')) {
store.set('Preferences.Appearance.SaveXYWH.isSave', true)
store.set('Preferences.Appearance.SaveXYWH.W', 600)
store.set('Preferences.Appearance.SaveXYWH.H', 300)
let size = screen.getPrimaryDisplay().workAreaSize
store.set('Preferences.Appearance.SaveXYWH.X', parseInt(size.width * 0.5) - 300)
store.set('Preferences.Appearance.SaveXYWH.Y', parseInt(size.height * 0.5) - 150)
}
if (!store.has('Preferences.Appearance.Transparency.value')) {
store.set('Preferences.Appearance.Transparency.value', 50)
store.set('Preferences.Appearance.Transparency.percent', 50)
}
if (!store.has('Preferences.Appearance.Curvature.value')) {
store.set('Preferences.Appearance.Curvature.value', 0)
store.set('Preferences.Appearance.Curvature.percent', 0)
}
if (!store.has('Preferences.Appearance.FontSize.isSetSize')) {
store.set('Preferences.Appearance.FontSize.isSetSize', false)
store.set('Preferences.Appearance.FontSize.fontSizeTitle.value', 28)
store.set('Preferences.Appearance.FontSize.fontSizeTitle.percent', 45)
store.set('Preferences.Appearance.FontSize.fontSizeText.value', 26)
store.set('Preferences.Appearance.FontSize.fontSizeText.percent', 40)
store.set('Preferences.Appearance.FontSize.fontSizeFrom.value', 18)
store.set('Preferences.Appearance.FontSize.fontSizeFrom.percent', 20)
}
if (!store.has('Preferences.Other.ifMinimize')) {
store.set('Preferences.Other.ifMinimize', false)
}
if (!store.has('Preferences.Other.ifOpenAtStart')) {
store.set('Preferences.Other.ifOpenAtStart', true)
}
if (!store.has('Preferences.Other.ifCustomizationAPI.isAPI')) {
store.set('Preferences.Other.ifCustomizationAPI.isAPI', true)
store.set('Preferences.Other.ifCustomizationAPI.https', "https://v1.hitokoto.cn/${Types}")
store.set('Preferences.Other.ifCustomizationAPI.js', `content.innerText = data.hitokoto;
from.innerText = data.from + (data.from_who ? ' · ' + data.from_who : '');`)
}
if (!store.has('Preferences.RightClick')) {
store.set('Preferences.RightClick', DefaultRightClickData)
}
if (!store.has('Preferences.LastData.text')) {
store.set('Preferences.LastData.text', '醉后不知天在水,满船清梦压星河。')
store.set('Preferences.LastData.from', '题龙阳县青草湖 · 唐温如')
}
}
//设置是否开机启动
function setIFOpenAtStart () {
app.setLoginItemSettings({
openAtLogin: store.get('Other.ifOpenAtStart'),
path:appPath,
});
}