refactor: convert to script setup
This commit is contained in:
@@ -156,61 +156,54 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineComponent, ref } from "@nuxtjs/composition-api"
|
import { ref, watch } from "@nuxtjs/composition-api"
|
||||||
import { defineActionHandler } from "~/helpers/actions"
|
import { defineActionHandler } from "~/helpers/actions"
|
||||||
import { showChat } from "~/helpers/support"
|
import { showChat } from "~/helpers/support"
|
||||||
import { useSetting } from "~/newstore/settings"
|
import { useSetting } from "~/newstore/settings"
|
||||||
|
|
||||||
export default defineComponent({
|
const showShortcuts = ref(false)
|
||||||
setup() {
|
const showShare = ref(false)
|
||||||
const showShortcuts = ref(false)
|
|
||||||
const showShare = ref(false)
|
|
||||||
|
|
||||||
defineActionHandler("flyouts.keybinds.toggle", () => {
|
defineActionHandler("flyouts.keybinds.toggle", () => {
|
||||||
showShortcuts.value = !showShortcuts.value
|
showShortcuts.value = !showShortcuts.value
|
||||||
})
|
|
||||||
|
|
||||||
defineActionHandler("modals.share.toggle", () => {
|
|
||||||
showShare.value = !showShare.value
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
|
||||||
EXPAND_NAVIGATION: useSetting("EXPAND_NAVIGATION"),
|
|
||||||
SIDEBAR: useSetting("SIDEBAR"),
|
|
||||||
ZEN_MODE: useSetting("ZEN_MODE"),
|
|
||||||
COLUMN_LAYOUT: useSetting("COLUMN_LAYOUT"),
|
|
||||||
SIDEBAR_ON_LEFT: useSetting("SIDEBAR_ON_LEFT"),
|
|
||||||
|
|
||||||
navigatorShare: !!navigator.share,
|
|
||||||
|
|
||||||
showShortcuts,
|
|
||||||
showShare,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
ZEN_MODE() {
|
|
||||||
this.EXPAND_NAVIGATION = !this.ZEN_MODE
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
nativeShare() {
|
|
||||||
if (navigator.share) {
|
|
||||||
navigator
|
|
||||||
.share({
|
|
||||||
title: "Hoppscotch",
|
|
||||||
text: "Hoppscotch • Open source API development ecosystem - Helps you create requests faster, saving precious time on development.",
|
|
||||||
url: "https://hoppscotch.io",
|
|
||||||
})
|
|
||||||
.then(() => {})
|
|
||||||
.catch(console.error)
|
|
||||||
} else {
|
|
||||||
// fallback
|
|
||||||
}
|
|
||||||
},
|
|
||||||
chatWithUs() {
|
|
||||||
showChat()
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
defineActionHandler("modals.share.toggle", () => {
|
||||||
|
showShare.value = !showShare.value
|
||||||
|
})
|
||||||
|
|
||||||
|
const EXPAND_NAVIGATION = useSetting("EXPAND_NAVIGATION")
|
||||||
|
const SIDEBAR = useSetting("SIDEBAR")
|
||||||
|
const ZEN_MODE = useSetting("ZEN_MODE")
|
||||||
|
const COLUMN_LAYOUT = useSetting("COLUMN_LAYOUT")
|
||||||
|
const SIDEBAR_ON_LEFT = useSetting("SIDEBAR_ON_LEFT")
|
||||||
|
|
||||||
|
const navigatorShare = !!navigator.share
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => ZEN_MODE.value,
|
||||||
|
() => {
|
||||||
|
EXPAND_NAVIGATION.value = !ZEN_MODE.value
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const nativeShare = () => {
|
||||||
|
if (navigator.share) {
|
||||||
|
navigator
|
||||||
|
.share({
|
||||||
|
title: "Hoppscotch",
|
||||||
|
text: "Hoppscotch • Open source API development ecosystem - Helps you create requests faster, saving precious time on development.",
|
||||||
|
url: "https://hoppscotch.io",
|
||||||
|
})
|
||||||
|
.then(() => {})
|
||||||
|
.catch(console.error)
|
||||||
|
} else {
|
||||||
|
// fallback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const chatWithUs = () => {
|
||||||
|
showChat()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -18,19 +18,13 @@
|
|||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
import { defineComponent } from "@nuxtjs/composition-api"
|
|
||||||
import GithubButton from "vue-github-button"
|
import GithubButton from "vue-github-button"
|
||||||
|
|
||||||
export default defineComponent({
|
defineProps({
|
||||||
components: {
|
size: {
|
||||||
GithubButton,
|
type: String,
|
||||||
},
|
default: undefined,
|
||||||
props: {
|
|
||||||
size: {
|
|
||||||
type: String,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4,15 +4,11 @@
|
|||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineComponent } from "@nuxtjs/composition-api"
|
defineProps({
|
||||||
|
label: {
|
||||||
export default defineComponent({
|
type: String,
|
||||||
props: {
|
default: "Section",
|
||||||
label: {
|
|
||||||
type: String,
|
|
||||||
default: "Section",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<SmartModal
|
<SmartModal
|
||||||
v-if="show"
|
v-if="show"
|
||||||
:title="$t('app.invite_your_friends')"
|
:title="$t('app.invite_your_friends')"
|
||||||
@close="$emit('hide-modal')"
|
@close="hideModal"
|
||||||
>
|
>
|
||||||
<template #body>
|
<template #body>
|
||||||
<p class="text-secondaryLight mb-8 px-2">
|
<p class="text-secondaryLight mb-8 px-2">
|
||||||
@@ -34,70 +34,73 @@
|
|||||||
</SmartModal>
|
</SmartModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
import { defineComponent } from "@nuxtjs/composition-api"
|
import { ref, useContext } from "@nuxtjs/composition-api"
|
||||||
import { copyToClipboard } from "~/helpers/utils/clipboard"
|
import { copyToClipboard } from "~/helpers/utils/clipboard"
|
||||||
|
|
||||||
export default defineComponent({
|
const {
|
||||||
props: {
|
$toast,
|
||||||
show: Boolean,
|
app: { i18n },
|
||||||
},
|
} = useContext()
|
||||||
data() {
|
const t = i18n.t.bind(i18n)
|
||||||
const url = "https://hoppscotch.io"
|
|
||||||
const text = "Hoppscotch - Open source API development ecosystem."
|
|
||||||
const description =
|
|
||||||
"Helps you create requests faster, saving precious time on development."
|
|
||||||
const subject =
|
|
||||||
"Checkout Hoppscotch - an open source API development ecosystem"
|
|
||||||
const summary = `Hi there!%0D%0A%0D%0AI thought you’ll like this new platform that I joined called Hoppscotch - https://hoppscotch.io.%0D%0AIt is a simple and intuitive interface for creating and managing your APIs. You can build, test, document, and share your APIs.%0D%0A%0D%0AThe best part about Hoppscotch is that it is open source and free to get started.%0D%0A%0D%0A`
|
|
||||||
const twitter = "hoppscotch_io"
|
|
||||||
|
|
||||||
return {
|
defineProps<{
|
||||||
url: "https://hoppscotch.io",
|
show: Boolean
|
||||||
copyIcon: "copy",
|
}>()
|
||||||
platforms: [
|
|
||||||
{
|
const emit = defineEmits<{
|
||||||
name: "Email",
|
(e: "hide-modal"): void
|
||||||
icon: "mail",
|
}>()
|
||||||
link: `mailto:?subject=${subject}&body=${summary}`,
|
|
||||||
},
|
const url = "https://hoppscotch.io"
|
||||||
{
|
const text = "Hoppscotch - Open source API development ecosystem."
|
||||||
name: "Twitter",
|
const description =
|
||||||
icon: "brands/twitter",
|
"Helps you create requests faster, saving precious time on development."
|
||||||
link: `https://twitter.com/intent/tweet?text=${text} ${description}&url=${url}&via=${twitter}`,
|
const subject = "Checkout Hoppscotch - an open source API development ecosystem"
|
||||||
},
|
const summary = `Hi there!%0D%0A%0D%0AI thought you’ll like this new platform that I joined called Hoppscotch - https://hoppscotch.io.%0D%0AIt is a simple and intuitive interface for creating and managing your APIs. You can build, test, document, and share your APIs.%0D%0A%0D%0AThe best part about Hoppscotch is that it is open source and free to get started.%0D%0A%0D%0A`
|
||||||
{
|
const twitter = "hoppscotch_io"
|
||||||
name: "Facebook",
|
|
||||||
icon: "brands/facebook",
|
const copyIcon = ref("copy")
|
||||||
link: `https://www.facebook.com/sharer/sharer.php?u=${url}`,
|
const platforms = [
|
||||||
},
|
{
|
||||||
{
|
name: "Email",
|
||||||
name: "Reddit",
|
icon: "mail",
|
||||||
icon: "brands/reddit",
|
link: `mailto:?subject=${subject}&body=${summary}`,
|
||||||
link: `https://www.reddit.com/submit?url=${url}&title=${text}`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "LinkedIn",
|
|
||||||
icon: "brands/linkedin",
|
|
||||||
link: `https://www.linkedin.com/sharing/share-offsite/?url=${url}`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
{
|
||||||
copyAppLink() {
|
name: "Twitter",
|
||||||
copyToClipboard(this.url)
|
icon: "brands/twitter",
|
||||||
this.copyIcon = "check"
|
link: `https://twitter.com/intent/tweet?text=${text} ${description}&url=${url}&via=${twitter}`,
|
||||||
this.$toast.success(this.$t("state.copied_to_clipboard"), {
|
|
||||||
icon: "content_paste",
|
|
||||||
})
|
|
||||||
setTimeout(() => (this.copyIcon = "copy"), 1000)
|
|
||||||
},
|
|
||||||
hideModal() {
|
|
||||||
this.$emit("hide-modal")
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
{
|
||||||
|
name: "Facebook",
|
||||||
|
icon: "brands/facebook",
|
||||||
|
link: `https://www.facebook.com/sharer/sharer.php?u=${url}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Reddit",
|
||||||
|
icon: "brands/reddit",
|
||||||
|
link: `https://www.reddit.com/submit?url=${url}&title=${text}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "LinkedIn",
|
||||||
|
icon: "brands/linkedin",
|
||||||
|
link: `https://www.linkedin.com/sharing/share-offsite/?url=${url}`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
const copyAppLink = () => {
|
||||||
|
copyToClipboard(url)
|
||||||
|
copyIcon.value = "check"
|
||||||
|
$toast.success(t("state.copied_to_clipboard").toString(), {
|
||||||
|
icon: "content_paste",
|
||||||
|
})
|
||||||
|
setTimeout(() => (copyIcon.value = "copy"), 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
const hideModal = () => {
|
||||||
|
emit("hide-modal")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -26,50 +26,46 @@
|
|||||||
</aside>
|
</aside>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineComponent } from "@nuxtjs/composition-api"
|
import { useContext } from "@nuxtjs/composition-api"
|
||||||
import useWindowSize from "~/helpers/utils/useWindowSize"
|
import useWindowSize from "~/helpers/utils/useWindowSize"
|
||||||
import { useSetting } from "~/newstore/settings"
|
import { useSetting } from "~/newstore/settings"
|
||||||
|
|
||||||
export default defineComponent({
|
const {
|
||||||
setup() {
|
app: { i18n },
|
||||||
return {
|
} = useContext()
|
||||||
windowInnerWidth: useWindowSize(),
|
const t = i18n.t.bind(i18n)
|
||||||
EXPAND_NAVIGATION: useSetting("EXPAND_NAVIGATION"),
|
|
||||||
}
|
const windowInnerWidth = useWindowSize()
|
||||||
|
const EXPAND_NAVIGATION = useSetting("EXPAND_NAVIGATION")
|
||||||
|
|
||||||
|
const primaryNavigation = [
|
||||||
|
{
|
||||||
|
target: "index",
|
||||||
|
svg: "link-2",
|
||||||
|
title: t("navigation.rest"),
|
||||||
},
|
},
|
||||||
data() {
|
{
|
||||||
return {
|
target: "graphql",
|
||||||
primaryNavigation: [
|
svg: "graphql",
|
||||||
{
|
title: t("navigation.graphql"),
|
||||||
target: "index",
|
|
||||||
svg: "link-2",
|
|
||||||
title: this.$t("navigation.rest"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target: "graphql",
|
|
||||||
svg: "graphql",
|
|
||||||
title: this.$t("navigation.graphql"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target: "realtime",
|
|
||||||
svg: "globe",
|
|
||||||
title: this.$t("navigation.realtime"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target: "documentation",
|
|
||||||
svg: "book-open",
|
|
||||||
title: this.$t("navigation.doc"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target: "settings",
|
|
||||||
svg: "settings",
|
|
||||||
title: this.$t("navigation.settings"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
})
|
{
|
||||||
|
target: "realtime",
|
||||||
|
svg: "globe",
|
||||||
|
title: t("navigation.realtime"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: "documentation",
|
||||||
|
svg: "book-open",
|
||||||
|
title: t("navigation.doc"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: "settings",
|
||||||
|
svg: "settings",
|
||||||
|
title: t("navigation.settings"),
|
||||||
|
},
|
||||||
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -33,37 +33,34 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
import { defineComponent } from "@nuxtjs/composition-api"
|
import { onMounted, watch } from "@nuxtjs/composition-api"
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps<{
|
||||||
props: {
|
show: Boolean
|
||||||
show: {
|
}>()
|
||||||
type: Boolean,
|
|
||||||
required: true,
|
const emit = defineEmits<{
|
||||||
default: false,
|
(e: "close"): void
|
||||||
},
|
}>()
|
||||||
},
|
|
||||||
watch: {
|
watch(
|
||||||
show: {
|
() => props.show,
|
||||||
immediate: true,
|
(show) => {
|
||||||
handler(show) {
|
if (process.client) {
|
||||||
if (process.client) {
|
if (show) document.body.style.setProperty("overflow", "hidden")
|
||||||
if (show) document.body.style.setProperty("overflow", "hidden")
|
else document.body.style.removeProperty("overflow")
|
||||||
else document.body.style.removeProperty("overflow")
|
}
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
},
|
|
||||||
},
|
onMounted(() => {
|
||||||
mounted() {
|
document.addEventListener("keydown", (e) => {
|
||||||
document.addEventListener("keydown", (e) => {
|
if (e.keyCode === 27 && props.show) close()
|
||||||
if (e.keyCode === 27 && this.show) this.close()
|
})
|
||||||
})
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
close() {
|
|
||||||
this.$emit("close")
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
emit("close")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -23,10 +23,7 @@
|
|||||||
:description="$t('support.shortcuts')"
|
:description="$t('support.shortcuts')"
|
||||||
info-icon="chevron_right"
|
info-icon="chevron_right"
|
||||||
active
|
active
|
||||||
@click.native="
|
@click.native="showShortcuts()"
|
||||||
showShortcuts()
|
|
||||||
hideModal()
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
<SmartItem
|
<SmartItem
|
||||||
svg="gift"
|
svg="gift"
|
||||||
@@ -44,10 +41,7 @@
|
|||||||
:description="$t('support.chat')"
|
:description="$t('support.chat')"
|
||||||
info-icon="chevron_right"
|
info-icon="chevron_right"
|
||||||
active
|
active
|
||||||
@click.native="
|
@click.native="chatWithUs()"
|
||||||
chatWithUs()
|
|
||||||
hideModal()
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
<SmartItem
|
<SmartItem
|
||||||
svg="brands/discord"
|
svg="brands/discord"
|
||||||
@@ -74,25 +68,28 @@
|
|||||||
</SmartModal>
|
</SmartModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
import { defineComponent } from "@nuxtjs/composition-api"
|
|
||||||
import { invokeAction } from "~/helpers/actions"
|
import { invokeAction } from "~/helpers/actions"
|
||||||
import { showChat } from "~/helpers/support"
|
import { showChat } from "~/helpers/support"
|
||||||
|
|
||||||
export default defineComponent({
|
defineProps<{
|
||||||
props: {
|
show: Boolean
|
||||||
show: Boolean,
|
}>()
|
||||||
},
|
|
||||||
methods: {
|
const emit = defineEmits<{
|
||||||
chatWithUs() {
|
(e: "hide-modal"): void
|
||||||
showChat()
|
}>()
|
||||||
},
|
|
||||||
showShortcuts() {
|
const chatWithUs = () => {
|
||||||
invokeAction("flyouts.keybinds.toggle")
|
showChat()
|
||||||
},
|
hideModal()
|
||||||
hideModal() {
|
}
|
||||||
this.$emit("hide-modal")
|
|
||||||
},
|
const showShortcuts = () => {
|
||||||
},
|
invokeAction("flyouts.keybinds.toggle")
|
||||||
})
|
}
|
||||||
|
|
||||||
|
const hideModal = () => {
|
||||||
|
emit("hide-modal")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user