Skip to content

Commit

Permalink
fix: known bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Horbin-Magician committed Apr 15, 2024
1 parent c1545e4 commit 700eb7a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 25 deletions.
55 changes: 31 additions & 24 deletions front-end/src/pages/SecretPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@
const message = useMessage()
const router = useRouter()
checkLogin().then((result) => {
if (!result) {
router.push('/')
message.error("请先登录!")
}
if (!result) {
router.push('/')
message.error("请先登录!")
}

const start_words_first =
'欢迎来到秘密树洞!@' +
Expand All @@ -102,28 +102,35 @@
const start_words = '准备好接收今天的小秘密了吗?';

// update states
getSecret().then(data => {
if(data && data.status === '0') {
data = data.data
secret_state.value = parseInt(data.state)
msg_board_text.value = data.message
secret = data.secret

if(secret_state.value === -1) {
// 得到格式化的当前日期
const today = new Date();
const year = today.getFullYear(); // 获取年份
const month = today.getMonth() + 1; // 获取月份,月份是从0开始的,所以需要加1
const date = today.getDate(); // 获取日期
const formattedDate = year + String(month).padStart(2, '0') + String(date).padStart(2, '0');
// 根据日期判断提示词
if(formattedDate == '20240415') typeLines(start_words_first);
else typeLines(start_words);
let try_num = 3;
function initSecret() {
getSecret().then(data => {
if(data && data.status === '0') {
data = data.data
secret_state.value = parseInt(data.state)
msg_board_text.value = data.message
secret = data.secret

if(secret_state.value === -1) {
// 得到格式化的当前日期
const today = new Date();
const year = today.getFullYear(); // 获取年份
const month = today.getMonth() + 1; // 获取月份,月份是从0开始的,所以需要加1
const date = today.getDate(); // 获取日期
const formattedDate = year + String(month).padStart(2, '0') + String(date).padStart(2, '0');
// 根据日期判断提示词
if(formattedDate == '20240415') typeLines(start_words_first);
else typeLines(start_words);
} else {
typeLines(secret);
}
} else {
typeLines(secret);
try_num -= 1;
if(try_num > 0) setTimeout(initSecret, 50); // 如果没有获取成功,50毫秒后再次检查
}
}
})
});
}
initSecret();
});
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion front-end/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineConfig({
},
server: {
proxy: {
"/api": "http://localhost:5000",
"/api": "https://api.fluctus.cc",
},
},
})

0 comments on commit 700eb7a

Please sign in to comment.