You've already forked AstralRinth
forked from didirus/AstralRinth
Fix some moderation bugs
This commit is contained in:
@@ -56,33 +56,25 @@ export default {
|
||||
ModCard,
|
||||
ModIcon,
|
||||
},
|
||||
async fetch() {
|
||||
async asyncData(data) {
|
||||
const config = {
|
||||
headers: {
|
||||
Authorization: this.$auth.getToken('local'),
|
||||
Authorization: data.$auth.getToken('local'),
|
||||
},
|
||||
}
|
||||
|
||||
try {
|
||||
let res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/user/${this.$auth.user.id}/mods`,
|
||||
config
|
||||
)
|
||||
let res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/mods`,
|
||||
config
|
||||
)
|
||||
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(res.data)}`,
|
||||
config
|
||||
)
|
||||
|
||||
if (res.data) {
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(
|
||||
res.data
|
||||
)}`,
|
||||
config
|
||||
)
|
||||
this.mods = res.data
|
||||
}
|
||||
} catch (err) {}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
mods: [],
|
||||
mods: res.data,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -12,37 +12,41 @@ export default {
|
||||
components: { ModPage },
|
||||
auth: false,
|
||||
async asyncData(data) {
|
||||
const config = {
|
||||
headers: {
|
||||
Authorization: data.$auth.getToken('local'),
|
||||
},
|
||||
}
|
||||
|
||||
let res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
||||
config
|
||||
)
|
||||
const mod = res.data
|
||||
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/team/${mod.team}/members`
|
||||
`https://api.modrinth.com/api/v1/team/${mod.team}/members`,
|
||||
config
|
||||
)
|
||||
const members = res.data
|
||||
for (let i = 0; i < members.length; i++) {
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/user/${members[i].user_id}`
|
||||
`https://api.modrinth.com/api/v1/user/${members[i].user_id}`,
|
||||
config
|
||||
)
|
||||
members[i].avatar_url = res.data.avatar_url
|
||||
}
|
||||
|
||||
const body = (await axios.get(mod.body_url)).data
|
||||
|
||||
const versions = []
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/versions?ids=${JSON.stringify(
|
||||
mod.versions
|
||||
)}`,
|
||||
config
|
||||
)
|
||||
|
||||
for (const version of mod.versions) {
|
||||
try {
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/version/${version}`
|
||||
)
|
||||
versions.push(res.data)
|
||||
} catch {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Some versions may be missing...')
|
||||
}
|
||||
}
|
||||
const versions = res.data.reverse()
|
||||
|
||||
return {
|
||||
mod,
|
||||
|
||||
@@ -119,34 +119,39 @@ export default {
|
||||
},
|
||||
auth: false,
|
||||
async asyncData(data) {
|
||||
const config = {
|
||||
headers: {
|
||||
Authorization: data.$auth.getToken('local'),
|
||||
},
|
||||
}
|
||||
|
||||
let res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
||||
config
|
||||
)
|
||||
const mod = res.data
|
||||
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/team/${mod.team}/members`
|
||||
`https://api.modrinth.com/api/v1/team/${mod.team}/members`,
|
||||
config
|
||||
)
|
||||
const members = res.data
|
||||
for (let i = 0; i < members.length; i++) {
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/user/${members[i].user_id}`
|
||||
`https://api.modrinth.com/api/v1/user/${members[i].user_id}`,
|
||||
config
|
||||
)
|
||||
members[i].avatar_url = res.data.avatar_url
|
||||
}
|
||||
|
||||
const versions = []
|
||||
for (const version of mod.versions) {
|
||||
try {
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/version/${version}`
|
||||
)
|
||||
versions.push(res.data)
|
||||
} catch {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Some versions may be missing...')
|
||||
}
|
||||
}
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/versions?ids=${JSON.stringify(
|
||||
mod.versions
|
||||
)}`,
|
||||
config
|
||||
)
|
||||
|
||||
const versions = res.data.reverse()
|
||||
|
||||
const version = versions.find((x) => x.id === data.params.version)
|
||||
|
||||
|
||||
@@ -218,34 +218,39 @@ export default {
|
||||
},
|
||||
auth: false,
|
||||
async asyncData(data) {
|
||||
const config = {
|
||||
headers: {
|
||||
Authorization: data.$auth.getToken('local'),
|
||||
},
|
||||
}
|
||||
|
||||
let res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
||||
config
|
||||
)
|
||||
const mod = res.data
|
||||
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/team/${mod.team}/members`
|
||||
`https://api.modrinth.com/api/v1/team/${mod.team}/members`,
|
||||
config
|
||||
)
|
||||
const members = res.data
|
||||
for (let i = 0; i < members.length; i++) {
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/user/${members[i].user_id}`
|
||||
`https://api.modrinth.com/api/v1/user/${members[i].user_id}`,
|
||||
config
|
||||
)
|
||||
members[i].avatar_url = res.data.avatar_url
|
||||
}
|
||||
|
||||
const versions = []
|
||||
for (const version of mod.versions) {
|
||||
try {
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/version/${version}`
|
||||
)
|
||||
versions.push(res.data)
|
||||
} catch {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Some versions may be missing...')
|
||||
}
|
||||
}
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/versions?ids=${JSON.stringify(
|
||||
mod.versions
|
||||
)}`,
|
||||
config
|
||||
)
|
||||
|
||||
const versions = res.data.reverse()
|
||||
|
||||
res = await axios.get(`https://api.modrinth.com/api/v1/tag/loader`)
|
||||
const selectableLoaders = res.data
|
||||
|
||||
@@ -389,6 +389,7 @@ export default {
|
||||
for (const facet of [...this.facets]) await this.toggleFacet(facet, true)
|
||||
|
||||
this.selectedVersions = []
|
||||
this.facets.push('host:modrinth')
|
||||
await this.onSearchChange(1)
|
||||
},
|
||||
async toggleFacet(elementName, sendRequest) {
|
||||
|
||||
@@ -91,18 +91,27 @@ export default {
|
||||
MFooter,
|
||||
},
|
||||
async asyncData(data) {
|
||||
const config = {
|
||||
headers: {
|
||||
Authorization: data.$auth.getToken('local'),
|
||||
},
|
||||
}
|
||||
|
||||
let res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/user/${data.params.id}`
|
||||
`https://api.modrinth.com/api/v1/user/${data.params.id}`,
|
||||
config
|
||||
)
|
||||
const user = res.data
|
||||
|
||||
let mods = []
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/user/${data.params.id}/mods`
|
||||
`https://api.modrinth.com/api/v1/user/${data.params.id}/mods`,
|
||||
config
|
||||
)
|
||||
if (res.data) {
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(res.data)}`
|
||||
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(res.data)}`,
|
||||
config
|
||||
)
|
||||
mods = res.data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user