-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c0640c
commit 5ef645f
Showing
21 changed files
with
1,048 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ipcMain } from 'electron'; | ||
import Store from 'electron-store'; | ||
import { schema } from './default-data'; | ||
|
||
const store = new Store(); | ||
// 重构判断是否为空并 | ||
|
||
import { imageRetrieval } from './traverseFolder'; | ||
|
||
function init () { | ||
if (!store.get('itemNum')) store.store = schema; | ||
console.log('pre inited.'); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any | ||
export function ipcMains (value: void): any { | ||
init(); | ||
ipcMain.on('read-file', event => { | ||
// const fileContent = fs.readFileSync('./file-to-read.txt', { encoding: 'utf-8' }) | ||
const fileContent = 'ddd'; | ||
// Send back an IPC event to the renderer process with the file content. | ||
event.sender.send('read-file-success', fileContent); | ||
}); | ||
|
||
ipcMain.handle('store-get', (event, key) => { | ||
// console.log(store.get(key)); | ||
return store.get(key); | ||
}); | ||
|
||
ipcMain.handle('store-set', (event, key, value) => { | ||
return store.set(key, value); | ||
}); | ||
|
||
ipcMain.handle('tool-traverseFolder', (event, path) => { | ||
console.log(path); | ||
return imageRetrieval(path); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
export const schema: any = { | ||
itemNum: { | ||
type: 'number', | ||
maximum: 10000, | ||
minimum: 1, | ||
default: 50 | ||
}, | ||
viewer_navbar: { | ||
type: 'number', | ||
maximum: 5, | ||
minimum: 0, | ||
default: 0 | ||
}, | ||
foo: { | ||
type: 'number', | ||
maximum: 100, | ||
minimum: 1, | ||
default: 50 | ||
}, | ||
bar: { | ||
type: 'string', | ||
format: 'url' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
// import remote from '@electron/remote' | ||
import fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
|
||
// 指定要遍历的根路径 | ||
const rootPath = 'D:\\Picture\\五维介质'; | ||
|
||
// 存储图片文件链接的数组 | ||
const imageLinks: any[] = []; | ||
|
||
// 递归遍历文件夹 | ||
export function traverseFolder (currentPath) { | ||
const files = fs.readdirSync(currentPath); | ||
// console.log(files); | ||
files.sort((a, b) => a.localeCompare(b, undefined, { sensitivity: 'base' })); | ||
|
||
for (const file of files) { | ||
const filePath = path.join(currentPath, file); | ||
// const thefile = fs.statSync(filePath); | ||
// console.log(sha256sum(filePath)) | ||
if (isPathDirectory(filePath)) { | ||
// 如果是文件夹,递归遍历 | ||
traverseFolder(filePath); | ||
} else { | ||
// 如果是文件,检查文件扩展名是否是图片格式 | ||
const extname = path.extname(filePath).toLowerCase(); | ||
if ( | ||
[ | ||
'.webp', | ||
'.jxl', | ||
'.jpg', | ||
'.jpeg', | ||
'.png', | ||
'.gif', | ||
'.bmp', | ||
'.jfif' | ||
].includes(extname) | ||
) { | ||
// 如果是图片文件,将其链接添加到数组中 | ||
// const relativePath = path.relative(rootPath, filePath); | ||
imageLinks.push('atom://' + filePath); | ||
} | ||
} | ||
} | ||
} | ||
|
||
function isPathDirectory (thepath: string) { | ||
const thefile = fs.statSync(thepath); | ||
return thefile.isDirectory(); | ||
} | ||
|
||
export function imageRetrieval (thepath) { | ||
traverseFolder(thepath); | ||
return imageLinks; | ||
} | ||
// // 开始遍历 | ||
// traverseFolder(rootPath); | ||
|
||
// // 打印图片链接列表 | ||
// console.log(imageLinks); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
|
||
|
||
<template> | ||
<router-view /> | ||
<n-config-provider :theme-overrides="themeOverrides"> | ||
<router-view /> | ||
</n-config-provider> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
// window.storeAPI.initData() | ||
import { NConfigProvider } from 'naive-ui' | ||
const themeOverrides = { | ||
common: { | ||
primaryColor: '#1976d2' | ||
}, | ||
// Button: { | ||
// textColor: '#FF0000' | ||
// }, | ||
// Select: { | ||
// peers: { | ||
// InternalSelection: { | ||
// textColor: '#FF0000' | ||
// } | ||
// } | ||
// } | ||
} | ||
</script> |
Oops, something went wrong.