Skip to content

Commit 657a2b0

Browse files
V1.1.1
1 parent 4e56815 commit 657a2b0

File tree

17 files changed

+527
-105
lines changed

17 files changed

+527
-105
lines changed

.vscode/settings.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,14 @@
66
"editor.codeActionsOnSave": ["source.fixAll.eslint"],
77
"eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"],
88
"typescript.tsdk": "node_modules/typescript/lib",
9-
"i18n-ally.localesPaths": ["src/i18n"]
9+
"i18n-ally.localesPaths": ["src/i18n"],
10+
"cSpell.words": [
11+
"autorenew",
12+
"fpath",
13+
"fullfpath",
14+
"photoswipe",
15+
"pswp",
16+
"todos",
17+
"viewerjs"
18+
]
1019
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@
5252
## 最后
5353

5454
希望大家赏个**Star**,以满足吾辈这小小的虚荣心吧!!!
55+

Todos.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
## 任务
3+
4+
- [ ] 添加视频格式支持! (怎样获取大小数据呢?)
5+
通过 https://www.npmjs.com/package/file-type 判断文件类型,通过 前端方案,动态载入(瀑布流变动?) 大小数据。
6+
7+
- 如果上述方案不可行,用户可选择 图片查看器引擎,从而支持图片+视频查看。
8+
viewer.js v-viewer。 https://videojs.com/city 不好?
9+
10+
bigger-picture 这些都是参考的库。

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "waterfall-picture-viewer",
3-
"version": "1.0.1",
3+
"version": "1.1.1",
44
"description": "A simple picture viewer",
55
"productName": "W Viewer",
66
"author": "边缘坐标 <[email protected]>",
@@ -16,15 +16,13 @@
1616
"dependencies": {
1717
"@electron/remote": "^2.1.1",
1818
"@quasar/extras": "^1.16.4",
19-
"bigger-picture": "^1.1.14",
2019
"electron-store": "^8.1.0",
2120
"fs-extra": "^11.2.0",
2221
"image-size": "^1.1.1",
2322
"photoswipe": "^5.4.3",
2423
"pinia": "^2.0.11",
2524
"quasar": "^2.6.0",
26-
"v-viewer": "^3.0.13",
27-
"viewerjs": "^1.11.6",
25+
"trash": "^7.2.0",
2826
"vue": "^3.0.0",
2927
"vue-i18n": "^9.2.2",
3028
"vue-router": "^4.0.0"

src-electron/IPC-main.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@ import { ipcMain, shell } from 'electron';
22
import Store from 'electron-store';
33
import { schema } from './default-data';
44

5+
const fs = require('fs-extra');
6+
import trash from 'trash';
7+
8+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
9+
function isFileSync (path) {
10+
try {
11+
// 使用 fs.existsSync 检查路径是否存在
12+
if (fs.existsSync(path)) {
13+
// 使用 fs.statSync 获取路径的状态
14+
const stats = fs.statSync(path);
15+
// 判断是否是文件
16+
return stats.isFile();
17+
}
18+
return false;
19+
} catch (err) {
20+
// 处理错误
21+
console.error('Error checking file synchronously:', err);
22+
return false;
23+
}
24+
}
25+
526
let store = new Store();
627
// 重构判断是否为空并
728

@@ -45,4 +66,16 @@ export function ipcMains (value: void): any {
4566
console.log(link);
4667
return shell.openExternal(link);
4768
});
69+
70+
ipcMain.handle('tool-openPath', (event, link) => {
71+
shell.openPath(link);
72+
});
73+
74+
ipcMain.handle('tool-delPic', (event, src) => {
75+
// fs.removeSync(src);
76+
if (isFileSync(src)) {
77+
trash(src);
78+
}
79+
console.log('Del: ', src);
80+
});
4881
}

src-electron/electron-preload.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ export type myWindowAPI = {
5252
export type myToolAPI = {
5353
traverseFolder: (path: string, pFormats: any) => any;
5454
openLink: (link: string) => any;
55+
delPic: (src: string) => any;
56+
openPath: (src: string) => any;
57+
showItemInFolder: (src: string) => any;
5558
};
5659

5760
import { contextBridge, ipcRenderer } from 'electron';
58-
import { BrowserWindow, app } from '@electron/remote';
61+
import { BrowserWindow, app, shell } from '@electron/remote';
5962

6063
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6164

@@ -65,6 +68,15 @@ const myToolAPIs: myToolAPI = {
6568
},
6669
async openLink (link) {
6770
return await ipcRenderer.invoke('tool-openLink', link);
71+
},
72+
async delPic (src) {
73+
return await ipcRenderer.invoke('tool-delPic', src);
74+
},
75+
async openPath (src) {
76+
return await ipcRenderer.invoke('tool-openPath', src);
77+
},
78+
async showItemInFolder (src) {
79+
shell.showItemInFolder(src);
6880
}
6981
};
7082

src/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ async function initData() {
1818
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1919
let tmpdata: any
2020
if (tmpdata = await window.storeAPI.get('itemNum')) setStore.perPageNum = tmpdata
21-
console.log(await window.storeAPI.get('itemNum'), setStore.perPageNum)
21+
if (tmpdata = await window.storeAPI.get('WBreakpoint')) setStore.waterfallBreakpoint = tmpdata
22+
console.log(await window.storeAPI.get('WBreakpoint'), setStore.waterfallBreakpoint)
2223
console.log('APP setData inited!')
2324
}
2425

src/components/DropdownReader.vue

Whitespace-only changes.

src/components/SetComponent.vue

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,18 @@
6262

6363
<q-tab-panel name="alarms">
6464
<div class="text-h4 q-mb-md">查看器设置</div>
65-
<p>暂时没有!</p>
66-
<p>
67-
早晨起来,泡一碗浓茶,向院子一坐,你也能看得到很高很高的碧绿的天色,听得到青天下驯鸽的飞声。从槐树叶底,朝东细数着一丝一丝漏下来的日光,或在破壁腰中,静对着像喇叭似的牵牛花(朝荣)的蓝朵,自然而然地也能够感觉到十分的秋意。
68-
</p>
69-
<p>
70-
入秋以后,蜻蜓变弱了,肉体死后,只剩灵魂,摇摇晃晃飞来飞去。透过秋日的阳光,能看到蜻蜓的身体是透明的。
71-
</p>
65+
<n-dynamic-input v-model:value="WBValue" preset="pair" key-placeholder="环境变量名"
66+
value-placeholder="环境变量值" />
67+
<q-btn class="float-right" round dense flat icon="mdi-content-save"
68+
@click="saveData('WBreakpoint')"><q-tooltip class="bg-purple text-body2" :offset="[10, 10]">
69+
保存设置
70+
</q-tooltip></q-btn>
71+
<div>
72+
<br />
73+
键值对设置 瀑布流断点:e.g. <b>1200 4</b> 代表宽度大于 1200 之后每行显示四张图片~<br />
74+
但是众所周知,软件是不会显示具体宽度的,所以你们量子调整一下就好。
75+
</div>
76+
<!-- <pre>{{ JSON.stringify(WBValue, null, 2) }}</pre> -->
7277
</q-tab-panel>
7378

7479
<q-tab-panel name="movies">
@@ -97,13 +102,13 @@
97102
</template>
98103

99104
<template v-slot:after>
100-
<q-btn round dense flat icon="mdi-send" />
105+
<q-btn disable round dense flat icon="mdi-send" />
101106
</template>
102107
</q-input>
103108

104109
<q-input bottom-slots v-model="text" label="Label">
105110
<template v-slot:after>
106-
<q-btn round dense flat icon="mdi-send" />
111+
<q-btn disable round dense flat icon="mdi-send" />
107112
</template>
108113
</q-input>
109114
</q-tab-panel>
@@ -123,6 +128,7 @@
123128
<script setup lang="ts">
124129
let text, dense
125130
import { ref, reactive, onMounted } from 'vue'
131+
import { NDynamicInput } from 'naive-ui'
126132
127133
import { useSettingStore } from 'stores/viewerSet-store';
128134
const setStore = useSettingStore()
@@ -135,6 +141,22 @@ const simpleSetData = reactive({
135141
136142
const tab = ref('mails')
137143
const splitterModel = ref(20) // 这啥啊?
144+
const WBValue: any = ref(WB2WBV(setStore.waterfallBreakpoint))
145+
146+
function WB2WBV(fValue: any) {
147+
let resultArray: any = Object.entries(fValue)
148+
resultArray = resultArray.map(([key, { rowPerView }]) => ({ key: parseInt(key), value: rowPerView }));
149+
return resultArray
150+
}
151+
152+
function WBV2WB(fValue: any) {
153+
// let resultArray: any = Object.entries(fValue)
154+
let resultArray = fValue.reduce((acc, { key, value }) => {
155+
acc[key] = { rowPerView: value };
156+
return acc;
157+
}, {});
158+
return resultArray
159+
}
138160
139161
function checked(a, b) {
140162
if (a) return a
@@ -145,8 +167,10 @@ function updateStore() {
145167
if (simpleSetData.perPageNum) setStore.perPageNum = <any>simpleSetData.perPageNum
146168
setStore.imageFormat = <any>simpleSetData.imageFormat.replace(/\s/g, '').split(',');
147169
setStore.vNavbar = Number(simpleSetData.vNavbar)
170+
setStore.waterfallBreakpoint = WBV2WB(WBValue.value)
148171
console.log(simpleSetData)
149172
console.log(setStore.vNavbar)
173+
// console.log(WBV2WB(WBValue.value))
150174
}
151175
152176
function saveData(id) {
@@ -156,6 +180,11 @@ function saveData(id) {
156180
setStore.perPageNum = checked(<any>simpleSetData.perPageNum, setStore.perPageNum)
157181
window.storeAPI.set('itemNum', setStore.perPageNum)
158182
break;
183+
case 'WBreakpoint':
184+
setStore.waterfallBreakpoint = WBV2WB(WBValue.value)
185+
window.storeAPI.set('WBreakpoint', JSON.parse(JSON.stringify(setStore.waterfallBreakpoint)))
186+
break
187+
159188
}
160189
}
161190

0 commit comments

Comments
 (0)