Skip to content

Commit

Permalink
Merge pull request #105 from eugene-serb/dev
Browse files Browse the repository at this point in the history
Release 1.26.0
  • Loading branch information
eugene-serb authored Feb 2, 2024
2 parents ca6ff98 + 5506080 commit 10b09a5
Show file tree
Hide file tree
Showing 16 changed files with 356 additions and 386 deletions.
333 changes: 54 additions & 279 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wavelovers",
"version": "1.25.0",
"version": "1.26.0",
"description": "Wavelovers is a vibration test tool for gamepads and mobile devices that can also turn them into vibration massagers. It has free vibration templates, template editor and manual control mode.",
"keywords": [
"wavelovers",
Expand Down Expand Up @@ -55,17 +55,17 @@
"@rushstack/eslint-patch": "^1.7.2",
"@tsconfig/node18": "^18.2.2",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.19.10",
"@types/node": "^18.19.14",
"@vitejs/plugin-vue": "^4.6.2",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/test-utils": "^2.4.4",
"@vue/tsconfig": "^0.5.1",
"eslint": "^8.56.0",
"eslint-plugin-vue": "^9.20.1",
"eslint-plugin-vue": "^9.21.1",
"jsdom": "^23.2.0",
"npm-run-all2": "^6.1.1",
"npm-run-all2": "^6.1.2",
"prettier": "^3.2.4",
"sass": "^1.70.0",
"typescript": "~5.3.0",
Expand Down
18 changes: 9 additions & 9 deletions public/sitemap-internal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,55 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://wavelovers.ru/</loc>
<lastmod>2024-01-29</lastmod>
<lastmod>2024-02-02</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/custom</loc>
<lastmod>2024-01-29</lastmod>
<lastmod>2024-02-02</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/manual</loc>
<lastmod>2024-01-29</lastmod>
<lastmod>2024-02-02</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/diagnostic</loc>
<lastmod>2024-01-29</lastmod>
<lastmod>2024-02-02</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/mobile</loc>
<lastmod>2024-01-29</lastmod>
<lastmod>2024-02-02</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/mobile-custom</loc>
<lastmod>2024-01-29</lastmod>
<lastmod>2024-02-02</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/faq</loc>
<lastmod>2024-01-29</lastmod>
<lastmod>2024-02-02</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/about</loc>
<lastmod>2024-01-29</lastmod>
<lastmod>2024-02-02</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://wavelovers.ru/donate</loc>
<lastmod>2024-01-29</lastmod>
<lastmod>2024-02-02</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
Expand Down
2 changes: 1 addition & 1 deletion public/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://wavelovers.ru/sitemap-internal.xml</loc>
<lastmod>2024-01-29</lastmod>
<lastmod>2024-02-02</lastmod>
</sitemap>
</sitemapindex>
9 changes: 2 additions & 7 deletions src/components/molecules/MAnnouncement.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { defineComponent, defineProps, computed, ref, toRefs } from 'vue';
import { defineComponent, defineProps, computed, toRefs } from 'vue';
import { useRouter } from 'vue-router';
import { AAnnouncement } from '@/components/atoms';
import { useAnnouncements } from '@/composables';
Expand Down Expand Up @@ -29,12 +29,7 @@ const { path } = currentRoute.value;
const { announcements } = toRefs(props);
/**
* Ключ хранилища анонсов.
*/
const storageKey = ref<string>('announcements');
const { announcements: actualAnnouncements } = useAnnouncements(storageKey, announcements);
const { announcements: actualAnnouncements } = useAnnouncements(announcements);
/**
* Уведомления которые будут показаны, если они включены и маршрут удовлетворяет условиям, если они указаны.
Expand Down
37 changes: 7 additions & 30 deletions src/components/molecules/MHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,21 @@
import { defineComponent } from 'vue';
import { ATextLogo } from '@/components/atoms';
import MHeaderMenu from '@/components/molecules/MHeaderMenu.vue';
import { URL_TO_HOME, URL_TO_FAQ, URL_TO_ABOUT, URL_TO_DONATE, URL_TO_MOBILE } from '@/constants';
import { URL_TO_HOME } from '@/constants';
import type { PropType } from 'vue';
import type { Link } from '@/models';
defineComponent({
name: 'MHeader',
});
/**
* Ссылки.
*/
const links: Link[] = [
{
text: 'Gamepad',
to: URL_TO_HOME,
target: '_self',
defineProps({
links: {
type: Array as PropType<Link[]>,
default: () => [],
},
{
text: 'Mobile',
to: URL_TO_MOBILE,
target: '_self',
},
{
text: 'FAQ',
to: URL_TO_FAQ,
target: '_self',
},
{
text: 'About',
to: URL_TO_ABOUT,
target: '_self',
},
{
text: 'Donate',
to: URL_TO_DONATE,
target: '_self',
},
];
});
</script>

<template>
Expand Down
65 changes: 10 additions & 55 deletions src/composables/useAnnouncements.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ref, watch } from 'vue';
import { storage } from '@/storage';

import type { Ref } from 'vue';
import type { Announcement, AnnouncementSavedData } from '@/models';
Expand All @@ -14,20 +15,16 @@ type AnnouncementComposable = {
/**
* Композабл для получения соответствующего маршруту списка анонсов.
*
* @param storageKey Ключ для хранилища.
* @param originAnnouncements Анонсы.
* @returns AnnouncementComposable.
*/
export function useAnnouncements(
storageKey: Ref<string>,
originAnnouncements: Ref<Announcement[]>,
): AnnouncementComposable {
export function useAnnouncements(originAnnouncements: Ref<Announcement[]>): AnnouncementComposable {
/**
* Копия сохранённой конфигурации анонсов.
*
* @private
*/
const _announcementSavedData = ref<AnnouncementSavedData[]>(_getDataFromStorage());
const _announcementSavedData = ref<AnnouncementSavedData[]>(_getSavedData());

/**
* Анонсы.
Expand All @@ -39,7 +36,7 @@ export function useAnnouncements(
watch(
announcements,
() => {
_setDataIntoStorage(announcements.value);
_setSavedData(announcements.value);
},
{ deep: true },
);
Expand Down Expand Up @@ -88,50 +85,14 @@ export function useAnnouncements(
}

/**
* Десериализовать DTO AnnouncementSavedData.
*
* @private
* @param dto DTO сохранённой конфигурации анонсов.
* @returns Сохранённая конфигурация анонсов.
*/
function _deserialize(dto: string): AnnouncementSavedData[] {
const raw = JSON.parse(dto);

if (!Array.isArray(raw)) {
return [];
}

const filtered = raw.filter((entity) => {
const { id, enabled } = entity;

if (!(id && typeof id === 'string')) {
return false;
}

if (!(typeof enabled === 'boolean')) {
return false;
}

return true;
});

return filtered.map((entity) => ({
id: entity.id,
enabled: entity.enabled,
}));
}

/**
* Сохранить данные в localStorage
* Сохранить данные в localStorage.
*
* @private
* @param announcements Данные, которые надо поместить в localStorage.
*/
function _setDataIntoStorage(announcements: Announcement[]): void {
const save = _createAnnouncementSavedData(announcements);
const dto = JSON.stringify(save);

window.localStorage.setItem(storageKey.value, dto);
function _setSavedData(announcements: Announcement[]): void {
const savedData = _createAnnouncementSavedData(announcements);
storage.announcements.set(savedData);
}

/**
Expand All @@ -140,14 +101,8 @@ export function useAnnouncements(
* @private
* @returns Сохранённое состояние анонсов.
*/
function _getDataFromStorage(): AnnouncementSavedData[] {
const dto = window.localStorage.getItem(storageKey.value);

if (!dto) {
return [];
}

return _deserialize(dto);
function _getSavedData(): AnnouncementSavedData[] {
return storage.announcements.get();
}

return {
Expand Down
36 changes: 35 additions & 1 deletion src/layouts/LDefault.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
<script setup lang="ts">
import { defineComponent } from 'vue';
import { MHeader, MFooter, MAnnouncement } from '@/components/molecules';
import { URL_TO_HOME, URL_TO_FAQ, URL_TO_ABOUT, URL_TO_DONATE, URL_TO_MOBILE } from '@/constants';
import announcements from '@/assets/announcements.json';
import type { Link } from '@/models';
defineComponent({
name: 'LDefault',
});
/**
* Ссылки.
*/
const links: Link[] = [
{
text: 'Gamepad',
to: URL_TO_HOME,
target: '_self',
},
{
text: 'Mobile',
to: URL_TO_MOBILE,
target: '_self',
},
{
text: 'FAQ',
to: URL_TO_FAQ,
target: '_self',
},
{
text: 'About',
to: URL_TO_ABOUT,
target: '_self',
},
{
text: 'Donate',
to: URL_TO_DONATE,
target: '_self',
},
];
</script>

<template>
<MHeader />
<MHeader :links="links" />

<main class="page container">
<MAnnouncement :announcements="announcements" />
Expand Down
41 changes: 41 additions & 0 deletions src/storage/controllers/announcements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import fetcher from '../core/fetcher';
import { announcementStorage } from '../models';

import type { CommonStorageController } from '../core';
import type { AnnouncementSavedData } from '@/models';

/**
* Извлечь данные.
*
* @returns Данные.
*/
function get(): AnnouncementSavedData[] {
return fetcher.get<AnnouncementSavedData[]>(announcementStorage());
}

/**
* Записать данные.
*
* @param data Данные.
*/
function set(data: AnnouncementSavedData[]): void {
fetcher.set<AnnouncementSavedData[]>(data, announcementStorage());
}

/**
* Удалить данные.
*/
function remove(): void {
fetcher.remove<AnnouncementSavedData[]>(announcementStorage());
}

/**
* Контроллер хранилища данных Announcements.
*/
const announcements: CommonStorageController<AnnouncementSavedData[]> = {
get,
set,
remove,
};

export default announcements;
1 change: 1 addition & 0 deletions src/storage/controllers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as announcements } from './announcements';
Loading

0 comments on commit 10b09a5

Please sign in to comment.