-
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.
Merge pull request #2 from Saebasol/develop
feat(src): add src
- Loading branch information
Showing
6 changed files
with
169 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,59 @@ | ||
import * as React from 'react' | ||
import JSZip from 'jszip' | ||
import saveAs from 'file-saver' | ||
import api from './api' | ||
|
||
|
||
function App() { | ||
const { useState, useEffect } = React | ||
|
||
const [index, setIndex] = useState(0) | ||
|
||
async function mainFunc() { | ||
const params = new URLSearchParams(window.location.search) | ||
const downloadIndex = params.get("index") | ||
|
||
if (!downloadIndex || !Number.isNaN(downloadIndex)) { | ||
alert("인자값이 주어지지 않았습니다!") | ||
return | ||
} | ||
if (window.confirm("브라우저의 한계로 많은 이미지는 다운로드 할수 없을수도 있습니다. 시도하시겠습니까?")) { | ||
const zip = new JSZip() | ||
const imageFolder = zip.folder(downloadIndex) | ||
|
||
const imageInfoResponse = await fetch(api + `hitomi/images/${downloadIndex}`) | ||
if (imageInfoResponse.status == 404) { | ||
alert("찾을수 없습니다.") | ||
return | ||
} | ||
const imagesInfo = await imageInfoResponse.json() | ||
|
||
let count = 0 | ||
|
||
const downloadImage = imagesInfo.files.map(async (imageInfo, index) => { | ||
const image = await fetch(api + "proxy/" + imageInfo.image) | ||
const imgBlob = await image.blob() | ||
|
||
imageFolder.file(imageInfo.name, imgBlob) | ||
setIndex(count += 1) | ||
}) | ||
|
||
await Promise.all(downloadImage) | ||
const content = await zip.generateAsync({ type: 'blob' }) | ||
saveAs.saveAs(content, `${downloadIndex}.zip`) | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
mainFunc() | ||
}, []) | ||
|
||
return ( | ||
<div className='App'> | ||
<h1>다운로드 중: {index}</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 @@ | ||
export default "https://beta.doujinshiman.ga/v4/api/" |
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 * as React from 'react' | ||
import * as ReactDOM from 'react-dom' | ||
import App from './App.jsx' | ||
import 'normalize.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(); | ||
} |
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