加入点击发布 点赞 评论等打开弹窗
This commit is contained in:
102
app.vue
102
app.vue
@@ -10,25 +10,25 @@
|
||||
<RouterView></RouterView>
|
||||
</template>
|
||||
<script setup>
|
||||
const route = useRoute()
|
||||
const route = useRoute();
|
||||
// 是否是 生产环境
|
||||
const isProduction = process.env.NODE_ENV === "production"
|
||||
const isProduction = process.env.NODE_ENV === "production";
|
||||
// console.log(process.env.NODE_ENV, "NODE_ENV")
|
||||
onMounted(() => {
|
||||
// isNeedLogin.value = false
|
||||
if (!isProduction) {
|
||||
isNeedLogin.value = false
|
||||
isNeedLogin.value = false;
|
||||
// setTimeout(() => (isGetLoginState.value = false), 10000)
|
||||
userInfoWin.value = {
|
||||
"username": "",
|
||||
"uid": 256624,
|
||||
"uin": 4171117,
|
||||
"avatar": "https://oss.x-php.com/avatar/97K4EWIMLrsbGTWXslC1XFxTFauOikN42jDKLNjtax7HLtRjKcKMSdU9oWFhY2E~/small?random=1739160957",
|
||||
"messagenum": 0,
|
||||
"newprompt": 1,
|
||||
"todaysigned": 0,
|
||||
}
|
||||
} else determineIsLogin()
|
||||
username: "",
|
||||
uid: 256624,
|
||||
uin: 4171117,
|
||||
avatar: "https://oss.x-php.com/avatar/97K4EWIMLrsbGTWXslC1XFxTFauOikN42jDKLNjtax7HLtRjKcKMSdU9oWFhY2E~/small?random=1739160957",
|
||||
messagenum: 0,
|
||||
newprompt: 1,
|
||||
todaysigned: 0,
|
||||
};
|
||||
} else determineIsLogin();
|
||||
|
||||
// window["userInfoWin"] = {
|
||||
// "username": "",
|
||||
@@ -40,46 +40,76 @@ onMounted(() => {
|
||||
// "todaysigned": 0,
|
||||
// }
|
||||
|
||||
determineIsLogin()
|
||||
})
|
||||
determineIsLogin();
|
||||
|
||||
let isNeedLogin = ref(true) // 是否需要登录状态
|
||||
let isGetLoginState = ref(true) // 在获取登录状态 false 代表没有已经确定了
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const isLoginValue = params.get("islogin");
|
||||
if (isLoginValue == 1) getUserInfoWin();
|
||||
else realname.value = 1;
|
||||
});
|
||||
|
||||
let userInfoWin = ref({})
|
||||
let isNeedLogin = ref(true); // 是否需要登录状态
|
||||
let isGetLoginState = ref(true); // 在获取登录状态 false 代表没有已经确定了
|
||||
let realname = ref(0) // 是否已经实名
|
||||
let userInfoWin = ref({});
|
||||
|
||||
provide("userInfoWin", userInfoWin)
|
||||
provide("userInfoWin", userInfoWin);
|
||||
|
||||
// 判断是否登录状态
|
||||
const determineIsLogin = () => {
|
||||
let count = 0
|
||||
let count = 0;
|
||||
let timer = setInterval(() => {
|
||||
if (Object.keys(window["userInfoWin"]).length !== 0) {
|
||||
clearInterval(timer)
|
||||
isGetLoginState.value = false
|
||||
if (window["userInfoWin"]["uid"] || window["userInfoWin"]["uin"]) isNeedLogin.value = false
|
||||
userInfoWin.value = window["userInfoWin"]
|
||||
clearInterval(timer);
|
||||
isGetLoginState.value = false;
|
||||
if (window["userInfoWin"]["uid"] || window["userInfoWin"]["uin"]) isNeedLogin.value = false;
|
||||
userInfoWin.value = window["userInfoWin"];
|
||||
}
|
||||
count++
|
||||
count++;
|
||||
if (count >= 10) {
|
||||
clearInterval(timer)
|
||||
isGetLoginState.value = false
|
||||
clearInterval(timer);
|
||||
isGetLoginState.value = false;
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
|
||||
// 跳转登录
|
||||
const goLogin = () => {
|
||||
if (typeof window === "undefined") return
|
||||
if (typeof window === "undefined") return;
|
||||
if (window["userInfoWin"] && Object.keys(window["userInfoWin"]).length !== 0) {
|
||||
if (window["userInfoWin"]["uid"]) isNeedLogin.value = false
|
||||
else ajax_login()
|
||||
} else ajax_login()
|
||||
}
|
||||
if (window["userInfoWin"]["uid"]) isNeedLogin.value = false;
|
||||
else ajax_login();
|
||||
} else ajax_login();
|
||||
};
|
||||
|
||||
provide("isNeedLogin", isNeedLogin)
|
||||
provide("goLogin", goLogin)
|
||||
provide("isGetLoginState", isGetLoginState)
|
||||
const getUserInfoWin = () => {
|
||||
const checkUser = () => {
|
||||
const user = window.userInfoWin;
|
||||
if (!user) {
|
||||
setTimeout(checkUser, 100);
|
||||
return;
|
||||
}
|
||||
realname.value = user.realname || 0;
|
||||
};
|
||||
|
||||
setTimeout(checkUser, 100);
|
||||
};
|
||||
|
||||
const openAttest = () => {
|
||||
const handleAttestClose = () => {
|
||||
document.removeEventListener("closeAttest", handleAttestClose);
|
||||
realname.value = window.userInfoWin?.realname || 0;
|
||||
};
|
||||
// 启动认证流程时添加监听
|
||||
document.addEventListener("closeAttest", handleAttestClose);
|
||||
loadAttest(2);
|
||||
};
|
||||
|
||||
provide("isNeedLogin", isNeedLogin);
|
||||
provide("goLogin", goLogin);
|
||||
provide("isGetLoginState", isGetLoginState);
|
||||
provide("realname", realname);
|
||||
provide("openAttest", openAttest);
|
||||
</script>
|
||||
<style lang="less">
|
||||
* {
|
||||
|
||||
Reference in New Issue
Block a user