-
Notifications
You must be signed in to change notification settings - Fork 80
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
Showing
7 changed files
with
80 additions
and
8 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
node_modules | ||
dist/ |
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
#app>div{ | ||
padding: 0 0 0.8em; | ||
border-top: var(--sub-bg) 2px dashed; | ||
position: relative; | ||
} | ||
|
||
#app h3 { | ||
|
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 @@ | ||
export {default as ResultArea} from './result-area' |
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,55 @@ | ||
import {dom, Loading} from "../ui/index.js"; | ||
import './result.css' | ||
|
||
export default class { | ||
/** @type {HTMLDivElement} */ | ||
#parentElement | ||
/** @type {HTMLDivElement} */ | ||
#element | ||
/** @type {HTMLImageElement} */ | ||
#imageEle | ||
/** @type {Loading} */ | ||
#loading | ||
|
||
constructor() { | ||
this.#parentElement = dom() | ||
this.#element = dom('div', {id: 'result-area'}) | ||
this.#parentElement.append( | ||
dom('h3', {html: 'Result: 生成结果'}), | ||
this.#element | ||
) | ||
|
||
this.#imageEle = new Image() | ||
this.#hideImg() | ||
this.#element.appendChild(this.#imageEle) | ||
this.#loading = new Loading(this.#element) | ||
this.#loading.show() | ||
} | ||
|
||
set promise(imgPromise) { | ||
(async () => { | ||
this.#loading.show() | ||
try { | ||
const data = await imgPromise | ||
this.#imageEle.src = URL.createObjectURL(await data.blob()) | ||
this.#showImg() | ||
this.#loading.hide() | ||
} catch (e) { | ||
this.#loading.error() | ||
throw new Error(e) | ||
} | ||
})() | ||
} | ||
|
||
#hideImg() { | ||
this.#imageEle.classList.add('hide') | ||
} | ||
|
||
#showImg() { | ||
this.#imageEle.classList.remove('hide') | ||
} | ||
|
||
get dom() { | ||
return this.#parentElement | ||
} | ||
} |
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,11 @@ | ||
#result-area { | ||
position: relative; | ||
max-width: calc(min(50vw, 24em) + 8em); | ||
min-height: 8em; | ||
border-radius: 16px; | ||
} | ||
|
||
#result-area>img { | ||
width: 100%; | ||
border-radius: inherit; | ||
} |
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