Skip to content

Commit 0bc0312

Browse files
fix: 修改了图片的访问和上传后的访问地址,配合cdn进行访问
1 parent 52d1198 commit 0bc0312

File tree

11 files changed

+23
-17
lines changed

11 files changed

+23
-17
lines changed

admin/src/components/AddArticle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import AntdIcon from '../components/AntdIcon'
55
import '../static/style/components/addarticle.css'
66
import axios from 'axios'
77
import moment from 'moment'
8-
import { servicePath, serverUrl } from '../config/apiBaseUrl'
8+
import { servicePath, imgServerUrl } from '../config/apiBaseUrl'
99
import { formatTime } from '../static/js/tools'
1010
import marked from 'marked'
1111
import hljs from 'highlight.js'
@@ -236,7 +236,7 @@ const AddArticle = (props)=>{
236236
fileUrl += item + '/'
237237
})
238238
fileUrl = fileUrl.substr(0, fileUrl.length - 1)
239-
const filePath = serverUrl + fileUrl
239+
const filePath = imgServerUrl + fileUrl
240240
setIntroduceImg(filePath)
241241
setUploadIntroduceImgLoading(false)
242242
}

admin/src/config/apiBaseUrl.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const serverUrl = 'https://immortalboy.cn'
2+
const imgServerUrl = 'https://image.immortalboy.cn'
23
const baseUrl = 'https://immortalboy.cn/api/admin'
34

45
const servicePath = {
@@ -39,5 +40,6 @@ const servicePath = {
3940

4041
export {
4142
serverUrl,
43+
imgServerUrl,
4244
servicePath
4345
}

admin/src/pages/AddNovel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
22
import { Row, Col, Input, Upload, Button, message } from 'antd'
33
import AntdIcon from '../components/AntdIcon'
44
import api from '../api/api'
5-
import { servicePath, serverUrl } from '../config/apiBaseUrl'
5+
import { servicePath, imgServerUrl } from '../config/apiBaseUrl'
66
import '../static/style/pages/addnovel.css'
77

88
const { TextArea } = Input
@@ -48,7 +48,7 @@ const AddNovel = (props)=>{
4848
fileUrl += item + '/'
4949
})
5050
fileUrl = fileUrl.substr(0, fileUrl.length - 1)
51-
const filePath = serverUrl + fileUrl
51+
const filePath = imgServerUrl + fileUrl
5252
setCoverImg(filePath)
5353
setUploadImgLoading(false)
5454
}

admin/src/pages/AdvertiseManage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import api from '../api/api'
33
import { Button, Input, Row, Col, List, Switch, Modal, Pagination, Spin, message, Upload } from 'antd'
44
import '../static/style/pages/advertisemanage.css'
55
import AntdIcon from '../components/AntdIcon'
6-
import { servicePath, serverUrl } from "../config/apiBaseUrl";
6+
import { servicePath, imgServerUrl } from "../config/apiBaseUrl";
77
import { formatTime } from '../static/js/tools'
88

99
const { confirm } = Modal
@@ -91,7 +91,7 @@ const AdvertiseManage = ()=>{
9191
fileUrl += item + '/'
9292
})
9393
fileUrl = fileUrl.substr(0, fileUrl.length - 1)
94-
const filePath = serverUrl + fileUrl
94+
const filePath = imgServerUrl + fileUrl
9595
const obj = JSON.parse(JSON.stringify(modalObj))
9696
obj.imgUrl = filePath
9797
setUploadImgLoading(false)

admin/src/pages/UserSetting.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
22
import api from '../api/api'
33
import { Form, Input, Upload, Button, message } from 'antd'
44
import AntdIcon from '../components/AntdIcon'
5-
import { servicePath, serverUrl } from '../config/apiBaseUrl'
5+
import { servicePath, imgServerUrl } from '../config/apiBaseUrl'
66
import '../static/style/pages/usersetting.css'
77

88
const UserSetting = ()=>{
@@ -73,7 +73,7 @@ const UserSetting = ()=>{
7373
fileUrl += item + '/'
7474
})
7575
fileUrl = fileUrl.substr(0, fileUrl.length - 1)
76-
const filePath = serverUrl + fileUrl
76+
const filePath = imgServerUrl + fileUrl
7777
setPortrait(filePath)
7878
setUploadPortraitLoading(false)
7979
}
@@ -108,7 +108,7 @@ const UserSetting = ()=>{
108108
fileUrl += item + '/'
109109
})
110110
fileUrl = fileUrl.substr(0, fileUrl.length - 1)
111-
const filePath = serverUrl + fileUrl
111+
const filePath = imgServerUrl + fileUrl
112112
setBgImg(filePath)
113113
setUploadBgImgLoading(false)
114114
}

blog/components/Comment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Modal, Form, Input, Button, Avatar, Upload, message } from 'antd'
33
import Icon from './Icon'
44
import axios from 'axios'
55
import Cookies from 'js-cookie'
6-
import { servicePath, serverUrl } from '../config/apiBaseUrl'
6+
import { servicePath, imgServerUrl } from '../config/apiBaseUrl'
77
import '../public/style/components/comment.css'
88
import { formatDate } from '../public/js/tools'
99

@@ -28,7 +28,7 @@ const myComment = (props)=>{
2828
fileUrl += item + '/'
2929
})
3030
fileUrl = fileUrl.substr(0, fileUrl.length - 1)
31-
const filePath = serverUrl + fileUrl
31+
const filePath = imgServerUrl + fileUrl
3232
setPortrait(filePath)
3333
Cookies.set('visitorPortrait', filePath, { expires: 365 })
3434
axios({

blog/config/apiBaseUrl.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const vuebaseUrl = 'https://vue.immortalboy.cn'
22
const serverUrl = 'https://immortalboy.cn'
3+
const imgServerUrl = 'https://iamge.immortalboy.cn'
34
const baseUrl = 'https://immortalboy.cn/api/blog'
45

56
const servicePath = {
@@ -27,5 +28,6 @@ const servicePath = {
2728
export {
2829
serverUrl,
2930
servicePath,
31+
imgServerUrl,
3032
vuebaseUrl
3133
}

blogvue/src/components/Comment.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178

179179
<script>
180180
import Cookies from 'js-cookie'
181-
import { servicePath, serverUrl } from '../config/apiBaseUrl'
181+
import { servicePath, imgServerUrl } from '../config/apiBaseUrl'
182182
import { formatDate } from '../assets/js/tools'
183183
import commentAvatar from '../assets/images/comment-avatar.png'
184184
import Icon from '../components/Icon'
@@ -202,7 +202,7 @@ const uploadProps = { // 上传头像
202202
fileUrl += item + '/'
203203
})
204204
fileUrl = fileUrl.substr(0, fileUrl.length - 1)
205-
const filePath = serverUrl + fileUrl
205+
const filePath = imgServerUrl + fileUrl
206206
setPortrait(filePath)
207207
Cookies.set('visitorPortrait', filePath, { expires: 365 })
208208
axios({
@@ -332,7 +332,7 @@ export default {
332332
fileUrl += item + '/'
333333
})
334334
fileUrl = fileUrl.substr(0, fileUrl.length - 1)
335-
const filePath = serverUrl + fileUrl
335+
const filePath = imgServerUrl + fileUrl
336336
this.portrait = filePath
337337
Cookies.set('visitorPortrait', filePath, { expires: 365 })
338338
this.$api({

blogvue/src/config/apiBaseUrl.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const serverUrl = 'https://immortalboy.cn'
2-
const baseUrl = 'https://immortalboy.cn/api/blog'
3-
// const baseUrl = '/api/blog'
2+
const imgServerUrl = 'https://iamge.immortalboy.cn'
3+
// const baseUrl = 'https://immortalboy.cn/api/blog'
4+
const baseUrl = '/api/blog'
45

56
const servicePath = {
67
visitorLogin: baseUrl + '/comment/visitorLogin', // 评论接口:获取文章列表
@@ -26,5 +27,6 @@ const servicePath = {
2627

2728
export {
2829
serverUrl,
30+
imgServerUrl,
2931
servicePath
3032
}

blogvue/vue.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module.exports = {
1616
rules: []
1717
},
1818
plugins: [
19-
new BundleAanlyzerPlugin(),
2019
new ImageminPlugin({
2120
test: /\.(gif|png|jpe?g|svg)$/i,
2221
disable: false, // Disable during development

0 commit comments

Comments
 (0)