-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
44 changed files
with
1,077 additions
and
341 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
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
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
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,48 @@ | ||
const { dialog } = require('electron'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const sharp = require('sharp'); | ||
const store = require('./store'); | ||
|
||
const copy = (oldPath, newPath) => { | ||
let readStream = fs.createReadStream(oldPath); | ||
let writeStream = fs.createWriteStream(newPath); | ||
readStream.on('error', () => {}); | ||
writeStream.on('error', () => {}); | ||
readStream.on('close', () => { | ||
// fs.unlink(oldPath, () => {}); | ||
}); | ||
readStream.pipe(writeStream); | ||
}; | ||
const previews = async (previews, userDataPath, filePath) => { | ||
if (!fs.existsSync(path.join(userDataPath, 'previews'))) { | ||
fs.mkdirSync(path.join(userDataPath, 'previews')); | ||
} | ||
const fileName = path.parse(filePath).name; | ||
const fileExt = path.parse(filePath).ext; | ||
const dest = path.join(userDataPath, `previews/${fileName}${fileExt}`); | ||
console.log(dest); | ||
await sharp(filePath) | ||
.resize(200, 200) | ||
.toFile(dest, (err, resizeImage) => { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log(resizeImage); | ||
} | ||
}); | ||
const oldPreviews = await previews.get('paths'); | ||
await previews.set('paths', [...oldPreviews, `${dest.split(path.sep).join(path.posix.sep)}`]); | ||
}; | ||
|
||
const openFile = async () => { | ||
const { filePaths } = await dialog.showOpenDialog({ | ||
filters: [{ name: 'Изображения', extensions: ['jpg', 'png', 'gif'] }], | ||
properties: ['openFile'], | ||
}); | ||
file = [...filePaths]; | ||
filePathPosix = [filePaths[0].split(path.sep).join(path.posix.sep)]; | ||
return { file, filePathPosix }; | ||
}; | ||
|
||
module.exports = { copy, previews, openFile }; |
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.
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,5 +1,6 @@ | ||
.wrapper { | ||
border: 4px dashed var(--accent); | ||
|
||
position: relative; | ||
} | ||
.text { | ||
|
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,6 @@ | ||
.wrapper { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 20px; | ||
} |
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,24 @@ | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
import { Image } from '../'; | ||
import styles from './Editor.module.css'; | ||
|
||
const Editor = (props) => { | ||
const { image, progress, percent } = props; | ||
const editor = useRef(null); | ||
const [size, setSize] = useState(500); | ||
const resize = () => setSize(Math.min(editor.current.offsetWidth, editor.current.offsetHeight)); | ||
useEffect(() => { | ||
resize(); | ||
window.addEventListener('resize', resize); | ||
return () => { | ||
window.removeEventListener('resize', resize); | ||
}; | ||
}, []); | ||
return ( | ||
<div ref={editor} className={styles.wrapper}> | ||
<Image image={image} size={size} progress={progress} percent={percent} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Editor; |
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,5 @@ | ||
.wrapper { | ||
padding: 20px; | ||
height: calc(100vh - 32px); | ||
background-color: var(--frame); | ||
} |
Oops, something went wrong.