refacto: migrate to composition API everywhere
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
<script lang="ts" setup>
|
||||
import { useI18n } from "vue-i18n"
|
||||
|
||||
import { locales } from "@/locales/message"
|
||||
|
||||
const { t } = useI18n()
|
||||
const i18n = useI18n()
|
||||
|
||||
const toggleLanguage = () =>
|
||||
(i18n.locale.value =
|
||||
locales[(locales.indexOf(i18n.locale.value) + 1) % locales.length])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<footer class="footer-translation">
|
||||
<button class="button" @click="toggleLanguage">
|
||||
@@ -5,26 +18,3 @@
|
||||
</button>
|
||||
</footer>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue"
|
||||
import { useI18n } from "vue-i18n"
|
||||
|
||||
import { locales } from "@/locales/message"
|
||||
|
||||
export default defineComponent({
|
||||
name: "FooterTranslation",
|
||||
setup() {
|
||||
const { t } = useI18n()
|
||||
|
||||
const i18n = useI18n()
|
||||
|
||||
return {
|
||||
t,
|
||||
toggleLanguage: () =>
|
||||
(i18n.locale.value =
|
||||
locales[(locales.indexOf(i18n.locale.value) + 1) % locales.length]),
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
<script lang="ts" setup>
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const { push } = useRouter()
|
||||
|
||||
const back = () =>
|
||||
push({
|
||||
name: 'Home'
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button class="button is-white go-back" @click="back">
|
||||
<svg
|
||||
@@ -20,25 +31,6 @@
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'GoBack',
|
||||
setup() {
|
||||
const { push } = useRouter()
|
||||
|
||||
return {
|
||||
back: () =>
|
||||
push({
|
||||
name: 'Home'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.go-back {
|
||||
margin: 10px 0;
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
<script lang="ts" setup>
|
||||
const url = new URL('https://github.com/login/oauth/authorize')
|
||||
url.searchParams.append('client_id', 'Iv1.87be14adcc912fa0')
|
||||
url.searchParams.append('redirect_uri', location.href)
|
||||
url.searchParams.append('scope', 'repo')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="login-github">
|
||||
<br />
|
||||
@@ -28,21 +35,3 @@
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'LoginGithub',
|
||||
setup() {
|
||||
const url = new URL('https://github.com/login/oauth/authorize')
|
||||
url.searchParams.append('client_id', 'Iv1.87be14adcc912fa0')
|
||||
url.searchParams.append('redirect_uri', location.href)
|
||||
url.searchParams.append('scope', 'repo')
|
||||
|
||||
return {
|
||||
url
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { useLastVisitedRepos } from '@/modules/history/hooks/useLastVisitedRepos.hook'
|
||||
|
||||
const { lastVisitedRepos } = useLastVisitedRepos()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section v-if="lastVisitedRepos.length" class="last-visited">
|
||||
<h4>Last visited repos</h4>
|
||||
@@ -23,23 +29,6 @@
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
import { useLastVisitedRepos } from '@/modules/history/hooks/useLastVisitedRepos.hook'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'LastVisited',
|
||||
setup() {
|
||||
const { lastVisitedRepos } = useLastVisitedRepos()
|
||||
|
||||
return {
|
||||
lastVisitedRepos
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.last-visited {
|
||||
li {
|
||||
|
||||
5
src/shims-vue.d.ts
vendored
5
src/shims-vue.d.ts
vendored
@@ -1,8 +1,3 @@
|
||||
declare module "*.vue" {
|
||||
import { defineComponent } from "vue"
|
||||
const component: ReturnType<typeof defineComponent>
|
||||
export default component
|
||||
}
|
||||
declare module "pouchdb-adapter-indexeddb"
|
||||
declare module "@toycode/markdown-it-class"
|
||||
declare module "markdown-it-block-embed"
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import GoBack from '@/components/GoBack.vue'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="about content">
|
||||
<go-back />
|
||||
@@ -21,16 +25,6 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
import GoBack from '@/components/GoBack.vue'
|
||||
|
||||
export default defineComponent({
|
||||
components: { GoBack }
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.about {
|
||||
padding: 1rem;
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
<script lang="ts" setup>
|
||||
import GoBack from '@/components/GoBack.vue'
|
||||
import { useGitHubLogin } from '@/hooks/useGitHubLogin.hook'
|
||||
import { useRepos } from '@/hooks/useRepos.hook'
|
||||
import { useRepoList } from '@/modules/repo/hooks/useRepoList.hook'
|
||||
|
||||
const { username } = useGitHubLogin()
|
||||
const { isReady } = useRepos()
|
||||
const { favoriteRepos, otherRepos, favoriteCheckboxes, toggleCheckbox } =
|
||||
useRepoList()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="repo-list">
|
||||
<h1 class="title is-1">Repositories</h1>
|
||||
@@ -78,35 +90,6 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
import GoBack from '@/components/GoBack.vue'
|
||||
import { useGitHubLogin } from '@/hooks/useGitHubLogin.hook'
|
||||
import { useRepos } from '@/hooks/useRepos.hook'
|
||||
import { useRepoList } from '@/modules/repo/hooks/useRepoList.hook'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'RepoList',
|
||||
components: { GoBack },
|
||||
setup() {
|
||||
const { username } = useGitHubLogin()
|
||||
const { isReady } = useRepos()
|
||||
const { favoriteRepos, otherRepos, favoriteCheckboxes, toggleCheckbox } =
|
||||
useRepoList()
|
||||
|
||||
return {
|
||||
isReady,
|
||||
username,
|
||||
favoriteRepos,
|
||||
otherRepos,
|
||||
favoriteCheckboxes,
|
||||
toggleCheckbox
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.repo-list {
|
||||
flex: 1;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="space-cowboy content">
|
||||
<p>
|
||||
@@ -44,14 +47,6 @@
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SpaceCowboy'
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.space-cowboy {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user