mirror of
https://github.com/certd/certd.git
synced 2026-04-16 05:50:50 +08:00
perf: 优化内存占用
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { Inject, Provide } from '@midwayjs/core';
|
||||
import { CacheManager } from '@midwayjs/cache';
|
||||
import svgCaptcha from 'svg-captcha';
|
||||
|
||||
// {data: '<svg.../svg>', text: 'abcd'}
|
||||
/**
|
||||
@@ -14,6 +13,7 @@ export class CodeService {
|
||||
*/
|
||||
async generateCaptcha(randomStr) {
|
||||
console.assert(randomStr < 10, 'randomStr 过长');
|
||||
const svgCaptcha = await import('svg-captcha');
|
||||
const c = svgCaptcha.create();
|
||||
//{data: '<svg.../svg>', text: 'abcd'}
|
||||
const imgCode = c.text; // = RandomUtil.randomStr(4, true);
|
||||
|
||||
Reference in New Issue
Block a user