Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.14.0 #54

Merged
merged 8 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wavelovers",
"version": "1.13.0",
"version": "1.14.0",
"description": "Wavelovers is a tool that can turn your gamepad into a vibration massager or simply a gamepad vibration and buttons test tool.",
"keywords": [
"wavelovers",
Expand Down
11 changes: 6 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<script setup lang="ts">
import { defineComponent, onMounted, onUnmounted } from 'vue';
import { RouterView } from 'vue-router';
import { useGamepads } from '@/store/useGamepads';
import LDefault from '@/layouts/LDefault.vue';
import { useLayouts } from '@/composables/useLayouts';
import { useGamepadsStore } from '@/store/useGamepadsStore';

defineComponent({
name: 'App',
});

const { addGamepad, deleteGamepad } = useGamepads();
const { layout } = useLayouts();
const { addGamepad, deleteGamepad } = useGamepadsStore();

/**
* Добавить слушатели событий.
Expand All @@ -31,7 +32,7 @@ onUnmounted(() => removeEventListeners());
</script>

<template>
<LDefault>
<Component :is="layout">
<RouterView />
</LDefault>
</Component>
</template>
14 changes: 2 additions & 12 deletions src/components/organisms/OCustom.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<script setup lang="ts">
import { defineComponent, ref } from 'vue';
import { storeToRefs } from 'pinia';
import { useGamepads } from '@/store/useGamepads';
import { AMessage } from '@/components/atoms';
import { MToolsNav, MGamepadList } from '@/components/molecules';
import { useGamepadsStore } from '@/store/useGamepadsStore';

defineComponent({
name: 'OCustom',
});

const store = useGamepads();
const { gamepads } = storeToRefs(store);
const { reset, loop } = store;
const { reset, loop } = useGamepadsStore();

/**
* Пауза перед стартом вибрации.
Expand Down Expand Up @@ -52,8 +47,6 @@ function start(): void {
</script>

<template>
<MToolsNav />

<div class="content-item app-custom">
<fieldset class="custom-form">
<label class="custom-form__input">
Expand Down Expand Up @@ -94,9 +87,6 @@ function start(): void {
</div>
</fieldset>
</div>

<MGamepadList v-if="gamepads.length" :gamepads="gamepads" />
<AMessage v-else>Press any gamepad button or connect a new gamepad to vibrate.</AMessage>
</template>

<style lang="scss">
Expand Down
12 changes: 3 additions & 9 deletions src/components/organisms/ODiagnostic.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<script setup lang="ts">
import { defineComponent } from 'vue';
import { storeToRefs } from 'pinia';
import { useGamepads } from '@/store/useGamepads';
import { AMessage } from '@/components/atoms';
import { MToolsNav, MGamepadList, MDiagnosticItem } from '@/components/molecules';
import { useGamepadsStore } from '@/store/useGamepadsStore';
import { MDiagnosticItem } from '@/components/molecules';

defineComponent({
name: 'ODiagnostic',
});

const store = useGamepads();
const store = useGamepadsStore();
const { gamepads, timestamp } = storeToRefs(store);
</script>

<template>
<MToolsNav />

<div v-if="gamepads.length" class="content-item">
<MDiagnosticItem
v-for="gamepad in gamepads"
Expand All @@ -24,7 +21,4 @@ const { gamepads, timestamp } = storeToRefs(store);
:timestamp="timestamp"
/>
</div>

<MGamepadList v-if="gamepads.length" :gamepads="gamepads" />
<AMessage v-else>Press any gamepad button or connect a new gamepad to vibrate.</AMessage>
</template>
11 changes: 2 additions & 9 deletions src/components/organisms/OManual.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<script setup lang="ts">
import { defineComponent, ref, onMounted, onUnmounted } from 'vue';
import { storeToRefs } from 'pinia';
import { useGamepads } from '@/store/useGamepads';
import { AMessage } from '@/components/atoms';
import { MToolsNav, MGamepadList } from '@/components/molecules';
import { useGamepadsStore } from '@/store/useGamepadsStore';

import type { TVibrator } from '@/models';

defineComponent({
name: 'OManual',
});

const store = useGamepads();
const store = useGamepadsStore();
const { gamepads, isActive, patternMode } = storeToRefs(store);
const { vibrate, reset } = store;

Expand Down Expand Up @@ -156,8 +154,6 @@ onUnmounted(() => clearInterval(interval.value));
</script>

<template>
<MToolsNav />

<div class="content-item app-manual">
<label class="manual-form__input">
<span>Weak Magnitude</span>
Expand Down Expand Up @@ -206,9 +202,6 @@ onUnmounted(() => clearInterval(interval.value));
</div>
</div>
</div>

<MGamepadList v-if="gamepads.length" :gamepads="gamepads" />
<AMessage v-else>Press any gamepad button or connect a new gamepad to vibrate.</AMessage>
</template>

<style lang="scss">
Expand Down
13 changes: 4 additions & 9 deletions src/components/organisms/OPatterns.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<script setup lang="ts">
import { defineComponent } from 'vue';
import { storeToRefs } from 'pinia';
import { useGamepads } from '@/store/useGamepads';
import { useGamepadsStore } from '@/store/useGamepadsStore';
import { AMessage } from '@/components/atoms';
import { MToolsNav, MGamepadList, MPatternList } from '@/components/molecules';
import { MPatternList } from '@/components/molecules';

defineComponent({
name: 'OPatterns',
});

const store = useGamepads();
const { gamepads, patternMode, isActive } = storeToRefs(store);
const store = useGamepadsStore();
const { patternMode, isActive } = storeToRefs(store);
const { change, patterns } = store;
</script>

<template>
<MToolsNav />

<div class="app-patterns">
<MPatternList
v-if="patterns.length"
Expand All @@ -27,7 +25,4 @@ const { change, patterns } = store;
/>
<AMessage v-else>Loading...</AMessage>
</div>

<MGamepadList v-if="gamepads.length" :gamepads="gamepads" />
<AMessage v-else>Press any gamepad button or connect a new gamepad to vibrate.</AMessage>
</template>
49 changes: 49 additions & 0 deletions src/composables/useLayouts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { computed } from 'vue';
import { useRoute } from 'vue-router';
import LDefault from '@/layouts/LDefault.vue';
import LGamepad from '@/layouts/LGamepad.vue';

import type { Component } from 'vue';

/**
* Лейауты.
*/
type Layouts = {
[index: string]: Component;
};

/**
* Результат работы композабла лейатов.
*/
type LayoutsComposable = {
layout: Component;
};

/**
* Лейауты.
*/
const layouts: Layouts = {
DEFAULT: LDefault,
GAMEPAD: LGamepad,
};

/**
* Композабл для получения соответствующего лейаута маршруту.
*
* @returns Лейаут.
*/
export function useLayouts(): LayoutsComposable {
const route = useRoute();

const layout = computed<Component>(() => {
const routeLayout = route?.meta?.layout;

return routeLayout && typeof routeLayout === 'string' ? layouts[routeLayout] : layouts.DEFAULT;
});

return {
layout,
};
}

export default useLayouts;
45 changes: 45 additions & 0 deletions src/layouts/LGamepad.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<script setup lang="ts">
import { defineComponent } from 'vue';
import { storeToRefs } from 'pinia';
import { useGamepadsStore } from '@/store/useGamepadsStore';
import { AMessage } from '@/components/atoms';
import { MHeader, MFooter, MToolsNav, MGamepadList } from '@/components/molecules';

defineComponent({
name: 'LGamepad',
});

const store = useGamepadsStore();
const { gamepads } = storeToRefs(store);
</script>

<template>
<MHeader />

<main class="page container">
<div class="wavelovers">
<MToolsNav />
<slot name="default" />

<MGamepadList v-if="gamepads.length" :gamepads="gamepads" />
<AMessage v-else>Press any gamepad button or connect a new gamepad to vibrate.</AMessage>
</div>
</main>

<MFooter />
</template>

<style lang="scss">
.page {
flex-grow: 1;
margin-top: 32px;
margin-bottom: 32px;
}

@media only screen and (min-width: 540px) {
.page {
margin-top: 64px;
margin-bottom: 64px;
}
}
</style>
12 changes: 12 additions & 0 deletions src/router/assets/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,33 @@ const routes: Array<RouteRecordRaw> = [
path: '/',
name: 'patterns-view',
component: () => import('@/views/PatternsView.vue'),
meta: {
layout: 'GAMEPAD',
},
},
{
path: '/custom',
name: 'custom-view',
component: () => import('@/views/CustomView.vue'),
meta: {
layout: 'GAMEPAD',
},
},
{
path: '/manual',
name: 'manual-view',
component: () => import('@/views/ManualView.vue'),
meta: {
layout: 'GAMEPAD',
},
},
{
path: '/diagnostic',
name: 'diagnostic-view',
component: () => import('@/views/DiagnosticView.vue'),
meta: {
layout: 'GAMEPAD',
},
},
{
path: '/faq',
Expand Down
4 changes: 3 additions & 1 deletion src/store/useGamepads.ts → src/store/useGamepadsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { TVibrator } from '@/models';
/**
* Стор геймпадов.
*/
export const useGamepads = defineStore('gamepads', () => {
export const useGamepadsStore = defineStore('gamepads', () => {
/**
* Номер шаблона вибрации.
*/
Expand Down Expand Up @@ -148,3 +148,5 @@ export const useGamepads = defineStore('gamepads', () => {
deleteGamepad,
};
});

export default useGamepadsStore;
Loading