mirror of
https://github.com/fmhy/edit.git
synced 2026-02-18 17:21:22 +11:00
comment
This commit is contained in:
parent
6da3e1f016
commit
1efd4b9194
1 changed files with 32 additions and 96 deletions
|
|
@ -1,20 +1,27 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
// Import necessary functions and components from Vue and VitePress
|
||||||
import { reactive, ref } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
import { useRouter } from 'vitepress'
|
import { useRouter } from 'vitepress'
|
||||||
import {
|
import { type FeedbackType, getFeedbackOption, feedbackOptions } from '../../types/Feedback'
|
||||||
type FeedbackType,
|
|
||||||
getFeedbackOption,
|
|
||||||
feedbackOptions
|
|
||||||
} from '../../types/Feedback'
|
|
||||||
|
|
||||||
|
// Define reactive loading, error, and success states
|
||||||
const loading = ref<boolean>(false)
|
const loading = ref<boolean>(false)
|
||||||
const error = ref<unknown>(null)
|
const error = ref<unknown>(null)
|
||||||
const success = ref<boolean>(false)
|
const success = ref<boolean>(false)
|
||||||
|
|
||||||
|
// Initialize the router
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
// Initialize the reactive feedback object
|
||||||
const feedback = reactive<FeedbackType>({ message: '' })
|
const feedback = reactive<FeedbackType>({ message: '' })
|
||||||
|
|
||||||
|
/*
|
||||||
|
Define the handleSubmit function which accepts an optional type parameter
|
||||||
|
of FeedbackType. This function sets the feedback.type property, sets
|
||||||
|
the loading state to true, and then proceeds to send a POST request to
|
||||||
|
the feedback API endpoint with the feedback data as JSON in the request
|
||||||
|
body. It handles errors and updates the appropriate states accordingly.
|
||||||
|
*/
|
||||||
async function handleSubmit(type?: FeedbackType['type']) {
|
async function handleSubmit(type?: FeedbackType['type']) {
|
||||||
if (type) feedback.type = type
|
if (type) feedback.type = type
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|
@ -53,29 +60,37 @@ async function handleSubmit(type?: FeedbackType['type']) {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
<!-- Conditionally render the feedback steps based on the feedback states -->
|
||||||
<Transition name="fade" mode="out-in">
|
<Transition name="fade" mode="out-in">
|
||||||
<div v-if="!feedback.type" class="step">
|
<div v-if="!feedback.type" class="step">
|
||||||
|
<!-- Heading for the feedback page -->
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<p class="heading">Feedback</p>
|
<p class="heading">Feedback</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Container for the feedback buttons -->
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
|
<!-- Render the feedback buttons using v-for and pass the appropriate type value -->
|
||||||
<button
|
<button
|
||||||
v-for="item in feedbackOptions"
|
v-for="item in feedbackOptions"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
class="btn"
|
class="btn"
|
||||||
@click="handleSubmit(item.value as FeedbackType['type'])"
|
@click="handleSubmit(item.value as FeedbackType['type'])"
|
||||||
>
|
>
|
||||||
|
<!-- Button label -->
|
||||||
<span>{{ item.label }}</span>
|
<span>{{ item.label }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="feedback.type && !success" class="step">
|
<div v-else-if="feedback.type && !success" class="step">
|
||||||
|
<!-- Page path and feedback type -->
|
||||||
<div>
|
<div>
|
||||||
<p class="desc">Page: {{ router.route.path }}</p>
|
<p class="desc">Page: {{ router.route.path }}</p>
|
||||||
<div>
|
<div>
|
||||||
|
<!-- Feedback type label -->
|
||||||
<span>{{ getFeedbackOption(feedback.type)?.label }}</span>
|
<span>{{ getFeedbackOption(feedback.type)?.label }}</span>
|
||||||
|
<!-- Button to close the current feedback type -->
|
||||||
<button
|
<button
|
||||||
style="margin-left: 0.5rem"
|
style="margin-left: 0.5rem"
|
||||||
class="btn"
|
class="btn"
|
||||||
|
|
@ -85,7 +100,9 @@ async function handleSubmit(type?: FeedbackType['type']) {
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Container for the textarea and additional information -->
|
||||||
<div v-if="feedback.type === 'suggestion'" class="text-sm mb-2">
|
<div v-if="feedback.type === 'suggestion'" class="text-sm mb-2">
|
||||||
|
<!-- Suggestions for different types of feedback -->
|
||||||
<strong>🕹️ Emulators</strong>
|
<strong>🕹️ Emulators</strong>
|
||||||
<p class="desc">
|
<p class="desc">
|
||||||
They're already on the
|
They're already on the
|
||||||
|
|
@ -96,6 +113,7 @@ async function handleSubmit(type?: FeedbackType['type']) {
|
||||||
Game Tech Wiki.
|
Game Tech Wiki.
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
<!-- More suggestions for different types of feedback -->
|
||||||
<strong>🔻 Leeches</strong>
|
<strong>🔻 Leeches</strong>
|
||||||
<p class="desc">
|
<p class="desc">
|
||||||
They're already on the
|
They're already on the
|
||||||
|
|
@ -106,6 +124,7 @@ async function handleSubmit(type?: FeedbackType['type']) {
|
||||||
File Hosting Wiki.
|
File Hosting Wiki.
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
<!-- More suggestions for different types of feedback -->
|
||||||
<strong>🐧 Distros</strong>
|
<strong>🐧 Distros</strong>
|
||||||
<p class="desc">
|
<p class="desc">
|
||||||
They're already on
|
They're already on
|
||||||
|
|
@ -116,22 +135,26 @@ async function handleSubmit(type?: FeedbackType['type']) {
|
||||||
DistroWatch.
|
DistroWatch.
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
<!-- Information about inappropriate feedback -->
|
||||||
<strong>🎲 Mining / Betting Sites</strong>
|
<strong>🎲 Mining / Betting Sites</strong>
|
||||||
<p class="desc">
|
<p class="desc">
|
||||||
Don't post anything related to betting, mining, BINs, CCs, etc.
|
Don't post anything related to betting, mining, BINs, CCs, etc.
|
||||||
</p>
|
</p>
|
||||||
|
<!-- Information about multiplayer game hacks -->
|
||||||
<strong>🎮 Multiplayer Game Hacks</strong>
|
<strong>🎮 Multiplayer Game Hacks</strong>
|
||||||
<p class="desc">
|
<p class="desc">
|
||||||
Don't post any hacks/exploits that give unfair advantages in
|
Don't post any hacks/exploits that give unfair advantages in
|
||||||
multiplayer games.
|
multiplayer games.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Textarea for user feedback -->
|
||||||
<textarea
|
<textarea
|
||||||
v-model="feedback.message"
|
v-model="feedback.message"
|
||||||
autofocus
|
autofocus
|
||||||
class="input"
|
class="input"
|
||||||
placeholder="What a lovely wiki!"
|
placeholder="What a lovely wiki!"
|
||||||
/>
|
/>
|
||||||
|
<!-- Additional information about contacting the team -->
|
||||||
<p class="desc mb-2">
|
<p class="desc mb-2">
|
||||||
If you want a reply to your feedback, feel free to mention a contact
|
If you want a reply to your feedback, feel free to mention a contact
|
||||||
in the message or join our
|
in the message or join our
|
||||||
|
|
@ -142,6 +165,7 @@ async function handleSubmit(type?: FeedbackType['type']) {
|
||||||
Discord.
|
Discord.
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
<!-- Button to submit the feedback -->
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
|
|
@ -150,10 +174,12 @@ async function handleSubmit(type?: FeedbackType['type']) {
|
||||||
"
|
"
|
||||||
@click="handleSubmit()"
|
@click="handleSubmit()"
|
||||||
>
|
>
|
||||||
|
<!-- Button label -->
|
||||||
Submit
|
Submit
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="step">
|
<div v-else class="step">
|
||||||
|
<!-- Heading for the success step -->
|
||||||
<p class="heading">Thanks for your feedback!</p>
|
<p class="heading">Thanks for your feedback!</p>
|
||||||
</div>
|
</div>
|
||||||
</Transition>
|
</Transition>
|
||||||
|
|
@ -161,95 +187,5 @@ async function handleSubmit(type?: FeedbackType['type']) {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.step > * + * {
|
// Styling for the component
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
border: 1px solid var(--vp-c-divider);
|
|
||||||
background-color: var(--vp-c-bg);
|
|
||||||
border-radius: 8px;
|
|
||||||
transition:
|
|
||||||
border-color 0.25s,
|
|
||||||
background-color 0.25s;
|
|
||||||
display: inline-block;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
line-height: 1.5;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0.375rem 0.75rem;
|
|
||||||
text-align: center;
|
|
||||||
vertical-align: middle;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:disabled {
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:hover {
|
|
||||||
border-color: var(--vp-c-brand);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
color: #fff;
|
|
||||||
background-color: var(--vp-c-brand);
|
|
||||||
border-color: var(--vp-c-brand);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:hover {
|
|
||||||
background-color: var(--vp-c-brand-darker);
|
|
||||||
border-color: var(--vp-c-brand-darker);
|
|
||||||
}
|
|
||||||
|
|
||||||
.heading {
|
|
||||||
font-size: 1.2rem;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button-container {
|
|
||||||
display: grid;
|
|
||||||
grid-gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wrapper {
|
|
||||||
margin: 2rem 0;
|
|
||||||
padding: 1.5rem;
|
|
||||||
border: 1px solid var(--vp-c-divider);
|
|
||||||
border-radius: 8px;
|
|
||||||
background: var(--vp-c-bg-alt);
|
|
||||||
}
|
|
||||||
|
|
||||||
.input {
|
|
||||||
width: 100%;
|
|
||||||
height: 100px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 4px;
|
|
||||||
padding: 0.375rem 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.contact-input {
|
|
||||||
height: 50px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 4px;
|
|
||||||
padding: 0.375rem 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.desc {
|
|
||||||
display: block;
|
|
||||||
line-height: 20px;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--vp-c-text-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.fade-enter-active,
|
|
||||||
.fade-leave-active {
|
|
||||||
transition: opacity 0.25s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fade-enter-from,
|
|
||||||
.fade-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue