Clean vuex
This commit is contained in:
parent
ccb046a08a
commit
8c6c40cd78
@ -7,11 +7,11 @@
|
||||
:key="link.name"
|
||||
class="text-blue-200"
|
||||
>
|
||||
<router-link
|
||||
<nuxt-link
|
||||
v-if="link.url"
|
||||
:to="link.url"
|
||||
class="underline"
|
||||
>{{ link.name }}</router-link
|
||||
>{{ link.name }}</nuxt-link
|
||||
>
|
||||
<button v-else class="underline" @click="link.action">
|
||||
{{ link.name }}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
import { mapState, mapActions, mapGetters } from 'vuex'
|
||||
import renderMarkdown from '@/utils/markdown'
|
||||
|
||||
export default {
|
||||
@ -20,6 +20,7 @@ export default {
|
||||
}),
|
||||
computed: {
|
||||
...mapState('notes', ['notes', 'isInitialized']),
|
||||
...mapGetters('notes', ['find']),
|
||||
uuid() {
|
||||
return this.$route.params.uuid
|
||||
},
|
||||
@ -27,11 +28,11 @@ export default {
|
||||
mounted() {
|
||||
if (!this.isInitialized) {
|
||||
this.load().then(() => {
|
||||
this.note = this.notes.find((e) => e.uuid === this.uuid)
|
||||
this.note = this.find(this.uuid)
|
||||
this.render()
|
||||
})
|
||||
} else {
|
||||
this.note = this.notes.find((e) => e.uuid === this.uuid)
|
||||
this.note = this.find(this.uuid)
|
||||
this.render()
|
||||
}
|
||||
},
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="container p-4 mx-auto bg-gray-700">
|
||||
<div class="container p-4 mx-auto bg-gray-800">
|
||||
<h1 class="text-center">My Notes</h1>
|
||||
<input
|
||||
id="search"
|
||||
@ -10,9 +10,9 @@
|
||||
/>
|
||||
<div v-for="note in notes" :key="note.uuid">
|
||||
<div class="flex justify-between items-center">
|
||||
<router-link :to="'/notes/' + note.uuid" class="text-lg">{{
|
||||
<nuxt-link :to="'/notes/' + note.uuid" class="text-lg">{{
|
||||
note.title
|
||||
}}</router-link>
|
||||
}}</nuxt-link>
|
||||
<div class="py-2">
|
||||
<span
|
||||
v-for="(tag, index) in note.tags"
|
||||
|
||||
@ -48,7 +48,6 @@ export const actions = {
|
||||
}
|
||||
|
||||
export const getters = {
|
||||
isEmpty(state) {
|
||||
return state.isInitialized && state.notes.length === 0
|
||||
},
|
||||
isEmpty: (state) => state.isInitialized && state.notes.length === 0,
|
||||
find: (state) => (uuid) => state.notes.find((note) => note.uuid === uuid),
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user