mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
add comma settings (#302)
This commit is contained in:
parent
5b23ea3349
commit
4648012408
@ -1,5 +1,6 @@
|
||||
import lodash from 'lodash'
|
||||
import { Character } from '../models/index.js'
|
||||
import { Cfg } from '../components/index.js'
|
||||
|
||||
let CharId = Character.CharId
|
||||
|
||||
@ -10,7 +11,8 @@ let Format = {
|
||||
comma: function (num, fix = 0) {
|
||||
num = parseFloat((num * 1).toFixed(fix))
|
||||
let [integer, decimal] = String.prototype.split.call(num, '.')
|
||||
integer = integer.replace(/\d(?=(\d{3})+$)/g, '$&,') // 正则先行断言
|
||||
let re = new RegExp(`\\d(?=(\\d{${Cfg.get('commaGroup', 3)}})+$)`, 'g');
|
||||
integer = integer.replace(re, '$&,') // 正则先行断言 = /\d(?=(\d{3})+$)/g
|
||||
return `${integer}${fix > 0 ? '.' + (decimal || lodash.repeat('0', fix)) : ''}`
|
||||
},
|
||||
pct: function (num, fix = 1) {
|
||||
|
@ -17,6 +17,9 @@ export const avatarWife = true
|
||||
// 戳一戳卡片
|
||||
export const avatarPoke = true
|
||||
|
||||
// 数字分组
|
||||
export const commaGroup = 3
|
||||
|
||||
/** ************ 【角色资料与信息查询】 ************* */
|
||||
// #刻晴图鉴 的图鉴信息
|
||||
export const charWiki = true
|
||||
|
@ -47,7 +47,14 @@ export const cfgSchema = {
|
||||
key: '戳一戳',
|
||||
def: true,
|
||||
oldCfgKey: 'char.poke'
|
||||
}
|
||||
},
|
||||
commaGroup: {
|
||||
title: '数字逗号分组',
|
||||
key: '逗号',
|
||||
def: 3,
|
||||
type: 'num',
|
||||
desc: '根据语言习惯设置数字分组,如千位组设为 3,万位组设为 4。(暂不支持欧洲样式)'
|
||||
},
|
||||
}
|
||||
},
|
||||
wiki: {
|
||||
|
Loading…
Reference in New Issue
Block a user