diff --git a/src/layouts/header/index.vue b/src/layouts/header/index.vue index 145f038..124326e 100644 --- a/src/layouts/header/index.vue +++ b/src/layouts/header/index.vue @@ -97,10 +97,10 @@ $height: 90px; width: 100%; min-width: $min-width; height: $height; - border-bottom: 1px solid #f7f7f7; box-sizing: content-box; &:not(.channel) { background-color: #fff; + border-bottom: 1px solid #f7f7f7; } .logo{ position: absolute; diff --git a/src/main.js b/src/main.js index 0bd0b87..e9a544c 100644 --- a/src/main.js +++ b/src/main.js @@ -34,8 +34,8 @@ Vue.config.productionTip = false; Vue.use(VueI18n); Vue.use(ElementUI, { size: "small" }); const i18n = new VueI18n({ - locale: Setting.i18n.default, - messages + locale: Setting.i18n.default, + messages }); new Vue({ diff --git a/src/mixins/page/index.js b/src/mixins/page/index.js index 96a77dd..fa43f64 100644 --- a/src/mixins/page/index.js +++ b/src/mixins/page/index.js @@ -27,12 +27,13 @@ export default { if (data.data.isDisable) { return Util.errorMsg('该文章已禁用!') } else { - href = '/article?articleId=' + link.articleId + '&id=' + link.columnId[link.columnId.length - 1] + href = '/article?articleId=' + link.articleId } } else { // 栏目 href = '/column?id=' + link.columnId[link.columnId.length - 1] } - href = this.$router.resolve(href + '&siteId=' + (this.$route.query.siteId || this.site)).href + href += '&siteId=' + (this.$route.query.siteId || this.site) + if (!link.articleId) href = this.$router.resolve(href).href } else if (type === 3) { // 站外链接 if (link.otherArticleId) { // 文章 // 查询文章详情。禁用的文章要提示 @@ -40,14 +41,27 @@ export default { if (data.data.isDisable) { return Util.errorMsg('该文章已禁用!') } else { - href = '/article?articleId=' + link.otherArticleId + '&id=' + link.otherColumnId[link.otherColumnId.length - 1] + href = '/article?articleId=' + link.otherArticleId } } else { // 栏目 href = '/column?id=' + link.otherColumnId[link.otherColumnId.length - 1] } - href = this.$router.resolve(href + '&siteId=' + link.site).href + href += '&siteId=' + link.site + if (!link.otherArticleId) href = this.$router.resolve(href).href } - if (link.isOpen) { + // 如果是站内/站外链接,并且选择的是文章,则要获取当前长页名称传到文章详情里,面包屑点返回的时候需要返回到当前长页 + if ((type === 1 && link.articleId) || (type === 3 && link.otherArticleId)) { + this.$post(`${this.api.findColumn}?id=${this.id}`).then(({ data }) => { + href = this.$router.resolve(href + '&id=' + this.id + '&columnName=' + data.columnName + '&path=' + this.$route.path.replace('/', '')).href + this.toHref(link.isOpen, href) + }).catch(res => {}) + } else { + this.toHref(link.isOpen, href) + } + }, + // 跳转地址 + toHref(isOpen, href) { + if (isOpen) { window.open(href) } else { location.href = href diff --git a/src/pages/column/index.vue b/src/pages/column/index.vue index 5362f52..6f306b3 100644 --- a/src/pages/column/index.vue +++ b/src/pages/column/index.vue @@ -167,7 +167,8 @@ export default { label: 'columnName' }, news: [], - hots: [] + hots: [], + deepestId: '' } }, computed: { @@ -206,7 +207,6 @@ export default { convokeType: null } } else { - this.getLeftColumn() this.getInfo() } this.getColumn() @@ -221,6 +221,7 @@ export default { if (!data.columnBanner) data.columnBanner = require('@/assets/images/column-banner.png') this.info = data this.showNav = this.showNavIds.includes(data.listStyleId) + this.getLeftColumn() this.getClassification() }).catch(res => {}) }, @@ -243,24 +244,46 @@ export default { }).catch(err => {}) }, // 递归查询是否每个层级的栏目都是同一列表样式,如果是,则查询全部栏目下的文章,否则查询当前栏目下的 - handleColumn(data, id) { + handleColumn(data, parent) { for (const e of data) { - this.allColumnId.push(e.id) - if (e.listStyleId !== id) { - this.sameStyle = 0 - break + if (this.info.typeId === 4) { // 子级优先 + if (e.children.length) { + this.handleColumn(e.children) + } else if (!this.deepestId) { + this.deepestId = e.id + } + } else { // 常规栏目 + if (e.id == this.id) { + this.allColumnId.push(e.id) + e.children.length && this.handleColumn(e.children, 1) + } else if (parent) { + if (e.listStyleId !== this.info.listStyleId) { + this.sameStyle = 0 + break + } else { + this.allColumnId.push(e.id) + e.children.length && this.handleColumn(e.children, parent) + } + } else { + e.children.length && this.handleColumn(e.children, parent) + } } - this.handleColumn(e.children, id) } }, // 左边栏目 getLeftColumn() { this.$post(`${this.api.oneLevelChecksThemAll}?id=${this.id}`).then(({ data }) => { const fromColumn = this.$route.query.column // 有column标识的,说明是通过点击左侧导航跳转过来的,这种情况只查询该栏目下的文章 + const { typeId } = this.info this.sameStyle = 1 this.allColumnId = [] - data.length && this.handleColumn(data, data[0].listStyleId) - this.getArticle(this.sameStyle && !fromColumn ? this.allColumnId : [+this.$route.query.id]) + this.deepestId = '' + data.length && this.handleColumn(data) + let id = this.sameStyle && typeId === 1 ? this.allColumnId : [+this.$route.query.id] + if (typeId === 4 && !fromColumn) { + id = [this.deepestId] + } + this.getArticle(id) this.columns = data this.$nextTick(() => { const el = this.$refs.leftColumn @@ -339,8 +362,9 @@ export default { // 子级优先栏目,并且有子级 const el = this.$refs.leftColumn if (el) { - this.$refs.leftColumn.store.nodesMap[to.id].expanded = !this.$refs.leftColumn.store.nodesMap[to.id].expanded // - this.getArticle([to.children[0].id]) + const exp = el.store.nodesMap[to.id].expanded + el.store.nodesMap[to.id].expanded = !exp // 展开收缩子级 + el.setCurrentKey(this.id) } } }, @@ -367,7 +391,6 @@ export default { ...this.form }).then(({ data }) => { this.articles = Util.removeTag(data.records) - console.log("🚀 ~ file: index.vue:369 ~ getArticle ~ this.articles", this.articles) this.total = +data.total // 如果栏目那勾选了“只有一篇文章时,以详情方式展示”,并且只有一篇文章,则跳转到详情页 // this.total == 1 && this.info.showWithDetails && this.$router.push(`/article?articleId=${this.articles[0].id}&id=${this.articles[0].columnId}`) diff --git a/src/pages/news/index.vue b/src/pages/news/index.vue index c9a27de..aea4ae9 100644 --- a/src/pages/news/index.vue +++ b/src/pages/news/index.vue @@ -20,13 +20,7 @@