长页联调及bug修复

master
yujialong 2 years ago
parent fa3304b0e2
commit 861944f20e
  1. 2
      public/tinymce/langs/zh_CN.js
  2. BIN
      src/assets/images/page/exp.png
  3. BIN
      src/assets/images/page/science.png
  4. BIN
      src/assets/images/page/sfel.png
  5. BIN
      src/assets/images/page/survey.png
  6. BIN
      src/assets/images/page/talent.png
  7. BIN
      src/assets/images/page/userSharing.png
  8. 1
      src/components/editor.js
  9. 26
      src/const/column.js
  10. 2
      src/mixins/page/index.js
  11. 3
      src/pages/article/add/editor.js
  12. 154
      src/pages/article/add/index.vue
  13. 21
      src/pages/column/add/index.vue
  14. 1
      src/pages/column/page/news.vue
  15. 37
      src/pages/role/list/index.vue
  16. 4
      src/pages/user/list/index.vue
  17. 183
      src/plugins/requests/index.js
  18. 2
      src/setting.js
  19. 1
      src/styles/page/page.scss

@ -4,7 +4,7 @@
* Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc. * Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc.
* Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/ * Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/
*/ */
tinymce.addI18n('zh-Hans', { tinymce.addI18n('zh_CN', {
"Redo": "重做", "Redo": "重做",
"Undo": "撤销", "Undo": "撤销",
"Cut": "剪切", "Cut": "剪切",

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 623 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 KiB

@ -5,6 +5,7 @@ import Util from '@/libs/util'
export default { export default {
//skin:'oxide-dark', //skin:'oxide-dark',
language:'zh_CN', language:'zh_CN',
language_url: './tinymce/langs/zh_CN.js',
plugins: 'print powerpaste preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template advcode codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern help emoticons autosave autoresize formatpainter', plugins: 'print powerpaste preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template advcode codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern help emoticons autosave autoresize formatpainter',
toolbar: 'code undo redo restoredraft | cut copy powerpaste pastetext | forecolor backcolor bold italic underline strikethrough link anchor | alignleft aligncenter alignright alignjustify outdent indent | \ toolbar: 'code undo redo restoredraft | cut copy powerpaste pastetext | forecolor backcolor bold italic underline strikethrough link anchor | alignleft aligncenter alignright alignjustify outdent indent | \
styleselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \ styleselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \

@ -22,6 +22,32 @@ export default {
name: '子级优先栏目' name: '子级优先栏目'
} }
], ],
long: [
{
name: 'SFEL',
path: 'sfel'
},
{
name: 'SFEL-科普之窗',
path: 'science'
},
{
name: 'SFEL-装置介绍-实验站',
path: 'exp'
},
{
name: 'SFEL-人才队伍',
path: 'talent'
},
{
name: 'SFEL-用户共享',
path: 'userSharing'
},
{
name: 'SFEL-概况',
path: 'survey'
},
],
// 出版物类型 // 出版物类型
publicationTypes: [ publicationTypes: [
{ {

@ -68,7 +68,7 @@ export default {
this.id = json.id this.id = json.id
const str = json[json.state ? 'theEditedJson' : 'jsonBeforeEditing'] const str = json[json.state ? 'theEditedJson' : 'jsonBeforeEditing']
this.originModules = str // 原始json,用以页面离开的时候判断是否需要提示保存 this.originModules = str // 原始json,用以页面离开的时候判断是否需要提示保存
// this.modules = JSON.parse(str) this.modules = JSON.parse(str)
console.log("🚀 ~ file: index.js ~ line 53 ~ this.$post ~ this.modules", this.modules) console.log("🚀 ~ file: index.js ~ line 53 ~ this.$post ~ this.modules", this.modules)
} }
}).catch(err => {}) }).catch(err => {})

@ -5,8 +5,9 @@ import Util from '@/libs/util'
export default { export default {
//skin:'oxide-dark', //skin:'oxide-dark',
language:'zh_CN', language:'zh_CN',
language_url: './tinymce/langs/zh_CN.js',
plugins: 'print powerpaste preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template advcode codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern help emoticons autosave autoresize formatpainter', plugins: 'print powerpaste preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template advcode codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern help emoticons autosave autoresize formatpainter',
toolbar: 'code undo redo restoredraft | cut copy powerpaste pastetext | forecolor backcolor bold italic underline strikethrough link anchor | alignleft aligncenter alignright alignjustify | \ toolbar: 'code undo redo restoredraft | cut copy powerpaste pastetext | forecolor backcolor headings lineHeight bold italic underline strikethrough link anchor | alignleft aligncenter alignright alignjustify | \
styleselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \ styleselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \
table image media charmap emoticons hr pagebreak insertdatetime print preview | fullscreen | indent2em formatpainter', table image media charmap emoticons hr pagebreak insertdatetime print preview | fullscreen | indent2em formatpainter',
style_formats: [ style_formats: [

@ -18,7 +18,7 @@
</div> </div>
<ul v-if="form.templateStatus" class="styles"> <ul v-if="form.templateStatus" class="styles">
<template v-for="(item, i) in detailStyle"> <template v-for="(item, i) in detailStyle">
<li v-if="item.id !== column.detailStyle" :key="i" @click="form.articleTemplate = item.id"> <li v-if="item.id !== column.detailStyle" :key="i" @click="styleChange(item.id)">
<div class="review"> <div class="review">
<img :class="{'is-link': item.id == 24}" :src="require('@/assets/images/style/' + item.id + '.png')" alt=""> <img :class="{'is-link': item.id == 24}" :src="require('@/assets/images/style/' + item.id + '.png')" alt="">
</div> </div>
@ -321,14 +321,27 @@
<el-radio :label="3">其他站点链接</el-radio> <el-radio :label="3">其他站点链接</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item v-show="form.connectionType === 1" prop="connectionType" label="站内链接"> <template v-if="form.connectionType === 1">
<el-cascader <el-form-item label="站内链接">
v-model="links" <el-cascader
:options="columns" v-model="links"
:props="columnProps" :options="columns"
clearable></el-cascader> :props="columnProps"
</el-form-item> clearable
<el-form-item v-show="form.connectionType === 2" prop="connectionType" label="站内链接"> @change="getArticle"></el-cascader>
</el-form-item>
<el-form-item label="文章">
<el-select v-model="article" clearable>
<el-option
v-for="item in articles"
:key="item.id"
:label="item.title"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</template>
<el-form-item v-show="form.connectionType === 2" prop="linkAddress" label="站外链接">
<el-input <el-input
placeholder="请输入站外链接" placeholder="请输入站外链接"
v-model.trim="form.linkAddress" v-model.trim="form.linkAddress"
@ -339,10 +352,10 @@
<el-form-item prop="siteSelection" label="站点选择"> <el-form-item prop="siteSelection" label="站点选择">
<el-select v-model="form.siteSelection" @change="getOtherColumn"> <el-select v-model="form.siteSelection" @change="getOtherColumn">
<el-option <el-option
v-for="item in sites" v-for="item in sites"
:key="item.id" :key="item.id"
:label="item.siteName" :label="item.siteName"
:value="item.id"> :value="item.id">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -351,9 +364,27 @@
v-model="otherLink" v-model="otherLink"
:options="otherColumns" :options="otherColumns"
:props="columnProps" :props="columnProps"
clearable></el-cascader> clearable
@change="getArticle"></el-cascader>
</el-form-item>
<el-form-item label="文章">
<el-select v-model="otherArticle" clearable>
<el-option
v-for="item in otherArticles"
:key="item.id"
:label="item.title"
:value="item.id">
</el-option>
</el-select>
</el-form-item> </el-form-item>
</template> </template>
<el-form-item prop="isOpen" label="新窗口打开">
<el-switch
v-model="form.isOpen"
:active-value="1"
:inactive-value="0">
</el-switch>
</el-form-item>
</template> </template>
</el-form> </el-form>
<div class="btns"> <div class="btns">
@ -458,16 +489,20 @@ export default {
}, },
nameRepeat: false, nameRepeat: false,
sites: [], sites: [],
otherColumns: [],
otherLink: [],
detailStyle: [], detailStyle: [],
columns: [], columns: [],
articles: [],
otherArticles: [],
columnProps: { columnProps: {
checkStrictly: true, checkStrictly: true,
value: 'id', value: 'id',
label: 'columnName' label: 'columnName'
}, },
links: [], links: [],
article: '',
otherColumns: [],
otherLink: [],
otherArticle: '',
form: { form: {
siteId: this.$store.state.content.site.id, siteId: this.$store.state.content.site.id,
id: this.$route.query.id || '', id: this.$route.query.id || '',
@ -505,7 +540,8 @@ export default {
connectionType : 1, connectionType : 1,
linkAddress: '', linkAddress: '',
siteSelection: 1, siteSelection: 1,
fileList: [] fileList: [],
isOpen: 1
}, },
rules: { rules: {
title: [ title: [
@ -668,6 +704,22 @@ export default {
e.children.length ? this.getId(e.children, e.ids) : delete e.children e.children.length ? this.getId(e.children, e.ids) : delete e.children
}) })
}, },
//
getArticle() {
// /
const inner = this.form.connectionType === 1
const id = inner ? this.links[this.links.length - 1] : this.otherLink[this.otherLink.length - 1]
this[inner ? 'article' : 'otherArticle'] = ''
this.$post(this.api.queryArticle, {
siteId: inner ? this.site.id : this.form.siteSelection,
columnIds: [id],
pageNum: 1,
pageSize: 1000,
title: ''
}).then(({ data }) => {
this[inner ? 'articles' : 'otherArticles'] = data.records.filter(e => e.isRelease) //
}).catch(err => {})
},
// //
getData() { getData() {
this.$post(`${this.api.findArticle}?id=${this.form.id}`).then(({ data }) => { this.$post(`${this.api.findArticle}?id=${this.form.id}`).then(({ data }) => {
@ -681,14 +733,36 @@ export default {
} }
// //
if (data.articleTemplate === 24 && data.connectionType !== 2 && data.linkAddress) { if (data.articleTemplate === 24 && data.connectionType !== 2 && data.linkAddress) {
const links = data.linkAddress.split(',').map(e => +e) const columnArticle = data.linkAddress.split('-')
if (data.connectionType === 1) this.links = links const column = columnArticle[0].split(',').map(e => +e)
if (data.connectionType === 3) this.otherLink = links console.log("🚀 ~ file: index.vue:737 ~ this.$post ~ columnArticle", column)
data.linkAddress = ''
const article = columnArticle[1] || '' // ididlinkAddress-
const { connectionType } = data
//
this.$post(this.api.queryArticle, {
siteId: connectionType === 1 ? this.site.id : data.siteSelection,
columnIds: [column[column.length - 1]], // ididid
pageNum: 1,
pageSize: 1000,
title: ''
}).then(res => {
this[connectionType === 1 ? 'articles' : 'otherArticles'] = res.data.records
// /
if (connectionType === 1) {
this.links = column
this.form.linkAddress = ''
if (article) this.article = +article
} else if (connectionType === 3) {
this.otherLink = column
this.form.linkAddress = ''
if (article) this.otherArticle = +article
}
}).catch(err => {})
} }
data.siteSelection && this.getOtherColumn()
this.originalName = data.title this.originalName = data.title
this.form = data this.form = data
data.siteSelection && this.getOtherColumn()
this.getColumn() this.getColumn()
}).catch(err => {}) }).catch(err => {})
}, },
@ -701,17 +775,28 @@ export default {
if (!form.templateStatus) { if (!form.templateStatus) {
form.articleTemplate = (data.typeId === 1 || data.typeId === 4) ? data.detailStyleId : 23 form.articleTemplate = (data.typeId === 1 || data.typeId === 4) ? data.detailStyleId : 23
} }
// this.handleRules()
if (form.articleTemplate === 25) {
this.rules.titleImg[0].required = false
this.rules.classificationId[0].required = true
}
this.getClassification() this.getClassification()
this.$nextTick(() => { this.$nextTick(() => {
this.updateTime = 0 this.updateTime = 0
}) })
}).catch(err => {}) }).catch(err => {})
}, },
//
handleRules() {
const { articleTemplate } = this.form
//
if (articleTemplate === 25) {
this.rules.titleImg[0].required = false
} else {
this.rules.titleImg[0].required = true
}
},
//
styleChange(id) {
this.form.articleTemplate = id
this.handleRules()
},
// //
getSite() { getSite() {
this.$post(this.api.site, { this.$post(this.api.site, {
@ -723,7 +808,7 @@ export default {
}).catch(e => {}) }).catch(e => {})
}, },
// //
getOtherColumn() { getOtherColumn(val) {
this.$post(this.api.listWithTree, { this.$post(this.api.listWithTree, {
siteId: this.form.siteSelection, siteId: this.form.siteSelection,
columnName: '', columnName: '',
@ -731,6 +816,11 @@ export default {
typeId : '', typeId : '',
isSort: 1 isSort: 1
}).then(({ data }) => { }).then(({ data }) => {
if (val) {
this.otherArticles = []
this.otherArticle = ''
this.otherLink = ''
}
this.otherColumns = data this.otherColumns = data
}).catch(err => {}) }).catch(err => {})
}, },
@ -998,9 +1088,9 @@ export default {
}, },
// //
handleRemove(e, fileList) { handleRemove(e, fileList) {
e.id && this.$post(`${this.api.delContentFile}?id=${e.id}`).then(res => { e.id ? this.$post(`${this.api.delContentFile}?id=${e.id}`).then(res => {
this.form.fileList = fileList this.form.fileList = fileList
}).catch(res => {}) }).catch(res => {}) : (this.form.fileList = fileList)
}, },
// banner // banner
uploadSuccessBanner(res) { uploadSuccessBanner(res) {
@ -1080,7 +1170,7 @@ export default {
if (tId !== 25) { if (tId !== 25) {
if (!form.releaseTime) return Util.errorMsg('请选择发布日期') if (!form.releaseTime) return Util.errorMsg('请选择发布日期')
} }
if (tId === 22 || tId === 23) { if (tId === 22 || tId === 23 || tId === 24) {
if (!form.titleImg ) return Util.errorMsg('请上传封面') if (!form.titleImg ) return Util.errorMsg('请上传封面')
} }
if (tId === 25) { if (tId === 25) {
@ -1101,8 +1191,10 @@ export default {
if (this.uploading) return Util.errorMsg('文件正在上传,请上传完成后再发布') if (this.uploading) return Util.errorMsg('文件正在上传,请上传完成后再发布')
if (form.connectionType === 1) { if (form.connectionType === 1) {
form.linkAddress = this.links.join() form.linkAddress = this.links.join()
if (this.article) form.linkAddress += '-' + this.article
} else if (form.connectionType === 3) { } else if (form.connectionType === 3) {
form.linkAddress = this.otherLink.join() form.linkAddress = this.otherLink.join()
if (this.otherArticle) form.linkAddress += '-' + this.otherArticle
} }
const { columnId, bannerImg, fileList, titleImg } = form const { columnId, bannerImg, fileList, titleImg } = form
const fileId = [] const fileId = []

@ -159,7 +159,7 @@
<el-form-item label="文章"> <el-form-item label="文章">
<el-select v-model="otherArticle" clearable> <el-select v-model="otherArticle" clearable>
<el-option <el-option
v-for="item in articles" v-for="item in otherArticles"
:key="item.id" :key="item.id"
:label="item.title" :label="item.title"
:value="item.id"> :value="item.id">
@ -242,6 +242,7 @@ export default {
sites: [], sites: [],
columns: [], columns: [],
articles: [], articles: [],
otherArticles: [],
columnProps: { columnProps: {
checkStrictly: true, checkStrictly: true,
value: 'id', value: 'id',
@ -408,7 +409,7 @@ export default {
pageSize: 1000, pageSize: 1000,
title: '' title: ''
}).then(({ data }) => { }).then(({ data }) => {
this.articles = data.records.filter(e => e.isRelease) // this[inner ? 'articles' : 'otherArticles'] = data.records.filter(e => e.isRelease) //
}).catch(err => {}) }).catch(err => {})
}, },
// //
@ -422,21 +423,22 @@ export default {
const columnArticle = data.linkAddress.split('-') const columnArticle = data.linkAddress.split('-')
const column = columnArticle[0].split(',').map(e => +e) const column = columnArticle[0].split(',').map(e => +e)
const article = columnArticle[1] || '' // ididlinkAddress- const article = columnArticle[1] || '' // ididlinkAddress-
const { connectionType } = data
// //
this.$post(this.api.queryArticle, { this.$post(this.api.queryArticle, {
siteId: data.connectionType === 1 ? this.site.id : data.siteSelection, siteId: connectionType === 1 ? this.site.id : data.siteSelection,
columnIds: [column[column.length - 1]], // ididid columnIds: [column[column.length - 1]], // ididid
pageNum: 1, pageNum: 1,
pageSize: 1000, pageSize: 1000,
title: '' title: ''
}).then(res => { }).then(res => {
this.articles = res.data.records this[connectionType === 1 ? 'articles' : 'otherArticles'] = res.data.records
// / // /
if (data.connectionType === 1) { if (connectionType === 1) {
this.links = column this.links = column
this.form.linkAddress = '' this.form.linkAddress = ''
if (article) this.article = +article if (article) this.article = +article
} else if (data.connectionType === 3) { } else if (connectionType === 3) {
this.otherLink = column this.otherLink = column
this.form.linkAddress = '' this.form.linkAddress = ''
if (article) this.otherArticle = +article if (article) this.otherArticle = +article
@ -496,7 +498,7 @@ export default {
}).catch(e => {}) }).catch(e => {})
}, },
// //
getOtherColumn() { getOtherColumn(val) {
this.$post(this.api.listWithTree, { this.$post(this.api.listWithTree, {
siteId: this.form.siteSelection, siteId: this.form.siteSelection,
columnName: '', columnName: '',
@ -504,6 +506,11 @@ export default {
typeId : '', typeId : '',
isSort: 1 isSort: 1
}).then(({ data }) => { }).then(({ data }) => {
if (val) {
this.otherArticles = []
this.otherArticle = ''
this.otherLink = ''
}
this.otherColumns = data this.otherColumns = data
}).catch(err => {}) }).catch(err => {})
}, },

@ -299,6 +299,7 @@ export default {
box-shadow: 0px 2px 14px 0px rgba(167,167,167,0.26); box-shadow: 0px 2px 14px 0px rgba(167,167,167,0.26);
li { li {
position: relative; position: relative;
min-width: 100px;
padding: 25px 19px; padding: 25px 19px;
margin: 0 10px; margin: 0 10px;
font-size: 22px; font-size: 22px;

@ -108,14 +108,15 @@ export default {
}, },
methods: { methods: {
getData() { getData() {
this.$post(this.api.roles, { this.$post(this.api.roles, {
page: this.page, page: this.page,
limit: this.pageSize, limit: this.pageSize,
name: this.keyword, name: this.keyword,
}).then(({ data }) => { }).then(({ data }) => {
this.list = data.records const list = data.records.filter(e => e.id !== 1) //
this.total = +data.total this.list = list
}).catch(res => {}) this.total = data.total == 0 ? 0 : +data.total - 1
}).catch(res => {})
}, },
initData() { initData() {
this.$refs.table.clearSelection() this.$refs.table.clearSelection()
@ -123,18 +124,18 @@ export default {
this.getData() this.getData()
}, },
currentChange(val) { currentChange(val) {
this.page = val; this.page = val
this.getData(); this.getData()
}, },
handleDelete(row) { handleDelete(row) {
this.$confirm("确定要删除吗?", "提示", { this.$confirm("确定要删除吗?", "提示", {
type: "warning" type: "warning"
}).then(() => { }).then(() => {
this.$del(this.api.deleteRole, [row.id]).then(res => { this.$del(this.api.deleteRole, [row.id]).then(res => {
util.successMsg("删除成功"); util.successMsg("删除成功");
this.getData(); this.getData()
}).catch(res => {}); }).catch(res => {})
}).catch(() => {}); }).catch(() => {})
}, },
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val; this.multipleSelection = val;

@ -1,6 +1,6 @@
<template> <template>
<div class="flex"> <div class="flex">
<div class="page" style="width: 218px;border-right: 1px solid #EBEDF0"> <div class="page" style="width: 230px;border-right: 1px solid #EBEDF0">
<div class="m-b-20"> <div class="m-b-20">
<p class="page-name mb">后台员工账号</p> <p class="page-name mb">后台员工账号</p>
<el-radio-group v-model="staffType" @change="changeType"> <el-radio-group v-model="staffType" @change="changeType">
@ -885,6 +885,6 @@ export default {
} }
} }
.list-wrap { .list-wrap {
width: calc(100% - 219px); width: calc(100% - 231px);
} }
</style> </style>

@ -1,134 +1,111 @@
import axios from "axios"; import axios from "axios";
import util from "@/libs/util"; import Util from "@/libs/util";
import router from "@/router/index";
import Setting from "@/setting"; import Setting from "@/setting";
import store from '@/store' import store from '@/store'
const service = axios.create({ const service = axios.create({
baseURL: Setting.apiBaseURL, baseURL: Setting.apiBaseURL,
timeout: 10000000 timeout: 10000000
}); });
// post请求头 // post请求头
service.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8"; service.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
// service.defaults.withCredentials = true
// 请求拦截器 // 请求拦截器
service.interceptors.request.use(config => { service.interceptors.request.use(config => {
let token = util.local.get(Setting.tokenKey); let token = Util.local.get(Setting.tokenKey);
if (token) config.headers.token = token if (token) config.headers.token = token
return config; return config;
}, err => { }, err => {
util.errorMsg({ Util.errorMsg({
message: "退出登陆", message: "退出登陆",
onClose: function() { onClose: function() {
store.dispatch('user/logout') store.dispatch('user/logout')
} }
}); });
return Promise.reject(err); return Promise.reject(err);
}); });
// 响应拦截器 // 响应拦截器
service.interceptors.response.use( service.interceptors.response.use(
response => { response => {
const res = response.data; const res = response.data
if (res.code == 200) { const { code } = res
return Promise.resolve(res).catch(e => {}); if (code == 200) {
} else { return Promise.resolve(res).catch(e => {});
util.errorMsg(res.msg); } else if (code === 401) {
return Promise.reject(res) Util.errorMsg(res.msg)
// return Promise.resolve(res).catch(e => {}); setTimeout(() => {
} store.dispatch('user/logout')
}, }, 1000)
// 服务器状态码不是200的情况 return Promise.reject(res)
error => { } else {
if (error.response.status) { Util.errorMsg(res.msg);
switch (error.response.status) { return Promise.reject(res)
// 401: 未登录
// 未登录则跳转登录页面,并携带当前页面的路径
// 在登录成功后返回当前页面,这一步需要在登录页操作。
case 401:
util.local.remove(Setting.storeKey);
util.local.remove(Setting.tokenKey);
util.errorMsg("登录过期,请重新登录");
setTimeout(() => {
store.dispatch('user/logout')
}, 1000);
break;
case 500:
util.errorMsg("网络错误");
break;
// 403 token过期
// 登录过期对用户进行提示
// 清除本地token和清空vuex中token对象
// 跳转登录页面
case 403:
util.local.remove(Setting.storeKey);
util.local.remove(Setting.tokenKey);
util.errorMsg("登录过期,请重新登录");
// 清除token
// store.commit('loginSuccess', null);
// 跳转登录页面,并将要浏览的页面fullPath传过去,登录成功后跳转需要访问的页面
setTimeout(() => {
store.dispatch('user/logout')
}, 1000);
break;
// 404请求不存在
case 404:
util.errorMsg("网络请求不存在!");
break;
case 401001:
util.errorMsg(error.response.data.msg);
break;
// 其他错误,直接抛出错误提示
default:
util.errorMsg(error.response.data.msg);
Promise.reject(res);
}
return Promise.reject(error.response);
}
} }
},
// 服务器状态码不是200的情况
error => {
if (error.response.status) {
switch (error.response.status) {
case 500:
Util.errorMsg("网络错误");
break;
// 404请求不存在
case 404:
Util.errorMsg("网络请求不存在!");
break;
case 401001:
Util.errorMsg(error.response.data.msg);
break;
// 其他错误,直接抛出错误提示
default:
Util.errorMsg(error.response.data.msg);
Promise.reject(res);
}
return Promise.reject(error.response);
}
}
); );
function get(url, params) { function get(url, params) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
service.get(url, { params: params }).then(res => { service.get(url, { params: params }).then(res => {
resolve(res); resolve(res);
}).catch(err => { }).catch(err => {
reject(err); reject(err);
}); });
}); });
} }
function post(url, params) { function post(url, params) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
service.post(url, params).then(res => { service.post(url, params).then(res => {
resolve(res); resolve(res);
}).catch(err => { }).catch(err => {
reject(err.data); reject(err.data);
}); });
}); });
} }
function del(url, params) { function del(url, params) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
service.delete(url, { service.delete(url, {
data: params data: params
}).then(res => { }).then(res => {
resolve(res); resolve(res);
}).catch(err => { }).catch(err => {
reject(err.data); reject(err.data);
}); });
}); });
} }
function put(url, params) { function put(url, params) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
service.put(url, params).then(res => { service.put(url, params).then(res => {
resolve(res); resolve(res);
}).catch(err => { }).catch(err => {
reject(err.data); reject(err.data);
}); });
}); });
} }
export { get, post, del, put }; export { get, post, del, put };

@ -7,7 +7,7 @@ let host = `${location.origin}/`
if (isDev) { if (isDev) {
host = 'http://192.168.31.136:10000/' // 测试服 host = 'http://192.168.31.136:10000/' // 测试服
// host = 'http://192.168.31.51:10000/' // 榕 // host = 'http://192.168.31.51:10000/' // 榕
// host = 'http://192.168.31.116:10000/' // 赓 host = 'http://192.168.31.116:10000/' // 赓
} }
const Setting = { const Setting = {

@ -64,6 +64,7 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
font-size: 22px; font-size: 22px;
white-space: nowrap;
color: #fff; color: #fff;
background-color: rgba(0, 0, 0, .5); background-color: rgba(0, 0, 0, .5);
cursor: pointer; cursor: pointer;

Loading…
Cancel
Save