ai-assistant-pro 0.0.1

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.
@@ -0,0 +1,35 @@
1
+ import CryptoJS from 'crypto-js';
2
+ import { Base64 } from 'js-base64';
3
+
4
+ const a = 'RU5D';
5
+ const b = 'ODE';
6
+ const c = 'AE';
7
+ const d = 'S_K';
8
+ const e = 'RVkx';
9
+ const z = Base64.decode(a).concat(b, '_', c, d, Base64.decode(e), '6');
10
+ const f = 'd3d3';
11
+ const g = 'w.e';
12
+ const i = 'mru';
13
+ const j = 'bik';
14
+ const k = 'Y29t';
15
+ const n = Base64.decode(f).concat(g, i, j, '.', Base64.decode(k));
16
+ const key = CryptoJS.enc.Utf8.parse(z);
17
+ const iv = CryptoJS.enc.Utf8.parse(n);
18
+ // 解密方法
19
+ export function decrypt(word) {
20
+ const stringToEncode = 'Hello, World!'; // 要进行 Base64 编码的字符串
21
+ const encodedString = Base64.encode(stringToEncode); // 进行 Base64 编码
22
+ const decodedString = Base64.decode(encodedString); // 进行 Base64 解码
23
+
24
+ let base64 = CryptoJS.enc.Base64.parse(word);
25
+ let src = CryptoJS.enc.Base64.stringify(base64);
26
+
27
+ let decrypt = CryptoJS.AES.decrypt(src, key, {
28
+ iv: iv,
29
+ mode: CryptoJS.mode.CBC,
30
+ padding: CryptoJS.pad.Pkcs7,
31
+ });
32
+
33
+ let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
34
+ return decryptedStr.toString();
35
+ }
@@ -0,0 +1,57 @@
1
+ import { ssoAuth, authUser } from '../api/index';
2
+ import constants from '../utils/constants';
3
+ import cache from '../plugins/cache';
4
+
5
+ export const errorList = [
6
+ {
7
+ name: "格式问题",
8
+ code: "1",
9
+ },
10
+ {
11
+ name: "逻辑问题",
12
+ code: "2",
13
+ },
14
+ {
15
+ name: "有害信息",
16
+ code: "3",
17
+ },
18
+ {
19
+ name: "事实错误",
20
+ code: "4",
21
+ },
22
+ {
23
+ name: "没有帮助",
24
+ code: "5",
25
+ },
26
+ {
27
+ name: "答非所问",
28
+ code: "6",
29
+ },
30
+ ]
31
+
32
+ export const cacheMessageList = [
33
+ {
34
+ type: 'user',
35
+ message: '电磁感应定律是如何描述的?请给出相关公式并解释。'
36
+ },
37
+ {
38
+ type: 'robot',
39
+ message: '电磁感应定律是描述磁场与电场之间关系的物理定律。具体来说,当导体回路中的磁通量发生变化时,会在回路中产生感应电动势。这个感应电动势的大小与磁通量变化的速率成正比,这就是法拉第电磁感应定律。\n' +
40
+ ' 相关的公式是:ε = -dΦ/dt\n' +
41
+ ' 其中,ε 表示感应电动势,Φ 表示磁通量,t 表示时间,dΦ/dt 则表示磁通量对时间的变化率。注意这里的负号,它表示感应电动势的方向与磁通量变化的方向相反,这是楞次定律的体现。\n' +
42
+ ' 解释这个公式时,我们可以理解为:当穿过一个闭合导体回路的磁通量发生变化时,会在回路中产生感应电动势,其大小正比于磁通量变化的速率。这种感应电动势是由于磁场的变化而引发的,它是磁场变化对电场的直接影响,体现了磁场与电场之间的紧密联系。'
43
+ }
44
+ ]
45
+
46
+ export const getUserInfo = async (token) => {
47
+ const ssoRes = await ssoAuth(token);
48
+ const userRes = await authUser({
49
+ 'X-Auth-User': encodeURIComponent(ssoRes.name),
50
+ 'X-Auth-Token': ssoRes.password,
51
+ 'X-Enterprise-Id': `${constants['X-Enterprise-Id']}`,
52
+ 'X-App-Id': `${constants['X-App-Id']}`,
53
+ 'X-App-Secret': `${constants['X-App-Secret']}`,
54
+ 'X-Auth-User-Type': '1',
55
+ });
56
+ cache.session.setJSON('SRKJ_TOKEN_CACHE', userRes);
57
+ }
@@ -0,0 +1,13 @@
1
+ let appId = '601a39a2a4a7cd88d5ddcef5';
2
+ const whiteList = ['/home', '/overview'];
3
+ if (process.env.VITE_APP_BUILD_TYPE === 'aliyun') {
4
+ appId = '6572ba195ec962924cc39951';
5
+ }
6
+
7
+ export default {
8
+ 'X-Enterprise-Id': 'www.hep-zj.com.cn',
9
+ 'X-App-Id': '90403a27c0704259ab7a3c8aab4489b3',
10
+ 'X-App-Secret': 'bc11ce7c44824fcaa23ff301a54b7094',
11
+ appId,
12
+ whiteList,
13
+ };
@@ -0,0 +1,69 @@
1
+ import axios from 'axios'
2
+ import cache from '../plugins/cache'
3
+ import { Message } from 'element-ui'
4
+ const door = sessionStorage.getItem('AI_BASE_URL_FOR_TEST');
5
+ import { decrypt } from './aes-utils';
6
+
7
+ axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
8
+
9
+ const service = axios.create({
10
+ // axios中请求配置有baseURL选项,表示请求URL公共部分
11
+ baseURL: door || 'https://zjyw.icve.com.cn/ai-api',
12
+ // 超时
13
+ timeout: 80000
14
+ })
15
+
16
+ service.interceptors.request.use(config => {
17
+ if (cache.session.getJSON('SRKJ_TOKEN_CACHE')) {
18
+ config.headers["X-Id-Token"] = cache.session.getJSON('SRKJ_TOKEN_CACHE');
19
+ }
20
+ // 是否需要防止数据重复提交
21
+ const isRepeatSubmit = (config.headers || {}).repeatSubmit === false;
22
+ if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) {
23
+ const requestObj = {
24
+ url: config.url,
25
+ data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data,
26
+ time: new Date().getTime()
27
+ }
28
+ const sessionObj = cache.session.getJSON('sessionObj')
29
+ if (sessionObj === undefined || sessionObj === null || sessionObj === '') {
30
+ cache.session.setJSON('sessionObj', requestObj)
31
+ } else {
32
+ const s_url = sessionObj.url; // 请求地址
33
+ const s_data = sessionObj.data; // 请求数据
34
+ const s_time = sessionObj.time; // 请求时间
35
+ const interval = 100; // 间隔时间(ms),小于此时间视为重复提交
36
+ if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) {
37
+ } else {
38
+ cache.session.setJSON('sessionObj', requestObj)
39
+ }
40
+ }
41
+ }
42
+ return config
43
+ }, error => {
44
+ Promise.reject(error)
45
+ })
46
+
47
+ service.interceptors.response.use(res => {
48
+ // 二进制数据则直接返回
49
+ if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
50
+ return res.data
51
+ }
52
+ let srkjData = res.data;
53
+ if (srkjData) {
54
+ const respData = decrypt(srkjData);
55
+ try {
56
+ srkjData = JSON.parse(respData);
57
+ } catch (e) {}
58
+ }
59
+ if (res.status === 401) {
60
+ Message.warning(srkjData.message.description);
61
+ return;
62
+ }
63
+ if (!srkjData.resultCode.endsWith('0000')) {
64
+ Message.warning(srkjData.message.description)
65
+ }
66
+ return srkjData.queryData || srkjData.data || srkjData.token;
67
+ })
68
+
69
+ export default service
@@ -0,0 +1,15 @@
1
+ import AiAssistant from './demo'
2
+ const components = {
3
+ AiAssistant
4
+ }
5
+
6
+ const install = function (Vue) {
7
+ if (install.installed) return
8
+ Object.keys(components).forEach(key => {
9
+ Vue.component(components[key].name,components[key])
10
+ });
11
+ }
12
+
13
+ export default {
14
+ install
15
+ }