no message
This commit is contained in:
parent
e29e0e36b9
commit
1abc53b06d
2
dist/index.html
vendored
2
dist/index.html
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@
|
|||||||
import Vue from 'vue'
|
import Vue from "vue"
|
||||||
import Vuex from 'vuex'
|
import Vuex from "vuex"
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
@ -16,8 +16,7 @@ export default new Vuex.Store({
|
|||||||
hotSearchkeywords: [], // 热门搜索
|
hotSearchkeywords: [], // 热门搜索
|
||||||
loading: null,
|
loading: null,
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {},
|
||||||
},
|
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
setHistoricalSearch(state, payload) {
|
setHistoricalSearch(state, payload) {
|
||||||
@ -26,7 +25,7 @@ export default new Vuex.Store({
|
|||||||
if (targetArr.length > 10) targetArr = targetArr.slice(0, 10)
|
if (targetArr.length > 10) targetArr = targetArr.slice(0, 10)
|
||||||
|
|
||||||
state.historicalSearch = targetArr
|
state.historicalSearch = targetArr
|
||||||
localStorage.setItem('historicalSearch', JSON.stringify(targetArr))
|
localStorage.setItem("historicalSearch", JSON.stringify(targetArr))
|
||||||
},
|
},
|
||||||
|
|
||||||
setAllForumList(state, payload) {
|
setAllForumList(state, payload) {
|
||||||
@ -59,64 +58,92 @@ export default new Vuex.Store({
|
|||||||
|
|
||||||
setMenu(state, payload) {
|
setMenu(state, payload) {
|
||||||
state.menu = payload
|
state.menu = payload
|
||||||
}
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
// 获取历史搜索的数据
|
// 获取历史搜索的数据
|
||||||
fetchHistoricalSearch({ commit }) {
|
fetchHistoricalSearch({ commit }) {
|
||||||
let historicalSearch = JSON.parse(localStorage.getItem('historicalSearch')) || []
|
let historicalSearch = JSON.parse(localStorage.getItem("historicalSearch")) || []
|
||||||
commit('setHistoricalSearch', historicalSearch)
|
commit("setHistoricalSearch", historicalSearch)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 获取当前 HOST
|
||||||
|
// const host = window.location.hostname;
|
||||||
|
|
||||||
|
// 简单的哈希函数,返回十六进制字符串
|
||||||
|
simpleHash() {
|
||||||
|
const str = window.location.hostname
|
||||||
|
let hash = 0
|
||||||
|
for (let i = 0; i < str.length; i++) {
|
||||||
|
const char = str.charCodeAt(i)
|
||||||
|
hash = (hash << 5) - hash + char
|
||||||
|
hash |= 0 // Convert to 32bit integer
|
||||||
|
}
|
||||||
|
return (hash >>> 0).toString(16) // 将哈希值转换为无符号整数,然后转换为十六进制字符串
|
||||||
|
},
|
||||||
|
|
||||||
|
// // 生成唯一值
|
||||||
|
// const uniqueValue = simpleHash(host);
|
||||||
|
// console.log(uniqueValue); // 输出基于 HOST 生成的唯一值
|
||||||
|
|
||||||
// 获取全部板块的数据
|
// 获取全部板块的数据
|
||||||
getAllForum({ commit }, that) {
|
getAllForum({ commit }, that) {
|
||||||
that.$http.get("/api/home/allForum?type=forum").then(res => {
|
const str = window.location.hostname
|
||||||
if (res.code != 200) return;
|
let hash = 0
|
||||||
|
for (let i = 0; i < str.length; i++) {
|
||||||
|
const char = str.charCodeAt(i)
|
||||||
|
hash = (hash << 5) - hash + char
|
||||||
|
hash |= 0 // Convert to 32bit integer
|
||||||
|
}
|
||||||
|
const strr = (hash >>> 0).toString(16) // 将哈希值转换为无符号整数,然后转换为十六进制字符串
|
||||||
|
|
||||||
|
that.$http
|
||||||
|
.get("/api/home/allForum?" + strr)
|
||||||
|
.then(res => {
|
||||||
|
if (res.code != 200) return
|
||||||
let allForumList = res.data
|
let allForumList = res.data
|
||||||
commit('setAllForumList', allForumList)
|
commit("setAllForumList", allForumList)
|
||||||
}).catch(err => {
|
})
|
||||||
|
.catch(err => {
|
||||||
that.$message.error(err.message)
|
that.$message.error(err.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取用户信息 获取收藏信息那些数据
|
// 获取用户信息 获取收藏信息那些数据
|
||||||
getUserInfo({ state, commit }, that) {
|
getUserInfo({ state, commit }, that) {
|
||||||
if (state.getUserInfoState) return
|
if (state.getUserInfoState) return
|
||||||
commit('setgetUserInfoState', true)
|
commit("setgetUserInfoState", true)
|
||||||
that.$http.post("/api/home").then(res => {
|
that.$http
|
||||||
if (res.code != 200) return;
|
.post("/api/home")
|
||||||
|
.then(res => {
|
||||||
|
if (res.code != 200) return
|
||||||
let data = res.data
|
let data = res.data
|
||||||
let { config, favorite, hotSearchkeywords, recommend, user, menu } = data
|
let { config, favorite, hotSearchkeywords, recommend, user, menu } = data
|
||||||
|
|
||||||
commit('setHomeRequestState', true)
|
commit("setHomeRequestState", true)
|
||||||
commit('setUser', user)
|
commit("setUser", user)
|
||||||
commit('setFavoriteList', favorite)
|
commit("setFavoriteList", favorite)
|
||||||
commit('setRecommendList', recommend)
|
commit("setRecommendList", recommend)
|
||||||
commit('setHotSearchkeywords', hotSearchkeywords)
|
commit("setHotSearchkeywords", hotSearchkeywords)
|
||||||
commit('setMenu', menu)
|
commit("setMenu", menu)
|
||||||
|
|
||||||
if (that.userInfo) { // 这个是顶部用户数据的 这样不用监听是否请求成功
|
if (that.userInfo) {
|
||||||
|
// 这个是顶部用户数据的 这样不用监听是否请求成功
|
||||||
that.userInfo = user
|
that.userInfo = user
|
||||||
that.islogin = user.uid > 0 ? true : false;
|
that.islogin = user.uid > 0 ? true : false
|
||||||
that.hotSearchkeywords = hotSearchkeywords
|
that.hotSearchkeywords = hotSearchkeywords
|
||||||
that.menu = menu
|
that.menu = menu
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}).catch(err => {
|
.catch(err => {
|
||||||
that.$message.error(err.message)
|
that.$message.error(err.message)
|
||||||
}).finally(() => {
|
})
|
||||||
|
.finally(() => {
|
||||||
// that.$closeUnderLoading(that)
|
// that.$closeUnderLoading(that)
|
||||||
commit('setgetUserInfoState', false)
|
commit("setgetUserInfoState", false)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
modules: {
|
modules: {},
|
||||||
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user