Decomposited vuex-store to patterns and gamepads modules. Describe interfaces for vuex-states. Updated sitemaps. Rebuild production.

This commit is contained in:
Eugene Serb 2022-08-06 00:06:30 +03:00
parent 06f4c26226
commit d3cdd92890
15 changed files with 169 additions and 86 deletions

View File

@ -15,4 +15,4 @@
webvisor: true
});</script><style>[v-cloak] {
display: none;
}</style><script defer="defer" src="/js/chunk-vendors.d42e1256.js"></script><script defer="defer" src="/js/app.b6a47de1.js"></script><link href="/css/app.a72a8a93.css" rel="stylesheet"></head><body><header class="header"><div class="header-wrapper container"><div class="logo-wrapper"><span class="logo-wrapper__logo" translate="no">Wavelovers</span></div><nav class="menu-wrapper"><ul class="navigation"><li class="navigation__item"><a href="/" target="_self" class="navigation__link">Home</a></li><li class="navigation__item"><a href="/faq.html" target="_self" class="navigation__link">FAQ</a></li><li class="navigation__item"><a href="/about.html" target="_self" class="navigation__link">About</a></li><li class="navigation__item"><a href="/donate.html" target="_self" class="navigation__link">Donate</a></li></ul></nav></div></header><main class="page container"><h1 class="visually-hidden">Wavelovers</h1><div id="app" v-cloak></div></main><footer class="footer"><div class="footer-wrapper container"><div class="annotation"><span class="annotation__text">© 2022 Wavelovers. Content licensed under </span><a href="https://wavelovers.ru/LICENSE.md" target="_blank">GNU General Public License v3.0</a><br><span class="annotation__text">This site is open source. </span><a href="https://github.com/eugene-serb/wavelovers/" target="_blank">Improve this page.</a></div><div class="annotation created-by"><span class="annotation__text">Created by</span><a href="https://eugene-serb.github.io/" target="_blank" translate="no">Eugene Serb</a></div></div></footer><noscript>You need to enable JavaScript to run this app.</noscript><noscript><div><img src="https://mc.yandex.ru/watch/89252711" style="position:absolute; left:-9999px;" alt=""/></div></noscript></body></html>
}</style><script defer="defer" src="/js/chunk-vendors.d42e1256.js"></script><script defer="defer" src="/js/app.5a58d0e1.js"></script><link href="/css/app.a72a8a93.css" rel="stylesheet"></head><body><header class="header"><div class="header-wrapper container"><div class="logo-wrapper"><span class="logo-wrapper__logo" translate="no">Wavelovers</span></div><nav class="menu-wrapper"><ul class="navigation"><li class="navigation__item"><a href="/" target="_self" class="navigation__link">Home</a></li><li class="navigation__item"><a href="/faq.html" target="_self" class="navigation__link">FAQ</a></li><li class="navigation__item"><a href="/about.html" target="_self" class="navigation__link">About</a></li><li class="navigation__item"><a href="/donate.html" target="_self" class="navigation__link">Donate</a></li></ul></nav></div></header><main class="page container"><h1 class="visually-hidden">Wavelovers</h1><div id="app" v-cloak></div></main><footer class="footer"><div class="footer-wrapper container"><div class="annotation"><span class="annotation__text">© 2022 Wavelovers. Content licensed under </span><a href="https://wavelovers.ru/LICENSE.md" target="_blank">GNU General Public License v3.0</a><br><span class="annotation__text">This site is open source. </span><a href="https://github.com/eugene-serb/wavelovers/" target="_blank">Improve this page.</a></div><div class="annotation created-by"><span class="annotation__text">Created by</span><a href="https://eugene-serb.github.io/" target="_blank" translate="no">Eugene Serb</a></div></div></footer><noscript>You need to enable JavaScript to run this app.</noscript><noscript><div><img src="https://mc.yandex.ru/watch/89252711" style="position:absolute; left:-9999px;" alt=""/></div></noscript></body></html>

2
docs/js/app.5a58d0e1.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,25 +2,25 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://wavelovers.ru/</loc>
<lastmod>2022-08-05</lastmod>
<lastmod>2022-08-06</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/faq.html</loc>
<lastmod>2022-08-05</lastmod>
<lastmod>2022-08-06</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/about.html</loc>
<lastmod>2022-08-05</lastmod>
<lastmod>2022-08-06</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/donate.html</loc>
<lastmod>2022-08-05</lastmod>
<lastmod>2022-08-06</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>

View File

@ -2,7 +2,7 @@
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://wavelovers.ru/sitemap-internal.xml</loc>
<lastmod>2022-08-05</lastmod>
<lastmod>2022-08-06</lastmod>
</sitemap>
</sitemapindex>

View File

@ -2,25 +2,25 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://wavelovers.ru/</loc>
<lastmod>2022-08-05</lastmod>
<lastmod>2022-08-06</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/faq.html</loc>
<lastmod>2022-08-05</lastmod>
<lastmod>2022-08-06</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/about.html</loc>
<lastmod>2022-08-05</lastmod>
<lastmod>2022-08-06</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/donate.html</loc>
<lastmod>2022-08-05</lastmod>
<lastmod>2022-08-06</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>

View File

@ -2,7 +2,7 @@
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://wavelovers.ru/sitemap-internal.xml</loc>
<lastmod>2022-08-05</lastmod>
<lastmod>2022-08-06</lastmod>
</sitemap>
</sitemapindex>

View File

@ -1,94 +1,42 @@
import { createStore } from 'vuex';
import IGamepad from '@/models/IGamepad';
import IGamepadEvent from '@/models/IGamepadEvent';
import TPattern from '@/models/TPattern';
import TPatternUnit from '@/models/TPatternUnit';
import Vibrator from '@/models/Vibrator';
import { createStore, Store } from 'vuex';
import IRootState from './models/IRootState';
import MGamepads from '@/store/modules/MGamepads';
import MPatterns from '@/store/modules/MPatterns';
export default createStore({
state: {
gamepads: [] as Vibrator[],
patterns: [] as TPattern[],
const store: Store<IRootState> = createStore({
state: () => ({
mode: 0 as number,
isActive: false as boolean,
},
}),
getters: {
gamepads: function (state): Vibrator[] {
return state.gamepads as Vibrator[];
},
patterns: function (state): TPattern[] {
return state.patterns as TPattern[];
},
mode: function (state): number {
mode: function (state: IRootState): number {
return state.mode as number;
},
isActive: function (state): boolean {
isActive: function (state: IRootState): boolean {
return state.isActive as boolean;
},
},
mutations: {
setPatterns: function (state, patterns: TPattern[]): void {
state.patterns = patterns as TPattern[];
},
setMode: function (state, mode: number): void {
setMode: function (state: IRootState, mode: number): void {
state.mode = mode as number;
},
setIsActive: function (state, isActive: boolean): void {
setIsActive: function (state: IRootState, isActive: boolean): void {
state.isActive = isActive as boolean;
},
addGamepad: function (state, gamepad: Vibrator): void {
state.gamepads.push(gamepad as Vibrator);
},
deleteGamepad: function (state, index: number): void {
state.gamepads.splice(index, 1);
},
},
actions: {
loadPatterns: async function (context): Promise<void> {
const url = 'https://wavelovers.ru/assets/patterns.json';
try {
const response: Response = await fetch(url);
if (response.ok) {
const json: TPattern[] = await response.json();
context.commit('setPatterns', json as TPattern[]);
} else {
console.log('Connect to the Internet for download more patterns...');
}
} catch (error) {
console.log(error);
}
},
setMode: function (context, index: number): void {
setMode: function (
context,
index: number
): void {
context.commit('setMode', index as number);
},
setIsActive: function (context, isActive: boolean): void {
setIsActive: function (
context,
isActive: boolean
): void {
context.commit('setIsActive', isActive as boolean);
},
addGamepad: function (context, event: GamepadEvent): void {
const iEvent: IGamepadEvent = event as unknown as IGamepadEvent;
if (context.getters.gamepads.length >= 1) {
return;
} else {
context.commit('addGamepad', new Vibrator(iEvent.gamepad as IGamepad));
}
},
deleteGamepad: function (context, event: GamepadEvent): void {
context.getters.gamepads.forEach((gamepad: Vibrator, index: number) => {
if (gamepad.unit.id === event.gamepad.id) {
context.commit('deleteGamepad', index as number);
}
});
},
vibrate: function (context): void {
context.getters.gamepads.forEach((gamepad: Vibrator) => {
gamepad.vibrate(context.getters.patterns[context.getters.mode].pattern as TPatternUnit[]);
});
},
reset: function (context): void {
context.getters.gamepads.forEach((gamepad: Vibrator) => {
gamepad.reset();
});
},
change: function (context, index: number): void {
if (context.getters.mode === index) {
context.dispatch('setIsActive', !context.getters.isActive);
@ -104,6 +52,11 @@ export default createStore({
}
},
},
modules: {},
modules: {
MGamepads: MGamepads,
MPatterns: MPatterns,
},
});
export default store;

View File

@ -0,0 +1,8 @@
import Vibrator from '@/models/Vibrator';
interface IGamepadsState {
gamepads: Vibrator[];
}
export default IGamepadsState;

View File

@ -0,0 +1,8 @@
import TPattern from '@/models/TPattern';
interface IPatternState {
patterns: TPattern[];
}
export default IPatternState;

View File

@ -0,0 +1,7 @@
interface IRootState {
mode: number;
isActive: boolean;
}
export default IRootState;

View File

@ -0,0 +1,66 @@
import { ActionContext, Module } from 'vuex';
import IRootState from '@/store/models/IRootState';
import IGamepadsState from '@/store/models/IGamepadsState';
import Vibrator from '@/models/Vibrator';
import IGamepad from '@/models/IGamepad';
import IGamepadEvent from '@/models/IGamepadEvent';
import TPatternUnit from '@/models/TPatternUnit';
const MGamepads: Module<IGamepadsState, IRootState> = {
state: () => ({
gamepads: [] as Vibrator[],
}),
getters: {
gamepads: function (state: IGamepadsState): Vibrator[] {
return state.gamepads as Vibrator[];
},
},
mutations: {
addGamepad: function (state: IGamepadsState, gamepad: Vibrator): void {
state.gamepads.push(gamepad as Vibrator);
},
deleteGamepad: function (state: IGamepadsState, index: number): void {
state.gamepads.splice(index, 1);
},
},
actions: {
addGamepad: function (
context: ActionContext<IGamepadsState, IRootState>,
event: GamepadEvent
): void {
const iEvent: IGamepadEvent = event as unknown as IGamepadEvent;
if (context.getters.gamepads.length >= 1) {
return;
} else {
context.commit('addGamepad', new Vibrator(iEvent.gamepad as IGamepad));
}
},
deleteGamepad: function (
context: ActionContext<IGamepadsState, IRootState>,
event: GamepadEvent
): void {
context.getters.gamepads.forEach((gamepad: Vibrator, index: number) => {
if (gamepad.unit.id === event.gamepad.id) {
context.commit('deleteGamepad', index as number);
}
});
},
vibrate: function (
context: ActionContext<IGamepadsState, IRootState>
): void {
context.getters.gamepads.forEach((gamepad: Vibrator) => {
gamepad.vibrate(context.getters.patterns[context.getters.mode].pattern as TPatternUnit[]);
});
},
reset: function (
context: ActionContext<IGamepadsState, IRootState>
): void {
context.getters.gamepads.forEach((gamepad: Vibrator) => {
gamepad.reset();
});
},
},
};
export default MGamepads;

View File

@ -0,0 +1,41 @@
import { ActionContext, Module } from 'vuex';
import IRootState from '@/store/models/IRootState';
import IPatternState from '@/store/models/IPatternState';
import TPattern from '@/models/TPattern';
const MPatterns: Module<IPatternState, IRootState> = {
state: () => ({
patterns: [] as TPattern[],
}),
getters: {
patterns: function (state: IPatternState): TPattern[] {
return state.patterns as TPattern[];
},
},
mutations: {
setPatterns: function (state: IPatternState, patterns: TPattern[]): void {
state.patterns = patterns as TPattern[];
},
},
actions: {
loadPatterns: async function (
context: ActionContext<IPatternState, IRootState>
): Promise<void> {
const url = 'https://wavelovers.ru/assets/patterns.json';
try {
const response: Response = await fetch(url);
if (response.ok) {
const json: TPattern[] = await response.json();
context.commit('setPatterns', json as TPattern[]);
} else {
console.log('Connect to the Internet for download more patterns...');
}
} catch (error) {
console.log(error);
}
},
},
};
export default MPatterns;