Move auth_redirect and API base URL to global variables via the mixin.
This commit is contained in:
parent
572c8b1674
commit
0d3e0f8f5a
5 changed files with 7 additions and 29 deletions
|
|
@ -1,9 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="maximize_size">
|
<div class="maximize_size">
|
||||||
<LoginCard v-if="!is_authed" :redirect="auth.redirect" />
|
<LoginCard v-if="!is_authed" />
|
||||||
<MainView
|
<MainView
|
||||||
v-else
|
v-else
|
||||||
:auth_redirect="auth.redirect"
|
|
||||||
:preview_mode="is_preview"
|
:preview_mode="is_preview"
|
||||||
:dev_mode="is_dev"
|
:dev_mode="is_dev"
|
||||||
/>
|
/>
|
||||||
|
|
@ -24,11 +23,6 @@ export default {
|
||||||
"LoginCard": LoginCard,
|
"LoginCard": LoginCard,
|
||||||
"MainView": MainView
|
"MainView": MainView
|
||||||
},
|
},
|
||||||
data() { return {
|
|
||||||
auth: {
|
|
||||||
redirect: process.env.NODE_ENV === `production` ? `https://oliver.akins.me/top-lists` : `http://localhost:8080`
|
|
||||||
}
|
|
||||||
} },
|
|
||||||
computed: {
|
computed: {
|
||||||
is_dev() {
|
is_dev() {
|
||||||
let params = new URLSearchParams(window.location.search.slice(1));
|
let params = new URLSearchParams(window.location.search.slice(1));
|
||||||
|
|
|
||||||
|
|
@ -93,17 +93,9 @@ export default {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
api_url: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
token: {
|
token: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
|
||||||
auth_redirect: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,6 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'LoginView',
|
name: 'LoginView',
|
||||||
props: {
|
|
||||||
redirect: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() { return {
|
data() { return {
|
||||||
alert: `We will only be able to access your top tracks and artists, nothing else. This is also only done on your browser. Our servers do not see any of the data from your account.`,
|
alert: `We will only be able to access your top tracks and artists, nothing else. This is also only done on your browser. Our servers do not see any of the data from your account.`,
|
||||||
auth_base: `https://accounts.spotify.com/authorize`,
|
auth_base: `https://accounts.spotify.com/authorize`,
|
||||||
|
|
@ -35,7 +29,7 @@ export default {
|
||||||
let params = [
|
let params = [
|
||||||
`client_id=${this.client_id}`,
|
`client_id=${this.client_id}`,
|
||||||
`response_type=token`,
|
`response_type=token`,
|
||||||
`redirect_uri=${encodeURIComponent(this.redirect)}`,
|
`redirect_uri=${encodeURIComponent(this.auth_redirect)}`,
|
||||||
`scope=${encodeURIComponent(this.scopes.join(" "))}`,
|
`scope=${encodeURIComponent(this.scopes.join(" "))}`,
|
||||||
`show_dialog=${this.show_dialog}`
|
`show_dialog=${this.show_dialog}`
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
<Control
|
<Control
|
||||||
:dev="dev_mode"
|
:dev="dev_mode"
|
||||||
:preview="preview_mode"
|
:preview="preview_mode"
|
||||||
:api_url="api_base"
|
|
||||||
:auth_redirect="auth_redirect"
|
:auth_redirect="auth_redirect"
|
||||||
:token="get_token()"
|
:token="get_token()"
|
||||||
:data_exists="data.length !== 0"
|
:data_exists="data.length !== 0"
|
||||||
|
|
@ -39,10 +38,6 @@ export default {
|
||||||
dev_mode: {
|
dev_mode: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
|
||||||
auth_redirect: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -54,7 +49,6 @@ export default {
|
||||||
config: {},
|
config: {},
|
||||||
data: [],
|
data: [],
|
||||||
error: ``,
|
error: ``,
|
||||||
api_base: `https://api.spotify.com/v1`,
|
|
||||||
};},
|
};},
|
||||||
computed: {
|
computed: {
|
||||||
items() {
|
items() {
|
||||||
|
|
@ -70,7 +64,7 @@ export default {
|
||||||
console.log("Handling the export");
|
console.log("Handling the export");
|
||||||
},
|
},
|
||||||
get_data(config) {
|
get_data(config) {
|
||||||
let url = `${this.api_base}/me/top/${config.type.toLowerCase()}`;
|
let url = `${this.api_url}/me/top/${config.type.toLowerCase()}`;
|
||||||
|
|
||||||
let limit = config.limit || 10;
|
let limit = config.limit || 10;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@ Vue.use(VueEllipseProgress, `percent`);
|
||||||
|
|
||||||
// global mixings
|
// global mixings
|
||||||
Vue.mixin({
|
Vue.mixin({
|
||||||
|
data() {return {
|
||||||
|
api_url: `https://api.spotify.com/v1`,
|
||||||
|
auth_redirect: process.env.NODE_ENV === `production` ? `https://oliver.akins.me/top-lists` : `http://localhost:8080`,
|
||||||
|
}},
|
||||||
methods: {
|
methods: {
|
||||||
css_var(var_name) {
|
css_var(var_name) {
|
||||||
return getComputedStyle(document.documentElement).getPropertyValue(var_name);
|
return getComputedStyle(document.documentElement).getPropertyValue(var_name);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue