Realm page

This commit is contained in:
2024-03-17 22:43:31 +08:00
parent cbea87f74d
commit d954cb87e6
6 changed files with 141 additions and 35 deletions

View File

@ -1,16 +1,16 @@
import { defineStore } from "pinia"
import { reactive, ref } from "vue"
import { getAtk } from "@/stores/userinfo"
import { defineStore } from "pinia";
import { reactive, ref } from "vue";
import { checkLoggedIn, getAtk } from "@/stores/userinfo";
export const useEditor = defineStore("editor", () => {
const done = ref(false)
const done = ref(false);
const show = reactive({
moment: false,
article: false,
comment: false,
delete: false
})
});
const related = reactive<{
edit_to: any
@ -24,7 +24,24 @@ export const useEditor = defineStore("editor", () => {
reply_to: null,
repost_to: null,
delete_to: null
})
});
return { show, related, done }
})
const availableRealms = ref<any[]>([]);
async function listRealms() {
if (!checkLoggedIn()) return;
const res = await fetch("/api/realms/me/available", {
headers: { Authorization: `Bearer ${getAtk()}` }
});
if (res.status !== 200) {
throw new Error(await res.text());
} else {
availableRealms.value = await res.json();
}
}
listRealms().then(() => console.log("[STARTUP HOOK] Fetch available realm successes."));
return { show, related, availableRealms, listRealms, done };
});