-
Notifications
You must be signed in to change notification settings - Fork 0
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
e7f62a4
commit 681cc6f
Showing
3 changed files
with
77 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { useState, useEffect } from 'react' | ||
import JSZip from 'jszip' | ||
import saveAs from 'file-saver'; | ||
|
||
|
||
function App() { | ||
|
||
const [data, setData] = useState(0) | ||
// const headers = { 'Authorization': '' } | ||
|
||
// TODO: Change the user to selectively download using the url path, and change the folder and compressed file name | ||
async function mainFunc() { | ||
let zip = new JSZip() | ||
let imageFolder = zip.folder('1') | ||
|
||
const imageInfoResponse = await fetch('https://doujinshiman.ga/v3/api/hitomi/images/1', { headers }) | ||
const imagesInfo = await imageInfoResponse.json() | ||
|
||
const downloadImage = imagesInfo.images.map(async (imageInfo, index) => { | ||
const image = await fetch(imageInfo.url) | ||
const imgBlob = await image.blob() | ||
|
||
// TODO: Get filename | ||
imageFolder.file(`${index}.png`, imgBlob) | ||
setData(index + 1) | ||
}) | ||
|
||
Promise.all(downloadImage).then(() => | ||
zip.generateAsync({ type: 'blob' }) | ||
.then(content => { | ||
saveAs.saveAs(content, '1.zip') | ||
})) | ||
} | ||
|
||
useEffect(() => { | ||
mainFunc() | ||
}, []) | ||
|
||
return ( | ||
<div className='App'> | ||
<h1>다운로드 중: {data}</h1> | ||
</div> | ||
|
||
) | ||
} | ||
|
||
export default App; |
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,13 @@ | ||
body { | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | ||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | ||
sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
code { | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | ||
monospace; | ||
} |
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,17 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import App from './App.jsx'; | ||
import './index.css'; | ||
|
||
ReactDOM.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode>, | ||
document.getElementById('root'), | ||
); | ||
|
||
// Hot Module Replacement (HMR) - Remove this snippet to remove HMR. | ||
// Learn more: https://www.snowpack.dev/concepts/hot-module-replacement | ||
if (import.meta.hot) { | ||
import.meta.hot.accept(); | ||
} |