import './style.scss' ; const Vue = process . env . NODE_ENV === 'development' ? require ( '../../node_modules/vue/dist/vue.js' ) : require ( '../../node_modules/vue/dist/vue.min.js' ) ; const app = new Vue ( { el : "#root" , data ( ) { return { throttleHandler : 0 , isSupport : false , saveTypes : [ 'svg' , 'png' , 'jpg' , 'webp' ] , iconSize : + localStorage . getItem ( '_icon_font_site_' ) || 200 , iconColor : localStorage . getItem ( '_icon_font_color_' ) || '' , } ; } , filters : { uppercase ( text ) { return text . toString ( ) . toUpperCase ( ) ; } } , methods : { param data param data . type { string } sendMessage ( data ) { chrome . tabs . query ( { active : true , currentWindow : true } , function ( tabs ) { const params = Object . assign ( { target : 'content' } , data ) ; chrome . tabs . sendMessage ( tabs [ 0 ] . id , params , function ( response ) { console . log ( "response =>" + response ) ; } ) ; } ) ; } , param type select ( type ) { return this . sendMessage ( { type } ) ; } , param type download ( type ) { return this . sendMessage ( { type : `download-${ type }` , size : this . iconSize , } ) ; } , param color setColor ( color ) { localStorage . setItem ( '_icon_font_color_' , color ) ; this . sendMessage ( { type : 'set-icon-color' , color } ) ; } , /**
         * 应用颜色
         */ applyColor ( ) { this . setColor ( this . iconColor ) ; } , /**
         * 重置颜色
         */ resetColor ( ) { this . setColor ( '' ) ; } } , watch : { iconSize ( newVal , oldVal ) { clearTimeout ( this . throttleHandler ) ; if ( newVal === oldVal ) return ; this . throttleHandler = window . setTimeout ( ( ) => localStorage . setItem ( '_icon_font_site_' , newVal ) , 200 ) ; } } , created ( ) { chrome && chrome . tabs && chrome . tabs . query && chrome . tabs . query ( { active : true } , ( tabs ) => { const tab = tabs [ 0 ] ; const url = tab . url ; this . isSupport = /^https?:\/\/(www.)?iconfont.cn/ . test ( url ) ; } ) ; } } ) ;