console.log( "===== simpread option read mode load =====" ) import th from 'theme'; import * as ss from 'stylesheet'; import * as conf from 'config'; import TextField from 'textfield'; import SelectField from 'selectfield'; import Slider from 'slider'; import AC from 'ac'; import ThemeSel from 'themesel'; import Shortcuts from 'shortcuts'; const getName = ( value, items ) => { for ( const item of items ) { if ( value == "" ) return item.name; else if ( item.value == value ) return item.name; } }; export default class ReadOpt extends React.Component { parse( value ) { const news = parseInt( value ); return isNaN(news) ? 0 : news; } changeBgColor( theme ) { this.props.option.theme = theme; th.Change( this.props.option.theme ); this.props.onChange && this.props.onChange( `theme_${theme}` ); console.log( "this.props.option.theme = ", this.props.option.theme ) } changeShortcuts( shortcuts ) { this.props.option.shortcuts = shortcuts; this.props.onChange && this.props.onChange( `shortcuts_${shortcuts}` ); console.log( "this.props.option.shortcuts = ", this.props.option.shortcuts ) } changeFontfamily( name, value ) { value.trim() == "" && ( value = "default" ); conf.fontfamily.forEach( obj => { return obj.name == name && ( value = obj.value ); }) ss.FontFamily( value ); this.props.option.fontfamily = value; this.props.onChange && this.props.onChange( `fontfamily_${value}` ); console.log( "this.props.option.fontfamily = ", value, name ) } changeFontsize( value ) { this.props.option.fontsize = value + "%"; ss.FontSize( this.props.option.fontsize ); this.props.onChange && this.props.onChange( `fontsize_${this.props.option.fontsize}` ); console.log( "this.props.option.fontsize = ", this.props.option.fontsize ) } changeLayout( value ) { this.props.option.layout = `${ 100 - value }%`; ss.Layout( this.props.option.layout ); this.props.onChange && this.props.onChange( `layout_${this.props.option.layout}` ); console.log( "this.props.option.layout = ", this.props.option.layout ) } changeStyle( value, type ) { let news = value if ( value == 0 ) { news = ""; } else news = type != "lineHeight" ? value + "px" : value; this.props.option.custom.art[type] = news; ss.Custom( "art", this.props.option.custom.art ); this.props.onChange && this.props.onChange( `custom_${this.props.option.custom.art[type]}`, type ); console.log( "this.props.option.custom.art", this.props.option.custom.art[type] ) } render() { const slider_width = location.protocol.includes( "extension" ) ? "660.09px" : undefined; return ( 主题色 this.changeBgColor(val) } /> this.changeShortcuts(val) } /> 字体类型 this.changeFontfamily(n,v) } /> 字体大小 this.changeFontsize(v) }/> 版面宽度 this.changeLayout(v) }/> 字间距 this.changeStyle(v, "letterSpacing") }/> 行间距 this.changeStyle(v, "lineHeight") }/> 单词间距 this.changeStyle(v, "wordSpacing") }/> 首行缩进 this.changeStyle(v, "textIndent") }/> ) } }