Ver código fonte

增加一个小工具集,包括进制转换、颜色转换

zxlie 6 anos atrás
pai
commit
e4a6c3344d

+ 1 - 0
README.md

@@ -43,6 +43,7 @@ https://chrome.google.com/webstore/detail/pkgccpejnmalmdinmhkkfafefagiiiad?hl=zh
 - 编码规范检测(HTML/CSS/JS规范检测)
 - 页面性能检测(页面响应时间、Header监测)
 - 页面栅格标尺(页面栅格化、屏幕标尺)
+- 多维小工具集(进制转换、RGBA/HEX颜色转换等)
 - Ajax调试功能(需在控制台中使用)
 - 网页编码设置(UTF-8、GBK、日文、韩文等)
 - 我的便签笔记(便签笔记,支持导出)

+ 3 - 0
apps/background/index.js

@@ -493,6 +493,9 @@ var BgPageInstance = (function () {
                     MENU_REMOVE_BG: function (info, tab) {
                         _openFileAndRun(tab, MSG_TYPE.REMOVE_BG);
                     },
+                    MENU_MULTI_TOOLKIT: function (info, tab) {
+                        _openFileAndRun(tab, MSG_TYPE.MULTI_TOOLKIT);
+                    },
                     MENU_GRID_RULER: function (info, tab) {
                         _doGridDetect(tab);
                     },

+ 2 - 2
apps/manifest.json

@@ -1,9 +1,9 @@
 {
   "name": "WEB前端助手(FeHelper)",
-  "version": "2019.04.1811",
+  "version": "2019.04.2919",
   "manifest_version": 2,
   "default_locale": "zh_CN",
-  "description": "FE助手:JSON格式化、JSON比对、二维码生成与解码、信息编解码、代码压缩&美化、页面取色、Markdown与HTML、网页截屏、编码设置、正则、时间转换、网页性能检测、Ajax调试、密码生成器、便签笔记、chrome插件下载",
+  "description": "FE助手:JSON格式化、JSON比对、二维码生成与解码、信息编解码、代码压缩&美化、页面取色、Markdown与HTML、网页截屏、编码设置、正则、时间转换、网页性能检测、Ajax调试、密码生成器、便签笔记、chrome插件下载",
   "icons": {
     "16": "static/img/fe-16.png",
     "48": "static/img/fe-48.png",

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
apps/options/index.html


+ 6 - 1
apps/options/settings.js

@@ -35,7 +35,8 @@ module.exports = (() => {
         'AUTO_TEXT_DECODE',
         'STICKY_NOTES',
         'GRID_RULER',
-        'REMOVE_BG'
+        'REMOVE_BG',
+        'MULTI_TOOLKIT'
     ];
 
     // 默认处理关闭状态的功能,除非用户手动打开
@@ -135,6 +136,10 @@ module.exports = (() => {
             icon: '✚',
             text: '页面栅格标尺'
         },
+        MENU_MULTI_TOOLKIT: {
+            icon: '❖',
+            text: '多维小工具集'
+        },
         MENU_REMOVE_BG: {
             icon: '⚘',
             text: '人像背景移除'

+ 3 - 1
apps/popup/index.css

@@ -154,10 +154,12 @@ ul.fe-function-list li.-x-sticky-notes b {
 ul.fe-function-list li.-x-grid-ruler b {
     background-position: -33px -127px;
 }
-
 ul.fe-function-list li.-x-remove-bg b {
     background-position: -145px -127px;
 }
+ul.fe-function-list li.-x-multi-toolkit b {
+    background-position: -176px -111px;
+}
 
 ul.fe-function-list li i {
     color: #aaa;

+ 2 - 0
apps/popup/index.html

@@ -43,6 +43,8 @@
                     <b></b>页面性能检测</li>
                 <li class="-x-grid-ruler" @click="runHelper('GRID_RULER',0)" v-if="canMeShow.GRID_RULER">
                     <b></b>页面栅格标尺</li>
+                <li class="-x-multi-toolkit" @click="runHelper('MULTI_TOOLKIT',1)" v-if="canMeShow.MULTI_TOOLKIT">
+                    <b></b>多维小工具集</li>
                 <li class="-x-ajax-debugger" title="在开发者工具-Console面板使用" @click="runHelper('AJAX_DEBUGGER',0)" v-if="canMeShow.AJAX_DEBUGGER">
                     <b></b>Ajax调试:<i>{{ ajaxDebugger }}</i></li>
                 <li class="-x-sticky-notes" @click="runHelper('STICKY_NOTES',1)" v-if="canMeShow.STICKY_NOTES">

+ 3 - 0
apps/static/js/msg_type.js

@@ -111,6 +111,9 @@ const MSG_TYPE = {
     // 屏幕栅格标尺
     GRID_RULER: 'grid-ruler',
 
+    // 多维小工具
+    MULTI_TOOLKIT: 'toolkit',
+
     // 人像背景移除
     REMOVE_PERSON_IMG_BG:'remove-person-img-bg',
     REMOVE_BG:'remove-bg'

BIN
apps/static/screenshot/crx/WEB前端助手(FeHelper)_v2019.04.2919.crx


+ 85 - 0
apps/toolkit/index.css

@@ -0,0 +1,85 @@
+@import url("../static/css/bootstrap.min.css");
+
+
+.ui-widget-content {
+    border:none;
+}
+
+.ui-widget-header {
+    background: #fff;
+    border:none;
+    border-bottom: 1px solid #ccc;
+    border-radius: 10px;
+}
+
+.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default {
+    background: none;
+    border:0;
+}
+
+.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active {
+    background: none;
+    color: #48b;
+    border:0;
+}
+.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited {
+    color: #48b;
+}
+
+
+.mod-tab {
+    display: none;
+}
+.ui-tabs {
+    padding-bottom: 5em;
+}
+.mod-radios {
+    font-size: 14px;
+}
+.mod-tab label {
+    margin-right: 20px;
+    font-weight: normal;
+    font-size: 14px;
+}
+.mod-value label{
+    margin-right: 0;
+    font-size: 16px;
+}
+.mod-value .x-input {
+    display: inline-block;
+    width: 400px;
+}
+select.x-select {
+    display: inline-block;
+    width: 114px;
+}
+.radix-tips {
+    margin-left: 160px;
+    font-size: 12px;
+    color: #bbb;
+    font-style: italic;
+}
+.row.x-tips {
+    font-size: 14px;
+    color: #aaa;
+    font-style: italic;
+    margin-bottom: 40px;
+}
+
+.mod-color .col-input {
+    display: inline-block;
+    width: 220px;
+}
+.mod-color label {
+    margin-right: 0;
+}
+.mod-color .demo-color {
+    display: inline-block;
+    width: 60px;
+    height: 24px;
+    border: 1px solid #000;
+    margin-left: 5px;
+}
+.mod-color .x-xlabel {
+    margin-left: 80px;
+}

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
apps/toolkit/index.html


+ 99 - 0
apps/toolkit/index.js

@@ -0,0 +1,99 @@
+/**
+ * FeHelper 多维度工具组合
+ */
+new Vue({
+    el: '#pageContainer',
+    data: {
+        radix: {
+            fromArray: [2, 4, 8, 10, 16],
+            fromSelected: 10,
+            toArray: [2, 4, 8, 10, 16],
+            toSelected: 16,
+            srcValue: 100,
+            rstValue: 0
+        },
+
+        color: {
+            fromHEX: '#43ad7f7f',
+            toRGB: '',
+            fromRGB: 'rgba(190,20,128,0.5)',
+            toHEX: ''
+        }
+    },
+
+    mounted: function () {
+        jQuery('#tabs').tabs();
+
+        // 进制转换的初始化
+        this.radixConvert();
+
+        // 初始化颜色转换
+        this.colorHexToRgb();
+        this.colorRgbToHex();
+    },
+
+    methods: {
+        getId: (type, id) => [type, id].join('_'),
+
+        radixRadioClicked: function (type, n) {
+            if (type === 1) {
+                this.radix.fromSelected = n;
+            } else {
+                this.radix.toSelected = n;
+            }
+            this.radixConvert();
+        },
+
+        radixConvert: function () {
+            this.$nextTick(() => {
+                this.radix.rstValue = parseInt(this.radix.srcValue, this.radix.fromSelected).toString(this.radix.toSelected);
+            });
+        },
+
+        colorHexToRgb: function () {
+            let hex = this.color.fromHEX.trim().replace(/^#/, '');
+            let rgb = [];
+            switch (hex.length) {
+                case 3:
+                case 4:
+                    rgb.push(parseInt(hex[0] + '' + hex[0], 16).toString(10));                       // r
+                    rgb.push(parseInt(hex[1] + '' + hex[1], 16).toString(10));                       // g
+                    rgb.push(parseInt(hex[2] + '' + hex[2], 16).toString(10));                       // b
+                    hex.length === 4 && rgb.push((parseInt(parseInt(hex[3] + '' + hex[3], 16).toString(10)) / 256).toFixed(2));   // a
+                    break;
+                case 6:
+                case 8:
+                    rgb.push(parseInt(hex[0] + '' + hex[1], 16).toString(10));                       // r
+                    rgb.push(parseInt(hex[2] + '' + hex[3], 16).toString(10));                       // g
+                    rgb.push(parseInt(hex[4] + '' + hex[5], 16).toString(10));                       // b
+                    hex.length === 8 && rgb.push((parseInt(parseInt(hex[6] + '' + hex[7], 16).toString(10)) / 256).toFixed(2));   // a
+                    break;
+            }
+            if (rgb.length === 3) {
+                this.color.toRGB = 'rgb(' + rgb.join(', ') + ')';
+            } else if (rgb.length === 4) {
+                this.color.toRGB = 'rgba(' + rgb.join(', ') + ')';
+            } else {
+                this.color.toRGB = '';
+            }
+        },
+
+        colorRgbToHex: function () {
+            let rgb = this.color.fromRGB.trim().replace(/\s+/g, '').replace(/[^\d,\.]/g, '').split(',').filter(n => {
+                return n.length && parseInt(n, 10) <= 255;
+            });
+            let hex = [];
+            if (rgb.length === 3 || rgb.length === 4) {
+                hex.push(parseInt(rgb[0], 10).toString(16).padStart(2, '0'));                       // r
+                hex.push(parseInt(rgb[1], 10).toString(16).padStart(2, '0'));                       // g
+                hex.push(parseInt(rgb[2], 10).toString(16).padStart(2, '0'));                       // b
+                rgb.length === 4 && hex.push(Math.floor(parseFloat(rgb[3], 10) * 256).toString(16).padStart(2, '0'));   // a
+            }
+            if (hex.length) {
+                this.color.toHEX = '#' + hex.join('');
+            } else {
+                this.color.toHEX = '';
+            }
+        }
+    }
+});

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff