Skip to content

Commit d33bea8

Browse files
0.0.2 version
1 parent 3c1ba37 commit d33bea8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+429
-34
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
根据硬盘性能,图片大小等因素,页面加载速度会受到影响。
1010

11+
支持定制 每页显示图片数量(当硬盘一般且单张图片过大时,建议选择较少的数量,10~20张比较不错),查看器是否显示 图片缩略图集
12+
13+
1114
这是第一个版本。
1215

1316
以上?

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "waterfall_picture_viewer",
33
"description": "瀑布流图片查看器",
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"private": false,
66
"author": {
77
"email": "edgecoordinates@gmail.com",
@@ -72,6 +72,7 @@
7272
},
7373
"dependencies": {
7474
"electron-serve": "^1.1.0",
75+
"electron-store": "^8.1.0",
7576
"electron-updater": "6.1.1",
7677
"opn": "^6.0.0"
7778
}

packages/main/src/index.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {app, protocol} from 'electron';
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import {app, protocol, ipcMain} from 'electron';
23
import './security-restrictions';
34
import {restoreOrCreateWindow} from '/@/mainWindow';
45
import {platform} from 'node:process';
@@ -93,3 +94,40 @@ app.whenReady().then(() => {
9394
callback(decodeURI(path.normalize(url)));
9495
});
9596
});
97+
98+
import Store from 'electron-store';
99+
100+
const schema: any = {
101+
itemNum: {
102+
type: 'number',
103+
maximum: 10000,
104+
minimum: 1,
105+
default: 50,
106+
},
107+
viewer_navbar: {
108+
type: 'number',
109+
maximum: 5,
110+
minimum: 0,
111+
default: 0,
112+
},
113+
foo: {
114+
type: 'number',
115+
maximum: 100,
116+
minimum: 1,
117+
default: 50,
118+
},
119+
bar: {
120+
type: 'string',
121+
format: 'url',
122+
},
123+
};
124+
125+
const store = new Store({schema});
126+
127+
// IPC listener
128+
ipcMain.on('getStore', async (event, val) => {
129+
event.returnValue = store.get(val);
130+
});
131+
ipcMain.on('setStore', async (event, key, val) => {
132+
store.set(key, val);
133+
});

packages/preload/src/filetools.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as fs from 'fs'
1+
import * as fs from 'fs';
22

3-
export function isPathDirectory(thepath: string) {
4-
const thefile = fs.statSync(thepath);
5-
return thefile.isDirectory()
6-
}
3+
export function isPathDirectory (thepath: string) {
4+
const thefile = fs.statSync(thepath);
5+
return thefile.isDirectory();
6+
}

packages/preload/src/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
/* eslint-disable @typescript-eslint/no-unused-vars */
13
/**
24
* @module preload
35
*/
6+
47
import * as fs from 'fs';
58
import * as path from 'path';
69

710
export {sha256sum} from './nodeCrypto';
811
export {versions} from './versions';
912
export {isPathDirectory} from './filetools';
13+
// export {myStore} from './store';
1014
export {fs, path};
15+
16+
import {contextBridge, ipcRenderer, IpcRendererEvent} from 'electron';
17+
18+
const electronHandler = {
19+
ipcRenderer: {
20+
setStoreValue: (key: string, value: any) => {
21+
ipcRenderer.send('setStore', key, value);
22+
},
23+
24+
getStoreValue (key: string) {
25+
const resp = ipcRenderer.sendSync('getStore', key);
26+
return resp;
27+
},
28+
},
29+
};
30+
31+
contextBridge.exposeInMainWorld('electron', electronHandler);

packages/preload/src/store.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable no-mixed-spaces-and-tabs */
2+
/* eslint-disable @typescript-eslint/no-explicit-any */
3+
/* eslint-disable @typescript-eslint/no-unused-vars */
4+
class MyStore {
5+
setStoreValue(key, value) {
6+
// 使用 ipcRenderer 发送设置数据的消息给主进程
7+
window.electron.ipcRenderer.setStoreValue(key, value);
8+
}
9+
10+
getStoreValue(key) {
11+
window.electron.ipcRenderer.getStoreValue(key);
12+
}
13+
}
14+
15+
export const myStore = new MyStore();

packages/preload/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
"skipLibCheck": true,
88
"strict": true,
99
"isolatedModules": true,
10+
"allowSyntheticDefaultImports":true,
11+
"noImplicitAny": false,
1012
"types": ["node"],
1113
"baseUrl": "."
1214
},
13-
"include": ["src/**/*.ts", "../../types/**/*.d.ts"],
15+
"include": ["src/**/*.ts", "../../types/**/*.d.ts", "src/store.js"],
1416
"exclude": ["**/*.spec.ts", "**/*.test.ts"]
1517
}

packages/renderer/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
interface window {
3+
require: any;
4+
}

packages/renderer/src/app.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
@tailwind base;
22
@tailwind components;
33
@tailwind utilities;
4+
5+
6+
.viewer-info {
7+
color: #fff;
8+
font-size: 0.75rem;
9+
line-height: 1.5rem;
10+
font-family: FontAwesome, serif;
11+
text-align: center;
12+
}
13+
.viewer-info::before {
14+
content: "\f129";
15+
}

packages/renderer/src/app.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
66
<meta name="viewport" content="width=device-width" />
77
<link href="https://cdn.jsdelivr.net/npm/css.gg/icons/icons.css" rel="stylesheet" />
8+
<link href="/css/fontawesome-pro.all.css" rel="stylesheet" />
89
%sveltekit.head%
910
</head>
1011
<body data-sveltekit-preload-data="hover">

0 commit comments

Comments
 (0)