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>
|
<template>
|
||||||
<footer class="footer-translation">
|
<footer class="footer-translation">
|
||||||
<button class="button" @click="toggleLanguage">
|
<button class="button" @click="toggleLanguage">
|
||||||
@@ -5,26 +18,3 @@
|
|||||||
</button>
|
</button>
|
||||||
</footer>
|
</footer>
|
||||||
</template>
|
</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>
|
<template>
|
||||||
<button class="button is-white go-back" @click="back">
|
<button class="button is-white go-back" @click="back">
|
||||||
<svg
|
<svg
|
||||||
@@ -20,25 +31,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</template>
|
</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>
|
<style lang="scss" scoped>
|
||||||
.go-back {
|
.go-back {
|
||||||
margin: 10px 0;
|
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>
|
<template>
|
||||||
<div class="login-github">
|
<div class="login-github">
|
||||||
<br />
|
<br />
|
||||||
@@ -28,21 +35,3 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</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>
|
<template>
|
||||||
<section v-if="lastVisitedRepos.length" class="last-visited">
|
<section v-if="lastVisitedRepos.length" class="last-visited">
|
||||||
<h4>Last visited repos</h4>
|
<h4>Last visited repos</h4>
|
||||||
@@ -23,23 +29,6 @@
|
|||||||
</section>
|
</section>
|
||||||
</template>
|
</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">
|
<style scoped lang="scss">
|
||||||
.last-visited {
|
.last-visited {
|
||||||
li {
|
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 "pouchdb-adapter-indexeddb"
|
||||||
declare module "@toycode/markdown-it-class"
|
declare module "@toycode/markdown-it-class"
|
||||||
declare module "markdown-it-block-embed"
|
declare module "markdown-it-block-embed"
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import GoBack from '@/components/GoBack.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="about content">
|
<div class="about content">
|
||||||
<go-back />
|
<go-back />
|
||||||
@@ -21,16 +25,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { defineComponent } from 'vue'
|
|
||||||
|
|
||||||
import GoBack from '@/components/GoBack.vue'
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
components: { GoBack }
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.about {
|
.about {
|
||||||
padding: 1rem;
|
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>
|
<template>
|
||||||
<div class="repo-list">
|
<div class="repo-list">
|
||||||
<h1 class="title is-1">Repositories</h1>
|
<h1 class="title is-1">Repositories</h1>
|
||||||
@@ -78,35 +90,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</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>
|
<style lang="scss" scoped>
|
||||||
.repo-list {
|
.repo-list {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<main class="space-cowboy content">
|
<main class="space-cowboy content">
|
||||||
<p>
|
<p>
|
||||||
@@ -44,14 +47,6 @@
|
|||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { defineComponent } from 'vue'
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'SpaceCowboy'
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.space-cowboy {
|
.space-cowboy {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
Reference in New Issue
Block a user