Skip to content

Commit

Permalink
Finished Custom Nitro H3 API Impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
Type-32 committed Feb 24, 2024
1 parent 13eef3f commit 9006e1e
Show file tree
Hide file tree
Showing 9 changed files with 1,286 additions and 1,124 deletions.
38 changes: 35 additions & 3 deletions app.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<script setup lang="ts">
const { finalizePendingLocaleChange } = useI18n()
const config = useRuntimeConfig()
const i18n = useI18n()
const showModal = ref(true)
const onBeforeEnter = async () => {
await finalizePendingLocaleChange()
function closeModal(){
showModal.value = false;
}
function stopShowingModal(){
localStorage.setItem('show-support-modal', "false");
showModal.value = false;
}
useHead({
Expand All @@ -25,12 +30,39 @@ useSeoMeta({
ogImage: '/moodhelper.png',
twitterCard: 'summary_large_image',
})
onBeforeMount(() => {
const dontShowSupportModal = localStorage.getItem('show-support-modal')
if (dontShowSupportModal) showModal.value = false;
})
</script>

<template>
<html data-theme="light" class="max-h-screen">
<NuxtLayout>
<dialog id="support_on_kofi_modal" :class="`modal ${showModal ? 'modal-open' : ''}`">
<div class="modal-box">
<h3 class="font-bold text-lg">{{ $t('support-modal.title') }}</h3>
<p class="py-4">{{ $t('support-modal.text') }}</p>
<div class="modal-action grid grid-cols-2 items-center w-full justify-center">
<a class="btn btn-primary" href="https://ko-fi.com/type32">{{ $t('support-modal.support') }}</a>
<button class="btn" @click="closeModal()">{{ $t('support-modal.deny') }}</button>
</div>
<button class="btn btn-sm btn-ghost w-full mt-2" @click="stopShowingModal()">{{ $t('support-modal.stop-showing-modal') }}</button>
</div>
</dialog>
<NuxtPage/>
<footer class="footer p-10 bg-neutral text-neutral-content mt-20">
<aside>
<svg width="50" height="50" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" class="fill-current"><path d="M22.672 15.226l-2.432.811.841 2.515c.33 1.019-.209 2.127-1.23 2.456-1.15.325-2.148-.321-2.463-1.226l-.84-2.518-5.013 1.677.84 2.517c.391 1.203-.434 2.542-1.831 2.542-.88 0-1.601-.564-1.86-1.314l-.842-2.516-2.431.809c-1.135.328-2.145-.317-2.463-1.229-.329-1.018.211-2.127 1.231-2.456l2.432-.809-1.621-4.823-2.432.808c-1.355.384-2.558-.59-2.558-1.839 0-.817.509-1.582 1.327-1.846l2.433-.809-.842-2.515c-.33-1.02.211-2.129 1.232-2.458 1.02-.329 2.13.209 2.461 1.229l.842 2.515 5.011-1.677-.839-2.517c-.403-1.238.484-2.553 1.843-2.553.819 0 1.585.509 1.85 1.326l.841 2.517 2.431-.81c1.02-.33 2.131.211 2.461 1.229.332 1.018-.21 2.126-1.23 2.456l-2.433.809 1.622 4.823 2.433-.809c1.242-.401 2.557.484 2.557 1.838 0 .819-.51 1.583-1.328 1.847m-8.992-6.428l-5.01 1.675 1.619 4.828 5.011-1.674-1.62-4.829z"></path></svg>
<p>{{ $t('main.footer.org') }}<br>{{ $t('main.footer.org_desc') }}<br><b>{{ $t("role.assistant") }}</b> {{ $t('main.footer.built-with-love') }}</p>
</aside>
<nav>
<h6 class="footer-title">{{ $t('main.footer.nav.links') }}</h6>
<a href="https://ko-fi.com/type32" class="link link-hover">{{ $t('main.footer.nav.links.kofi-support') }}</a>
<a href="https://github.com/Type-32" class="link link-hover">{{ $t('main.footer.nav.links.view-github') }}</a>
</nav>
</footer>
</NuxtLayout>
</html>
</template>
Expand Down
6 changes: 5 additions & 1 deletion locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@
"role.assistant.desc": "MoodHelper is a mood-management assistance bot using Mistral AI.",
"locales.title": "Locales",
"locales.en": "English",
"locales.cn": "Chinese"
"locales.cn": "Chinese",
"main.response.error": "An error occurred while generating a response. Please refresh the page. If this issue persists, please contact the site admin.",
"docs.coming_soon": "Coming Soon...",
"main.check_docs.1": "Want to use it in your own project?",
"main.check_docs.2": "Check out our docs!"
}
6 changes: 5 additions & 1 deletion locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@
"role.assistant.desc": "情绪帮手是一个帮助人控制情绪的AI助手,由 Mistral AI 驱动。",
"locales.title": "语言",
"locales.en": "英语",
"locales.cn": "中文"
"locales.cn": "中文",
"main.response.error": "哦不!在生成回复时遇到一个错误。请刷新该网页;若该问题持续发生,请联系站点管理员。",
"docs.coming_soon": "敬请等待...",
"main.check_docs.1": "想要在你自己的项目中使用吗?",
"main.check_docs.2": "来看看我们的文档吧!"
}
16 changes: 13 additions & 3 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,24 @@ export default defineNuxtConfig({
},
devtools: { enabled: true },
css: ['~/assets/main.css'],
modules: ['@nuxtjs/tailwindcss', '@nuxtjs/i18n', '@nuxt/content'],
modules: ['@nuxtjs/tailwindcss', 'nuxt-rate-limit', '@nuxtjs/i18n', '@nuxt/content'],
nuxtRateLimit: {
routes: {
'/api/v1/*': {
maxRequests: (!process.env.NUXT_API_RATE_LIMIT ? 50 : process.env.NUXT_API_RATE_LIMIT as unknown as number),
intervalSeconds: ((!process.env.NUXT_API_WINDOW_DURATION ? 15 * 60 : process.env.NUXT_API_WINDOW_DURATION as unknown as number * 60)),
},
},
},
runtimeConfig: {
apiRateLimit: 50, // Default: 50 requests per min
apiWindowDuration: 15, // Default: 15 minutes
openaiApiKey: '',
public:{
openaiApiKey: '',
apiModel: 'gpt-3.5-turbo',
aiEndpoint: 'https://api.openai.com/v1/chat/completions',
siteUrl: '',
siteName: '',
}
}
},
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "nuxt-app",
"name": "moodhelper-nuxt",
"private": true,
"type": "module",
"scripts": {
Expand All @@ -16,6 +16,7 @@
"@tailwindcss/typography": "^0.5.10",
"express": "^4.18.2",
"nuxt": "^3.10.2",
"nuxt-rate-limit": "^1.2.0",
"openai": "^4.28.0",
"vue": "^3.4.19",
"vue-markdown-render": "^2.1.1",
Expand Down
28 changes: 28 additions & 0 deletions pages/docs/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script setup lang="ts">
const i18n = useI18n()
const { locale, locales, setLocale } = useI18n()
const selectedLocale = computed({
get: () => locale.value,
set: (value) => {
// console.log(value)
localStorage.setItem('page-locale', value)
locale.value = value
}
})
onBeforeMount(() => {
const dontShowSupportModal = localStorage.getItem('show-support-modal')
if (dontShowSupportModal) showModal.value = false;
locale.value = localStorage.getItem('page-locale') || i18n.getBrowserLocale() || 'en'
})
</script>

<template>
<div class="min-h-screen w-full flex justify-center items-center">
<span class="text-center text-base-content">{{ $t('docs.coming_soon') }}</span>
</div>
</template>

<style scoped>
</style>
Loading

0 comments on commit 9006e1e

Please sign in to comment.