From 476bd710657a813912517c0c203212e28aaed2bf Mon Sep 17 00:00:00 2001 From: xiazeyu Date: Sat, 26 May 2018 11:56:18 +0800 Subject: [PATCH] feat(config): rename defaultConfig.json to defaultConfig.js, remove mobileShow&mobileScale(use displ prototype BREAKING CHANGE: rename defaultConfig.json to defaultConfig.js, remove mobileShow&mobileScale(use displayFunc instead), remove modelScale(nouse), add z-index&displayFunc re #19 --- README.md | 2 +- build/afterBuild.js | 8 ++++---- src/config/configMgr.js | 3 +-- src/config/defaultConfig.js | 30 ++++++++++++++++++++++++++++++ src/config/defaultConfig.json | 19 ------------------- src/index.js | 2 +- 6 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 src/config/defaultConfig.js delete mode 100644 src/config/defaultConfig.json diff --git a/README.md b/README.md index 7b1aeb5..21ee983 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ javascript:function loadScript(c,b){var a=document.createElement("script");a.typ See the [document](https://l2dwidget.js.org/docs/typedef/index.html#static-typedef-Config). -Default settings are at[defaultConfig.json](https://cdn.jsdelivr.net/npm/live2d-widget@4/dist/defaultConfig.json). +Default settings are at[defaultConfig.js](https://cdn.jsdelivr.net/npm/live2d-widget@4/dist/defaultConfig.js). Enjoy!:beer: diff --git a/build/afterBuild.js b/build/afterBuild.js index 722ced5..33ffd46 100644 --- a/build/afterBuild.js +++ b/build/afterBuild.js @@ -2,18 +2,18 @@ const fs = require('fs'); const path = require('path'); const getProjPath = require('./getProjPath'); -// Copy defaultConfig.json +// Copy defaultConfig.js getProjPath((projPath) => { - fs.copyFile(path.resolve(projPath, 'src/config/defaultConfig.json'), path.resolve(projPath, 'dist/defaultConfig.json'), (err) => { + fs.copyFile(path.resolve(projPath, 'src/config/defaultConfig.js'), path.resolve(projPath, 'dist/defaultConfig.js'), (err) => { if (err) { - console.error('Failed copying defaultConfig.json'); + console.error('Failed copying defaultConfig.js'); throw err; } - console.log('succeeded copying defaultConfig.json'); + console.log('succeeded copying defaultConfig.js'); }); diff --git a/src/config/configMgr.js b/src/config/configMgr.js index e7184f3..c743e2b 100644 --- a/src/config/configMgr.js +++ b/src/config/configMgr.js @@ -2,7 +2,7 @@ import defaultConfig from './defaultConfig'; /** * @typedef {Object} Config - * @desc The object structure for config. Default config sees [dist/defaultConfig.json](https://cdn.jsdelivr.net/npm/live2d-widget/dist/defaultConfig.json). + * @desc The object structure for config. Default config sees [dist/defaultConfig.js](https://cdn.jsdelivr.net/npm/live2d-widget/dist/defaultConfig.js). * @property {String} modelJsonPath="https://cdn.jsdelivr.net/npm/live2d-widget-model-shizuku/assets/shizuku.model.json" Specifies the path to `.model.json`. 模型`.model.json`文件路径
eg. `"/live2d/miku.model.json"`
`"https://test.com/live2d/miku.model.json"`
`"http://test.com/live2d/miku.model.json"`
`"file:///d:/live2d/miku.model.json"` * @property {String} displayWidth="150px" Specifies the width of actual widget element. 插件宽度
eg. `150` == `"150px"`, `"35%"`, `"auto"`
*used as canvas.element.width.* * @property {String} displaySide="right" Specifies left or right side to show. 左右侧显示位置
eg. `"left"`, `"right"` @@ -16,7 +16,6 @@ import defaultConfig from './defaultConfig'; * @property {Number} displaySampleLevel Sampling level. 采样等级 * @property {Number} displayOffsetV Vertical offset of canvas. canvas垂直偏移 * @property {Number} displayOffsetH Horizontal offset of canvas. canvas水平偏移 - * @property {Boolean} mobileShow If show on mobile device. 是否在移动设备上显示 * @property {Boolean} mobileMotion If enable motion reaction on mobile devices. 是否在移动设备上开启运动响应 * @property {Boolean} devMouseLog=false If shows mouse log. 显示鼠标日志 * @property {Boolean} devLog=false If shows log. 显示日志 diff --git a/src/config/defaultConfig.js b/src/config/defaultConfig.js new file mode 100644 index 0000000..a06c78a --- /dev/null +++ b/src/config/defaultConfig.js @@ -0,0 +1,30 @@ +export default { + 'devLog': false, + 'devMouseLog': false, + 'displayFunc': () => ({ + 'displayHeight': null, + 'displayMotion': null, + 'displayOffsetH': null, + 'displayOffsetV': null, + 'displayOpacityDefault': null, + 'displayOpacityOnHover': null, + 'displaySampleLevel': null, + 'displayShow': null, + 'displaySide': null, + 'displayWidth': null, + }), + 'displayHeight': '300px', + 'displayMotion': true, + 'displayOffsetH': 0, + 'displayOffsetV': -20, + 'displayOpacityDefault': 0.7, + 'displayOpacityOnHover': 0.2, + 'displaySampleLevel': 2, + 'displayShow': true, + 'displaySide': 'right', + 'displayWidth': '150px', + 'modelHeadPosH': 0.5, + 'modelHeadPosV': 0.618, + 'modelJsonPath': 'https://cdn.jsdelivr.net/npm/live2d-widget-model-shizuku/assets/shizuku.model.json', + 'z-index': 2333, +}; diff --git a/src/config/defaultConfig.json b/src/config/defaultConfig.json deleted file mode 100644 index f76037c..0000000 --- a/src/config/defaultConfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "devLog": false, - "devMouseLog": false, - "displayHeight": "300px", - "displayOffsetH": 0, - "displayOffsetV": -20, - "displaySampleLevel": 2, - "displaySide": "right", - "displayWidth": "150px", - "mobileMotion": true, - "mobileScale": 0.5, - "mobileShow": true, - "modelHeadPosH": 0.5, - "modelHeadPosV": 0.618, - "modelJsonPath": "https://cdn.jsdelivr.net/npm/live2d-widget-model-shizuku/assets/shizuku.model.json", - "modelScale": 1, - "reactOpacityDefault": 0.7, - "reactOpacityOnHover": 0.2 -} diff --git a/src/index.js b/src/index.js index 23ddd6b..d177109 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -/* global process, device */ +/* global process */ import { configDefaulter,