// my-component.js // 引入全局 Vue 对象(因在 HTML 中通过 script 引入,Vue 已挂载到 window) const { defineComponent, ref, onMounted, nextTick } = Vue; // 定义组件(直接使用模板) export const headTop = defineComponent({ name: "headTop", props: {}, setup(props) { onMounted(() => {}); let state = ref(0); // 是否已经签到 let userInfoWinTimerCount = 0; const userInfoWinTimer = setInterval(() => { if (todaysignedState) { state.value = todaysigned; clearInterval(userInfoWinTimer); } userInfoWinTimerCount++; if (userInfoWinTimerCount >= 3000) clearInterval(userInfoWinTimer); }, 50); const signIn = () => { ajax("/v2/api/forum/sign").then((res) => { if (res.code != 200) { creationAlertBox("error", res.message); return; } let data = res.data; state.value = 1; creationAlertBox("success", res.message || "签到成功"); }); }; let input = ref(""); let defaultSearchText = ref("屯特"); const goSearch = () => { const searchText = input.value || defaultSearchText.value; redirectToExternalWebsite("/search/" + searchText); }; let pitchState = ref(false); return { pitchState, state, signIn, input, defaultSearchText, goSearch }; }, template: `
签到领寄托币
GO
已签到,明天再来
`, });