yuang-framework-ui-common 1.0.107 → 1.0.108

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,7 @@ const http = axios.create({
29
29
  timeout: 10000,
30
30
  headers: {},
31
31
  // 允许跨域请求携带凭证(Cookie等),在本地开发与网关api不是同域,访问api会报错:各种跨域访问,比如:http://localhost:8000/gateway-server/sso-api/client/sso-user/getSsoIdentity
32
- withCredentials: import.meta.env.VITE_PROFILES_ACTIVE === 'dev' ? true : false,
32
+ withCredentials: import.meta.env.VITE_PROFILE_ID === 'dev' ? true : false,
33
33
  })
34
34
 
35
35
 
@@ -0,0 +1,62 @@
1
+
2
+
3
+ /**
4
+ * 字符串编码为 Base64
5
+ * @param str 原始字符串(支持中文)
6
+ */
7
+ const base64Encode = (str: string): string => {
8
+ try {
9
+ const utf8Bytes = unescape(encodeURIComponent(str));
10
+ return btoa(utf8Bytes);
11
+ } catch (e) {
12
+ console.error('Base64 encode error:', e);
13
+ return '';
14
+ }
15
+ };
16
+
17
+ /**
18
+ * Base64 解码为字符串
19
+ * @param base64 Base64 字符串
20
+ */
21
+ const base64Decode = (base64: string): string => {
22
+ try {
23
+ const utf8Bytes = atob(base64);
24
+ return decodeURIComponent(escape(utf8Bytes));
25
+ } catch (e) {
26
+ console.error('Base64 decode error:', e);
27
+ return '';
28
+ }
29
+ };
30
+
31
+ /**
32
+ * Uint8Array 转 Base64
33
+ */
34
+ const base64EncodeUint8Array = (uint8Array: Uint8Array): string => {
35
+ let binary = '';
36
+ const len = uint8Array.byteLength;
37
+ for (let i = 0; i < len; i++) {
38
+ binary += String.fromCharCode(uint8Array[i]);
39
+ }
40
+ return btoa(binary);
41
+ };
42
+
43
+ /**
44
+ * Base64 转 Uint8Array
45
+ */
46
+ const base64DecodeToUint8Array = (base64: string): Uint8Array => {
47
+ const binary = atob(base64);
48
+ const len = binary.length;
49
+ const uint8Array = new Uint8Array(len);
50
+ for (let i = 0; i < len; i++) {
51
+ uint8Array[i] = binary.charCodeAt(i);
52
+ }
53
+ return uint8Array;
54
+ }
55
+
56
+ export {
57
+ base64Encode,
58
+ base64Decode,
59
+
60
+ base64EncodeUint8Array,
61
+ base64DecodeToUint8Array
62
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuang-framework-ui-common",
3
- "version": "1.0.107",
3
+ "version": "1.0.108",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -23,6 +23,10 @@ const router = createRouter({
23
23
  path: '/example/utils/rsa-aes-utils',
24
24
  component: () => import('@/views/example/utils/rsa-aes-utils.vue')
25
25
  },
26
+ {
27
+ path: '/example/utils/base64-utils',
28
+ component: () => import('@/views/example/utils/base64-utils.vue')
29
+ },
26
30
  {
27
31
  path: '/example/utils/sso-utils',
28
32
  component: () => import('@/views/example/utils/sso-utils.vue')
@@ -1,3 +1,6 @@
1
+ <!--
2
+ http://localhost:8020/framework-ui-common/example/utils/aes-utils
3
+ -->
1
4
  <template>
2
5
  <div>encryptData:{{encryptData }}</div>
3
6
  <div>decryptData:{{decryptData }}</div>
@@ -5,7 +8,7 @@
5
8
 
6
9
  <script setup lang="ts">
7
10
  import { onMounted, ref } from 'vue';
8
- import {getAesRandomKey, aesEncrypt, aesDecrypt} from '../../../lib/utils/aesUtils';
11
+ import {getAesRandomKey, aesEncrypt, aesDecrypt} from '../../../../lib/utils/aesUtils';
9
12
 
10
13
  let encryptData = ref('');
11
14
  let decryptData = ref('');
@@ -0,0 +1,24 @@
1
+ <!--
2
+ http://localhost:8020/framework-ui-common/example/utils/base64-utils
3
+ -->
4
+ <template>
5
+ <div>encodeData:{{encodeData }}</div>
6
+ <div>decodeData:{{decodeData }}</div>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ import { onMounted, ref } from 'vue';
11
+ import { base64Encode, base64Decode} from '../../../../lib/utils/base64Utils';
12
+
13
+ let encodeData = ref('');
14
+ let decodeData = ref('');
15
+ onMounted(() => {
16
+
17
+ encodeData.value = base64Encode( '测试');
18
+ decodeData.value = base64Decode( encodeData.value);
19
+ })
20
+ </script>
21
+
22
+ <style scoped>
23
+
24
+ </style>
@@ -1,3 +1,6 @@
1
+ <!--
2
+ http://localhost:8020/framework-ui-common/example/utils/gateway-utils
3
+ -->
1
4
  <template>
2
5
  <div>
3
6
  <el-button @click="sendRequest">发送请求</el-button>
@@ -5,7 +8,7 @@
5
8
  </template>
6
9
 
7
10
  <script setup lang="ts">
8
- import { http } from "../../../lib/config/httpConfig";
11
+ import { http } from "../../../../lib/config/httpConfig";
9
12
  import { ElMessage } from 'element-plus/es';
10
13
 
11
14
  const sendRequest = () => {
@@ -1,3 +1,6 @@
1
+ <!--
2
+ http://localhost:8020/framework-ui-common/example/utils/http-utils
3
+ -->
1
4
  <template>
2
5
  <div>http</div>
3
6
  </template>
@@ -6,7 +9,7 @@
6
9
  import { onMounted, ref } from 'vue';
7
10
  import { ElLoading } from 'element-plus';
8
11
 
9
- import { http } from '../../../lib/config/httpConfig';
12
+ import { http } from '../../../../lib/config/httpConfig';
10
13
 
11
14
 
12
15
  onMounted(async () => {
@@ -1,3 +1,6 @@
1
+ <!--
2
+ http://localhost:8020/framework-ui-common/example/utils/message-utils
3
+ -->
1
4
  <template>
2
5
  <el-button @click="showSuccessMessage('成功')">成功</el-button>
3
6
  <el-button @click="showInfoMessage('信息')">信息</el-button>
@@ -7,7 +10,7 @@
7
10
  </template>
8
11
 
9
12
  <script setup lang="ts">
10
- import {showSuccessMessage, showInfoMessage, showWarningMessage, showErrorMessage} from '../../../lib/utils/messageUtils';
13
+ import {showSuccessMessage, showInfoMessage, showWarningMessage, showErrorMessage} from '../../../../lib/utils/messageUtils';
11
14
  </script>
12
15
 
13
16
  <style scoped>
@@ -1,5 +1,5 @@
1
1
  <!--
2
- http://localhost:8020/framework-ui-common/utils/rsa-aes-utils
2
+ http://localhost:8020/framework-ui-common/example/utils/rsa-aes-utils
3
3
  -->
4
4
  <template>
5
5
  <div>encryptData:{{ encryptData }}</div>
@@ -8,8 +8,8 @@ http://localhost:8020/framework-ui-common/utils/rsa-aes-utils
8
8
 
9
9
  <script setup lang="ts">
10
10
  import {onMounted, ref} from 'vue';
11
- import { rsaAesDecrypt, rsaAesEncrypt } from '../../../lib/utils/rsaAesUtils';
12
- import { getAesRandomKey } from "../../../lib/utils/aesUtils";
11
+ import { rsaAesDecrypt, rsaAesEncrypt } from '../../../../lib/utils/rsaAesUtils';
12
+ import { getAesRandomKey } from "../../../../lib/utils/aesUtils";
13
13
 
14
14
  let encryptData = ref({});
15
15
  let decryptData = ref('');
@@ -1,3 +1,6 @@
1
+ <!--
2
+ http://localhost:8020/framework-ui-common/example/utils/rsa-utils
3
+ -->
1
4
  <template>
2
5
  <div>encryptData:{{ encryptData }}</div>
3
6
  <div>decryptData:{{ decryptData }}</div>
@@ -5,7 +8,7 @@
5
8
 
6
9
  <script setup lang="ts">
7
10
  import {onMounted, ref} from 'vue';
8
- import {getRsaKeys, rsaEncrypt, rsaDecrypt} from '../../../lib/utils/rsaUtils';
11
+ import {getRsaKeys, rsaEncrypt, rsaDecrypt} from '../../../../lib/utils/rsaUtils';
9
12
 
10
13
  let encryptData = ref('');
11
14
  let decryptData = ref('');
@@ -1,3 +1,6 @@
1
+ <!--
2
+ http://localhost:8020/framework-ui-common/example/utils/sso-utils
3
+ -->
1
4
  <template>
2
5
  <div> </div>
3
6
  </template>