mirror of
https://github.com/eugene-serb/wavelovers.git
synced 2023-09-09 23:41:16 +03:00
Decomposited vuex-store to patterns and gamepads modules. Describe interfaces for vuex-states. Updated sitemaps. Rebuild production.
This commit is contained in:
parent
06f4c26226
commit
d3cdd92890
@ -15,4 +15,4 @@
|
|||||||
webvisor: true
|
webvisor: true
|
||||||
});</script><style>[v-cloak] {
|
});</script><style>[v-cloak] {
|
||||||
display: none;
|
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
2
docs/js/app.5a58d0e1.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/js/app.5a58d0e1.js.map
Normal file
1
docs/js/app.5a58d0e1.js.map
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
@ -2,25 +2,25 @@
|
|||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
<url>
|
<url>
|
||||||
<loc>https://wavelovers.ru/</loc>
|
<loc>https://wavelovers.ru/</loc>
|
||||||
<lastmod>2022-08-05</lastmod>
|
<lastmod>2022-08-06</lastmod>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>1.0</priority>
|
<priority>1.0</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://wavelovers.ru/faq.html</loc>
|
<loc>https://wavelovers.ru/faq.html</loc>
|
||||||
<lastmod>2022-08-05</lastmod>
|
<lastmod>2022-08-06</lastmod>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>1.0</priority>
|
<priority>1.0</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://wavelovers.ru/about.html</loc>
|
<loc>https://wavelovers.ru/about.html</loc>
|
||||||
<lastmod>2022-08-05</lastmod>
|
<lastmod>2022-08-06</lastmod>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>1.0</priority>
|
<priority>1.0</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://wavelovers.ru/donate.html</loc>
|
<loc>https://wavelovers.ru/donate.html</loc>
|
||||||
<lastmod>2022-08-05</lastmod>
|
<lastmod>2022-08-06</lastmod>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>1.0</priority>
|
<priority>1.0</priority>
|
||||||
</url>
|
</url>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
<sitemap>
|
<sitemap>
|
||||||
<loc>https://wavelovers.ru/sitemap-internal.xml</loc>
|
<loc>https://wavelovers.ru/sitemap-internal.xml</loc>
|
||||||
<lastmod>2022-08-05</lastmod>
|
<lastmod>2022-08-06</lastmod>
|
||||||
</sitemap>
|
</sitemap>
|
||||||
</sitemapindex>
|
</sitemapindex>
|
||||||
|
|
||||||
|
@ -2,25 +2,25 @@
|
|||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
<url>
|
<url>
|
||||||
<loc>https://wavelovers.ru/</loc>
|
<loc>https://wavelovers.ru/</loc>
|
||||||
<lastmod>2022-08-05</lastmod>
|
<lastmod>2022-08-06</lastmod>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>1.0</priority>
|
<priority>1.0</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://wavelovers.ru/faq.html</loc>
|
<loc>https://wavelovers.ru/faq.html</loc>
|
||||||
<lastmod>2022-08-05</lastmod>
|
<lastmod>2022-08-06</lastmod>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>1.0</priority>
|
<priority>1.0</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://wavelovers.ru/about.html</loc>
|
<loc>https://wavelovers.ru/about.html</loc>
|
||||||
<lastmod>2022-08-05</lastmod>
|
<lastmod>2022-08-06</lastmod>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>1.0</priority>
|
<priority>1.0</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://wavelovers.ru/donate.html</loc>
|
<loc>https://wavelovers.ru/donate.html</loc>
|
||||||
<lastmod>2022-08-05</lastmod>
|
<lastmod>2022-08-06</lastmod>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>1.0</priority>
|
<priority>1.0</priority>
|
||||||
</url>
|
</url>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
<sitemap>
|
<sitemap>
|
||||||
<loc>https://wavelovers.ru/sitemap-internal.xml</loc>
|
<loc>https://wavelovers.ru/sitemap-internal.xml</loc>
|
||||||
<lastmod>2022-08-05</lastmod>
|
<lastmod>2022-08-06</lastmod>
|
||||||
</sitemap>
|
</sitemap>
|
||||||
</sitemapindex>
|
</sitemapindex>
|
||||||
|
|
||||||
|
@ -1,94 +1,42 @@
|
|||||||
import { createStore } from 'vuex';
|
import { createStore, Store } from 'vuex';
|
||||||
import IGamepad from '@/models/IGamepad';
|
import IRootState from './models/IRootState';
|
||||||
import IGamepadEvent from '@/models/IGamepadEvent';
|
import MGamepads from '@/store/modules/MGamepads';
|
||||||
import TPattern from '@/models/TPattern';
|
import MPatterns from '@/store/modules/MPatterns';
|
||||||
import TPatternUnit from '@/models/TPatternUnit';
|
|
||||||
import Vibrator from '@/models/Vibrator';
|
|
||||||
|
|
||||||
export default createStore({
|
const store: Store<IRootState> = createStore({
|
||||||
state: {
|
state: () => ({
|
||||||
gamepads: [] as Vibrator[],
|
|
||||||
patterns: [] as TPattern[],
|
|
||||||
mode: 0 as number,
|
mode: 0 as number,
|
||||||
isActive: false as boolean,
|
isActive: false as boolean,
|
||||||
},
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
gamepads: function (state): Vibrator[] {
|
mode: function (state: IRootState): number {
|
||||||
return state.gamepads as Vibrator[];
|
|
||||||
},
|
|
||||||
patterns: function (state): TPattern[] {
|
|
||||||
return state.patterns as TPattern[];
|
|
||||||
},
|
|
||||||
mode: function (state): number {
|
|
||||||
return state.mode as number;
|
return state.mode as number;
|
||||||
},
|
},
|
||||||
isActive: function (state): boolean {
|
isActive: function (state: IRootState): boolean {
|
||||||
return state.isActive as boolean;
|
return state.isActive as boolean;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setPatterns: function (state, patterns: TPattern[]): void {
|
setMode: function (state: IRootState, mode: number): void {
|
||||||
state.patterns = patterns as TPattern[];
|
|
||||||
},
|
|
||||||
setMode: function (state, mode: number): void {
|
|
||||||
state.mode = mode as number;
|
state.mode = mode as number;
|
||||||
},
|
},
|
||||||
setIsActive: function (state, isActive: boolean): void {
|
setIsActive: function (state: IRootState, isActive: boolean): void {
|
||||||
state.isActive = isActive as boolean;
|
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: {
|
actions: {
|
||||||
loadPatterns: async function (context): Promise<void> {
|
setMode: function (
|
||||||
const url = 'https://wavelovers.ru/assets/patterns.json';
|
context,
|
||||||
try {
|
index: number
|
||||||
const response: Response = await fetch(url);
|
): void {
|
||||||
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 {
|
|
||||||
context.commit('setMode', index as number);
|
context.commit('setMode', index as number);
|
||||||
},
|
},
|
||||||
setIsActive: function (context, isActive: boolean): void {
|
setIsActive: function (
|
||||||
|
context,
|
||||||
|
isActive: boolean
|
||||||
|
): void {
|
||||||
context.commit('setIsActive', isActive as boolean);
|
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 {
|
change: function (context, index: number): void {
|
||||||
if (context.getters.mode === index) {
|
if (context.getters.mode === index) {
|
||||||
context.dispatch('setIsActive', !context.getters.isActive);
|
context.dispatch('setIsActive', !context.getters.isActive);
|
||||||
@ -104,6 +52,11 @@ export default createStore({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
modules: {},
|
modules: {
|
||||||
|
MGamepads: MGamepads,
|
||||||
|
MPatterns: MPatterns,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default store;
|
||||||
|
|
||||||
|
8
src/store/models/IGamepadsState.ts
Normal file
8
src/store/models/IGamepadsState.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import Vibrator from '@/models/Vibrator';
|
||||||
|
|
||||||
|
interface IGamepadsState {
|
||||||
|
gamepads: Vibrator[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IGamepadsState;
|
||||||
|
|
8
src/store/models/IPatternState.ts
Normal file
8
src/store/models/IPatternState.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import TPattern from '@/models/TPattern';
|
||||||
|
|
||||||
|
interface IPatternState {
|
||||||
|
patterns: TPattern[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IPatternState;
|
||||||
|
|
7
src/store/models/IRootState.ts
Normal file
7
src/store/models/IRootState.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
interface IRootState {
|
||||||
|
mode: number;
|
||||||
|
isActive: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IRootState;
|
||||||
|
|
66
src/store/modules/MGamepads.ts
Normal file
66
src/store/modules/MGamepads.ts
Normal 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;
|
||||||
|
|
41
src/store/modules/MPatterns.ts
Normal file
41
src/store/modules/MPatterns.ts
Normal 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;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user