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:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user