1.0.4 • Published 5 years ago

qqlevel v1.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

仿QQ等级计算方法

{
  👑: 64,
  🌞: 16,
  🌙: 4,
  ⭐: 1
}

How to use?

npm i qqlevel
import QQlevel from 'qqlevel';

// 简单使用

const level = new QQlevel();
level.setLevel(48);
const mylevel = level.getLevel();
console.log(mylevel);
// { level: 48, crown: 0, sun: 3, moon: 0, star: 0 }

const level = new QQlevel(25);
const mylevel = level.getLevel();
console.log(mylevel);
// { level: 25, crown: 0, sun: 1, moon: 2, star: 1 }

Default configuration 默认配置

{
  maxLevelLimit: number = 255;
  minLevelLimit: number = 0;
  icon: {
    crown: string;
    sun: string;
    moon: string;
    star: string;
  } = {
    crown: './assets/crown.svg',
    sun: './assets/sun.svg',
    moon: './assets/moon.svg',
    star: './assets/star.svg',
  };
  iconString: {
    crown: string;
    sun: string;
    moon: string;
    star: string;
  } = {
    crown: '👑',
    sun: '🌞',
    moon: '🌙',
    star: '⭐',
  };
  iconLevel: {
    crown: number;
    sun: number;
    moon: number;
    star: number;    
  } = {
    crown: 64,
    sun: 16,
    moon: 4,
    star: 1,
  };
  iconStyle: string = `width: 1em;height: 1em;`;
  iconWrapStyle: string = `display: flex;align-items: center;font-szie: 12px;`;
};

Modify configuration 修改配置

  • Full revision 全量修改
import QQlevel from 'qqlevel';
const config = {
  maxLevelLimit: number = xxx;
  minLevelLimit: number = xxx;
  icon: {
    crown: string;
    sun: string;
    moon: string;
    star: string;
  } = {
    crown: 'xxx',
    sun: 'xxx',
    moon: 'xxx',
    star: 'xxx',
  };
  iconString: {
    crown: string;
    sun: string;
    moon: string;
    star: string;
  } = {
    crown: '👑',
    sun: '🌞',
    moon: '🌙',
    star: '⭐',
  };
  iconLevel: {
    crown: number;
    sun: number;
    moon: number;
    star: number;    
  } = {
    crown: 64,
    sun: 16,
    moon: 4,
    star: 1,
  };
  iconStyle: string = `xxx`;
  iconWrapStyle: string = `xxx`;
}

const level = new QQlevel(48, config);
// or 或者
const level = new QQlevel();
level.setConfig(config);
level.setLevel(48);
  • Partial modification 部分修改
import QQlevel from 'qqlevel';

const level = new QQlevel();

// 配置icon 字符串
const iconString: {
  crown: string;
  sun: string;
  moon: string;
  star: string;
} = {
  crown: '',
  sun: '',
  moon: '',
  star: '',
};
level.setIconString(iconString);

// 配置icon 地址
const icon: {
  crown: string;
  sun: string;
  moon: string;
  star: string;
} = {
  crown: '',
  sun: '',
  moon: '',
  star: '',
};
level.setIcon(icon);

// 配置icon 样式
const iconStyle: string = `
  with: 1em;
  height: 1em;
`;
level.setIconStyle(iconStyle);

// 追加icon 样式
const iconStyleMore: string = `
  font-size: 16px;
`;
level.addIconStyle(iconStyleMore);


// 配置icon 容器样式
const iconWrapStyle: string = `
  display: flex;
`;
level.setIconWrapStyle(iconWrapStyle);

// 追加icon 容器样式
const iconWrapStyleMore: string = `
  align-items: center;
`;
level.setIconWrapStyle(iconWrapStyleMore);

// 配置最大等级和最小等级限制
const range: {
  max: number,
  min: number,
} = {
  max: 255,
  min: 0,
};
level.setLevelLimit(range);

// 配置icon所代表的的等级
const = iconLevel: {
  crown: number;
  sun: number;
  moon: number;
  star: number;    
} = {
  crown: 64,
  sun: 16,
  moon: 4,
  star: 1,
};
level.setIconLevel(iconLevel):

Get result 获取结果

  const level = new QQlevel(100);
  const mylevel = level.getLevel();
  console.log(mylevel);
  // { level: 100, crown: 1, sun: 2, moon: 1, star: 0 }

  // or 或者

  const level = new QQlevel();
  level.setLevel(256);
  const mylevel = level.getLevel();
  console.log(mylevel); 
  // { level: 256, crown: 4, sun: 0, moon: 0, star: 0 }

Output 输出

// 输出HTML
const level = new QQlevel(16);
const levelHTML = level.outputLevelHTML();
// 或者
const levelHTML = level.outputLevelHTML(16);
console.log(levelHTML);
/*
<div style="display: flex;align-items: center;font-szie: 12px;">
  <img src="./src/assets/sun.svg" style="width: 1em;height: 1em;">
</div>
*/



// 输出字符
const level = new QQlevel(254);
const levelString = level.outputLevelString();
// 或者
const levelHTML = level.outputLevelString(254);
console.log(levelString);
// 👑👑👑🌞🌞🌞🌙🌙🌙⭐⭐

等级对照表

LevelCrownSunMoonStarLevelString
256+4000👑👑👑👑
2564000👑👑👑👑
2553333👑👑👑🌞🌞🌞🌙🌙🌙⭐⭐⭐
2543332👑👑👑🌞🌞🌞🌙🌙🌙⭐⭐
2533331👑👑👑🌞🌞🌞🌙🌙🌙⭐
2523330👑👑👑🌞🌞🌞🌙🌙🌙
2513323👑👑👑🌞🌞🌞🌙🌙⭐⭐⭐
2503322👑👑👑🌞🌞🌞🌙🌙⭐⭐
2493321👑👑👑🌞🌞🌞🌙🌙⭐
2483320👑👑👑🌞🌞🌞🌙🌙
2473313👑👑👑🌞🌞🌞🌙⭐⭐⭐
2463312👑👑👑🌞🌞🌞🌙⭐⭐
2453311👑👑👑🌞🌞🌞🌙⭐
2443310👑👑👑🌞🌞🌞🌙
2433303👑👑👑🌞🌞🌞⭐⭐⭐
2423302👑👑👑🌞🌞🌞⭐⭐
2413301👑👑👑🌞🌞🌞⭐
2403300👑👑👑🌞🌞🌞
2393233👑👑👑🌞🌞🌙🌙🌙⭐⭐⭐
2383232👑👑👑🌞🌞🌙🌙🌙⭐⭐
2373231👑👑👑🌞🌞🌙🌙🌙⭐
2363230👑👑👑🌞🌞🌙🌙🌙
2353223👑👑👑🌞🌞🌙🌙⭐⭐⭐
2343222👑👑👑🌞🌞🌙🌙⭐⭐
2333221👑👑👑🌞🌞🌙🌙⭐
2323220👑👑👑🌞🌞🌙🌙
2313213👑👑👑🌞🌞🌙⭐⭐⭐
2303212👑👑👑🌞🌞🌙⭐⭐
2293211👑👑👑🌞🌞🌙⭐
2283210👑👑👑🌞🌞🌙
2273203👑👑👑🌞🌞⭐⭐⭐
2263202👑👑👑🌞🌞⭐⭐
2253201👑👑👑🌞🌞⭐
2243200👑👑👑🌞🌞
2233133👑👑👑🌞🌙🌙🌙⭐⭐⭐
2223132👑👑👑🌞🌙🌙🌙⭐⭐
2213131👑👑👑🌞🌙🌙🌙⭐
2203130👑👑👑🌞🌙🌙🌙
2193123👑👑👑🌞🌙🌙⭐⭐⭐
2183122👑👑👑🌞🌙🌙⭐⭐
2173121👑👑👑🌞🌙🌙⭐
2163120👑👑👑🌞🌙🌙
2153113👑👑👑🌞🌙⭐⭐⭐
2143112👑👑👑🌞🌙⭐⭐
2133111👑👑👑🌞🌙⭐
2123110👑👑👑🌞🌙
2113103👑👑👑🌞⭐⭐⭐
2103102👑👑👑🌞⭐⭐
2093101👑👑👑🌞⭐
2083100👑👑👑🌞
2073033👑👑👑🌙🌙🌙⭐⭐⭐
2063032👑👑👑🌙🌙🌙⭐⭐
2053031👑👑👑🌙🌙🌙⭐
2043030👑👑👑🌙🌙🌙
2033023👑👑👑🌙🌙⭐⭐⭐
2023022👑👑👑🌙🌙⭐⭐
2013021👑👑👑🌙🌙⭐
2003020👑👑👑🌙🌙
1993013👑👑👑🌙⭐⭐⭐
1983012👑👑👑🌙⭐⭐
1973011👑👑👑🌙⭐
1963010👑👑👑🌙
1953003👑👑👑⭐⭐⭐
1943002👑👑👑⭐⭐
1933001👑👑👑⭐
1923000👑👑👑
1912333👑👑🌞🌞🌞🌙🌙🌙⭐⭐⭐
1902332👑👑🌞🌞🌞🌙🌙🌙⭐⭐
1892331👑👑🌞🌞🌞🌙🌙🌙⭐
1882330👑👑🌞🌞🌞🌙🌙🌙
1872323👑👑🌞🌞🌞🌙🌙⭐⭐⭐
1862322👑👑🌞🌞🌞🌙🌙⭐⭐
1852321👑👑🌞🌞🌞🌙🌙⭐
1842320👑👑🌞🌞🌞🌙🌙
1832313👑👑🌞🌞🌞🌙⭐⭐⭐
1822312👑👑🌞🌞🌞🌙⭐⭐
1812311👑👑🌞🌞🌞🌙⭐
1802310👑👑🌞🌞🌞🌙
1792303👑👑🌞🌞🌞⭐⭐⭐
1782302👑👑🌞🌞🌞⭐⭐
1772301👑👑🌞🌞🌞⭐
1762300👑👑🌞🌞🌞
1752233👑👑🌞🌞🌙🌙🌙⭐⭐⭐
1742232👑👑🌞🌞🌙🌙🌙⭐⭐
1732231👑👑🌞🌞🌙🌙🌙⭐
1722230👑👑🌞🌞🌙🌙🌙
1712223👑👑🌞🌞🌙🌙⭐⭐⭐
1702222👑👑🌞🌞🌙🌙⭐⭐
1692221👑👑🌞🌞🌙🌙⭐
1682220👑👑🌞🌞🌙🌙
1672213👑👑🌞🌞🌙⭐⭐⭐
1662212👑👑🌞🌞🌙⭐⭐
1652211👑👑🌞🌞🌙⭐
1642210👑👑🌞🌞🌙
1632203👑👑🌞🌞⭐⭐⭐
1622202👑👑🌞🌞⭐⭐
1612201👑👑🌞🌞⭐
1602200👑👑🌞🌞
1592133👑👑🌞🌙🌙🌙⭐⭐⭐
1582132👑👑🌞🌙🌙🌙⭐⭐
1572131👑👑🌞🌙🌙🌙⭐
1562130👑👑🌞🌙🌙🌙
1552123👑👑🌞🌙🌙⭐⭐⭐
1542122👑👑🌞🌙🌙⭐⭐
1532121👑👑🌞🌙🌙⭐
1522120👑👑🌞🌙🌙
1512113👑👑🌞🌙⭐⭐⭐
1502112👑👑🌞🌙⭐⭐
1492111👑👑🌞🌙⭐
1482110👑👑🌞🌙
1472103👑👑🌞⭐⭐⭐
1462102👑👑🌞⭐⭐
1452101👑👑🌞⭐
1442100👑👑🌞
1432033👑👑🌙🌙🌙⭐⭐⭐
1422032👑👑🌙🌙🌙⭐⭐
1412031👑👑🌙🌙🌙⭐
1402030👑👑🌙🌙🌙
1392023👑👑🌙🌙⭐⭐⭐
1382022👑👑🌙🌙⭐⭐
1372021👑👑🌙🌙⭐
1362020👑👑🌙🌙
1352013👑👑🌙⭐⭐⭐
1342012👑👑🌙⭐⭐
1332011👑👑🌙⭐
1322010👑👑🌙
1312003👑👑⭐⭐⭐
1302002👑👑⭐⭐
1292001👑👑⭐
1282000👑👑
1271333👑🌞🌞🌞🌙🌙🌙⭐⭐⭐
1261332👑🌞🌞🌞🌙🌙🌙⭐⭐
1251331👑🌞🌞🌞🌙🌙🌙⭐
1241330👑🌞🌞🌞🌙🌙🌙
1231323👑🌞🌞🌞🌙🌙⭐⭐⭐
1221322👑🌞🌞🌞🌙🌙⭐⭐
1211321👑🌞🌞🌞🌙🌙⭐
1201320👑🌞🌞🌞🌙🌙
1191313👑🌞🌞🌞🌙⭐⭐⭐
1181312👑🌞🌞🌞🌙⭐⭐
1171311👑🌞🌞🌞🌙⭐
1161310👑🌞🌞🌞🌙
1151303👑🌞🌞🌞⭐⭐⭐
1141302👑🌞🌞🌞⭐⭐
1131301👑🌞🌞🌞⭐
1121300👑🌞🌞🌞
1111233👑🌞🌞🌙🌙🌙⭐⭐⭐
1101232👑🌞🌞🌙🌙🌙⭐⭐
1091231👑🌞🌞🌙🌙🌙⭐
1081230👑🌞🌞🌙🌙🌙
1071223👑🌞🌞🌙🌙⭐⭐⭐
1061222👑🌞🌞🌙🌙⭐⭐
1051221👑🌞🌞🌙🌙⭐
1041220👑🌞🌞🌙🌙
1031213👑🌞🌞🌙⭐⭐⭐
1021212👑🌞🌞🌙⭐⭐
1011211👑🌞🌞🌙⭐
1001210👑🌞🌞🌙
991203👑🌞🌞⭐⭐⭐
981202👑🌞🌞⭐⭐
971201👑🌞🌞⭐
961200👑🌞🌞
951133👑🌞🌙🌙🌙⭐⭐⭐
941132👑🌞🌙🌙🌙⭐⭐
931131👑🌞🌙🌙🌙⭐
921130👑🌞🌙🌙🌙
911123👑🌞🌙🌙⭐⭐⭐
901122👑🌞🌙🌙⭐⭐
891121👑🌞🌙🌙⭐
881120👑🌞🌙🌙
871113👑🌞🌙⭐⭐⭐
861112👑🌞🌙⭐⭐
851111👑🌞🌙⭐
841110👑🌞🌙
831103👑🌞⭐⭐⭐
821102👑🌞⭐⭐
811101👑🌞⭐
801100👑🌞
791033👑🌙🌙🌙⭐⭐⭐
781032👑🌙🌙🌙⭐⭐
771031👑🌙🌙🌙⭐
761030👑🌙🌙🌙
751023👑🌙🌙⭐⭐⭐
741022👑🌙🌙⭐⭐
731021👑🌙🌙⭐
721020👑🌙🌙
711013👑🌙⭐⭐⭐
701012👑🌙⭐⭐
691011👑🌙⭐
681010👑🌙
671003👑⭐⭐⭐
661002👑⭐⭐
651001👑⭐
641000👑
630333🌞🌞🌞🌙🌙🌙⭐⭐⭐
620332🌞🌞🌞🌙🌙🌙⭐⭐
610331🌞🌞🌞🌙🌙🌙⭐
600330🌞🌞🌞🌙🌙🌙
590323🌞🌞🌞🌙🌙⭐⭐⭐
580322🌞🌞🌞🌙🌙⭐⭐
570321🌞🌞🌞🌙🌙⭐
560320🌞🌞🌞🌙🌙
550313🌞🌞🌞🌙⭐⭐⭐
540312🌞🌞🌞🌙⭐⭐
530311🌞🌞🌞🌙⭐
520310🌞🌞🌞🌙
510303🌞🌞🌞⭐⭐⭐
500302🌞🌞🌞⭐⭐
490301🌞🌞🌞⭐
480300🌞🌞🌞
470233🌞🌞🌙🌙🌙⭐⭐⭐
460232🌞🌞🌙🌙🌙⭐⭐
450231🌞🌞🌙🌙🌙⭐
440230🌞🌞🌙🌙🌙
430223🌞🌞🌙🌙⭐⭐⭐
420222🌞🌞🌙🌙⭐⭐
410221🌞🌞🌙🌙⭐
400220🌞🌞🌙🌙
390213🌞🌞🌙⭐⭐⭐
380212🌞🌞🌙⭐⭐
370211🌞🌞🌙⭐
360210🌞🌞🌙
350203🌞🌞⭐⭐⭐
340202🌞🌞⭐⭐
330201🌞🌞⭐
320200🌞🌞
310133🌞🌙🌙🌙⭐⭐⭐
300132🌞🌙🌙🌙⭐⭐
290131🌞🌙🌙🌙⭐
280130🌞🌙🌙🌙
270123🌞🌙🌙⭐⭐⭐
260122🌞🌙🌙⭐⭐
250121🌞🌙🌙⭐
240120🌞🌙🌙
230113🌞🌙⭐⭐⭐
220112🌞🌙⭐⭐
210111🌞🌙⭐
200110🌞🌙
190103🌞⭐⭐⭐
180102🌞⭐⭐
170101🌞⭐
160100🌞
150033🌙🌙🌙⭐⭐⭐
140032🌙🌙🌙⭐⭐
130031🌙🌙🌙⭐
120030🌙🌙🌙
110023🌙🌙⭐⭐⭐
100022🌙🌙⭐⭐
90021🌙🌙⭐
80020🌙🌙
70013🌙⭐⭐⭐
60012🌙⭐⭐
50011🌙⭐
40010🌙
30003⭐⭐⭐
20002⭐⭐
10001
00000
1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago