@@ -13,7 +13,6 @@ import {
1313 isAbreastMode ,
1414 isEnableBg ,
1515} from '../actions' ;
16- import { useStyleMemo } from '../hooks/useStyle' ;
1716import classes from '../index.module.css' ;
1817import { store } from '../store' ;
1918
@@ -44,33 +43,34 @@ export const ComicImg: Component<_ComicImg & { index: number }> = (img) => {
4443 const renderClone = ( ) =>
4544 ! store . gridMode && showState ( ) !== undefined && cloneNum ( ) > 0 ;
4645
47- const selector = `. ${ classes . img } [id^="_ ${ img . index } _"]` ;
48- useStyleMemo ( selector , {
49- 'grid-area' : ( ) =>
50- isAbreastMode ( ) && ! store . gridMode ? 'none' : `_ ${ img . index } ` ,
51- 'background-color' : ( ) => ( isEnableBg ( ) ? img . background : undefined ) ,
52- } ) ;
53- useStyleMemo ( `${ selector } > picture` , {
54- 'aspect-ratio' : ( ) => ` ${ img . size . width } / ${ img . size . height } ` ,
55- background : ( ) =>
56- img . progress &&
57- `linear-gradient(
58- to bottom,
59- var(--secondary-bg) ${ img . progress } %,
60- var(--hover-bg-color,#fff3) ${ img . progress } %
61- )` ,
62- } ) ;
46+ const styles = createMemo ( ( ) => ( {
47+ img : {
48+ 'grid-area' : isAbreastMode ( ) && ! store . gridMode ? 'none' : `_ ${ img . index } ` ,
49+ 'background-color' : isEnableBg ( ) ? img . background : undefined ,
50+ } ,
51+ picture : {
52+ 'aspect-ratio' : `${ img . size . width } / ${ img . size . height } ` ,
53+ background : img . progress
54+ ? `linear-gradient(
55+ to bottom,
56+ var(--secondary-bg) ${ img . progress } %,
57+ var(--hover-bg-color,#fff3) ${ img . progress } %
58+ )`
59+ : undefined ,
60+ } ,
61+ } ) ) ;
6362
6463 const _ComicImg : Component < { cloneIndex ?: number } > = ( props ) => (
6564 < div
6665 class = { classes . img }
6766 id = { `_${ img . index } _${ props . cloneIndex ?? 0 } ` }
67+ style = { styles ( ) . img }
6868 data-show = { showState ( ) }
6969 data-type = { img . type ?? store . defaultImgType }
7070 data-load-type = { img . loadType === 'loaded' ? undefined : img . loadType }
7171 >
7272 { /* 因为 img 无法使用 ::after,所以得用 picture 包一下 */ }
73- < picture >
73+ < picture style = { styles ( ) . picture } >
7474 < Show when = { img . loadType !== 'wait' && src ( ) } >
7575 < img
7676 src = { src ( ) }
0 commit comments