Просмотр исходного кода

fix(song reports): page no longer reloads

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 5 лет назад
Родитель
Сommit
b7efd52efe
2 измененных файлов с 42 добавлено и 30 удалено
  1. 7 3
      frontend/components/Modals/EditSong.vue
  2. 35 27
      frontend/components/pages/Admin.vue

+ 7 - 3
frontend/components/Modals/EditSong.vue

@@ -197,11 +197,15 @@
 							<span v-else>&nbsp;Report</span>
 						</span>
 						<div v-for="(report, index) in reports" :key="index">
-							<a
-								:href="`/admin/reports?id=${report}`"
+							<router-link
+								:to="{
+									path: '/admin/reports',
+									query: { id: report }
+								}"
 								class="report-link"
-								>Report - {{ report }}</a
 							>
+								Report - {{ report }}
+							</router-link>
 						</div>
 					</div>
 				</article>

+ 35 - 27
frontend/components/pages/Admin.vue

@@ -119,36 +119,44 @@ export default {
 		};
 	},
 	mounted() {
-		switch (window.location.pathname) {
-			case "/admin/queuesongs":
-				this.currentTab = "queueSongs";
-				break;
-			case "/admin/songs":
-				this.currentTab = "songs";
-				break;
-			case "/admin/stations":
-				this.currentTab = "stations";
-				break;
-			case "/admin/reports":
-				this.currentTab = "reports";
-				break;
-			case "/admin/news":
-				this.currentTab = "news";
-				break;
-			case "/admin/users":
-				this.currentTab = "users";
-				break;
-			case "/admin/statistics":
-				this.currentTab = "statistics";
-				break;
-			case "/admin/punishments":
-				this.currentTab = "punishments";
-				break;
-			default:
-				this.currentTab = "queueSongs";
+		this.changeTab(this.$route.path);
+	},
+	watch: {
+		$route(route) {
+			this.changeTab(route.path);
 		}
 	},
 	methods: {
+		changeTab: function(path) {
+			switch (path) {
+				case "/admin/queuesongs":
+					this.currentTab = "queueSongs";
+					break;
+				case "/admin/songs":
+					this.currentTab = "songs";
+					break;
+				case "/admin/stations":
+					this.currentTab = "stations";
+					break;
+				case "/admin/reports":
+					this.currentTab = "reports";
+					break;
+				case "/admin/news":
+					this.currentTab = "news";
+					break;
+				case "/admin/users":
+					this.currentTab = "users";
+					break;
+				case "/admin/statistics":
+					this.currentTab = "statistics";
+					break;
+				case "/admin/punishments":
+					this.currentTab = "punishments";
+					break;
+				default:
+					this.currentTab = "queueSongs";
+			}
+		},
 		showTab: function(tab) {
 			this.currentTab = tab;
 		}