Skip to content

Commit

Permalink
feat(src): add src
Browse files Browse the repository at this point in the history
  • Loading branch information
SaidBySolo committed Jan 8, 2021
1 parent e7f62a4 commit 681cc6f
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/App.jsx
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;
13 changes: 13 additions & 0 deletions src/index.css
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;
}
17 changes: 17 additions & 0 deletions src/index.jsx
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();
}

0 comments on commit 681cc6f

Please sign in to comment.