Finish up migration, currently not setup for foss version

This commit is contained in:
2025-09-28 14:33:13 +02:00
parent 0315241d76
commit 84b640ee5e
9 changed files with 140 additions and 125 deletions

View File

@@ -13,12 +13,12 @@
</template>
<script setup lang="ts">
import {
ref
} from 'vue';
import {
RouterView
} from 'vue-router';
import {
ref
} from 'vue';
const theme = ref( 'light_mode' );

View File

@@ -1,11 +1,13 @@
import App from './App.vue';
import {
createApp
} from 'vue';
import {
createPinia
} from 'pinia';
import App from './App.vue';
import router from './router';
import sdk from '@janishutz/login-sdk-browser';
const app = createApp( App );
@@ -14,5 +16,11 @@ app.use( router );
// localStorage.setItem( 'url', 'http://localhost:8082' );
localStorage.setItem( 'url', 'https://music-api.janishutz.com' );
sdk.setUp(
'jh-music',
String( localStorage.getItem( 'url' ) ),
'/app',
false // Set to false for deploy to actual backend
);
app.mount( '#app' );

View File

@@ -6,10 +6,9 @@ import {
// FOSS-VERSION: To enable the UI to be used with the FOSS version, change "isUserAuth" to true, you will be "logged in"
export const useUserStore = defineStore( 'user', {
'state': () => ( {
'isUserAuth': true,
'isUserAuth': false,
'hasSubscribed': false,
'isUsingKeyboard': false,
'username': '',
'isFOSSVersion': false
} ),
'getters': {
@@ -23,9 +22,6 @@ export const useUserStore = defineStore( 'user', {
setSubscriptionStatus ( status: boolean ) {
this.hasSubscribed = status;
},
setUsername ( username: string ) {
this.username = username;
},
setKeyboardUsageStatus ( status: boolean ) {
this.isUsingKeyboard = status;
}

View File

@@ -24,36 +24,24 @@
<script setup lang="ts">
// TODO: Make possible to install and use without account, if using FOSS version
import router from '@/router';
import {
RouterLink
} from 'vue-router';
import {
useUserStore
} from '@/stores/userStore';
import notificationsModule from '@/components/notificationsModule.vue';
import {
ref
} from 'vue';
import router from '@/router';
import sdk from '@janishutz/login-sdk-browser';
import {
useUserStore
} from '@/stores/userStore';
const notifications = ref( notificationsModule );
const isTryingToSignIn = ref( true );
interface JanishutzIDSDK {
'setLoginSDKURL': ( url: string ) => undefined;
'createSession': () => undefined;
'verifySession': () => Promise<JHIDSessionStatus>
}
interface JHIDSessionStatus {
'status': boolean;
'username': string;
}
let sdk: JanishutzIDSDK;
const login = () => {
sdk.createSession();
sdk.login();
};
const store = useUserStore();
@@ -62,11 +50,10 @@
router.push( localStorage.getItem( 'redirect' ) ?? '/app' );
localStorage.removeItem( 'redirect' );
} else {
if ( typeof sdk !== 'undefined' ) {
sdk.verifySession().then( res => {
if ( res.status ) {
sdk.verifyFull()
.then( res => {
if ( res ) {
store.isUserAuth = true;
store.username = res.username;
if ( localStorage.getItem( 'close-tab' ) ) {
localStorage.removeItem( 'close-tab' );
@@ -80,7 +67,6 @@
isTryingToSignIn.value = false;
}
} );
}
}
</script>