Commit 15e0dc391b24ba245a69ad63338211bb3eff208c

Authored by ww
1 parent 625fd627

perf: format camera streaming app secret

... ... @@ -16,6 +16,17 @@ export const streamingMediaSSLMapping = {
16 16 1: 'https',
17 17 };
18 18
  19 +export const formatSecret = (string: string) => {
  20 + if (string.length < 6) {
  21 + return string;
  22 + } else {
  23 + const reg = /(^\S{2}).*(\S{4}$)/;
  24 + const prefix = string.match(reg)?.at(1);
  25 + const suffix = string.match(reg)?.at(2);
  26 + return `${prefix}${''.padStart(string.length - 6, '*')}${suffix}`;
  27 + }
  28 +};
  29 +
19 30 export const columnSchema: BasicColumn[] = [
20 31 {
21 32 title: '平台地址',
... ... @@ -31,6 +42,9 @@ export const columnSchema: BasicColumn[] = [
31 42 title: '用户密钥',
32 43 dataIndex: 'appSecret',
33 44 width: 80,
  45 + format(text) {
  46 + return formatSecret(text);
  47 + },
34 48 },
35 49 {
36 50 title: '平台类型',
... ... @@ -103,7 +117,10 @@ export const formDetailSchema: FormSchema[] = [
103 117 label: '用户密钥',
104 118 field: 'appSecret',
105 119 component: 'Input',
106   - rules: [{ required: true, message: '用户密钥为必填项' }],
  120 + rules: [
  121 + { required: true, message: '用户密钥为必填项' },
  122 + { required: true, min: 20, message: '用户密钥不能少于20位字符' },
  123 + ],
107 124 componentProps: {
108 125 placeholder: '请输入用户密钥',
109 126 },
... ...