修改登录判断

This commit is contained in:
A1300399510 2025-02-08 11:45:15 +08:00
parent f6091b0b28
commit 2b2bd9da53
22 changed files with 144 additions and 147 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/index.html vendored

File diff suppressed because one or more lines are too long

1
dist/js/124.79130f1c.js vendored Normal file
View File

@ -0,0 +1 @@
"use strict";(self["webpackChunkninepage"]=self["webpackChunkninepage"]||[]).push([[124],{9143:function(e,t,n){n.r(t),n.d(t,{default:function(){return l}});var a=function(){var e=this,t=e._self._c;return t("div",[t("header-nav",{attrs:{issearch:!0,needgetuser:!0}},[t("template",{slot:"header-title"},[e._v("帖子详情")])],2),t("router-view",{key:e.key})],1)},r=[],u=n(517),s={name:"detail",data(){return{}},computed:{key(){return this.$route.path+Math.random()}},mounted(){},methods:{},components:{HeaderNav:u.Z}},d=s,i=n(1001),o=(0,i.Z)(d,a,r,!1,null,"10593ad7",null),l=o.exports}}]);

1
dist/js/337.4b2508a0.js vendored Normal file
View File

@ -0,0 +1 @@
"use strict";(self["webpackChunkninepage"]=self["webpackChunkninepage"]||[]).push([[337],{5817:function(e,t,n){n.r(t),n.d(t,{default:function(){return h}});var r=function(){var e=this,t=e._self._c;return t("div",[t("header-nav",{attrs:{issearch:!1,needgetuser:!0}},[t("template",{slot:"header-title"},[e._v("搜索帖子")])],2),t("router-view",{key:e.key})],1)},a=[],u=n(517),s={name:"search",data(){return{}},computed:{key(){return this.$route.path+Math.random()}},mounted(){},methods:{},components:{HeaderNav:u.Z}},o=s,c=n(1001),d=(0,c.Z)(o,r,a,!1,null,"24c9f798",null),h=d.exports}}]);

1
dist/js/354.bc2d16ec.js vendored Normal file
View File

@ -0,0 +1 @@
"use strict";(self["webpackChunkninepage"]=self["webpackChunkninepage"]||[]).push([[354],{6170:function(e,t,n){n.r(t),n.d(t,{default:function(){return o}});var r=function(){var e=this,t=e._self._c;return t("div",[t("header-nav",{attrs:{issearch:!0,needgetuser:!0}},[t("template",{slot:"header-title"},[e._v("我的寄托")])],2),t("router-view")],1)},a=[],u=n(517),s={name:"user",data(){return{}},mounted(){},methods:{},components:{HeaderNav:u.Z}},d=s,i=n(1001),l=(0,i.Z)(d,r,a,!1,null,"7090fd6a",null),o=l.exports}}]);

View File

@ -1 +0,0 @@
"use strict";(self["webpackChunkninepage"]=self["webpackChunkninepage"]||[]).push([[483],{5817:function(e,t,n){n.r(t),n.d(t,{default:function(){return h}});var r=function(){var e=this,t=e._self._c;return t("div",[t("header-nav",{attrs:{issearch:!1,needgetuser:!0}},[t("template",{slot:"header-title"},[e._v("搜索帖子")])],2),t("router-view",{key:e.key})],1)},a=[],u=n(4917),s={name:"search",data(){return{}},computed:{key(){return this.$route.path+Math.random()}},mounted(){},methods:{},components:{HeaderNav:u.Z}},o=s,c=n(1001),d=(0,c.Z)(o,r,a,!1,null,"24c9f798",null),h=d.exports}}]);

1
dist/js/517.b66c61bd.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
"use strict";(self["webpackChunkninepage"]=self["webpackChunkninepage"]||[]).push([[561],{9143:function(e,t,n){n.r(t),n.d(t,{default:function(){return l}});var a=function(){var e=this,t=e._self._c;return t("div",[t("header-nav",{attrs:{issearch:!0,needgetuser:!0}},[t("template",{slot:"header-title"},[e._v("帖子详情")])],2),t("router-view",{key:e.key})],1)},r=[],u=n(4917),s={name:"detail",data(){return{}},computed:{key(){return this.$route.path+Math.random()}},mounted(){},methods:{},components:{HeaderNav:u.Z}},d=s,i=n(1001),o=(0,i.Z)(d,a,r,!1,null,"10593ad7",null),l=o.exports}}]);

View File

@ -1 +0,0 @@
"use strict";(self["webpackChunkninepage"]=self["webpackChunkninepage"]||[]).push([[584],{6170:function(e,t,n){n.r(t),n.d(t,{default:function(){return o}});var r=function(){var e=this,t=e._self._c;return t("div",[t("header-nav",{attrs:{issearch:!0,needgetuser:!0}},[t("template",{slot:"header-title"},[e._v("我的寄托")])],2),t("router-view")],1)},a=[],u=n(4917),s={name:"user",data(){return{}},mounted(){},methods:{},components:{HeaderNav:u.Z}},d=s,i=n(1001),l=(0,i.Z)(d,r,a,!1,null,"7090fd6a",null),o=l.exports}}]);

File diff suppressed because one or more lines are too long

1
dist/js/718.165fc1ef.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/js/831.6fddd3bb.js vendored Normal file
View File

@ -0,0 +1 @@
"use strict";(self["webpackChunkninepage"]=self["webpackChunkninepage"]||[]).push([[831],{2013:function(e,t,n){n.r(t),n.d(t,{default:function(){return u}});var a=function(){var e=this,t=e._self._c;return t("div",[t("header-nav",{attrs:{issearch:!0,needgetuser:!0}},[t("template",{slot:"header-title"},[e._v("寄托天下论坛")])],2),t("nav",[t("router-link",{attrs:{to:e.recommendURl,exact:""}},[e._v("推荐阅读")]),t("router-link",{attrs:{to:e.collect,exact:""}},[e._v("收藏的版块")]),t("router-link",{attrs:{to:e.allSections,exact:""}},[e._v("全部版块")])],1),t("div",{staticClass:"publish flexcolumn flexcenter",on:{click:function(t){return t.stopPropagation(),e.$skipUrl(e.invitationPost)}}},[t("svg-icon",{attrs:{"icon-class":"add","class-name":"icon-publish"}}),e._v(" 发帖 ")],1),t("router-view",{key:e.key})],1)},l=[],o=n(517),i=n(6799),r={name:"Index",data(){return{favorite:[],recommend:[],fid:null,allSections:"/allSections",collect:"/collect",recommendURl:"/recommend",invitationPost:i.a}},computed:{key(){return this.$route.path+Math.random()}},watch:{"$store.state.homeRequestState":{handler(e,t){let{favoriteList:n,recommendList:a}=this.$store.state;this.favorite=n,this.recommend=a},immediate:!0},$route:{handler(e,t){let n=e.fullPath;-1!=n.indexOf("allSections")&&(this.allSections=n),-1!=n.indexOf("collect")&&(this.collect=n),-1!=n.indexOf("recommend")&&(this.recommendURl=n)},immediate:!0}},mounted(){},components:{HeaderNav:o.Z},methods:{}},s=r,c=n(1001),d=(0,c.Z)(s,a,l,!1,null,null,null),u=d.exports}}]);

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
"use strict";(self["webpackChunkninepage"]=self["webpackChunkninepage"]||[]).push([[94],{2013:function(e,t,n){n.r(t),n.d(t,{default:function(){return u}});var a=function(){var e=this,t=e._self._c;return t("div",[t("header-nav",{attrs:{issearch:!0,needgetuser:!0}},[t("template",{slot:"header-title"},[e._v("寄托天下论坛")])],2),t("nav",[t("router-link",{attrs:{to:e.recommendURl,exact:""}},[e._v("推荐阅读")]),t("router-link",{attrs:{to:e.collect,exact:""}},[e._v("收藏的版块")]),t("router-link",{attrs:{to:e.allSections,exact:""}},[e._v("全部版块")])],1),t("div",{staticClass:"publish flexcolumn flexcenter",on:{click:function(t){return t.stopPropagation(),e.$skipUrl(e.invitationPost)}}},[t("svg-icon",{attrs:{"icon-class":"add","class-name":"icon-publish"}}),e._v(" 发帖 ")],1),t("router-view",{key:e.key})],1)},l=[],o=n(4917),i=n(6799),r={name:"Index",data(){return{favorite:[],recommend:[],fid:null,allSections:"/allSections",collect:"/collect",recommendURl:"/recommend",invitationPost:i.a}},computed:{key(){return this.$route.path+Math.random()}},watch:{"$store.state.homeRequestState":{handler(e,t){let{favoriteList:n,recommendList:a}=this.$store.state;this.favorite=n,this.recommend=a},immediate:!0},$route:{handler(e,t){let n=e.fullPath;-1!=n.indexOf("allSections")&&(this.allSections=n),-1!=n.indexOf("collect")&&(this.collect=n),-1!=n.indexOf("recommend")&&(this.recommendURl=n)},immediate:!0}},mounted(){},components:{HeaderNav:o.Z},methods:{}},s=r,c=n(1001),d=(0,c.Z)(s,a,l,!1,null,null,null),u=d.exports}}]);

File diff suppressed because one or more lines are too long

View File

@ -18,8 +18,8 @@
</div>
</div>
<div class="head-arrows" :class="{animation: headMorePopState}" v-if="headMorePopState"></div>
<div class="head-more-pop" :class="{animation: headMorePopState}">
<div class="head-arrows" :class="{ animation: headMorePopState }" v-if="headMorePopState"></div>
<div class="head-more-pop" :class="{ animation: headMorePopState }">
<div class="head-more-userinfo flex1 flexacenter">
<div class="head-more-left flexacenter" v-if="islogin">
<router-link class="flexacenter" to="/user" @click.native="headMorePopState = !headMorePopState">
@ -46,7 +46,7 @@
</div>
<div class="tab-list">
<a class="tab-item flexacenter" :href="item.url" target="_blank" :class="{pitch: item.current == 1}" v-for="(item, index) in menu" :key="index">{{ item.name }}</a>
<a class="tab-item flexacenter" :href="item.url" target="_blank" :class="{ pitch: item.current == 1 }" v-for="(item, index) in menu" :key="index">{{ item.name }}</a>
</div>
<div class="head-more-post flexcenter" @click.stop="$skipUrl(invitationPost, false)">
@ -69,7 +69,7 @@
<script>
import SearchBox from "../components/SearchBox.vue"
import {invitationPost} from "@/utils/bizarreUrl"
import { invitationPost } from "@/utils/bizarreUrl"
export default {
name: "HeaderNav",
@ -98,11 +98,10 @@ export default {
if (JSON.stringify(user) === "{}") this.$store.dispatch("getUserInfo", this)
else {
this.userInfo = user
this.islogin = user.uid > 0 ? true : false
this.islogin = user.uid > 0 || user.uin > 0 ? true : false
this.hotSearchkeywords = this.$store.state.hotSearchkeywords
this.menu = this.$store.state.menu
}
},
methods: {

View File

@ -1,137 +1,135 @@
import Vue from 'vue'
import Vuex from 'vuex'
import Vue from "vue"
import Vuex from "vuex"
Vue.use(Vuex)
export default new Vuex.Store({
state: {
historicalSearch: [], // 历史数据
allForumList: [], // 全部板块数据
homeRequestState: false, // 首页推荐和收藏接口的数据请求状态 这个是是否需要发送请求,因为用户点击收藏后需要重新获取
getUserInfoState: false, // 这个是是否在请求状态
favoriteList: [], // 收藏板块 数据
recommendList: [], // 推荐板块数据
menu: [],
user: {}, // 用户信息
hotSearchkeywords: [], // 热门搜索
loading: null,
},
getters: {
},
state: {
historicalSearch: [], // 历史数据
allForumList: [], // 全部板块数据
homeRequestState: false, // 首页推荐和收藏接口的数据请求状态 这个是是否需要发送请求,因为用户点击收藏后需要重新获取
getUserInfoState: false, // 这个是是否在请求状态
favoriteList: [], // 收藏板块 数据
recommendList: [], // 推荐板块数据
menu: [],
user: {}, // 用户信息
hotSearchkeywords: [], // 热门搜索
loading: null,
},
getters: {},
mutations: {
setHistoricalSearch(state, payload) {
if (!Array.isArray(payload)) payload = [payload]
let targetArr = [...new Set([...payload, ...state.historicalSearch])]
if (targetArr.length > 10) targetArr = targetArr.slice(0, 10)
mutations: {
setHistoricalSearch(state, payload) {
if (!Array.isArray(payload)) payload = [payload]
let targetArr = [...new Set([...payload, ...state.historicalSearch])]
if (targetArr.length > 10) targetArr = targetArr.slice(0, 10)
state.historicalSearch = targetArr
localStorage.setItem('historicalSearch', JSON.stringify(targetArr))
state.historicalSearch = targetArr
localStorage.setItem("historicalSearch", JSON.stringify(targetArr))
},
setAllForumList(state, payload) {
state.allForumList = payload
},
setHomeRequestState(state, payload) {
state.homeRequestState = payload
},
setFavoriteList(state, payload) {
state.favoriteList = payload
},
setRecommendList(state, payload) {
state.recommendList = payload
},
setUser(state, payload) {
state.user = payload
},
setHotSearchkeywords(state, payload) {
state.hotSearchkeywords = payload
},
setgetUserInfoState(state, payload) {
state.getUserInfoState = payload
},
setMenu(state, payload) {
state.menu = payload
},
},
setAllForumList(state, payload) {
state.allForumList = payload
actions: {
// 获取历史搜索的数据
fetchHistoricalSearch({ commit }) {
let historicalSearch = JSON.parse(localStorage.getItem("historicalSearch")) || []
commit("setHistoricalSearch", historicalSearch)
},
// 获取全部板块的数据
getAllForum({ commit }, that) {
that.$http
.get("/api/home/allForum")
.then(res => {
if (res.code != 200) return
let allForumList = res.data
commit("setAllForumList", allForumList)
})
.catch(err => {
that.$message.error(err.message)
})
},
// 获取用户信息 获取收藏信息那些数据
getUserInfo({ state, commit }, that) {
if (state.getUserInfoState) return
commit("setgetUserInfoState", true)
that.$http
.post("/api/home")
.then(res => {
if (res.code != 200) return
let data = res.data
let { config, favorite, hotSearchkeywords, recommend, user, menu } = data
const islogin = user.uin > 0 || user.uid > 0 ? true : false
// console.log("islogin", islogin)
commit("setHomeRequestState", true)
commit("setUser", user)
commit("setFavoriteList", favorite)
commit("setRecommendList", recommend)
commit("setHotSearchkeywords", hotSearchkeywords)
commit("setMenu", menu)
if (user.uid > 0 || user.uin > 0) {
// 这个是顶部用户数据的 这样不用监听是否请求成功
setTimeout(() => {
if (typeof xstat !== "undefined") {
xstat.identify({
uid: user.uid,
uin: user.uin,
})
}
}, 600)
}
if (that.userInfo) {
// 这个是顶部用户数据的 这样不用监听是否请求成功
that.userInfo = user
that.islogin = user.uid > 0 || user.uin > 0 ? true : false
that.hotSearchkeywords = hotSearchkeywords
that.menu = menu
}
})
.catch(err => {
that.$message.error(err.message)
})
.finally(() => {
// that.$closeUnderLoading(that)
commit("setgetUserInfoState", false)
})
},
},
setHomeRequestState(state, payload) {
state.homeRequestState = payload
},
setFavoriteList(state, payload) {
state.favoriteList = payload
},
setRecommendList(state, payload) {
state.recommendList = payload
},
setUser(state, payload) {
state.user = payload
},
setHotSearchkeywords(state, payload) {
state.hotSearchkeywords = payload
},
setgetUserInfoState(state, payload) {
state.getUserInfoState = payload
},
setMenu(state, payload) {
state.menu = payload
}
},
actions: {
// 获取历史搜索的数据
fetchHistoricalSearch({ commit }) {
let historicalSearch = JSON.parse(localStorage.getItem('historicalSearch')) || []
commit('setHistoricalSearch', historicalSearch)
},
// 获取全部板块的数据
getAllForum({ commit }, that) {
that.$http.get("/api/home/allForum").then(res => {
if (res.code != 200) return;
let allForumList = res.data
commit('setAllForumList', allForumList)
}).catch(err => {
that.$message.error(err.message)
})
},
// 获取用户信息 获取收藏信息那些数据
getUserInfo({ state, commit }, that) {
if (state.getUserInfoState) return
commit('setgetUserInfoState', true)
that.$http.post("/api/home").then(res => {
if (res.code != 200) return;
let data = res.data
let { config, favorite, hotSearchkeywords, recommend, user, menu } = data
console.log("user",user.uid > 0);
const islogin = user.uid > 0 ? true : false;
console.log("islogin",islogin);
commit('setHomeRequestState', true)
commit('setUser', user)
commit('setFavoriteList', favorite)
commit('setRecommendList', recommend)
commit('setHotSearchkeywords', hotSearchkeywords)
commit('setMenu', menu)
if (user.uid > 0) { // 这个是顶部用户数据的 这样不用监听是否请求成功
setTimeout(() => {
if (typeof xstat !== "undefined") {
xstat.identify({
uid: user.uid,
uin: user.uin,
});
}
}, 600)
}
if (that.userInfo) { // 这个是顶部用户数据的 这样不用监听是否请求成功
that.userInfo = user
that.islogin = user.uid > 0 ? true : false;
that.hotSearchkeywords = hotSearchkeywords
that.menu = menu
}
}).catch(err => {
that.$message.error(err.message)
}).finally(() => {
// that.$closeUnderLoading(that)
commit('setgetUserInfoState', false)
})
},
},
modules: {
},
modules: {},
})

View File

@ -572,7 +572,7 @@ export default {
"$store.state.user": {
handler(newV, oldV) {
if (JSON.stringify(newV) != "{}") {
this.islogin = newV.uid > 0 ? true : false
this.islogin = newV.uid > 0 || newV.uin > 0 ? true : false
this.tid = this.$route.query["tid"]
this.postList.page = this.$route.query["page"] || 1