Browse Source

增加图片基础地址不同环境的环境变量,解决组件目录下新增index.js文件引起的页面报错,优化

master
wen 2 years ago
parent
commit
b02f076d01
  1. 3
      .env.development
  2. 2
      .env.production
  3. 1
      src/App.vue
  4. 2
      src/router/index.js
  5. 2
      src/styles/sidebar.scss
  6. 5
      src/utils/request.js
  7. 9
      src/views/subfile/index.vue
  8. 0
      src/views/subfile/indexs.js
  9. 3
      src/views/systme/switchtheme.vue

3
.env.development

@ -3,3 +3,6 @@ ENV = 'development'
# base api # base api
VUE_APP_BASE_API = '/api' VUE_APP_BASE_API = '/api'
# base imgurl
VUE_APP_IMG_URL = 'http://192.168.0.100'

2
.env.production

@ -4,3 +4,5 @@ ENV = 'production'
# base api # base api
VUE_APP_BASE_API = '/prod-api' VUE_APP_BASE_API = '/prod-api'
# base imgurl
VUE_APP_IMG_URL = 'https://dev.filesite.io'

1
src/App.vue

@ -5,6 +5,7 @@
</template> </template>
<script> <script>
export default { export default {
name: 'App' name: 'App'
} }

2
src/router/index.js

@ -69,7 +69,7 @@ export const constantRoutes = [
{ {
path: 'subfile', path: 'subfile',
name: 'Subfile', name: 'Subfile',
component: () => import('@/views/subfile/index'), component: () => import('@/views/subfile/index.vue'),
meta: { title: '子文件', icon: 'dashboard' } meta: { title: '子文件', icon: 'dashboard' }
} }
] ]

2
src/styles/sidebar.scss

@ -33,6 +33,8 @@
overflow-x: hidden !important; overflow-x: hidden !important;
} }
.el-scrollbar__view{padding-bottom:92px;}
.el-scrollbar__bar.is-vertical { .el-scrollbar__bar.is-vertical {
right: 0px; right: 0px;
} }

5
src/utils/request.js

@ -7,7 +7,10 @@ import axios from 'axios'
const service = axios.create({ const service = axios.create({
//baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url //baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests // withCredentials: true, // send cookies when cross-domain requests
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, //headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
headers: {
'Content-Type': 'multipart/form-data'
},
// headers: { 'Content-Type': 'multipart/form-data' }, // headers: { 'Content-Type': 'multipart/form-data' },
// headers: { // headers: {
// 'Content-Type': 'application/x-www-form-urlencoded' // 'Content-Type': 'application/x-www-form-urlencoded'

9
src/views/subfile/index.vue

@ -101,7 +101,8 @@
label="图片" label="图片"
width="auto"> width="auto">
<template slot-scope="scope"> <template slot-scope="scope">
<img :src="'http://192.168.0.100/'+scope.row.image" alt="图片"/> <!-- <img :src="'http://192.168.0.100/'+scope.row.image" alt="图片"/> -->
<img :src="imgurl+scope.row.image" alt="图片"/>
</template> </template>
</el-table-column> </el-table-column>
@ -222,10 +223,13 @@ export default {
// //
created() { created() {
this.getFileData(); this.getFileData();
console.log(this.imgurl);
}, },
// //
// mounted () {
// console.log(this.imgurl);
// },
filters: { filters: {
@ -262,6 +266,7 @@ export default {
// }, // },
// value2: '', // value2: '',
imgurl:process.env.VUE_APP_IMG_URL,
//haveRealpath: 0, //haveRealpath: 0,
// //
tableData: [], tableData: [],

0
src/views/subfile/index.js → src/views/subfile/indexs.js

3
src/views/systme/switchtheme.vue

@ -21,9 +21,10 @@
</template> </template>
<script> <script>
//console.log(process.env.VUE_APP_BASE_API);
import { switchthemeApi} from '@/api/user' import { switchthemeApi} from '@/api/user'
export default { export default {
data() { data() {
return { return {
options: [{ options: [{

Loading…
Cancel
Save