@cqsjjb/course-res-design 0.0.9 → 0.1.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/Preview.js +2 -1
- package/PreviewVideo.js +1 -0
- package/VideoPlayer.js +5 -2
- package/package.json +2 -2
- package/utils/index.js +9 -9
- package/utils/request.js +76 -76
package/Preview.js
CHANGED
|
@@ -363,7 +363,8 @@ export default class FormPreview extends React.Component {
|
|
|
363
363
|
style: {
|
|
364
364
|
borderRadius: '10px'
|
|
365
365
|
},
|
|
366
|
-
courseInfo: courseInfo
|
|
366
|
+
courseInfo: courseInfo,
|
|
367
|
+
apiBaseName: this.props.apiBaseName
|
|
367
368
|
})), /*#__PURE__*/React.createElement("div", {
|
|
368
369
|
className: "course-preview__item-video-info"
|
|
369
370
|
}, /*#__PURE__*/React.createElement("a", null, "\u89C6\u9891\u65F6\u957F\uFF1A", secondToFormat(Number(item.resourceTotalIden))), courseInfo?.hourRuleId ? /*#__PURE__*/React.createElement("a", null, "\u53C2\u8003\u5B66\u65F6\uFF1A", item.resourceHour || '--', "\u5B66\u65F6") : '', /*#__PURE__*/React.createElement("a", null, "\u8BD5\u770B\u5206\u949F\uFF1A", item.auditionTime || '--'), JSON.parse(item.testExamJson || '[]')?.length > 0 && /*#__PURE__*/React.createElement("a", {
|
package/PreviewVideo.js
CHANGED
package/VideoPlayer.js
CHANGED
|
@@ -8,6 +8,7 @@ const VideoPlayer = props => {
|
|
|
8
8
|
src,
|
|
9
9
|
id,
|
|
10
10
|
courseInfo,
|
|
11
|
+
apiBaseName,
|
|
11
12
|
...rest
|
|
12
13
|
} = props;
|
|
13
14
|
const [tracks, setTracks] = useState([]);
|
|
@@ -17,7 +18,8 @@ const VideoPlayer = props => {
|
|
|
17
18
|
if (id && courseInfo.sourceEnum !== 'OUT') {
|
|
18
19
|
getResUrlAction({
|
|
19
20
|
fileId: id,
|
|
20
|
-
courseId: courseInfo?.id
|
|
21
|
+
courseId: courseInfo?.id,
|
|
22
|
+
apiBaseName: apiBaseName
|
|
21
23
|
}).then(res => {
|
|
22
24
|
if (res.data) {
|
|
23
25
|
setNewSrc(res.data?.map((item, index) => {
|
|
@@ -44,7 +46,8 @@ const VideoPlayer = props => {
|
|
|
44
46
|
if (id) {
|
|
45
47
|
getVideoCaption({
|
|
46
48
|
fileId: id,
|
|
47
|
-
courseId: courseInfo?.id
|
|
49
|
+
courseId: courseInfo?.id,
|
|
50
|
+
apiBaseName: apiBaseName
|
|
48
51
|
}).then(res => {
|
|
49
52
|
if (res.data?.length) {
|
|
50
53
|
setTracks(res.data.map((item, index) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cqsjjb/course-res-design",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "课程资源设计组件库",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "jiaoxiwei",
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^1.12.2",
|
|
13
13
|
"@cqsjjb/web-video-player": "^1.0.0",
|
|
14
|
-
"@cqsjjb/jjb-cloud-component": "^0.0.
|
|
14
|
+
"@cqsjjb/jjb-cloud-component": "^0.0.9"
|
|
15
15
|
}
|
|
16
16
|
}
|
package/utils/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 获取API Host
|
|
3
|
-
* @returns {string} API Host地址,如果VITE_API_HOST为空则返回location.origin
|
|
4
|
-
*/
|
|
5
|
-
export function getApiHost() {
|
|
6
|
-
return process.env.NODE_ENV === 'development' ?
|
|
7
|
-
process.env?.app?.API_HOST || 'https://yjap.cqzxaq.com'
|
|
8
|
-
: window.location.origin;
|
|
9
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 获取API Host
|
|
3
|
+
* @returns {string} API Host地址,如果VITE_API_HOST为空则返回location.origin
|
|
4
|
+
*/
|
|
5
|
+
export function getApiHost() {
|
|
6
|
+
return process.env.NODE_ENV === 'development' ?
|
|
7
|
+
process.env?.app?.API_HOST || 'https://yjap.cqzxaq.com'
|
|
8
|
+
: window.location.origin;
|
|
9
|
+
}
|
package/utils/request.js
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import { getApiHost } from './index';
|
|
3
|
-
|
|
4
|
-
export const API_BASE_NAME = 'res';
|
|
5
|
-
|
|
6
|
-
// 创建 axios 实例
|
|
7
|
-
const request = axios.create({
|
|
8
|
-
// baseURL: 'http://192.168.3.47:3000',
|
|
9
|
-
// baseURL: 'http://10.43.82.219',
|
|
10
|
-
baseURL: getApiHost(),
|
|
11
|
-
// mock 阶段使用测试服务器
|
|
12
|
-
timeout: 10000 // 请求超时时间
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// 请求拦截器 - 添加 token
|
|
16
|
-
request.interceptors.request.use(
|
|
17
|
-
config => {
|
|
18
|
-
// 从 sessionStorage 获取 token
|
|
19
|
-
const token = sessionStorage.getItem('token');
|
|
20
|
-
if (token) {
|
|
21
|
-
config.headers.token = token;
|
|
22
|
-
}
|
|
23
|
-
return config;
|
|
24
|
-
},
|
|
25
|
-
error => {
|
|
26
|
-
return Promise.reject(error);
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
// 响应拦截器
|
|
31
|
-
request.interceptors.response.use(
|
|
32
|
-
response => {
|
|
33
|
-
// 直接返回 response.data,因为 axios 默认返回 response.data
|
|
34
|
-
// 如果后端返回格式是 { respCode: '0000', data: {...} },则统一处理
|
|
35
|
-
if (response.data) {
|
|
36
|
-
// 统一处理响应格式,兼容不同的后端响应结构
|
|
37
|
-
const data = response.data;
|
|
38
|
-
// 如果响应中有 respCode,判断是否成功
|
|
39
|
-
if (data.respCode !== undefined) {
|
|
40
|
-
return {
|
|
41
|
-
success: data.respCode === '0000',
|
|
42
|
-
data: data.data || data,
|
|
43
|
-
...data
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
// 如果响应中有 success 字段,直接使用
|
|
47
|
-
if (data.success !== undefined) {
|
|
48
|
-
return {
|
|
49
|
-
success: data.success,
|
|
50
|
-
data: data.data || data,
|
|
51
|
-
...data
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
// 默认返回数据
|
|
55
|
-
return {
|
|
56
|
-
success: true,
|
|
57
|
-
data: data.data || data,
|
|
58
|
-
...data
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return response;
|
|
62
|
-
},
|
|
63
|
-
error => {
|
|
64
|
-
console.error('请求失败:', error);
|
|
65
|
-
// 处理错误响应
|
|
66
|
-
if (error.response && error.response.data) {
|
|
67
|
-
return Promise.reject({
|
|
68
|
-
success: false,
|
|
69
|
-
message: error.response.data.message || error.message,
|
|
70
|
-
...error.response.data
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return Promise.reject(error);
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
export default request;
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { getApiHost } from './index';
|
|
3
|
+
|
|
4
|
+
export const API_BASE_NAME = 'res';
|
|
5
|
+
|
|
6
|
+
// 创建 axios 实例
|
|
7
|
+
const request = axios.create({
|
|
8
|
+
// baseURL: 'http://192.168.3.47:3000',
|
|
9
|
+
// baseURL: 'http://10.43.82.219',
|
|
10
|
+
baseURL: getApiHost(),
|
|
11
|
+
// mock 阶段使用测试服务器
|
|
12
|
+
timeout: 10000 // 请求超时时间
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// 请求拦截器 - 添加 token
|
|
16
|
+
request.interceptors.request.use(
|
|
17
|
+
config => {
|
|
18
|
+
// 从 sessionStorage 获取 token
|
|
19
|
+
const token = sessionStorage.getItem('token');
|
|
20
|
+
if (token) {
|
|
21
|
+
config.headers.token = token;
|
|
22
|
+
}
|
|
23
|
+
return config;
|
|
24
|
+
},
|
|
25
|
+
error => {
|
|
26
|
+
return Promise.reject(error);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// 响应拦截器
|
|
31
|
+
request.interceptors.response.use(
|
|
32
|
+
response => {
|
|
33
|
+
// 直接返回 response.data,因为 axios 默认返回 response.data
|
|
34
|
+
// 如果后端返回格式是 { respCode: '0000', data: {...} },则统一处理
|
|
35
|
+
if (response.data) {
|
|
36
|
+
// 统一处理响应格式,兼容不同的后端响应结构
|
|
37
|
+
const data = response.data;
|
|
38
|
+
// 如果响应中有 respCode,判断是否成功
|
|
39
|
+
if (data.respCode !== undefined) {
|
|
40
|
+
return {
|
|
41
|
+
success: data.respCode === '0000',
|
|
42
|
+
data: data.data || data,
|
|
43
|
+
...data
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// 如果响应中有 success 字段,直接使用
|
|
47
|
+
if (data.success !== undefined) {
|
|
48
|
+
return {
|
|
49
|
+
success: data.success,
|
|
50
|
+
data: data.data || data,
|
|
51
|
+
...data
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// 默认返回数据
|
|
55
|
+
return {
|
|
56
|
+
success: true,
|
|
57
|
+
data: data.data || data,
|
|
58
|
+
...data
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return response;
|
|
62
|
+
},
|
|
63
|
+
error => {
|
|
64
|
+
console.error('请求失败:', error);
|
|
65
|
+
// 处理错误响应
|
|
66
|
+
if (error.response && error.response.data) {
|
|
67
|
+
return Promise.reject({
|
|
68
|
+
success: false,
|
|
69
|
+
message: error.response.data.message || error.message,
|
|
70
|
+
...error.response.data
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return Promise.reject(error);
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
export default request;
|