Skip to content

Commit

Permalink
App link hidding
Browse files Browse the repository at this point in the history
Fixes #122
  • Loading branch information
dyakovri committed Apr 5, 2024
1 parent 2dee279 commit ad34479
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 46 deletions.
9 changes: 9 additions & 0 deletions src/api/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ export interface AppButton {
type: ButtonType;
}

export interface ServiceData {
id: number;
order: number;
icon: string;
name: string;
link: string;
type: ButtonType;
}

export interface AppButtonCategory {
id: number;
order: number;
Expand Down
6 changes: 5 additions & 1 deletion src/api/services/ServicesApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseApi } from '../BaseApi';
import { AppButton, AppButtonCategory } from '../models';
import { AppButton, AppButtonCategory, ServiceData } from '../models';

type GetButtonsResponse = AppButtonCategory & {
buttons: AppButton[];
Expand Down Expand Up @@ -28,6 +28,10 @@ class ServicesApi extends BaseApi {
public getButtons(categoryId: number) {
return this.get<GetButtonsResponse>(`/category/${categoryId}/button/`);
}

public getService(serviceId: number) {
return this.get<ServiceData>(`/service/${serviceId}`);
}
}

export const servicesApi = new ServicesApi();
4 changes: 2 additions & 2 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const routes: RouteRecordRaw[] = [
component: AppsView,
},
{
path: '/apps/browser',
component: () => import('@/views/apps/browser/AppBrowserView.vue'),
path: '/apps/:id(\\d+)',
component: () => import('@/views/apps/ApplicationFrame.vue'),
},
{
path: '/timetable',
Expand Down
87 changes: 87 additions & 0 deletions src/views/apps/ApplicationFrame.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useToolbar } from '@/store/toolbar';
import { servicesApi } from '@/api/services/ServicesApi';
import { ButtonType } from '@/api/models';
import FullscreenLoader from '@/components/FullscreenLoader.vue';
const route = useRoute();
const toolbar = useToolbar();
const router = useRouter();
enum AppState {
Wait = 1,
Show = 2,
Error = 3,
}
const url = ref();
const appState = ref(AppState.Wait);
toolbar.setup({
backUrl: '/apps',
});
onMounted(async () => {
const appId = +route.params.id;
servicesApi
.getService(appId)
.then(async response => {
console.log(response);
if (
response.status == 200 &&
response.data.type == ButtonType.Internal &&
response.data.link
) {
appState.value = AppState.Show;
url.value = response.data.link;
toolbar.title = response.data.name;
} else {
appState.value = AppState.Error;
}
})
.catch(() => {
appState.value = AppState.Error;
});
});
</script>

<template>
<v-main>
<iframe
v-if="appState == AppState.Show"
:src="url"
frameborder="0"
class="iframe"
allow="camera"
/>
<FullscreenLoader v-else-if="appState == AppState.Wait" />
<div v-else class="exception-container">
<h2>Не удалось загрузить приложение</h2>
<v-btn @click="router.push('/apps')">Вернуться к списку приложений</v-btn>
</div>
</v-main>
</template>

<style scoped>
v-main,
.iframe {
flex: 1;
width: 100%;
height: 100%;
}
.exception-container {
display: flex;
flex-direction: column;
flex: 1;
place-content: space-around center;
width: 100%;
height: 100%;
}
.exception-container > * {
margin: 16px auto;
}
</style>
6 changes: 1 addition & 5 deletions src/views/apps/AsyncContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ const sendMarketing = (url: string) => {
{{ buttonName }}
</a>

<RouterLink
v-else-if="type === ButtonType.Internal"
:to="`/apps/browser/?title=${buttonName}#${link}`"
class="app-link"
>
<RouterLink v-else-if="type === ButtonType.Internal" :to="`/apps/${id}`" class="app-link">
{{ buttonName }}
</RouterLink>

Expand Down
38 changes: 0 additions & 38 deletions src/views/apps/browser/AppBrowserView.vue

This file was deleted.

0 comments on commit ad34479

Please sign in to comment.