diff --git a/deploy.bat b/deploy.bat index 30f113a..d26671b 100644 --- a/deploy.bat +++ b/deploy.bat @@ -20,6 +20,10 @@ git push -f origin master:gh-pages # =============================================== +# add a tags +git tag -a doc -m "doc" + + # replease npm run build npm run release -- --release-as patch diff --git a/docs/guide/config.md b/docs/guide/config.md index 4758fcc..3f36235 100644 --- a/docs/guide/config.md +++ b/docs/guide/config.md @@ -360,9 +360,54 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect ------------ ### userInfo -- Type: String -- Default: `' rabbit'` -- Usage: User information display style in the upper right corner +- Type: String | Boolean | Object +- Default: false +- Usage: User information display style in the upper right corner,Support the following three formats + 1. HTML template string, such as: + + ```js + options:{ + // Other configuration + userInfo:' Lucky', + } + ``` + + Or an ordinary string, such as: + + ```js + options:{ + // Other configuration + userInfo:'Lucky', + } + ``` + + 2. Boolean type, such as: + + `false`: Do not show + ```js + options:{ + // Other configuration + userInfo:false, // Do not display user information + } + + ``` + `ture`: Show the default string + ```js + options:{ + // Other configuration + userInfo:true, // Show HTML:' Lucky' + } + + ``` + 3. Object format, set `userImage`: user avatar address and `userName`: user name, such as: + ```js + options:{ + // Other configuration + userImage:'https://cdn.jsdelivr.net/npm/luckyresources@1.0.3/assets/img/logo/logo.png', // Avatar url + userName:'Lucky', // username + } + ``` + 4. Note that if set to `undefined` or not set, the same as setting `false` ------------ ### userMenuItem diff --git a/docs/zh/guide/config.md b/docs/zh/guide/config.md index 53ed3e9..8aa22ad 100644 --- a/docs/zh/guide/config.md +++ b/docs/zh/guide/config.md @@ -450,9 +450,55 @@ Luckysheet开放了更细致的自定义配置选项,分别有 ------------ ### userInfo -- 类型:String -- 默认值:`' rabbit'` -- 作用:右上角的用户信息展示样式 +- 类型:String | Boolean | Object +- 默认值:false +- 作用:右上角的用户信息展示样式,支持以下三种形式 + 1. HTML模板字符串,如: + + ```js + options:{ + // 其他配置 + userInfo:' Lucky', + } + ``` + + 或者一个普通字符串,如: + + ```js + options:{ + // 其他配置 + userInfo:'Lucky', + } + ``` + + 2. Boolean类型,如: + + `false`:不展示 + ```js + options:{ + // 其他配置 + userInfo:false, // 不展示用户信息 + } + + ``` + `ture`:展示默认的字符串 + ```js + options:{ + // 其他配置 + userInfo:true, // 展示HTML:' Lucky' + } + + ``` + 3. 对象格式,设置 `userImage`:用户头像地址 和 `userName`:用户名,如: + ```js + options:{ + // 其他配置 + userImage:'https://cdn.jsdelivr.net/npm/luckyresources@1.0.3/assets/img/logo/logo.png', // 头像url + userName:'Lucky', // 用户名 + } + ``` + + 4. 注意,设置为`undefined`或者不设置,同设置`false` ------------ ### userMenuItem diff --git a/gulpfile.js b/gulpfile.js index d99bc18..3a84a7f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -91,7 +91,7 @@ const paths = { 'src/plugins/js/spectrum.min.js', 'src/plugins/js/jquery-ui.min.js', 'src/plugins/js/jquery.mousewheel.min.js', - 'src/plugins/js/numeral.min.js', + // 'src/plugins/js/numeral.min.js', 'src/plugins/js/html2canvas.min.js', 'src/plugins/js/localforage.min.js', 'src/plugins/js/lodash.min.js', diff --git a/package.json b/package.json index a405992..477acdd 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "dayjs": "^1.9.6", "flatpickr": "^4.6.6", "jquery": "^2.2.4", + "numeral": "^2.0.6", "pako": "^1.0.11" }, "scripts": { diff --git a/src/config.js b/src/config.js index 26e111c..5d13cdc 100644 --- a/src/config.js +++ b/src/config.js @@ -16,13 +16,7 @@ export default { // menu: "undo|redo|freezenrow|freezencolumn|download|share|chart|pivot", data: [{ "name": "Sheet1", color: "", "status": "1", "order": "0", "data": [], "config": {}, "index":0 }, { "name": "Sheet2", color: "", "status": "0", "order": "1", "data": [], "config": {}, "index":1 }, { "name": "Sheet3", color: "", "status": "0", "order": "2", "data": [], "config": {}, "index":2 }], //客户端sheet数据[shee1, sheet2, sheet3] title: "Luckysheet Demo", //表格的名称 - // userInfo: ' rabbit' - userInfo:{ - isShow:false, - str:'', - url:'', - username:'', - },//右上角的用户信息展示样式 + userInfo:false,// 右上角的用户信息展示样式,支持 1. boolean类型:false:不展示,ture:展示默认 ' rabbit' ,2. HTML模板字符串或者普通字符串,如:' Lucky'或者'用户名', 3. 对象格式,设置 userImage:用户头像地址 和 userName:用户名 4. 不设置或者设置undefined同设置false userMenuItem: [{url:"www.baidu.com", "icon":'', "name":"我的表格"}, {url:"www.baidu.com", "icon":'', "name":"退出登陆"}], //点击右上角的用户信息弹出的菜单 myFolderUrl: "www.baidu.com", //左上角<返回按钮的链接 config: {}, //表格行高、列宽、合并单元格、公式等设置 diff --git a/src/controllers/constant.js b/src/controllers/constant.js index dfcabc9..f7d5f1a 100644 --- a/src/controllers/constant.js +++ b/src/controllers/constant.js @@ -1,12 +1,13 @@ import locale from '../locale/locale'; import Store from '../store'; import luckysheetConfigsetting from './luckysheetConfigsetting'; +import { getObjType } from '../utils/util'; //dom variable const gridHTML = function(){ const _locale = locale(); const locale_info = _locale.info; const locale_print = _locale.print; - const userInfo = luckysheetConfigsetting.userInfo + const userInfo = luckysheetConfigsetting.userInfo === true ? ' Lucky' : luckysheetConfigsetting.userInfo; // When true, use the default HTML string return `
0;x--)h="0"+h;return k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+v+(q?q:""),n?l=(n&&w?"(":"")+l+(n&&w?")":""):j>=0?l=0===j?(w?"-":"+")+l:l+(w?"-":"+"):w&&(l="-"+l),l},stringToNumber:function(a){var b,c,d,e=f[h.currentLocale],g=a,i={thousand:3,million:6,billion:9,trillion:12};if(h.zeroFormat&&a===h.zeroFormat)c=0;else if(h.nullFormat&&a===h.nullFormat||!a.replace(/[^0-9]+/g,"").length)c=null;else{c=1,"."!==e.delimiters.decimal&&(a=a.replace(/\./g,"").replace(e.delimiters.decimal,"."));for(b in i)if(d=new RegExp("[^a-zA-Z]"+e.abbreviations[b]+"(?:\\)|(\\"+e.currency.symbol+")?(?:\\))?)?$"),g.match(d)){c*=Math.pow(10,i[b]);break}c*=(a.split("-").length+Math.min(a.split("(").length-1,a.split(")").length-1))%2?1:-1,a=a.replace(/[^0-9\.]+/g,""),c*=Number(a)}return c},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},insert:function(a,b,c){return a.slice(0,c)+b+a.slice(c)},reduce:function(a,b){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof b)throw new TypeError(b+" is not a function");var c,d=Object(a),e=d.length>>>0,f=0;if(3===arguments.length)c=arguments[2];else{for(;e>f&&!(f in d);)f++;if(f>=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;e>f;f++)f in d&&(c=b(c,d[f],f,d));return c},multiplier:function(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)},correctionFactor:function(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var d=c.multiplier(b);return a>d?a:d},1)},toFixed:function(a,b,c,d){var e,f,g,h,i=a.toString().split("."),j=b-(d||0);return e=2===i.length?Math.min(Math.max(i[1].length,j),b):j,g=Math.pow(10,e),h=(c(a+"e+"+e)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}},b.options=h,b.formats=e,b.locales=f,b.locale=function(a){return a&&(h.currentLocale=a.toLowerCase()),h.currentLocale},b.localeData=function(a){if(!a)return f[h.currentLocale];if(a=a.toLowerCase(),!f[a])throw new Error("Unknown locale : "+a);return f[a]},b.reset=function(){for(var a in g)h[a]=g[a]},b.zeroFormat=function(a){h.zeroFormat="string"==typeof a?a:null},b.nullFormat=function(a){h.nullFormat="string"==typeof a?a:null},b.defaultFormat=function(a){h.defaultFormat="string"==typeof a?a:"0.0"},b.register=function(a,b,c){if(b=b.toLowerCase(),this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");return this[a+"s"][b]=c,c},b.validate=function(a,c){var d,e,f,g,h,i,j,k;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a.match(/^\d+$/))return!0;if(""===a)return!1;try{j=b.localeData(c)}catch(l){j=b.localeData(b.locale())}return f=j.currency.symbol,h=j.abbreviations,d=j.delimiters.decimal,e="."===j.delimiters.thousands?"\\.":j.delimiters.thousands,k=a.match(/^[^\d]+/),null!==k&&(a=a.substr(1),k[0]!==f)?!1:(k=a.match(/[^\d]+$/),null!==k&&(a=a.slice(0,-1),k[0]!==h.thousand&&k[0]!==h.million&&k[0]!==h.billion&&k[0]!==h.trillion)?!1:(i=new RegExp(e+"{2}"),a.match(/[^\d.,]/g)?!1:(g=a.split(d),g.length>2?!1:g.length<2?!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i):1===g[0].length?!!g[0].match(/^\d+$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/):!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/))))},b.fn=a.prototype={clone:function(){return b(this)},format:function(a,c){var d,f,g,i=this._value,j=a||h.defaultFormat;if(c=c||Math.round,0===i&&null!==h.zeroFormat)f=h.zeroFormat;else if(null===i&&null!==h.nullFormat)f=h.nullFormat;else{for(d in e)if(j.match(e[d].regexps.format)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},input:function(){return this._input},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b,c,e){return a+Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([this._value,a],b,0)/d,this},subtract:function(a){function b(a,b,c,e){return a-Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([a],b,Math.round(this._value*d))/d,this},multiply:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)*Math.round(b*f)/Math.round(f*f)}return this._value=c.reduce([this._value,a],b,1),this},divide:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)/Math.round(b*f)}return this._value=c.reduce([this._value,a],b),this},difference:function(a){return Math.abs(b(this._value).subtract(a).value())}},b.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),function(){b.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(a,c,d){var e,f=b._.includes(c," BPS")?" ":"";return a=1e4*a,c=c.replace(/\s?BPS/,""),e=b._.numberToFormat(a,c,d),b._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"BPS"),e=e.join("")):e=e+f+"BPS",e},unformat:function(a){return+(1e-4*b._.stringToNumber(a)).toFixed(15)}})}(),function(){var a={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},c={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},d=a.suffixes.concat(c.suffixes.filter(function(b){return a.suffixes.indexOf(b)<0})),e=d.join("|");e="("+e.replace("B","B(?!PS)")+")",b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(e)},format:function(d,e,f){var g,h,i,j,k=b._.includes(e,"ib")?c:a,l=b._.includes(e," b")||b._.includes(e," ib")?" ":"";for(e=e.replace(/\s?i?b/,""),h=0;h<=k.suffixes.length;h++)if(i=Math.pow(k.base,h),j=Math.pow(k.base,h+1),null===d||0===d||d>=i&&j>d){l+=k.suffixes[h],i>0&&(d/=i);break}return g=b._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=b._.stringToNumber(d);if(g){for(e=a.suffixes.length-1;e>=0;e--){if(b._.includes(d,a.suffixes[e])){f=Math.pow(a.base,e);break}if(b._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){b.register("format","currency",{regexps:{format:/(\$)/},format:function(a,c,d){var e,f,g,h=b.locales[b.options.currentLocale],i={before:c.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:c.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(c=c.replace(/\s?\$\s?/,""),e=b._.numberToFormat(a,c,d),a>=0?(i.before=i.before.replace(/[\-\(]/,""),i.after=i.after.replace(/[\-\)]/,"")):0>a&&!b._.includes(i.before,"-")&&!b._.includes(i.before,"(")&&(i.before="-"+i.before),g=0;g