Procházet zdrojové kódy

Moving user to Vuex, add app create button

Ecconia před 7 roky
rodič
revize
775c20555f
3 změnil soubory, kde provedl 28 přidání a 10 odebrání
  1. 7 2
      src/App.vue
  2. 11 8
      src/store.js
  3. 10 0
      src/views/Applications.vue

+ 7 - 2
src/App.vue

@@ -31,15 +31,20 @@
 	export default {
 		data () {
 			return {
-				user: null,
 				menu_entries: {
 					'Startpage': '/',
 					'Applications': '/applications',
 					'Development Blog': '/devblog',
-				}
+				},
 			}
 		},
 
+		computed: {
+			user() {
+				return this.$store.state.user
+			},
+		},
+
 		components: {
 			MenuContainer
 		},

+ 11 - 8
src/store.js

@@ -4,13 +4,16 @@ import Vuex from 'vuex'
 Vue.use(Vuex)
 
 export default new Vuex.Store({
-  state: {
+	strict: process.env.NODE_ENV !== 'production',
+	state: {
+		user: null,
+	},
+	mutations: {
+		setUser(state, user) {
+			state.user = user
+		}
+	},
+	actions: {
 
-  },
-  mutations: {
-
-  },
-  actions: {
-
-  }
+	}
 })

+ 10 - 0
src/views/Applications.vue

@@ -3,6 +3,11 @@
 		<h1>Applications:</h1>
 		<p>This area is basically the first big GOAL of the final product. Creating and Judging apps. The path to get here is quite long though, many other issues have to be solved first.</p>
 
+		<div v-if="getUser && getUser.rank === undefined">
+			<router-link to="/myapp" v-if="getUser.appstate === 0">Create application.</router-link>
+			<router-link to="/myapp" v-else-if="getUser.appstate === 1">Edit application.</router-link>
+		</div>
+
 		<div class="app-container">
 			<router-link class="app-entry" :to="{ name: 'application', params: { id: app.id }}" v-for="app in apps" :key="app.id">
 				<p>Name: {{ app.playername }} </p>
@@ -52,6 +57,11 @@
 		},
 		created () {
 		},
+		computed: {
+			getUser() {
+				return this.$store.state.user
+			},
+		},
 		methods: {
 			readableTime(timestamp) {
 				let date = new Date(timestamp * 1000)