You've already forked AstralRinth
forked from didirus/AstralRinth
Creation work
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h2>Create Mod</h2>
|
<h2>Create Mod</h2>
|
||||||
|
<section class="error" v-if="currentError">
|
||||||
|
<h3>Error</h3>
|
||||||
|
<p>{{ currentError }}</p>
|
||||||
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<h3>Initial Data</h3>
|
<h3>Initial Data</h3>
|
||||||
<div class="initial">
|
<div class="initial">
|
||||||
@@ -24,17 +28,6 @@
|
|||||||
<div class="mod-data">
|
<div class="mod-data">
|
||||||
<label class="required" title="The name of your mod"> Name </label>
|
<label class="required" title="The name of your mod"> Name </label>
|
||||||
<input v-model="name" type="text" placeholder="Example Mod" />
|
<input v-model="name" type="text" placeholder="Example Mod" />
|
||||||
<label
|
|
||||||
class="required"
|
|
||||||
title="The namespace of your mod, an example is com.example.mod"
|
|
||||||
>
|
|
||||||
Namespace
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="namespace"
|
|
||||||
type="text"
|
|
||||||
placeholder="com.example.examplemod"
|
|
||||||
/>
|
|
||||||
<label
|
<label
|
||||||
class="required"
|
class="required"
|
||||||
title="The short-form description of your mod. This shows up in searches"
|
title="The short-form description of your mod. This shows up in searches"
|
||||||
@@ -46,6 +39,27 @@
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder="An example mod which does example stuff!"
|
placeholder="An example mod which does example stuff!"
|
||||||
/>
|
/>
|
||||||
|
<label
|
||||||
|
title="The categories of your mod, these help your mod appear in search results. Maximum of three!"
|
||||||
|
>
|
||||||
|
Categories
|
||||||
|
</label>
|
||||||
|
<multiselect
|
||||||
|
v-model="categories"
|
||||||
|
class="categories-input"
|
||||||
|
:options="selectableCategories"
|
||||||
|
:loading="selectableCategories.length === 0"
|
||||||
|
:multiple="true"
|
||||||
|
:searchable="false"
|
||||||
|
:show-no-results="false"
|
||||||
|
:close-on-select="false"
|
||||||
|
:clear-on-select="false"
|
||||||
|
:show-labels="false"
|
||||||
|
:max="3"
|
||||||
|
:limit="6"
|
||||||
|
:hide-selected="true"
|
||||||
|
placeholder="Choose categories..."
|
||||||
|
></multiselect>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -54,7 +68,10 @@
|
|||||||
<p>
|
<p>
|
||||||
You can type the of the long form of your description here. This editor
|
You can type the of the long form of your description here. This editor
|
||||||
supports markdown. You can find the syntax
|
supports markdown. You can find the syntax
|
||||||
<a href="https://github.com/dimerapp/markdown/blob/develop/syntax.md"
|
<a
|
||||||
|
href="https://github.com/dimerapp/markdown/blob/develop/syntax.md"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
>here</a
|
>here</a
|
||||||
>.
|
>.
|
||||||
</p>
|
</p>
|
||||||
@@ -85,14 +102,26 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<button @click="createMod">Create mod</button>
|
<button :disabled="!this.$nuxt.$loading" @click="createMod">
|
||||||
|
Create mod
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import Multiselect from 'vue-multiselect'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
Multiselect,
|
||||||
|
},
|
||||||
|
async asyncData() {
|
||||||
|
const res = await axios.get(`https://api.modrinth.com/api/v1/tag/category`)
|
||||||
|
return {
|
||||||
|
selectableCategories: res.data,
|
||||||
|
}
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
previewImage: null,
|
previewImage: null,
|
||||||
@@ -107,10 +136,14 @@ export default {
|
|||||||
source_url: null,
|
source_url: null,
|
||||||
wiki_url: null,
|
wiki_url: null,
|
||||||
icon: null,
|
icon: null,
|
||||||
|
currentError: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async createMod() {
|
async createMod() {
|
||||||
|
this.$nuxt.$loading.start()
|
||||||
|
this.currentError = null
|
||||||
|
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
|
|
||||||
formData.append(
|
formData.append(
|
||||||
@@ -149,12 +182,16 @@ export default {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await this.$router.replace('/dashboard/projects')
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(result)
|
console.log(result)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// eslint-disable-next-line no-console
|
this.currentError = err.response.data.description
|
||||||
console.error(err)
|
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$nuxt.$loading.stop()
|
||||||
},
|
},
|
||||||
showPreviewImage(e) {
|
showPreviewImage(e) {
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
@@ -170,6 +207,10 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.error {
|
||||||
|
border-left: #e04e3e 7px solid;
|
||||||
|
}
|
||||||
|
|
||||||
section {
|
section {
|
||||||
box-shadow: 0 2px 3px 1px var(--color-grey-2);
|
box-shadow: 0 2px 3px 1px var(--color-grey-2);
|
||||||
margin: 50px 25px;
|
margin: 50px 25px;
|
||||||
@@ -188,6 +229,10 @@ input {
|
|||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.multiselect {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.initial {
|
.initial {
|
||||||
display: flex;
|
display: flex;
|
||||||
.image-data {
|
.image-data {
|
||||||
@@ -249,7 +294,7 @@ input {
|
|||||||
textarea {
|
textarea {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
width: calc(50% - 50px);
|
width: calc(50% - 50px);
|
||||||
min-height: 500px;
|
height: 500px;
|
||||||
resize: none;
|
resize: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
border: none;
|
border: none;
|
||||||
@@ -262,12 +307,14 @@ input {
|
|||||||
div {
|
div {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
min-height: 540px;
|
height: 540px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: calc(50%);
|
width: calc(50%);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
background-color: var(--color-grey-2);
|
background-color: var(--color-grey-2);
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -372,7 +372,7 @@ export default {
|
|||||||
if (!sendRequest) await this.onSearchChange(1)
|
if (!sendRequest) await this.onSearchChange(1)
|
||||||
},
|
},
|
||||||
async onSearchChangeToTop(newPageNumber) {
|
async onSearchChangeToTop(newPageNumber) {
|
||||||
if (process.client) window.scrollTo(0, 0)
|
if (process.client) window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||||
|
|
||||||
await this.onSearchChange(newPageNumber)
|
await this.onSearchChange(newPageNumber)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user