修改细节

This commit is contained in:
clay
2022-06-07 22:37:45 +08:00
parent 3a3c657251
commit 25e94c1117
66 changed files with 202 additions and 1438 deletions

View File

@@ -4,10 +4,15 @@
* @descriptionsist
* @email: clay@hchyun.com
*/
let vm = null
import {info} from "@/api";
export function setThis(that) {
vm = that
}
export function getParentNode(id) {
try {
let menuList = JSON.parse(sessionStorage.getItem("menu"));
for (let menu of menuList) {
for (let child of menu.children) {
@@ -15,8 +20,7 @@ export function getParentNode(id) {
menu.children = []
child.children = []
return {
stair: menu,
second: child,
stair: menu, second: child,
}
}
for (let item of child.children) {
@@ -25,9 +29,7 @@ export function getParentNode(id) {
child.children = []
item.children = []
return {
stair: menu,
second: child,
three: item
stair: menu, second: child, three: item
}
}
}
@@ -39,30 +41,75 @@ export function getParentNode(id) {
}
}
export function setAppLanguage(that){
export function setAppLanguage() {
let lang = sessionStorage.getItem("lang");
if (lang != null){
that.$i18n.locale = lang
if (lang != null) {
vm.$i18n.locale = lang
return
}
var language = window.navigator.userLanguage || window.navigator.language;
if (language == 'zh-CN'){
if (language == 'zh-CN') {
lang = 'cn'
}else {
} else {
lang = 'en'
}
that.$i18n.locale = lang
sessionStorage.setItem("lang",lang)
vm.$i18n.locale = lang
sessionStorage.setItem("lang", lang)
}
export function setLanguage(that){
let lang = that.$route.query && that.$route.query.lang
if (lang != undefined){
that.$i18n.locale = lang
sessionStorage.setItem("lang",lang)
export function setLanguage() {
let lang = vm.$route.query && vm.$route.query.lang
if (lang != undefined) {
vm.$i18n.locale = lang
sessionStorage.setItem("lang", lang)
}
}
export function toArticle(news,width) {
info(news.id).then(res => {
let info = null
try {
info = getParentNode(res.data.encodeId)
}catch (e){}
if (info == null){
return
}
if (width) {
vm.$router.push("/pc/" + info.second.encodeId + "/" + info.three.encodeId + "?id=" + news.id + "&lang=" + sessionStorage.getItem("lang"));
} else {
vm.$router.push("/mobile/" + info.second.encodeId + "/" + info.three.encodeId + "?id=" + news.id + "&lang=" + sessionStorage.getItem("lang"));
}
})
}
export function lookMoreComment(item,width) {
info(item.id).then(res => {
let info = null
try {
info = getParentNode(res.data.encodeId)
}catch (e){}
if (info == null){
return
}
if (info.three == null) {
if (width) {
vm.$router.push("/pc/" + info.second.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"));
} else {
vm.$router.push("/mobile/" + info.second.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"));
}
} else {
if (width) {
vm.$router.push("/pc/" + info.second.encodeId + "/" + info.three.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"));
} else {
vm.$router.push("/mobile/" + info.second.encodeId + "/" + info.three.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"));
}
}
})
}