ai-question-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.
- package/README.md +33 -0
- package/components/demo/api/index.js +18 -0
- package/components/demo/index.js +7 -0
- package/components/demo/plugins/cache.js +77 -0
- package/components/demo/src/CyTreeSelect.vue +209 -0
- package/components/demo/src/main.vue +536 -0
- package/components/demo/src/questionItem.vue +146 -0
- package/components/demo/static/addQuesTitBg.png +0 -0
- package/components/demo/static/robot.png +0 -0
- package/components/demo/static/unzan_bg.png +0 -0
- package/components/demo/static/unzan_plain.png +0 -0
- package/components/demo/static/zan_bg.png +0 -0
- package/components/demo/static/zan_plain.png +0 -0
- package/components/demo/utils/request.js +76 -0
- package/components/index.js +15 -0
- package/dist/ai-question.common.js +5468 -0
- package/dist/ai-question.common.js.map +1 -0
- package/dist/ai-question.umd.js +5479 -0
- package/dist/ai-question.umd.js.map +1 -0
- package/dist/ai-question.umd.min.js +4 -0
- package/dist/ai-question.umd.min.js.map +1 -0
- package/dist/demo.html +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import Cookies from 'js-cookie'
|
|
3
|
+
import cache from '../plugins/cache'
|
|
4
|
+
// import { Message } from 'element-ui'
|
|
5
|
+
|
|
6
|
+
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
|
|
7
|
+
|
|
8
|
+
const service = axios.create({
|
|
9
|
+
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
|
10
|
+
// baseURL: process.env.VUE_APP_BASE_API_Aimp4,
|
|
11
|
+
baseURL: 'https://zjyw.icve.com.cn/ai-api',
|
|
12
|
+
// baseURL: 'http://192.168.130.70:8899',
|
|
13
|
+
// 超时
|
|
14
|
+
timeout: 80000
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
service.interceptors.request.use(config => {
|
|
18
|
+
// 是否需要设置 token
|
|
19
|
+
const isToken = (config.headers || {}).isToken === false
|
|
20
|
+
// 是否需要防止数据重复提交
|
|
21
|
+
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
|
|
22
|
+
if (Cookies.get("AiToken")) {
|
|
23
|
+
config.headers["Authorization"] = "Bearer " + Cookies.get("AiToken")
|
|
24
|
+
}
|
|
25
|
+
// get请求映射params参数
|
|
26
|
+
if (config.method === 'get' && config.params) {
|
|
27
|
+
let url = config.url + '?' + tansParams(config.params);
|
|
28
|
+
url = url.slice(0, -1);
|
|
29
|
+
config.params = {};
|
|
30
|
+
config.url = url;
|
|
31
|
+
}
|
|
32
|
+
if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) {
|
|
33
|
+
const requestObj = {
|
|
34
|
+
url: config.url,
|
|
35
|
+
data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data,
|
|
36
|
+
time: new Date().getTime()
|
|
37
|
+
}
|
|
38
|
+
const sessionObj = cache.session.getJSON('sessionObj')
|
|
39
|
+
if (sessionObj === undefined || sessionObj === null || sessionObj === '') {
|
|
40
|
+
cache.session.setJSON('sessionObj', requestObj)
|
|
41
|
+
} else {
|
|
42
|
+
const s_url = sessionObj.url; // 请求地址
|
|
43
|
+
const s_data = sessionObj.data; // 请求数据
|
|
44
|
+
const s_time = sessionObj.time; // 请求时间
|
|
45
|
+
const interval = 100; // 间隔时间(ms),小于此时间视为重复提交
|
|
46
|
+
if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) {
|
|
47
|
+
// const message = '数据正在处理,请勿重复提交';
|
|
48
|
+
// console.warn(`[${s_url}]: ` + message)
|
|
49
|
+
// return Promise.reject(new Error(message))
|
|
50
|
+
} else {
|
|
51
|
+
cache.session.setJSON('sessionObj', requestObj)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return config
|
|
56
|
+
}, error => {
|
|
57
|
+
// console.log(error)
|
|
58
|
+
Promise.reject(error)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
service.interceptors.response.use(res => {
|
|
62
|
+
// 二进制数据则直接返回
|
|
63
|
+
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
|
|
64
|
+
return res.data
|
|
65
|
+
}
|
|
66
|
+
if (res.data.code == 401) {
|
|
67
|
+
// Message.warning(res.data.msg)
|
|
68
|
+
}
|
|
69
|
+
if (!res.data.success) {
|
|
70
|
+
// Message.warning(res.data.errMessage)
|
|
71
|
+
} else {
|
|
72
|
+
return res.data
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
export default service
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import aiQuestion from './demo'
|
|
2
|
+
const components = {
|
|
3
|
+
aiQuestion
|
|
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
|
+
}
|