♻️ Refactor urls with aliased services

This commit is contained in:
LittleSheep 2024-08-17 23:56:03 +08:00
parent 0eaec5dd8d
commit ceca94c712
30 changed files with 55 additions and 55 deletions

View File

@ -14,7 +14,7 @@
<div v-if="post.body?.thumbnail" class="mb-5">
<v-img
:src="`${config.public.solarNetworkApi}/cgi/files/attachments/${post.body?.thumbnail}`"
:src="`${config.public.solarNetworkApi}/cgi/uc/attachments/${post.body?.thumbnail}`"
:aspect-ratio="16 / 9"
alt="Post thumbnail"
class="rounded-md"

View File

@ -33,7 +33,7 @@ async function loadPost({ done }: any) {
searchQueries.set("category", props.category)
}
const res = await fetch(`${config.public.solarNetworkApi}/cgi/interactive/posts?` + searchQueries)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/co/posts?` + searchQueries)
const result = await res.json()
if (result.data.length > 0) {

View File

@ -19,7 +19,7 @@ async function loadPost({ done }: any) {
offset: posts.value.length.toString(),
})
const res = await fetch(`${config.public.solarNetworkApi}/cgi/interactive/posts/${props.postId}/replies?` + searchQueries)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/co/posts/${props.postId}/replies?` + searchQueries)
const result = await res.json()
if (result.data.length > 0) {

View File

@ -46,7 +46,7 @@ const nickname = computed(() => {
}
})
const avatar = computed(() => {
return id.userinfo?.avatar ? `${config.public.solarNetworkApi}/cgi/files/attachments/${id.userinfo?.avatar}` : void 0
return id.userinfo?.avatar ? `${config.public.solarNetworkApi}/cgi/uc/attachments/${id.userinfo?.avatar}` : void 0
})
function signOut() {

View File

@ -126,7 +126,7 @@ async function readTickets({ page, itemsPerPage }: { page?: number; itemsPerPage
reverting.sessions = true
const res = await solarFetch(
"/cgi/auth/users/me/tickets?" +
"/cgi/id/users/me/tickets?" +
new URLSearchParams({
take: pagination.tickets.pageSize.toString(),
offset: ((pagination.tickets.page - 1) * pagination.tickets.pageSize).toString(),
@ -148,7 +148,7 @@ async function readEvents({ page, itemsPerPage }: { page?: number; itemsPerPage?
reverting.events = true
const res = await solarFetch(
"/cgi/auth/users/me/events?" +
"/cgi/id/users/me/events?" +
new URLSearchParams({
take: pagination.events.pageSize.toString(),
offset: ((pagination.events.page - 1) * pagination.events.pageSize).toString(),
@ -168,7 +168,7 @@ Promise.all([readTickets({}), readEvents({})])
async function killTicket(item: any) {
reverting.sessions = true
const res = await solarFetch(`/cgi/auth/users/me/tickets/${item.id}`, {
const res = await solarFetch(`/cgi/id/users/me/tickets/${item.id}`, {
method: "DELETE",
})
if (res.status !== 200) {

View File

@ -21,7 +21,7 @@ const loading = ref(false)
async function load() {
loading.value = true
const res = await fetch(`${config.public.solarNetworkApi}/cgi/interactive/posts?take=5&realmId=${config.public.solarRealmId}`)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/co/posts?take=5&realmId=${config.public.solarRealmId}`)
const result = await res.json()
items.value.push(...result.data)

View File

@ -24,7 +24,7 @@ const emits = defineEmits(["update:metadata"])
const config = useRuntimeConfig()
const { data } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/files/attachments?take=${props.attachments.length}&id=${props.attachments.join(",")}`)
const { data } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/uc/attachments?take=${props.attachments.length}&id=${props.attachments.join(",")}`)
const metadata = computed(() => data.value.data)
watch(metadata, (value) => {
@ -32,6 +32,6 @@ watch(metadata, (value) => {
}, { deep: true, immediate: true })
function getAttachmentUrl(id: number) {
return `${config.public.solarNetworkApi}/cgi/files/attachments/${id}`
return `${config.public.solarNetworkApi}/cgi/uc/attachments/${id}`
}
</script>

View File

@ -56,6 +56,6 @@ const item = computed(() => props.item)
const showMature = ref(false)
function getAttachmentUrl(id: number) {
return `${config.public.solarNetworkApi}/cgi/files/attachments/${id}`
return `${config.public.solarNetworkApi}/cgi/uc/attachments/${id}`
}
</script>

View File

@ -47,7 +47,7 @@ async function submit() {
if (!probe.value || !password.value) return
emits("update:loading", true)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/auth`, {
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/auth`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username: probe.value, password: password.value }),

View File

@ -36,7 +36,7 @@ async function load() {
onMounted(() => load())
async function getToken(tk: string) {
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/auth/token`, {
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/auth/token`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({

View File

@ -58,7 +58,7 @@ const emits = defineEmits(["swap", "update:ticket", "update:loading"])
async function submit() {
emits("update:loading", true)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/auth/mfa`, {
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/auth/mfa`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({

View File

@ -44,7 +44,7 @@ const emits = defineEmits(["swap", "update:loading", "update:currentFactor"])
async function load() {
emits("update:loading", true)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/auth/factors?ticketId=${props.ticket.id}`)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/auth/factors?ticketId=${props.ticket.id}`)
if (res.status !== 200) {
error.value = await res.text()
} else {
@ -59,7 +59,7 @@ async function submit() {
if (!focus.value) return
emits("update:loading", true)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/auth/factors/${focus.value}`, {
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/auth/factors/${focus.value}`, {
method: "POST",
})
if (res.status !== 200 && res.status !== 204) {

View File

@ -14,7 +14,7 @@ const { t } = useI18n()
const config = useRuntimeConfig()
const { status, data: post } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/interactive/posts/${props.id}`)
const { status, data: post } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/co/posts/${props.id}`)
</script>
<style scoped>

View File

@ -86,7 +86,7 @@ const panel = ref("confirm")
async function tryAuthorize() {
loading.value = true
const res = await solarFetch(`/cgi/auth/auth/o/authorize${window.location.search}`)
const res = await solarFetch(`/cgi/id/auth/o/authorize${window.location.search}`)
if (res.status !== 200) {
error.value = await res.text()
@ -115,7 +115,7 @@ function decline() {
async function approve() {
loading.value = true
const res = await solarFetch(`/cgi/auth/auth/o/authorize${window.location.search}`, {
const res = await solarFetch(`/cgi/id/auth/o/authorize${window.location.search}`, {
method: "POST",
})

View File

@ -120,7 +120,7 @@ async function submit() {
if (!payload.name || !payload.nick || !payload.email || !payload.password) return
loading.value = true
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/users`, {
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/users`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),

View File

@ -64,7 +64,7 @@ const config = useRuntimeConfig()
const firstImage = ref<string | null>()
const firstVideo = ref<string | null>()
const { data: attachment } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/files/attachments/${route.params.id}/meta`)
const { data: attachment } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/uc/attachments/${route.params.id}/meta`)
if (!attachment.value) {
throw createError({
@ -77,11 +77,11 @@ const title = computed(() => `Attachment from ${attachment.value.account.nick}`)
watch(attachment, (value) => {
if (value.mimetype.split("/")[0] == "image") {
firstImage.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${value.id}`
firstImage.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${value.id}`
}
if (value.mimetype.split("/")[0] == "video") {
firstVideo.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${value.id}`
firstVideo.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${value.id}`
}
}, { immediate: true, deep: true })

View File

@ -44,7 +44,7 @@ const loading = ref(false)
async function load() {
loading.value = true
const res = await fetch(`${config.public.solarNetworkApi}/cgi/files/attachments?take=20&offset=${items.value.length}&original=true`)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/uc/attachments?take=20&offset=${items.value.length}&original=true`)
const result = await res.json()
items.value.push(...result.data)

View File

@ -12,7 +12,7 @@
<v-card v-if="post.body?.thumbnail" class="mb-5">
<v-img
:src="`${config.public.solarNetworkApi}/cgi/files/attachments/${post.body?.thumbnail}`"
:src="`${config.public.solarNetworkApi}/cgi/uc/attachments/${post.body?.thumbnail}`"
:aspect-ratio="16 / 9"
cover
/>
@ -91,7 +91,7 @@ const slug = computed(() => {
const { t } = useI18n()
const { data: post } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/interactive/posts/${slug.value}`)
const { data: post } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/co/posts/${slug.value}`)
if (!post.value) {
throw createError({
@ -105,14 +105,14 @@ const description = computed(() => post.value.body?.description ?? post.value.bo
watch(attachments, (value) => {
if (post.value.body?.thumbnail) {
firstImage.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${post.value.body?.thumbnail}`
firstImage.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${post.value.body?.thumbnail}`
}
if (value.length > 0 && value[0].mimetype.split("/")[0] == "image") {
firstImage.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${attachments.value[0].id}`
firstImage.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${attachments.value[0].id}`
}
if (value.length > 0 && value[0].mimetype.split("/")[0] == "video") {
firstVideo.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${attachments.value[0].id}`
firstVideo.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${attachments.value[0].id}`
}
}, { immediate: true, deep: true })

View File

@ -38,7 +38,7 @@ const { t } = useI18n()
const route = useRoute()
const config = useRuntimeConfig()
const { data: account } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/auth/users/${route.params.name}`)
const { data: account } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/id/users/${route.params.name}`)
if (account.value == null) {
throw createError({
@ -47,8 +47,8 @@ if (account.value == null) {
})
}
const urlOfAvatar = computed(() => account.value?.avatar ? `${config.public.solarNetworkApi}/cgi/files/attachments/${account.value.avatar}` : void 0)
const urlOfBanner = computed(() => account.value?.banner ? `${config.public.solarNetworkApi}/cgi/files/attachments/${account.value.banner}` : void 0)
const urlOfAvatar = computed(() => account.value?.avatar ? `${config.public.solarNetworkApi}/cgi/uc/attachments/${account.value.avatar}` : void 0)
const urlOfBanner = computed(() => account.value?.banner ? `${config.public.solarNetworkApi}/cgi/uc/attachments/${account.value.banner}` : void 0)
const externalOpenLink = computed(() => `${config.public.solianUrl}/accounts/view/${route.params.name}`)
</script>

View File

@ -63,7 +63,7 @@ async function confirm() {
return
}
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/users/me/confirm`, {
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/users/me/confirm`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({

View File

@ -84,7 +84,7 @@ async function confirm() {
return
}
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/users/me/password-reset`, {
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/users/me/password-reset`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({

View File

@ -60,7 +60,7 @@ const config = useRuntimeConfig()
const firstImage = ref<string | null>()
const firstVideo = ref<string | null>()
const { data: attachment } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/files/attachments/${route.params.id}/meta`)
const { data: attachment } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/uc/attachments/${route.params.id}/meta`)
if (!attachment.value) {
throw createError({
@ -73,11 +73,11 @@ const title = computed(() => `Attachment from ${attachment.value.account.nick}`)
watch(attachment, (value) => {
if (value.mimetype.split("/")[0] == "image") {
firstImage.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${value.id}`
firstImage.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${value.id}`
}
if (value.mimetype.split("/")[0] == "video") {
firstVideo.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${value.id}`
firstVideo.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${value.id}`
}
}, { immediate: true, deep: true })

View File

@ -40,7 +40,7 @@ const loading = ref(false)
async function load() {
loading.value = true
const res = await fetch(`${config.public.solarNetworkApi}/cgi/files/attachments?take=20&offset=${items.value.length}&original=true`)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/uc/attachments?take=20&offset=${items.value.length}&original=true`)
const result = await res.json()
items.value.push(...result.data)

View File

@ -12,7 +12,7 @@
<v-card v-if="post.body?.thumbnail" class="mb-5">
<v-img
:src="`${config.public.solarNetworkApi}/cgi/files/attachments/${post.body?.thumbnail}`"
:src="`${config.public.solarNetworkApi}/cgi/uc/attachments/${post.body?.thumbnail}`"
:aspect-ratio="16 / 9"
cover
/>
@ -90,7 +90,7 @@ const slug = computed(() => {
const { t } = useI18n()
const { data: post } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/interactive/posts/${slug.value}`)
const { data: post } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/co/posts/${slug.value}`)
if (!post.value) {
throw createError({
@ -104,14 +104,14 @@ const description = computed(() => post.value.body?.description ?? post.value.bo
watch(attachments, (value) => {
if (post.value.body?.thumbnail) {
firstImage.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${post.value.body?.thumbnail}`
firstImage.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${post.value.body?.thumbnail}`
}
if (value.length > 0 && value[0].mimetype.split("/")[0] == "image") {
firstImage.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${attachments.value[0].id}`
firstImage.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${attachments.value[0].id}`
}
if (value.length > 0 && value[0].mimetype.split("/")[0] == "video") {
firstVideo.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${attachments.value[0].id}`
firstVideo.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${attachments.value[0].id}`
}
}, { immediate: true, deep: true })

View File

@ -37,7 +37,7 @@ const { t } = useI18n()
const route = useRoute()
const config = useRuntimeConfig()
const { data: account } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/auth/users/${route.params.name}`)
const { data: account } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/id/users/${route.params.name}`)
if (account.value == null) {
throw createError({
@ -46,8 +46,8 @@ if (account.value == null) {
})
}
const urlOfAvatar = computed(() => account.value?.avatar ? `${config.public.solarNetworkApi}/cgi/files/attachments/${account.value.avatar}` : void 0)
const urlOfBanner = computed(() => account.value?.banner ? `${config.public.solarNetworkApi}/cgi/files/attachments/${account.value.banner}` : void 0)
const urlOfAvatar = computed(() => account.value?.avatar ? `${config.public.solarNetworkApi}/cgi/uc/attachments/${account.value.avatar}` : void 0)
const urlOfBanner = computed(() => account.value?.banner ? `${config.public.solarNetworkApi}/cgi/uc/attachments/${account.value.banner}` : void 0)
const externalOpenLink = computed(() => `${config.public.solianUrl}/accounts/view/${route.params.name}`)
</script>

View File

@ -52,6 +52,6 @@ const config = useRuntimeConfig()
const auth = useUserinfo()
const urlOfAvatar = computed(() => auth.userinfo?.avatar ? `${config.public.solarNetworkApi}/cgi/files/attachments/${auth.userinfo.avatar}` : void 0)
const urlOfBanner = computed(() => auth.userinfo?.banner ? `${config.public.solarNetworkApi}/cgi/files/attachments/${auth.userinfo.banner}` : void 0)
const urlOfAvatar = computed(() => auth.userinfo?.avatar ? `${config.public.solarNetworkApi}/cgi/uc/attachments/${auth.userinfo.avatar}` : void 0)
const urlOfBanner = computed(() => auth.userinfo?.banner ? `${config.public.solarNetworkApi}/cgi/uc/attachments/${auth.userinfo.banner}` : void 0)
</script>

View File

@ -1,7 +1,7 @@
export default defineSitemapEventHandler(async () => {
const config = useRuntimeConfig();
const res = await fetch(`${config.public.solarNetworkApi}/cgi/interactive/posts/minimal?take=500`)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/co/posts/minimal?take=500`)
const result = await res.json()
return result.data.map((item: any) => asSitemapUrl({

View File

@ -19,13 +19,13 @@ export default defineEventHandler((event) => {
"subject_types_supported": [
"public",
],
"token_endpoint": `${config.public.solarNetworkApi}/cgi/auth/auth/token`,
"token_endpoint": `${config.public.solarNetworkApi}/cgi/id/auth/token`,
"token_endpoint_auth_methods_supported": [
"client_secret_post",
],
"token_endpoint_auth_signing_alg_values_supported": [
"HS512",
],
"userinfo_endpoint": `${config.public.solarNetworkApi}/cgi/auth/users/me`,
"userinfo_endpoint": `${config.public.solarNetworkApi}/cgi/id/users/me`,
}
})

View File

@ -39,7 +39,7 @@ export default defineEventHandler(async (event) => {
searchQuery.set("author", queries.author)
}
const res = await fetch(`${config.public.solarNetworkApi}/cgi/interactive/posts?` + searchQuery)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/co/posts?` + searchQuery)
const posts: any[] = (await res.json())["data"]
for (const post of posts) {
@ -64,7 +64,7 @@ export default defineEventHandler(async (event) => {
link: `https://solsynth.dev/@${post.author.name}`,
},
],
image: post.body.thumbnail ? `${config.public.solarNetworkApi}/cgi/files/attachments/${post.body.thumbnail}` : void 0,
image: post.body.thumbnail ? `${config.public.solarNetworkApi}/cgi/uc/attachments/${post.body.thumbnail}` : void 0,
})
}

View File

@ -44,7 +44,7 @@ export const useUserinfo = defineStore("userinfo", () => {
const config = useRuntimeConfig()
const res = await fetch(`${config.public.solarNetworkApi}/cgi/auth/auth/token`, {
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/auth/token`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
@ -77,7 +77,7 @@ export const useUserinfo = defineStore("userinfo", () => {
isReady.value = true
}
const res = await solarFetch("/cgi/auth/users/me")
const res = await solarFetch("/cgi/id/users/me")
if (res.status !== 200) {
fetchCompleter.complete(true)