You've already forked AstralRinth
forked from didirus/AstralRinth
Move everything to components, (WIP) Version creation
This commit is contained in:
@@ -73,6 +73,11 @@ export default {
|
||||
name: 'og:site_name',
|
||||
content: this.mod.title,
|
||||
},
|
||||
{
|
||||
hid: 'og:url',
|
||||
name: 'og:url',
|
||||
content: `https://modrinth.com/mod/${this.mod.id}`,
|
||||
},
|
||||
{
|
||||
hid: 'og:description',
|
||||
name: 'og:description',
|
||||
|
||||
50
pages/mod/_id/settings.vue
Normal file
50
pages/mod/_id/settings.vue
Normal file
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<ModPage :mod="mod" :versions="versions" :members="members"></ModPage>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ModPage from '@/components/ModPage'
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
components: { ModPage },
|
||||
auth: false,
|
||||
async asyncData(data) {
|
||||
let res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`
|
||||
)
|
||||
const mod = res.data
|
||||
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/team/${mod.team}/members`
|
||||
)
|
||||
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}`
|
||||
)
|
||||
members[i].avatar_url = res.data.avatar_url
|
||||
}
|
||||
|
||||
res = await axios.get(mod.body_url)
|
||||
|
||||
const versions = []
|
||||
|
||||
for (const version of mod.versions) {
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/version/${version}`
|
||||
)
|
||||
|
||||
versions.push(res.data)
|
||||
}
|
||||
|
||||
return {
|
||||
mod,
|
||||
versions,
|
||||
members,
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -1,7 +1,17 @@
|
||||
<template>
|
||||
<ModPage :mod="mod" :versions="versions" :members="members">
|
||||
<div class="version">
|
||||
<h3>{{ version.name }}</h3>
|
||||
<div class="header">
|
||||
<h3>{{ version.name }}</h3>
|
||||
<div class="user-actions">
|
||||
<button class="trash red">
|
||||
<TrashIcon />
|
||||
</button>
|
||||
<button class="upload">
|
||||
<UploadIcon />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="markdown-body" v-html="changelog"></div>
|
||||
<hr />
|
||||
<div class="columns metadata">
|
||||
@@ -46,6 +56,8 @@ import xss from 'xss'
|
||||
import marked from 'marked'
|
||||
|
||||
import DownloadIcon from '~/assets/images/utils/download.svg?inline'
|
||||
import UploadIcon from '~/assets/images/utils/upload.svg?inline'
|
||||
import TrashIcon from '~/assets/images/utils/trash.svg?inline'
|
||||
|
||||
import ForgeIcon from '~/assets/images/categories/forge.svg?inline'
|
||||
import FabricIcon from '~/assets/images/categories/fabric.svg?inline'
|
||||
@@ -56,6 +68,8 @@ export default {
|
||||
ForgeIcon,
|
||||
FabricIcon,
|
||||
DownloadIcon,
|
||||
UploadIcon,
|
||||
TrashIcon,
|
||||
},
|
||||
auth: false,
|
||||
async asyncData(data) {
|
||||
@@ -121,12 +135,17 @@ export default {
|
||||
name: 'og:site_name',
|
||||
content: this.mod.title + ' - Modrinth',
|
||||
},
|
||||
{
|
||||
hid: 'og:url',
|
||||
name: 'og:url',
|
||||
content: `https://modrinth.com/mod/${this.mod.id}`,
|
||||
},
|
||||
{
|
||||
hid: 'og:description',
|
||||
name: 'og:description',
|
||||
content: this.mod.description,
|
||||
},
|
||||
{ hid: 'og:type', name: 'og:type', content: 'article' },
|
||||
{ hid: 'og:type', name: 'og:type', content: 'website' },
|
||||
{
|
||||
hid: 'og:image',
|
||||
name: 'og:image',
|
||||
@@ -147,6 +166,36 @@ export default {
|
||||
box-shadow: 0 2px 3px 1px var(--color-grey-2);
|
||||
padding: 1em;
|
||||
|
||||
.header {
|
||||
h3 {
|
||||
display: inline-block;
|
||||
}
|
||||
.user-actions {
|
||||
float: right;
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
margin-right: 10px;
|
||||
padding: 5px;
|
||||
border: none;
|
||||
border-radius: var(--size-rounded-sm);
|
||||
}
|
||||
|
||||
.trash {
|
||||
color: #9b2c2c;
|
||||
background-color: var(--color-bg);
|
||||
}
|
||||
|
||||
.upload {
|
||||
color: var(--color-text);
|
||||
background-color: var(--color-grey-1);
|
||||
* {
|
||||
margin: auto 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hr {
|
||||
margin: 20px 0;
|
||||
color: var(--color-grey-1);
|
||||
|
||||
@@ -53,23 +53,159 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<Popup
|
||||
v-if="showPopup"
|
||||
:show-popup="showPopup"
|
||||
class="create-version-popup-body"
|
||||
>
|
||||
<h3>New Version</h3>
|
||||
<div v-if="currentError" class="error">
|
||||
<h4>Error</h4>
|
||||
<p>{{ currentError }}</p>
|
||||
</div>
|
||||
<label
|
||||
for="version-title"
|
||||
class="required"
|
||||
title="The title of your version"
|
||||
>
|
||||
Version Title
|
||||
</label>
|
||||
<input
|
||||
id="version-title"
|
||||
v-model="createdVersion.version_title"
|
||||
required
|
||||
type="text"
|
||||
placeholder="Combat Update"
|
||||
/>
|
||||
<label
|
||||
for="version-number"
|
||||
class="required"
|
||||
title="The version number of this version. Preferably following semantic versioning"
|
||||
>
|
||||
Version Number
|
||||
</label>
|
||||
<input
|
||||
id="version-number"
|
||||
v-model="createdVersion.version_number"
|
||||
required
|
||||
type="text"
|
||||
placeholder="v1.9"
|
||||
/>
|
||||
<label class="required" title="The release channel of this version.">
|
||||
Release Channel
|
||||
</label>
|
||||
<Multiselect
|
||||
v-model="createdVersion.release_channel"
|
||||
class="categories-input"
|
||||
placeholder="Select one"
|
||||
:options="['release', 'beta', 'alpha']"
|
||||
:searchable="false"
|
||||
:close-on-select="true"
|
||||
:show-labels="false"
|
||||
:allow-empty="false"
|
||||
/>
|
||||
<label
|
||||
title="The version number of this version. Preferably following semantic versioning"
|
||||
>
|
||||
Loaders
|
||||
</label>
|
||||
<multiselect
|
||||
v-model="createdVersion.loaders"
|
||||
class="categories-input"
|
||||
:options="selectableLoaders"
|
||||
:loading="selectableLoaders.length === 0"
|
||||
:multiple="true"
|
||||
:searchable="false"
|
||||
:show-no-results="false"
|
||||
:close-on-select="true"
|
||||
:clear-on-select="false"
|
||||
:show-labels="false"
|
||||
:limit="6"
|
||||
:hide-selected="true"
|
||||
placeholder="Choose loaders..."
|
||||
/>
|
||||
<label title="The versions of minecraft that this mod version supports">
|
||||
Game Versions
|
||||
</label>
|
||||
<multiselect
|
||||
v-model="createdVersion.game_versions"
|
||||
class="categories-input"
|
||||
:options="selectableVersions"
|
||||
:loading="selectableVersions.length === 0"
|
||||
:multiple="true"
|
||||
:searchable="true"
|
||||
:show-no-results="false"
|
||||
:close-on-select="false"
|
||||
:clear-on-select="false"
|
||||
:show-labels="false"
|
||||
:limit="6"
|
||||
:hide-selected="true"
|
||||
placeholder="Choose versions..."
|
||||
/>
|
||||
<label for="version-body" title="A list of changes for this version">
|
||||
Changelog
|
||||
</label>
|
||||
<textarea
|
||||
id="version-body"
|
||||
v-model="createdVersion.version_body"
|
||||
class="changelog-editor"
|
||||
/>
|
||||
<FileInput
|
||||
input-id="version-files"
|
||||
input-accept="application/java-archive,application/zip"
|
||||
default-text="Upload Files"
|
||||
:input-multiple="true"
|
||||
@change="updateVersionFiles"
|
||||
>
|
||||
<label class="required" title="The files associated with the version">
|
||||
Version Files
|
||||
</label>
|
||||
</FileInput>
|
||||
|
||||
<div class="popup-buttons">
|
||||
<button
|
||||
class="trash-button"
|
||||
@click="
|
||||
showPopup = false
|
||||
createdVersion = {}
|
||||
"
|
||||
>
|
||||
<TrashIcon />
|
||||
</button>
|
||||
<button class="default-button" @click="createVersion">
|
||||
Create Version
|
||||
</button>
|
||||
</div>
|
||||
</Popup>
|
||||
<button class="default-button" @click="showPopup = !showPopup">
|
||||
New Version
|
||||
</button>
|
||||
</ModPage>
|
||||
</template>
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
import Multiselect from 'vue-multiselect'
|
||||
|
||||
import ModPage from '@/components/ModPage'
|
||||
|
||||
import Popup from '@/components/Popup'
|
||||
import FileInput from '@/components/FileInput'
|
||||
import TrashIcon from '~/assets/images/utils/trash.svg?inline'
|
||||
import DownloadIcon from '~/assets/images/utils/download.svg?inline'
|
||||
import ForgeIcon from '~/assets/images/categories/forge.svg?inline'
|
||||
import FabricIcon from '~/assets/images/categories/fabric.svg?inline'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Multiselect,
|
||||
FileInput,
|
||||
Popup,
|
||||
ModPage,
|
||||
ForgeIcon,
|
||||
FabricIcon,
|
||||
DownloadIcon,
|
||||
TrashIcon,
|
||||
},
|
||||
auth: false,
|
||||
async asyncData(data) {
|
||||
@@ -98,12 +234,78 @@ export default {
|
||||
versions.push(res.data)
|
||||
}
|
||||
|
||||
res = await axios.get(`https://api.modrinth.com/api/v1/tag/loader`)
|
||||
const selectableLoaders = res.data
|
||||
|
||||
res = await axios.get(`https://api.modrinth.com/api/v1/tag/game_version`)
|
||||
const selectableVersions = res.data
|
||||
|
||||
return {
|
||||
mod,
|
||||
versions,
|
||||
members,
|
||||
selectableLoaders,
|
||||
selectableVersions,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showPopup: false,
|
||||
currentError: null,
|
||||
createdVersion: {},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateVersionFiles(e) {
|
||||
this.createdVersion.raw_files = e.target.files
|
||||
|
||||
const newFileParts = []
|
||||
for (let i = 0; i < e.target.files.length; i++) {
|
||||
newFileParts.push(e.target.files[i].name.concat('-' + i))
|
||||
}
|
||||
|
||||
this.createdVersion.file_parts = newFileParts
|
||||
},
|
||||
async createVersion() {
|
||||
this.$nuxt.$loading.start()
|
||||
this.currentError = null
|
||||
|
||||
const formData = new FormData()
|
||||
|
||||
this.createdVersion.mod_id = this.$route.params.id
|
||||
|
||||
formData.append('data', JSON.stringify(this.createdVersion))
|
||||
|
||||
if (this.createdVersion.raw_files) {
|
||||
for (let i = 0; i < this.createdVersion.raw_files.length; i++) {
|
||||
formData.append(
|
||||
this.createdVersion.file_parts[i],
|
||||
new Blob([this.createdVersion.raw_files[i]]),
|
||||
this.createdVersion.raw_files[i].name
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await axios({
|
||||
url: 'https://api.modrinth.com/api/v1/version/version',
|
||||
method: 'POST',
|
||||
data: formData,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
Authorization: this.$auth.getToken('local'),
|
||||
},
|
||||
})
|
||||
|
||||
await this.$router.go(null)
|
||||
} catch (err) {
|
||||
this.currentError = err.response.data.description
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
}
|
||||
|
||||
this.$nuxt.$loading.finish()
|
||||
},
|
||||
},
|
||||
head() {
|
||||
return {
|
||||
title: this.mod.title + ' - Modrinth',
|
||||
@@ -126,6 +328,11 @@ export default {
|
||||
name: 'og:site_name',
|
||||
content: this.mod.title,
|
||||
},
|
||||
{
|
||||
hid: 'og:url',
|
||||
name: 'og:url',
|
||||
content: `https://modrinth.com/mod/${this.mod.id}`,
|
||||
},
|
||||
{
|
||||
hid: 'og:description',
|
||||
name: 'og:description',
|
||||
@@ -209,4 +416,71 @@ table {
|
||||
}
|
||||
}
|
||||
}
|
||||
.multiselect {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
input {
|
||||
width: calc(100% - 15px);
|
||||
padding: 0.5rem 5px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.changelog-editor {
|
||||
padding: 20px;
|
||||
width: calc(100% - 40px);
|
||||
height: 200px;
|
||||
resize: none;
|
||||
outline: none;
|
||||
border: none;
|
||||
margin: 10px 0 30px;
|
||||
background-color: var(--color-grey-1);
|
||||
color: var(--color-text);
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.popup-buttons {
|
||||
margin-top: 20px;
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
justify-content: right;
|
||||
align-items: center;
|
||||
|
||||
.default-button {
|
||||
float: none;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.trash-button {
|
||||
cursor: pointer;
|
||||
margin-right: 10px;
|
||||
padding: 5px;
|
||||
border: none;
|
||||
border-radius: var(--size-rounded-sm);
|
||||
color: #9b2c2c;
|
||||
background-color: var(--color-bg);
|
||||
}
|
||||
}
|
||||
|
||||
.default-button {
|
||||
float: right;
|
||||
margin-top: 20px;
|
||||
border-radius: var(--size-rounded-sm);
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
padding: 10px;
|
||||
background-color: var(--color-grey-1);
|
||||
color: var(--color-grey-5);
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: var(--color-grey-4);
|
||||
}
|
||||
}
|
||||
|
||||
.error {
|
||||
margin: 20px 0;
|
||||
border-left: #e04e3e 7px solid;
|
||||
padding: 5px 20px 20px 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user