|
|
|
import Setting from '@/setting'
|
|
|
|
import Util from '@/libs/util'
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
id: +this.$route.query.id
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
site() {
|
|
|
|
return this.$route.query.siteId || this.$store.state.content.site
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
// 点击栏目回调
|
|
|
|
columnTo(to) {
|
|
|
|
const { typeId,menuVisible } = to
|
|
|
|
console.log('typeId=>' ,typeId)
|
|
|
|
console.log('to=>' ,to)
|
|
|
|
console.log('menuVisible=>' ,menuVisible)
|
|
|
|
// 跳转链接
|
|
|
|
if (typeId === 2) {
|
|
|
|
if ( menuVisible === 1 || to.children.find(i=>i.menuVisible ===1)) return
|
|
|
|
let href = to.linkAddress
|
|
|
|
const cType = to.connectionType
|
|
|
|
if (cType !== 2) { // 非站外链接
|
|
|
|
const ids = href.split('-') // 栏目文章是用-分割的,栏目是必选,文章不是必选。选择了文章则跳转到文章页,否则跳转到栏目页
|
|
|
|
// 站点id:站内链接取当前站点,其他站点链接取siteSelection
|
|
|
|
const site = cType === 1 ?
|
|
|
|
(this.site) :
|
|
|
|
to.siteSelection
|
|
|
|
if (ids[1]) { // 文章
|
|
|
|
href = '/article?articleId=' + ids[1]
|
|
|
|
} else { // 栏目
|
|
|
|
const columnIds = ids[0].split(',')
|
|
|
|
href = '/column?id=' + columnIds[columnIds.length - 1]
|
|
|
|
}
|
|
|
|
href = this.$router.resolve(href + '&siteId=' + site).href
|
|
|
|
}
|
|
|
|
// 是否新窗口打开
|
|
|
|
if (to.isOpen) {
|
|
|
|
var userAgent = navigator.userAgent;
|
|
|
|
var isSafari = /Safari/.test(userAgent) && !/Chrome/.test(userAgent);
|
|
|
|
if(isSafari) {
|
|
|
|
window.location.href = href
|
|
|
|
}else {
|
|
|
|
window.open(href)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
location.href = href
|
|
|
|
}
|
|
|
|
} else if (typeId !== 4 || (typeId === 4 && !to.children.length)) {
|
|
|
|
// 常规栏目跳转到column页,长页栏目直接获取path
|
|
|
|
this.$router.push(`/${typeId === 3 ? to.path : 'column'}?id=${to.id}&siteId=${this.site}`).catch(err => {})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 跳转文章页面
|
|
|
|
toArtice(item) {
|
|
|
|
if (item.articleTemplate === 24) { // 链接
|
|
|
|
let href = item.linkAddress
|
|
|
|
const cType = item.connectionType
|
|
|
|
if (cType !== 2) { // 非站外链接
|
|
|
|
const ids = href.split('-') // 栏目文章是用-分割的,栏目是必选,文章不是必选。选择了文章则跳转到文章页,否则跳转到栏目页
|
|
|
|
// 站点id:站内链接取当前站点,其他站点链接取siteSelection
|
|
|
|
const site = cType === 1 ?
|
|
|
|
(this.site) :
|
|
|
|
item.siteSelection
|
|
|
|
if (ids[1]) { // 文章
|
|
|
|
href = '/article?articleId=' + ids[1]
|
|
|
|
} else { // 栏目
|
|
|
|
const columnIds = ids[0].split(',')
|
|
|
|
href = '/column?id=' + columnIds[columnIds.length - 1]
|
|
|
|
}
|
|
|
|
href = this.$router.resolve(href + '&siteId=' + site).href
|
|
|
|
}
|
|
|
|
// 是否新窗口打开
|
|
|
|
if (item.isOpen) {
|
|
|
|
var userAgent = navigator.userAgent;
|
|
|
|
var isSafari = /Safari/.test(userAgent) && !/Chrome/.test(userAgent);
|
|
|
|
if(isSafari) {
|
|
|
|
window.location.href = href
|
|
|
|
}else {
|
|
|
|
window.open(href)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
location.href = href
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.$router.push(`/article?articleId=${item.id}&site=${this.site}&id=${item.columnId}`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|