AboutSoftwareModal.vue
2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<script lang="ts" setup>
  import { h } from 'vue';
  import { useI18n } from 'vue-i18n';
  import { Description, useDescription } from '/@/components/Description';
  import { BasicModal, useModal } from '/@/components/Modal';
  import { cacheCipher } from '/@/settings/encryptionSetting';
  import { AesEncryption } from '/@/utils/cipher';
  import { useGlobSetting } from '/@/hooks/setting';
  const encryption = new AesEncryption(cacheCipher);
  const { t } = useI18n();
  enum FiledKey {
    COPYRIGHT = 'field1',
    WEBSITE = 'filed2',
    AUTHORIZATION = 'field3',
    VERSION = 'field4',
  }
  // const handleEncode = (string: string) => {
  //   return encryption.encryptByAES(string);
  // };
  const handleDecode = (encodeString: string) => {
    return encryption.decryptByAES(encodeString);
  };
  const [register] = useModal();
  const { softwareVersionNumber } = useGlobSetting();
  const [registerDes] = useDescription({
    bordered: false,
    column: 1,
    labelStyle: {
      width: '100px',
      textAlign: 'right',
      justifyContent: 'right',
      paddingRight: '20px',
    },
    data: {
      [FiledKey.COPYRIGHT]: handleDecode(t('routes.aboutSoftware.copyright')),
      [FiledKey.WEBSITE]: handleDecode(t('routes.aboutSoftware.website')),
      [FiledKey.AUTHORIZATION]: handleDecode(t('routes.aboutSoftware.authorization')),
      [FiledKey.VERSION]: softwareVersionNumber,
    },
    schema: [
      {
        field: FiledKey.COPYRIGHT,
        label: handleDecode(t('routes.aboutSoftware.copyrightLabel')),
      },
      {
        field: FiledKey.WEBSITE,
        label: handleDecode(t('routes.aboutSoftware.websiteLabel')),
        render: (val: string) => {
          let joinWww = val.substring(0, 8) + 'www.' + val.substring(8);
          return h(
            'span',
            { class: 'text-blue-500 cursor-pointer', onClick: () => open(joinWww) },
            joinWww
          );
        },
      },
      {
        field: FiledKey.AUTHORIZATION,
        label: handleDecode(t('routes.aboutSoftware.authorizationLabel')),
        render: (val: string) => {
          // https://community.thingskit.com/question/20.html
          return h('div', {}, [
            h('span', val),
            h(
              'span',
              {
                class: 'text-blue-500 cursor-pointer',
                onClick: () => open('https://community.thingskit.com/question/20.html'),
              },
              '点击前往'
            ),
          ]);
        },
      },
      {
        field: FiledKey.VERSION,
        label: handleDecode(t('routes.aboutSoftware.versionLabel')),
        render: () => {
          return softwareVersionNumber;
        },
      },
    ],
  });
</script>
<template>
  <BasicModal
    @register="register"
    :title="handleDecode(t('routes.aboutSoftware.aboutSoftware'))"
    width="50%"
    cancel-text="关闭"
    :show-ok-btn="false"
  >
    <Description @register="registerDes" />
  </BasicModal>
</template>