no message

This commit is contained in:
A1300399510
2023-10-16 16:55:40 +08:00
parent 562481d08c
commit 07b7eb2471
7 changed files with 204 additions and 216 deletions

View File

@@ -1,286 +1,274 @@
<template>
<div id="app">
<div class="container">
<router-view />
</div>
</div>
<div id="app">
<div class="container">
<router-view />
</div>
</div>
</template>
<script>
export default {
name: "App",
data() {
return {
loading: null,
pathname: "",
parameterObject: {},
isPc: false,
socketTask: null,
}
},
watch: {
name: "App",
data() {
return {
loading: null,
pathname: "",
parameterObject: {},
isPc: false,
socketTask: null,
}
},
watch: {},
mounted() {
this.$store.dispatch("fetchHistoricalSearch") // 获取历史搜索记录
this.$store.dispatch("getAllForum", this) // 获取全部板块
},
mounted() {
this.$store.dispatch('fetchHistoricalSearch') // 获取历史搜索记录
this.$store.dispatch('getAllForum', this) // 获取全部板块
this.isJudgePc()
// this.$skipUrl("gggg", false)
// setTimeout(() => {
// // this.hasMiucmsSessionCookie()
// // this.useSocket
// console.log(this.$store.state['user']);
// }, 1000)
this.isJudgePc()
// this.$skipUrl("gggg", false)
// setTimeout(() => {
// // this.hasMiucmsSessionCookie()
// // this.useSocket
// console.log(this.$store.state['user']);
// }, 1000)
let timer = setInterval(() => {
if (Object.keys(this.$store.state.user).length !== 0) {
this.useSocket()
clearInterval(timer)
}
}, 1000)
},
let timer = setInterval(() => {
if (Object.keys(this.$store.state.user).length !== 0) {
this.useSocket()
clearInterval(timer)
}
}, 1000);
methods: {
// 开启socket
useSocket() {
let token = this.getMiucmsSessionCookie() || ""
this.socketTask = new WebSocket(`wss://app.gter.net/socket?token=${token}`)
this.socketTask.onopen = () => {
let user = this.$store.state.user || {}
if (user && token) {
this.socketTask.send(
JSON.stringify({
type: "bind",
data: {
token,
uid: user.uid || 0,
},
})
)
}
setTimeout(() => this.timedTransmission(), 50000)
}
this.socketTask.onclose = () => {
console.log("socket关闭了", new Date())
}
},
},
// 定时发送
timedTransmission() {
if (this.socketTask.readyState != 1) return
this.socketTask.send(JSON.stringify({type: "ping"}))
setTimeout(() => this.timedTransmission(), 50000)
},
methods: {
// 开启socket
useSocket() {
let token = this.getMiucmsSessionCookie() || ''
this.socketTask = new WebSocket(`wss://app.gter.net/socket?token=${token}`);
this.socketTask.onopen = () => {
let user = this.$store.state.user || {};
if (user && token) {
this.socketTask.send(JSON.stringify({
type: 'bind',
data: {
token,
uid: user.uid || 0
}
}))
}
setTimeout(() => this.timedTransmission(), 50000);
};
this.socketTask.onclose = () => {
console.log('socket关闭了', new Date());
};
},
getMiucmsSessionCookie() {
let cookies = document.cookie.split(";")
for (let i = 0; i < cookies.length; i++) {
let cookie = cookies[i].split("=")
if (cookie[0].trim() === "miucms_session") {
return cookie[1]
}
}
return null
},
isJudgePc() {
return
const userAgentInfo = navigator.userAgent
const Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]
let flag = true
for (let i = 0; i < Agents.length; i++) {
if (userAgentInfo.indexOf(Agents[i]) > 0) {
flag = false
break
}
}
// 定时发送
timedTransmission() {
if (this.socketTask.readyState != 1) return
this.socketTask.send(JSON.stringify({ type: 'ping' }))
setTimeout(() => this.timedTransmission(), 50000)
},
if (flag) {
console.log("flag", flag)
let pathname = window.location.pathname
getMiucmsSessionCookie() {
let cookies = document.cookie.split(";");
for (let i = 0; i < cookies.length; i++) {
let cookie = cookies[i].split("=");
if (cookie[0].trim() === "miucms_session") {
return cookie[1];
}
}
return null;
},
isJudgePc() {
const userAgentInfo = navigator.userAgent;
const Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
let flag = true;
for (let i = 0; i < Agents.length; i++) {
if (userAgentInfo.indexOf(Agents[i]) > 0) {
flag = false;
break;
}
}
const queryString = window.location.search
const parameters = queryString.substring(1)
let parameterObject = Object.fromEntries(new URLSearchParams(parameters))
this.pathname = pathname
this.parameterObject = parameterObject
if (flag) {
let pathname = window.location.pathname
if (this.pathname.indexOf("allSections") != -1 && this.parameterObject["fid"]) {
this.handleNeedAllSkipPc()
return
}
if (this.pathname.indexOf("userIndex") != -1) {
this.handleNeedInfo()
return
}
const queryString = window.location.search;
const parameters = queryString.substring(1);
let parameterObject = Object.fromEntries(new URLSearchParams(parameters));
this.pathname = pathname
this.parameterObject = parameterObject
let url = ""
if (this.pathname.indexOf("allSections") != -1 && this.parameterObject['fid']) {
this.handleNeedAllSkipPc()
return
}
if (this.pathname.indexOf("userIndex") != -1) {
this.handleNeedInfo()
return
}
if (pathname.indexOf("detailIndex") != -1) url = `https://bbs.gter.net/thread-${parameterObject["tid"]}-${parameterObject["page"] || 1}-1.html`
if (pathname.indexOf("searchResult") != -1) url = `https://search.gter.net/index.html?type=forum${parameterObject["kw"] ? `&kw=${parameterObject["kw"]}` : ""}`
if (pathname.indexOf("allSections") != -1 && !parameterObject["fid"]) url = `https://bbs.gter.net/forum.php`
if (pathname.indexOf("recommend") != -1) url = `https://bbs.gter.net/forum.php`
if (pathname.indexOf("collect") != -1) url = `https://bbs.gter.net/forum.php`
if (pathname == "/" || pathname == "" || !pathname) url = `https://bbs.gter.net/forum.php`
if (url) this.$skipUrl(url, false)
}
},
// 处理需要user信息的跳转PC端
handleNeedInfo() {
let user = this.$store.state.user || {}
let url = ""
if (JSON.stringify(user) != "{}") {
url = `https://bbs.gter.net/home.php?mod=space&uid=${user.uin}`
this.$skipUrl(url, false)
} else {
setTimeout(() => {
this.handleNeedInfo()
}, 300)
}
},
let url = ""
if (pathname.indexOf("detailIndex") != -1) url = `https://bbs.gter.net/thread-${parameterObject['tid']}-${parameterObject['page'] || 1}-1.html`
if (pathname.indexOf("searchResult") != -1) url = `https://search.gter.net/index.html?type=forum${parameterObject['kw'] ? `&kw=${parameterObject['kw']}` : ''}`
if (pathname.indexOf("allSections") != -1 && !parameterObject['fid']) url = `https://bbs.gter.net/forum.php`
if (pathname.indexOf("recommend") != -1) url = `https://bbs.gter.net/forum.php`
if (pathname.indexOf("collect") != -1) url = `https://bbs.gter.net/forum.php`
if (pathname == "/" || pathname == "" || !pathname) url = `https://bbs.gter.net/forum.php`
if (url) this.$skipUrl(url, false)
}
},
// 处理需要user信息的跳转PC端
handleNeedInfo() {
let user = this.$store.state.user || {}
let url = ""
if (JSON.stringify(user) != "{}") {
url = `https://bbs.gter.net/home.php?mod=space&uid=${user.uin}`
this.$skipUrl(url, false)
} else {
setTimeout(() => {
this.handleNeedInfo()
}, 300);
}
},
// 处理需要全部板块的跳转PC端
handleNeedAllSkipPc() {
let allForumList = this.$store.state.allForumList || []
let url = ""
let fid = this.parameterObject['fid'] || null
if (allForumList.length != 0) {
allForumList.forEach((element, index) => {
if (element.fid == fid) url = `https://bbs.gter.net/forum.php?gid=${element.fid}`
element.data.forEach((el, i) => {
if (el.fid == fid) url = `https://bbs.gter.net/forum-${el.fid}-${this.parameterObject['page'] || 1}.html`
})
})
this.$skipUrl(url, false)
} else {
setTimeout(() => {
this.handleNeedAllSkipPc()
}, 300)
}
},
},
// 处理需要全部板块的跳转PC端
handleNeedAllSkipPc() {
let allForumList = this.$store.state.allForumList || []
let url = ""
let fid = this.parameterObject["fid"] || null
if (allForumList.length != 0) {
allForumList.forEach((element, index) => {
if (element.fid == fid) url = `https://bbs.gter.net/forum.php?gid=${element.fid}`
element.data.forEach((el, i) => {
if (el.fid == fid) url = `https://bbs.gter.net/forum-${el.fid}-${this.parameterObject["page"] || 1}.html`
})
})
this.$skipUrl(url, false)
} else {
setTimeout(() => {
this.handleNeedAllSkipPc()
}, 300)
}
},
},
}
</script>
<style lang="scss">
@import 'assets/css/normalize.css';
@import 'assets/css/public.scss'; //帖子内容样式
@import "assets/css/normalize.css";
@import "assets/css/public.scss"; //帖子内容样式
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
display: flex;
flex-direction: column;
margin: 0 auto;
position: relative;
// overflow: hidden;
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
display: flex;
flex-direction: column;
margin: 0 auto;
position: relative;
// overflow: hidden;
}
a {
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
text-decoration: none;
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
text-decoration: none;
}
.container {
// padding: 0 0.35rem;
background-color: rgba(246, 246, 246, 1);
min-height: 100vh;
// padding: 0 0.35rem;
background-color: rgba(246, 246, 246, 1);
min-height: 100vh;
}
.flexflex {
display: flex;
display: flex;
}
.flexcenter {
display: flex;
justify-content: center;
align-items: center;
display: flex;
justify-content: center;
align-items: center;
}
.flexacenter {
display: flex;
align-items: center;
display: flex;
align-items: center;
}
.flexcolumn {
display: flex;
flex-direction: column;
display: flex;
flex-direction: column;
}
.flex1 {
flex: 1;
flex: 1;
}
.el-message {
min-width: 7rem !important;
min-width: 7rem !important;
}
// 文字一行显示
.one-line {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: -moz-box;
-moz-box-orient: vertical;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: -moz-box;
-moz-box-orient: vertical;
}
// 文字两行显示
.two-lines {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
// 文章三行显示
.three-lines {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
text-overflow: ellipsis;
}
// 阴影
.shadow {
-webkit-box-shadow: 0 0 .3rem rgba(0, 0, 0, .1);
box-shadow: 0 0 .3rem rgba(0, 0, 0, .1);
-webkit-box-shadow: 0 0 0.3rem rgba(0, 0, 0, 0.1);
box-shadow: 0 0 0.3rem rgba(0, 0, 0, 0.1);
}
// 弹窗公共类 蒙版
.pop-box {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.64);
z-index: 100;
align-items: center;
justify-content: flex-end;
overflow: auto;
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.64);
z-index: 100;
align-items: center;
justify-content: flex-end;
overflow: auto;
}
// 清除 input 和 textarea 的默认样式
input,
textarea {
border: none;
outline: none;
background: transparent;
resize: none;
border: none;
outline: none;
background: transparent;
resize: none;
}
</style>
</style>

View File

@@ -31,7 +31,7 @@ service.interceptors.request.use(config => {
// config['headers']['authorization'] = "qj2q1qk1on0curclipghjtv5ja1g9eq2"
// config['headers']['authorization'] = "661aiz52k5e6vqgmkxnz0wvbv8nciz8h"
if (process.env.NODE_ENV == "development") config['headers']['authorization'] = "0h870ovk2xckoqfsh8a3t3sg4sg5z7eg"
// if (process.env.NODE_ENV == "development") config['headers']['authorization'] = "0h870ovk2xckoqfsh8a3t3sg4sg5z7eg"
return config
}, error => {