-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hosub Lee <spyrr83@gmail.com>
- Loading branch information
Showing
8 changed files
with
126 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ services: | |
build: | ||
context: . | ||
ports: | ||
- 80:80 | ||
- 88:80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import axios from 'axios' | ||
|
||
const API_ADDR = 'http://localhost/api/v1' | ||
|
||
const state = { | ||
books: [{ | ||
// <id> : { | ||
// title: <title>, | ||
// author: <author>, | ||
// isActive: <true or false> | ||
// } | ||
}], | ||
sidebar: { | ||
isOpen: false, | ||
id: '', | ||
title: '', | ||
author: '', | ||
caption: 'New', | ||
}, | ||
} | ||
|
||
const mutations = { | ||
setBooks: function (state, books) { | ||
state.books = books | ||
}, | ||
openSidebar: function (state) { | ||
state.sidebar.isOpen = true | ||
}, | ||
closeSidebar: function (state) { | ||
state.sidebar.isOpen = false | ||
}, | ||
setSidebar: function (state, book) { | ||
state.sidebar = { | ||
...state.sidebar, | ||
...book | ||
} | ||
} | ||
} | ||
|
||
const getters = { | ||
book: function (state, id) { | ||
return state.books[id] | ||
}, | ||
allBooks: function (state) { | ||
return state.books | ||
}, | ||
sidebar: function (state) { | ||
return state.sidebar | ||
}, | ||
sidebarState: function (state) { | ||
return state.sidebar.isOpen | ||
} | ||
} | ||
|
||
const actions = { | ||
newBook: async function (context, book) { | ||
await axios.post(`${API_ADDR}/books`, { | ||
title: book.title, author: book.author | ||
}) | ||
context.dispatch('reset') | ||
}, | ||
updateBook: async function (context, book) { | ||
await axios.put(`${API_ADDR}/books/${book.id}`, { | ||
title: book.title, author: book.author | ||
}) | ||
context.dispatch('reset') | ||
}, | ||
reset: async function (context) { | ||
const res = await axios.get(`${API_ADDR}/books`) | ||
context.commit('setBooks', res.data) | ||
}, | ||
setSidebar: function (context, book) { | ||
context.commit('setSidebar', book) | ||
}, | ||
openSidebar: function (context) { | ||
context.commit('openSidebar') | ||
}, | ||
closeSidebar: function (context) { | ||
context.commit('closeSidebar') | ||
}, | ||
} | ||
|
||
export default { | ||
namespaced: true, | ||
state, | ||
mutations, | ||
actions, | ||
getters | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Vue from 'vue' | ||
import Vuex from 'vuex' | ||
import BookStore from './book' | ||
|
||
Vue.use(Vuex) | ||
|
||
export default new Vuex.Store({ | ||
modules: { | ||
book: BookStore | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters