You've already forked AstralRinth
forked from didirus/AstralRinth
Use base URL for axios (#241)
* Switch site to use axios base url * Fix team invites * Fix find/replace setting the wrong thing * Fix analytics being blocking, small issues
This commit is contained in:
3
app/router.scrollBehavior.js
Normal file
3
app/router.scrollBehavior.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default function (to, from, savedPosition) {
|
||||||
|
return savedPosition || { x: 0, y: 0 }
|
||||||
|
}
|
||||||
@@ -199,7 +199,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
authUrl() {
|
authUrl() {
|
||||||
return `https://api.modrinth.com/api/v1/auth/init?url=${process.env.domain}${this.$route.fullPath}`
|
return `${this.$axios.defaults.baseURL}auth/init?url=${process.env.domain}${this.$route.fullPath}`
|
||||||
},
|
},
|
||||||
userUrl() {
|
userUrl() {
|
||||||
return `/user/${this.$auth.user.id}`
|
return `/user/${this.$auth.user.id}`
|
||||||
|
|||||||
@@ -31,9 +31,6 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
layout: 'home',
|
layout: 'home',
|
||||||
created() {
|
|
||||||
// console.log(this.error)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
export default async function (context) {
|
export default function (context) {
|
||||||
|
if (context.$config.analytics.base_url == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let domain = ''
|
let domain = ''
|
||||||
if (process.server) {
|
if (process.server) {
|
||||||
domain = context.req.headers.host
|
domain = context.req.headers.host
|
||||||
@@ -8,13 +11,16 @@ export default async function (context) {
|
|||||||
}
|
}
|
||||||
const url = context.$config.analytics.base_url + '/register/visit'
|
const url = context.$config.analytics.base_url + '/register/visit'
|
||||||
const path = context.route.path.split('?')[0]
|
const path = context.route.path.split('?')[0]
|
||||||
try {
|
setTimeout(() => {
|
||||||
return await axios.post(url, {
|
axios
|
||||||
path,
|
.post(url, {
|
||||||
domain,
|
path,
|
||||||
consent: false,
|
domain,
|
||||||
})
|
consent: false,
|
||||||
} catch (e) {
|
})
|
||||||
// Simply silence the issue.
|
.then(() => {})
|
||||||
}
|
.catch((e) => {
|
||||||
|
console.error('An error occurred while registering the visit: ', e)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export default async function (context) {
|
|||||||
|
|
||||||
if (!context.$auth.user) {
|
if (!context.$auth.user) {
|
||||||
return context.redirect(
|
return context.redirect(
|
||||||
`https://api.modrinth.com/api/v1/auth/init?url=${process.env.domain}${context.route.fullPath}`
|
`${context.$axios.defaults.baseURL}auth/init?url=${process.env.domain}${context.route.fullPath}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ export default {
|
|||||||
** See https://axios.nuxtjs.org/options
|
** See https://axios.nuxtjs.org/options
|
||||||
*/
|
*/
|
||||||
axios: {
|
axios: {
|
||||||
|
baseURL: 'https://api.modrinth.com/api/v1/',
|
||||||
headers: {
|
headers: {
|
||||||
common: {
|
common: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
authUrl() {
|
authUrl() {
|
||||||
return `https://api.modrinth.com/api/v1/auth/init?url=${process.env.domain}${this.$route.fullPath}`
|
return `${this.$axios.defaults.baseURL}auth/init?url=${process.env.domain}${this.$route.fullPath}`
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,8 +46,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
import ModCard from '~/components/ui/ProjectCard'
|
import ModCard from '~/components/ui/ProjectCard'
|
||||||
import FollowIcon from '~/assets/images/utils/heart.svg?inline'
|
import FollowIcon from '~/assets/images/utils/heart.svg?inline'
|
||||||
import FollowIllustration from '~/assets/images/illustrations/follow_illustration.svg?inline'
|
import FollowIllustration from '~/assets/images/illustrations/follow_illustration.svg?inline'
|
||||||
@@ -59,15 +57,13 @@ export default {
|
|||||||
FollowIllustration,
|
FollowIllustration,
|
||||||
},
|
},
|
||||||
async asyncData(data) {
|
async asyncData(data) {
|
||||||
const res = await axios.get(
|
const res = await data.$axios.get(
|
||||||
`https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`,
|
`user/${data.$auth.user.id}/follows`,
|
||||||
data.$auth.headers
|
data.$auth.headers
|
||||||
)
|
)
|
||||||
|
|
||||||
const mods = (
|
const mods = (
|
||||||
await axios.get(
|
await data.$axios.get(`mods?ids=${JSON.stringify(res.data)}`)
|
||||||
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(res.data)}`
|
|
||||||
)
|
|
||||||
).data.sort((a, b) => a.title > b.title)
|
).data.sort((a, b) => a.title > b.title)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -76,8 +72,8 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async unfavMod(index) {
|
async unfavMod(index) {
|
||||||
await axios.delete(
|
await this.$axios.delete(
|
||||||
`https://api.modrinth.com/api/v1/mod/${this.mods[index].id}/follow`,
|
`mod/${this.mods[index].id}/follow`,
|
||||||
this.$auth.headers
|
this.$auth.headers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export default {
|
|||||||
async logout() {
|
async logout() {
|
||||||
this.$cookies.set('auth-token-reset', true)
|
this.$cookies.set('auth-token-reset', true)
|
||||||
await this.$router.replace(
|
await this.$router.replace(
|
||||||
`https://api.modrinth.com/api/v1/auth/init?url=${process.env.domain}${this.$route.fullPath}`
|
`auth/init?url=${process.env.domain}${this.$route.fullPath}`
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -87,8 +87,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
import ModCard from '~/components/ui/ProjectCard'
|
import ModCard from '~/components/ui/ProjectCard'
|
||||||
import Security from '~/assets/images/illustrations/security.svg?inline'
|
import Security from '~/assets/images/illustrations/security.svg?inline'
|
||||||
|
|
||||||
@@ -98,19 +96,10 @@ export default {
|
|||||||
Security,
|
Security,
|
||||||
},
|
},
|
||||||
async asyncData(data) {
|
async asyncData(data) {
|
||||||
const mods = (
|
const mods = (await data.$axios.get(`moderation/mods`, data.$auth.headers))
|
||||||
await axios.get(
|
.data
|
||||||
`https://api.modrinth.com/api/v1/moderation/mods`,
|
|
||||||
data.$auth.headers
|
|
||||||
)
|
|
||||||
).data
|
|
||||||
|
|
||||||
const reports = (
|
const reports = (await data.$axios.get(`report`, data.$auth.headers)).data
|
||||||
await axios.get(
|
|
||||||
`https://api.modrinth.com/api/v1/report`,
|
|
||||||
data.$auth.headers
|
|
||||||
)
|
|
||||||
).data
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mods,
|
mods,
|
||||||
@@ -119,8 +108,8 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async changeModStatus(id, status, index) {
|
async changeModStatus(id, status, index) {
|
||||||
await axios.patch(
|
await this.$axios.patch(
|
||||||
`https://api.modrinth.com/api/v1/mod/${id}`,
|
`mod/${id}`,
|
||||||
{
|
{
|
||||||
status,
|
status,
|
||||||
},
|
},
|
||||||
@@ -130,8 +119,8 @@ export default {
|
|||||||
this.mods.splice(index, 1)
|
this.mods.splice(index, 1)
|
||||||
},
|
},
|
||||||
async deleteReport(index) {
|
async deleteReport(index) {
|
||||||
await axios.delete(
|
await this.$axios.delete(
|
||||||
`https://api.modrinth.com/api/v1/report/${this.reports[index].id}`,
|
`report/${this.reports[index].id}`,
|
||||||
this.$auth.headers
|
this.$auth.headers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
import UpToDate from '~/assets/images/illustrations/up_to_date.svg?inline'
|
import UpToDate from '~/assets/images/illustrations/up_to_date.svg?inline'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -61,8 +60,8 @@ export default {
|
|||||||
},
|
},
|
||||||
async asyncData(data) {
|
async asyncData(data) {
|
||||||
const notifications = (
|
const notifications = (
|
||||||
await axios.get(
|
await data.$axios.get(
|
||||||
`https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/notifications`,
|
`user/${data.$auth.user.id}/notifications`,
|
||||||
data.$auth.headers
|
data.$auth.headers
|
||||||
)
|
)
|
||||||
).data.sort((a, b) => new Date(b.created) - new Date(a.created))
|
).data.sort((a, b) => new Date(b.created) - new Date(a.created))
|
||||||
@@ -79,17 +78,17 @@ export default {
|
|||||||
if (index) {
|
if (index) {
|
||||||
const config = {
|
const config = {
|
||||||
method: notification.actions[index].action_route[0].toLowerCase(),
|
method: notification.actions[index].action_route[0].toLowerCase(),
|
||||||
url: `https://api.modrinth.com/api/v1/${notification.actions[index].action_route[1]}`,
|
url: `${notification.actions[index].action_route[1]}`,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: this.$auth.token,
|
Authorization: this.$auth.token,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
await axios(config)
|
await this.$axios(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
await axios.delete(
|
await this.$axios.delete(
|
||||||
`https://api.modrinth.com/api/v1/notification/${notification.id}`,
|
`notification/${notification.id}`,
|
||||||
this.$auth.headers
|
this.$auth.headers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
import ModCard from '~/components/ui/ProjectCard'
|
import ModCard from '~/components/ui/ProjectCard'
|
||||||
import UpToDate from '~/assets/images/illustrations/up_to_date.svg?inline'
|
import UpToDate from '~/assets/images/illustrations/up_to_date.svg?inline'
|
||||||
|
|
||||||
@@ -56,13 +55,13 @@ export default {
|
|||||||
UpToDate,
|
UpToDate,
|
||||||
},
|
},
|
||||||
async asyncData(data) {
|
async asyncData(data) {
|
||||||
let res = await axios.get(
|
let res = await data.$axios.get(
|
||||||
`https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/mods`,
|
`user/${data.$auth.user.id}/mods`,
|
||||||
data.$auth.headers
|
data.$auth.headers
|
||||||
)
|
)
|
||||||
|
|
||||||
res = await axios.get(
|
res = await data.$axios.get(
|
||||||
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(res.data)}`,
|
`mods?ids=${JSON.stringify(res.data)}`,
|
||||||
data.$auth.headers
|
data.$auth.headers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
import ConfirmPopup from '~/components/ui/ConfirmPopup'
|
import ConfirmPopup from '~/components/ui/ConfirmPopup'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -167,8 +166,8 @@ export default {
|
|||||||
bio: this.bio,
|
bio: this.bio,
|
||||||
}
|
}
|
||||||
|
|
||||||
await axios.patch(
|
await this.$axios.patch(
|
||||||
`https://api.modrinth.com/api/v1/user/${this.$auth.user.id}`,
|
`user/${this.$auth.user.id}`,
|
||||||
data,
|
data,
|
||||||
this.$auth.headers
|
this.$auth.headers
|
||||||
)
|
)
|
||||||
@@ -191,8 +190,8 @@ export default {
|
|||||||
this.$nuxt.$loading.start()
|
this.$nuxt.$loading.start()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await axios.delete(
|
await this.$axios.delete(
|
||||||
`https://api.modrinth.com/api/v1/user/${this.$auth.user.id}`,
|
`user/${this.$auth.user.id}`,
|
||||||
this.$auth.headers
|
this.$auth.headers
|
||||||
)
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -137,6 +137,7 @@
|
|||||||
:featured-versions="featuredVersions"
|
:featured-versions="featuredVersions"
|
||||||
:members="members"
|
:members="members"
|
||||||
:current-member="currentMember"
|
:current-member="currentMember"
|
||||||
|
:all-members="allMembers"
|
||||||
:link-bar.sync="linkBar"
|
:link-bar.sync="linkBar"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -352,7 +353,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
import Categories from '~/components/ui/search/Categories'
|
import Categories from '~/components/ui/search/Categories'
|
||||||
import MFooter from '~/components/layout/MFooter'
|
import MFooter from '~/components/layout/MFooter'
|
||||||
|
|
||||||
@@ -398,22 +398,17 @@ export default {
|
|||||||
async asyncData(data) {
|
async asyncData(data) {
|
||||||
try {
|
try {
|
||||||
const mod = (
|
const mod = (
|
||||||
await axios.get(
|
await data.$axios.get(`mod/${data.params.id}`, data.$auth.headers)
|
||||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
|
||||||
data.$auth.headers
|
|
||||||
)
|
|
||||||
).data
|
).data
|
||||||
|
|
||||||
const [members, versions, featuredVersions, userFollows] = (
|
const [members, versions, featuredVersions, userFollows] = (
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
axios.get(`https://api.modrinth.com/api/v1/team/${mod.team}/members`),
|
data.$axios.get(`team/${mod.team}/members`, data.$auth.headers),
|
||||||
axios.get(`https://api.modrinth.com/api/v1/mod/${mod.id}/version`),
|
data.$axios.get(`mod/${mod.id}/version`),
|
||||||
axios.get(
|
data.$axios.get(`mod/${mod.id}/version?featured=true`),
|
||||||
`https://api.modrinth.com/api/v1/mod/${mod.id}/version?featured=true`
|
data.$axios.get(
|
||||||
),
|
|
||||||
axios.get(
|
|
||||||
data.$auth.user
|
data.$auth.user
|
||||||
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
|
? `user/${data.$auth.user.id}/follows`
|
||||||
: `https://api.modrinth.com`,
|
: `https://api.modrinth.com`,
|
||||||
data.$auth.headers
|
data.$auth.headers
|
||||||
),
|
),
|
||||||
@@ -421,10 +416,8 @@ export default {
|
|||||||
).map((it) => it.data)
|
).map((it) => it.data)
|
||||||
|
|
||||||
const users = (
|
const users = (
|
||||||
await axios.get(
|
await data.$axios.get(
|
||||||
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
|
`users?ids=${JSON.stringify(members.map((it) => it.user_id))}`,
|
||||||
members.map((it) => it.user_id)
|
|
||||||
)}`,
|
|
||||||
data.$auth.headers
|
data.$auth.headers
|
||||||
)
|
)
|
||||||
).data
|
).data
|
||||||
@@ -440,14 +433,15 @@ export default {
|
|||||||
: null
|
: null
|
||||||
|
|
||||||
if (mod.body_url && !mod.body) {
|
if (mod.body_url && !mod.body) {
|
||||||
mod.body = (await axios.get(mod.body_url)).data
|
mod.body = (await data.$axios.get(mod.body_url)).data
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mod,
|
mod,
|
||||||
versions,
|
versions,
|
||||||
featuredVersions,
|
featuredVersions,
|
||||||
members,
|
members: members.filter((x) => x.accepted),
|
||||||
|
allMembers: members,
|
||||||
currentMember,
|
currentMember,
|
||||||
userFollows: userFollows.name ? null : userFollows,
|
userFollows: userFollows.name ? null : userFollows,
|
||||||
linkBar: [],
|
linkBar: [],
|
||||||
@@ -477,9 +471,7 @@ export default {
|
|||||||
return file
|
return file
|
||||||
},
|
},
|
||||||
async downloadFile(hash, url) {
|
async downloadFile(hash, url) {
|
||||||
await axios.get(
|
await this.$axios.get(`version_file/${hash}/download`)
|
||||||
`https://api.modrinth.com/api/v1/version_file/${hash}/download`
|
|
||||||
)
|
|
||||||
|
|
||||||
const elem = document.createElement('a')
|
const elem = document.createElement('a')
|
||||||
elem.download = hash
|
elem.download = hash
|
||||||
@@ -487,8 +479,8 @@ export default {
|
|||||||
elem.click()
|
elem.click()
|
||||||
},
|
},
|
||||||
async followMod() {
|
async followMod() {
|
||||||
await axios.post(
|
await this.$axios.post(
|
||||||
`https://api.modrinth.com/api/v1/mod/${this.mod.id}/follow`,
|
`mod/${this.mod.id}/follow`,
|
||||||
{},
|
{},
|
||||||
this.$auth.headers
|
this.$auth.headers
|
||||||
)
|
)
|
||||||
@@ -496,10 +488,7 @@ export default {
|
|||||||
this.userFollows.push(this.mod.id)
|
this.userFollows.push(this.mod.id)
|
||||||
},
|
},
|
||||||
async unfollowMod() {
|
async unfollowMod() {
|
||||||
await axios.delete(
|
await this.$axios.delete(`mod/${this.mod.id}/follow`, this.$auth.headers)
|
||||||
`https://api.modrinth.com/api/v1/mod/${this.mod.id}/follow`,
|
|
||||||
this.$auth.headers
|
|
||||||
)
|
|
||||||
|
|
||||||
this.userFollows.splice(this.userFollows.indexOf(this.mod.id), 1)
|
this.userFollows.splice(this.userFollows.indexOf(this.mod.id), 1)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -297,7 +297,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
import Multiselect from 'vue-multiselect'
|
import Multiselect from 'vue-multiselect'
|
||||||
|
|
||||||
import FileInput from '~/components/ui/FileInput'
|
import FileInput from '~/components/ui/FileInput'
|
||||||
@@ -318,15 +317,12 @@ export default {
|
|||||||
availableDonationPlatforms,
|
availableDonationPlatforms,
|
||||||
] = (
|
] = (
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
axios.get(
|
data.$axios.get(`mod/${data.params.id}`, data.$auth.headers),
|
||||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
data.$axios.get(`tag/category`),
|
||||||
data.$auth.headers
|
data.$axios.get(`tag/loader`),
|
||||||
),
|
data.$axios.get(`tag/game_version`),
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/category`),
|
data.$axios.get(`tag/license`),
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/loader`),
|
data.$axios.get(`tag/donation_platform`),
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/game_version`),
|
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/license`),
|
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/donation_platform`),
|
|
||||||
])
|
])
|
||||||
).map((it) => it.data)
|
).map((it) => it.data)
|
||||||
|
|
||||||
@@ -337,7 +333,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mod.body_url && !mod.body) {
|
if (mod.body_url && !mod.body) {
|
||||||
mod.body = (await axios.get(mod.body_url)).data
|
mod.body = (await data.$axios.get(mod.body_url)).data
|
||||||
}
|
}
|
||||||
|
|
||||||
const donationPlatforms = []
|
const donationPlatforms = []
|
||||||
@@ -445,15 +441,11 @@ export default {
|
|||||||
data.status = 'processing'
|
data.status = 'processing'
|
||||||
}
|
}
|
||||||
|
|
||||||
await axios.patch(
|
await this.$axios.patch(`mod/${this.mod.id}`, data, this.$auth.headers)
|
||||||
`https://api.modrinth.com/api/v1/mod/${this.mod.id}`,
|
|
||||||
data,
|
|
||||||
this.$auth.headers
|
|
||||||
)
|
|
||||||
|
|
||||||
if (this.iconChanged) {
|
if (this.iconChanged) {
|
||||||
await axios.patch(
|
await this.$axios.patch(
|
||||||
`https://api.modrinth.com/api/v1/mod/${this.mod.id}/icon?ext=${
|
`mod/${this.mod.id}/icon?ext=${
|
||||||
this.icon.type.split('/')[this.icon.type.split('/').length - 1]
|
this.icon.type.split('/')[this.icon.type.split('/').length - 1]
|
||||||
}`,
|
}`,
|
||||||
this.icon,
|
this.icon,
|
||||||
|
|||||||
@@ -119,8 +119,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
import Multiselect from 'vue-multiselect'
|
import Multiselect from 'vue-multiselect'
|
||||||
import FileInput from '~/components/ui/FileInput'
|
import FileInput from '~/components/ui/FileInput'
|
||||||
|
|
||||||
@@ -141,8 +139,8 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const [selectableLoaders, selectableVersions] = (
|
const [selectableLoaders, selectableVersions] = (
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/loader`),
|
data.$axios.get(`tag/loader`),
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/game_version`),
|
data.$axios.get(`tag/game_version`),
|
||||||
])
|
])
|
||||||
).map((it) => it.data)
|
).map((it) => it.data)
|
||||||
|
|
||||||
@@ -188,8 +186,8 @@ export default {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const data = (
|
const data = (
|
||||||
await axios({
|
await this.$axios({
|
||||||
url: 'https://api.modrinth.com/api/v1/version',
|
url: 'version',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: formData,
|
data: formData,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -225,9 +223,7 @@ export default {
|
|||||||
this.createdVersion.file_parts = newFileParts
|
this.createdVersion.file_parts = newFileParts
|
||||||
},
|
},
|
||||||
async downloadFile(hash, url) {
|
async downloadFile(hash, url) {
|
||||||
await axios.get(
|
await this.$axios.get(`version_file/${hash}/download`)
|
||||||
`https://api.modrinth.com/api/v1/version_file/${hash}/download`
|
|
||||||
)
|
|
||||||
|
|
||||||
const elem = document.createElement('a')
|
const elem = document.createElement('a')
|
||||||
elem.download = hash
|
elem.download = hash
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-for="(member, index) in members"
|
v-for="(member, index) in allMembers"
|
||||||
:key="member.user_id"
|
:key="member.user_id"
|
||||||
class="member"
|
class="member"
|
||||||
:class="{ open: openTeamMembers.includes(member.user_id) }"
|
:class="{ open: openTeamMembers.includes(member.user_id) }"
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
<label>
|
<label>
|
||||||
Role:
|
Role:
|
||||||
<input
|
<input
|
||||||
v-model="members[index].role"
|
v-model="allMembers[index].role"
|
||||||
type="text"
|
type="text"
|
||||||
:disabled="
|
:disabled="
|
||||||
member.role === 'Owner' ||
|
member.role === 'Owner' ||
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
(currentMember.permissions & UPLOAD_VERSION) !== UPLOAD_VERSION
|
(currentMember.permissions & UPLOAD_VERSION) !== UPLOAD_VERSION
|
||||||
"
|
"
|
||||||
label="Upload Version"
|
label="Upload Version"
|
||||||
@input="members[index].permissions ^= UPLOAD_VERSION"
|
@input="allMembers[index].permissions ^= UPLOAD_VERSION"
|
||||||
/>
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:value="
|
:value="
|
||||||
@@ -128,7 +128,7 @@
|
|||||||
(currentMember.permissions & DELETE_VERSION) !== DELETE_VERSION
|
(currentMember.permissions & DELETE_VERSION) !== DELETE_VERSION
|
||||||
"
|
"
|
||||||
label="Delete Version"
|
label="Delete Version"
|
||||||
@input="members[index].permissions ^= DELETE_VERSION"
|
@input="allMembers[index].permissions ^= DELETE_VERSION"
|
||||||
/>
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:value="
|
:value="
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
(currentMember.permissions & EDIT_DETAILS) !== EDIT_DETAILS
|
(currentMember.permissions & EDIT_DETAILS) !== EDIT_DETAILS
|
||||||
"
|
"
|
||||||
label="Edit Details"
|
label="Edit Details"
|
||||||
@input="members[index].permissions ^= EDIT_DETAILS"
|
@input="allMembers[index].permissions ^= EDIT_DETAILS"
|
||||||
/>
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:value="
|
:value="
|
||||||
@@ -154,7 +154,7 @@
|
|||||||
(currentMember.permissions & EDIT_BODY) !== EDIT_BODY
|
(currentMember.permissions & EDIT_BODY) !== EDIT_BODY
|
||||||
"
|
"
|
||||||
label="Edit Body"
|
label="Edit Body"
|
||||||
@input="members[index].permissions ^= EDIT_BODY"
|
@input="allMembers[index].permissions ^= EDIT_BODY"
|
||||||
/>
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:value="
|
:value="
|
||||||
@@ -167,7 +167,7 @@
|
|||||||
(currentMember.permissions & MANAGE_INVITES) !== MANAGE_INVITES
|
(currentMember.permissions & MANAGE_INVITES) !== MANAGE_INVITES
|
||||||
"
|
"
|
||||||
label="Manage Invites"
|
label="Manage Invites"
|
||||||
@input="members[index].permissions ^= MANAGE_INVITES"
|
@input="allMembers[index].permissions ^= MANAGE_INVITES"
|
||||||
/>
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:value="
|
:value="
|
||||||
@@ -180,7 +180,7 @@
|
|||||||
(currentMember.permissions & REMOVE_MEMBER) !== REMOVE_MEMBER
|
(currentMember.permissions & REMOVE_MEMBER) !== REMOVE_MEMBER
|
||||||
"
|
"
|
||||||
label="Remove Member"
|
label="Remove Member"
|
||||||
@input="members[index].permissions ^= REMOVE_MEMBER"
|
@input="allMembers[index].permissions ^= REMOVE_MEMBER"
|
||||||
/>
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:value="
|
:value="
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
(currentMember.permissions & EDIT_MEMBER) !== EDIT_MEMBER
|
(currentMember.permissions & EDIT_MEMBER) !== EDIT_MEMBER
|
||||||
"
|
"
|
||||||
label="Edit Member"
|
label="Edit Member"
|
||||||
@input="members[index].permissions ^= EDIT_MEMBER"
|
@input="allMembers[index].permissions ^= EDIT_MEMBER"
|
||||||
/>
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:value="
|
:value="
|
||||||
@@ -205,7 +205,7 @@
|
|||||||
(currentMember.permissions & DELETE_MOD) !== DELETE_MOD
|
(currentMember.permissions & DELETE_MOD) !== DELETE_MOD
|
||||||
"
|
"
|
||||||
label="Delete Mod"
|
label="Delete Mod"
|
||||||
@input="members[index].permissions ^= DELETE_MOD"
|
@input="allMembers[index].permissions ^= DELETE_MOD"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
@@ -234,8 +234,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
import ConfirmPopup from '~/components/ui/ConfirmPopup'
|
import ConfirmPopup from '~/components/ui/ConfirmPopup'
|
||||||
import Checkbox from '~/components/ui/Checkbox'
|
import Checkbox from '~/components/ui/Checkbox'
|
||||||
|
|
||||||
@@ -250,7 +248,7 @@ export default {
|
|||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
members: {
|
allMembers: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default() {
|
default() {
|
||||||
return []
|
return []
|
||||||
@@ -286,18 +284,15 @@ export default {
|
|||||||
this.$nuxt.$loading.start()
|
this.$nuxt.$loading.start()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const user = (
|
const user = (await this.$axios.get(`user/${this.currentUsername}`))
|
||||||
await axios.get(
|
.data
|
||||||
`https://api.modrinth.com/api/v1/user/${this.currentUsername}`
|
|
||||||
)
|
|
||||||
).data
|
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
await axios.post(
|
await this.$axios.post(
|
||||||
`https://api.modrinth.com/api/v1/team/${this.mod.team}/members`,
|
`team/${this.mod.team}/members`,
|
||||||
data,
|
data,
|
||||||
this.$auth.headers
|
this.$auth.headers
|
||||||
)
|
)
|
||||||
@@ -317,8 +312,8 @@ export default {
|
|||||||
this.$nuxt.$loading.start()
|
this.$nuxt.$loading.start()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await axios.delete(
|
await this.$axios.delete(
|
||||||
`https://api.modrinth.com/api/v1/team/${this.mod.team}/members/${this.members[index].user_id}`,
|
`team/${this.mod.team}/members/${this.allMembers[index].user_id}`,
|
||||||
this.$auth.headers
|
this.$auth.headers
|
||||||
)
|
)
|
||||||
await this.$router.go(null)
|
await this.$router.go(null)
|
||||||
@@ -338,12 +333,12 @@ export default {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const data = {
|
const data = {
|
||||||
permissions: this.members[index].permissions,
|
permissions: this.allMembers[index].permissions,
|
||||||
role: this.members[index].role,
|
role: this.allMembers[index].role,
|
||||||
}
|
}
|
||||||
|
|
||||||
await axios.patch(
|
await this.$axios.patch(
|
||||||
`https://api.modrinth.com/api/v1/team/${this.mod.team}/members/${this.members[index].user_id}`,
|
`team/${this.mod.team}/members/${this.allMembers[index].user_id}`,
|
||||||
data,
|
data,
|
||||||
this.$auth.headers
|
this.$auth.headers
|
||||||
)
|
)
|
||||||
@@ -363,10 +358,7 @@ export default {
|
|||||||
this.$refs.delete_popup.show()
|
this.$refs.delete_popup.show()
|
||||||
},
|
},
|
||||||
async deleteMod() {
|
async deleteMod() {
|
||||||
await axios.delete(
|
await this.$axios.delete(`mod/${this.mod.id}`, this.$auth.headers)
|
||||||
`https://api.modrinth.com/api/v1/mod/${this.mod.id}`,
|
|
||||||
this.$auth.headers
|
|
||||||
)
|
|
||||||
await this.$router.push('/dashboard/projects')
|
await this.$router.push('/dashboard/projects')
|
||||||
this.$notify({
|
this.$notify({
|
||||||
group: 'main',
|
group: 'main',
|
||||||
|
|||||||
@@ -102,8 +102,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
import Multiselect from 'vue-multiselect'
|
import Multiselect from 'vue-multiselect'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -144,7 +142,7 @@ export default {
|
|||||||
|
|
||||||
if (!this.version.changelog && this.version.changelog_url) {
|
if (!this.version.changelog && this.version.changelog_url) {
|
||||||
this.version.changelog = (
|
this.version.changelog = (
|
||||||
await axios.get(this.version.changelog_url)
|
await this.$axios.get(this.version.changelog_url)
|
||||||
).data
|
).data
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -152,8 +150,8 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const [selectableLoaders, selectableVersions] = (
|
const [selectableLoaders, selectableVersions] = (
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/loader`),
|
data.$axios.get(`tag/loader`),
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/game_version`),
|
data.$axios.get(`tag/game_version`),
|
||||||
])
|
])
|
||||||
).map((it) => it.data)
|
).map((it) => it.data)
|
||||||
|
|
||||||
@@ -185,8 +183,8 @@ export default {
|
|||||||
this.$nuxt.$loading.start()
|
this.$nuxt.$loading.start()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await axios.patch(
|
await this.$axios.patch(
|
||||||
`https://api.modrinth.com/api/v1/version/${this.version.id}`,
|
`version/${this.version.id}`,
|
||||||
this.version,
|
this.version,
|
||||||
this.$auth.headers
|
this.$auth.headers
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -136,8 +136,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
import ConfirmPopup from '~/components/ui/ConfirmPopup'
|
import ConfirmPopup from '~/components/ui/ConfirmPopup'
|
||||||
|
|
||||||
import Categories from '~/components/ui/search/Categories'
|
import Categories from '~/components/ui/search/Categories'
|
||||||
@@ -201,11 +199,9 @@ export default {
|
|||||||
|
|
||||||
if (!this.version.changelog && this.version.changelog_url) {
|
if (!this.version.changelog && this.version.changelog_url) {
|
||||||
this.version.changelog = (
|
this.version.changelog = (
|
||||||
await axios.get(this.version.changelog_url)
|
await this.$axios.get(this.version.changelog_url)
|
||||||
).data
|
).data
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(this.version)
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -229,10 +225,7 @@ export default {
|
|||||||
async deleteFile(hash) {
|
async deleteFile(hash) {
|
||||||
this.$nuxt.$loading.start()
|
this.$nuxt.$loading.start()
|
||||||
|
|
||||||
await axios.delete(
|
await this.$axios.delete(`version_file/${hash}`, this.$auth.headers)
|
||||||
`https://api.modrinth.com/api/v1/version_file/${hash}`,
|
|
||||||
this.$auth.headers
|
|
||||||
)
|
|
||||||
|
|
||||||
await this.$router.go(null)
|
await this.$router.go(null)
|
||||||
this.$nuxt.$loading.finish()
|
this.$nuxt.$loading.finish()
|
||||||
@@ -240,8 +233,8 @@ export default {
|
|||||||
async makePrimary(hash) {
|
async makePrimary(hash) {
|
||||||
this.$nuxt.$loading.start()
|
this.$nuxt.$loading.start()
|
||||||
|
|
||||||
await axios.patch(
|
await this.$axios.patch(
|
||||||
`https://api.modrinth.com/api/v1/version/${this.version.id}`,
|
`version/${this.version.id}`,
|
||||||
{
|
{
|
||||||
primary_file: ['sha1', hash],
|
primary_file: ['sha1', hash],
|
||||||
},
|
},
|
||||||
@@ -273,8 +266,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await axios({
|
await this.$axios({
|
||||||
url: `https://api.modrinth.com/api/v1/version/${this.version.id}/file`,
|
url: `version/${this.version.id}/file`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: formData,
|
data: formData,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -302,10 +295,7 @@ export default {
|
|||||||
async deleteVersion() {
|
async deleteVersion() {
|
||||||
this.$nuxt.$loading.start()
|
this.$nuxt.$loading.start()
|
||||||
|
|
||||||
await axios.delete(
|
await this.$axios.delete(`version/${this.version.id}`, this.$auth.headers)
|
||||||
`https://api.modrinth.com/api/v1/version/${this.version.id}`,
|
|
||||||
this.$auth.headers
|
|
||||||
)
|
|
||||||
|
|
||||||
await this.$router.replace(`/mod/${this.mod.id}`)
|
await this.$router.replace(`/mod/${this.mod.id}`)
|
||||||
this.$nuxt.$loading.finish()
|
this.$nuxt.$loading.finish()
|
||||||
|
|||||||
@@ -499,7 +499,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
import Multiselect from 'vue-multiselect'
|
import Multiselect from 'vue-multiselect'
|
||||||
|
|
||||||
import FileInput from '~/components/ui/FileInput'
|
import FileInput from '~/components/ui/FileInput'
|
||||||
@@ -516,7 +515,7 @@ export default {
|
|||||||
ForgeIcon,
|
ForgeIcon,
|
||||||
FabricIcon,
|
FabricIcon,
|
||||||
},
|
},
|
||||||
async asyncData() {
|
async asyncData(data) {
|
||||||
const [
|
const [
|
||||||
availableCategories,
|
availableCategories,
|
||||||
availableLoaders,
|
availableLoaders,
|
||||||
@@ -525,11 +524,11 @@ export default {
|
|||||||
availableDonationPlatforms,
|
availableDonationPlatforms,
|
||||||
] = (
|
] = (
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/category`),
|
data.$axios.get(`tag/category`),
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/loader`),
|
data.$axios.get(`tag/loader`),
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/game_version`),
|
data.$axios.get(`tag/game_version`),
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/license`),
|
data.$axios.get(`tag/license`),
|
||||||
axios.get(`https://api.modrinth.com/api/v1/tag/donation_platform`),
|
data.$axios.get(`tag/donation_platform`),
|
||||||
])
|
])
|
||||||
).map((it) => it.data)
|
).map((it) => it.data)
|
||||||
|
|
||||||
@@ -654,8 +653,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await axios({
|
await this.$axios({
|
||||||
url: 'https://api.modrinth.com/api/v1/mod',
|
url: 'mod',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: formData,
|
data: formData,
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -315,7 +315,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Multiselect from 'vue-multiselect'
|
import Multiselect from 'vue-multiselect'
|
||||||
import axios from 'axios'
|
|
||||||
import SearchResult from '~/components/ui/ProjectCard'
|
import SearchResult from '~/components/ui/ProjectCard'
|
||||||
import Pagination from '~/components/ui/Pagination'
|
import Pagination from '~/components/ui/Pagination'
|
||||||
import SearchFilter from '~/components/ui/search/SearchFilter'
|
import SearchFilter from '~/components/ui/search/SearchFilter'
|
||||||
@@ -457,10 +456,10 @@ export default {
|
|||||||
async fillVersions() {
|
async fillVersions() {
|
||||||
try {
|
try {
|
||||||
const url = this.showSnapshots
|
const url = this.showSnapshots
|
||||||
? 'https://api.modrinth.com/api/v1/tag/game_version'
|
? 'tag/game_version'
|
||||||
: 'https://api.modrinth.com/api/v1/tag/game_version?type=release'
|
: 'tag/game_version?type=release'
|
||||||
|
|
||||||
const res = await axios.get(url)
|
const res = await this.$axios.get(url)
|
||||||
|
|
||||||
this.versions = res.data
|
this.versions = res.data
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -473,9 +472,7 @@ export default {
|
|||||||
await this.onSearchChange(1)
|
await this.onSearchChange(1)
|
||||||
},
|
},
|
||||||
async fillInitialLicenses() {
|
async fillInitialLicenses() {
|
||||||
const licences = (
|
const licences = (await this.$axios.get('tag/license')).data
|
||||||
await axios.get('https://api.modrinth.com/api/v1/tag/license')
|
|
||||||
).data
|
|
||||||
licences.sort((x, y) => {
|
licences.sort((x, y) => {
|
||||||
// Custom case for custom, so it goes to the bottom of the list.
|
// Custom case for custom, so it goes to the bottom of the list.
|
||||||
if (x.short === 'custom') return 1
|
if (x.short === 'custom') return 1
|
||||||
@@ -601,7 +598,7 @@ export default {
|
|||||||
params.push(`offset=${offset}`)
|
params.push(`offset=${offset}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = 'https://api.modrinth.com/api/v1/mod'
|
let url = 'mod'
|
||||||
|
|
||||||
if (params.length > 0) {
|
if (params.length > 0) {
|
||||||
for (let i = 0; i < params.length; i++) {
|
for (let i = 0; i < params.length; i++) {
|
||||||
@@ -609,7 +606,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await axios.get(url)
|
const res = await this.$axios.get(url)
|
||||||
this.results = res.data.hits
|
this.results = res.data.hits
|
||||||
|
|
||||||
const pageAmount = Math.ceil(res.data.total_hits / res.data.limit)
|
const pageAmount = Math.ceil(res.data.total_hits / res.data.limit)
|
||||||
|
|||||||
@@ -86,7 +86,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Multiselect from 'vue-multiselect'
|
import Multiselect from 'vue-multiselect'
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -96,10 +95,8 @@ export default {
|
|||||||
if (this.$route.query.id) this.itemId = this.$route.query.id
|
if (this.$route.query.id) this.itemId = this.$route.query.id
|
||||||
if (this.$route.query.t) this.itemType = this.$route.query.t
|
if (this.$route.query.t) this.itemType = this.$route.query.t
|
||||||
},
|
},
|
||||||
async asyncData() {
|
async asyncData(data) {
|
||||||
const reportTypes = (
|
const reportTypes = (await data.$axios.get(`tag/report_type`)).data
|
||||||
await axios.get(`https://api.modrinth.com/api/v1/tag/report_type`)
|
|
||||||
).data
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
reportTypes,
|
reportTypes,
|
||||||
@@ -127,11 +124,7 @@ export default {
|
|||||||
body: this.body,
|
body: this.body,
|
||||||
}
|
}
|
||||||
|
|
||||||
await axios.post(
|
await this.$axios.post('report', data, this.$auth.headers)
|
||||||
'https://api.modrinth.com/api/v1/report',
|
|
||||||
data,
|
|
||||||
this.$auth.headers
|
|
||||||
)
|
|
||||||
|
|
||||||
await this.$router.replace(`/${this.itemType}/${this.itemId}`)
|
await this.$router.replace(`/${this.itemType}/${this.itemId}`)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -89,7 +89,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
|
||||||
import SearchResult from '~/components/ui/ProjectCard'
|
import SearchResult from '~/components/ui/ProjectCard'
|
||||||
import MFooter from '~/components/layout/MFooter'
|
import MFooter from '~/components/layout/MFooter'
|
||||||
|
|
||||||
@@ -110,19 +109,13 @@ export default {
|
|||||||
},
|
},
|
||||||
async asyncData(data) {
|
async asyncData(data) {
|
||||||
try {
|
try {
|
||||||
let res = await axios.get(
|
let res = await data.$axios.get(`user/${data.params.id}`)
|
||||||
`https://api.modrinth.com/api/v1/user/${data.params.id}`
|
|
||||||
)
|
|
||||||
const user = res.data
|
const user = res.data
|
||||||
|
|
||||||
let mods = []
|
let mods = []
|
||||||
res = await axios.get(
|
res = await data.$axios.get(`user/${user.id}/mods`)
|
||||||
`https://api.modrinth.com/api/v1/user/${user.id}/mods`
|
|
||||||
)
|
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
res = await axios.get(
|
res = await data.$axios.get(`mods?ids=${JSON.stringify(res.data)}`)
|
||||||
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(res.data)}`
|
|
||||||
)
|
|
||||||
mods = res.data
|
mods = res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export const actions = {
|
|||||||
async fetchUser({ commit }, { token }) {
|
async fetchUser({ commit }, { token }) {
|
||||||
try {
|
try {
|
||||||
const user = (
|
const user = (
|
||||||
await this.$axios.get(`https://api.modrinth.com/api/v1/user`, {
|
await this.$axios.get(`user`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: token,
|
Authorization: token,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export const actions = {
|
|||||||
) {
|
) {
|
||||||
const notifications = (
|
const notifications = (
|
||||||
await this.$axios.get(
|
await this.$axios.get(
|
||||||
`https://api.modrinth.com/api/v1/user/${rootState.auth.user.id}/notifications`,
|
`user/${rootState.auth.user.id}/notifications`,
|
||||||
rootState.auth.headers
|
rootState.auth.headers
|
||||||
)
|
)
|
||||||
).data
|
).data
|
||||||
|
|||||||
Reference in New Issue
Block a user