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