From 599a93fe5ba9f4318e11ff540bdaab6afbed2d36 Mon Sep 17 00:00:00 2001 From: Norbaev Date: Tue, 25 Jun 2024 16:42:17 +0500 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20eslint,=20?= =?UTF-8?q?=D0=B3=D0=B4=D0=B5=20=D1=80=D1=83=D0=B3=D0=B0=D0=BB=D1=81=D1=8F?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B0?= =?UTF-8?q?=20babel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/.eslintrc.cjs | 19 ++-- client/.prettierrc.js | 3 + client/babel.config.cjs | 14 +-- client/package-lock.json | 22 ++++ client/package.json | 1 + client/quasar.config.js | 193 ++++++++++++++++++----------------- client/src/services/audio.js | 127 ++++++++++++----------- 7 files changed, 206 insertions(+), 173 deletions(-) create mode 100644 client/.prettierrc.js diff --git a/client/.eslintrc.cjs b/client/.eslintrc.cjs index 71f1cc6..37e26e8 100644 --- a/client/.eslintrc.cjs +++ b/client/.eslintrc.cjs @@ -7,12 +7,14 @@ module.exports = { parserOptions: { parser: '@babel/eslint-parser', ecmaVersion: 2021, // Allows for the parsing of modern ECMAScript features - sourceType: 'module' // Allows for the use of imports + sourceType: 'module', // Allows for the use of imports + // requireConfigFile: false, + babelOptions: { configFile: './babel.config.cjs' }, }, env: { browser: true, - 'vue/setup-compiler-macros': true + 'vue/setup-compiler-macros': true, }, // Rules order is important, please avoid shuffling them @@ -30,14 +32,12 @@ module.exports = { // 'plugin:vue/vue3-recommended', // Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead) // 'standard' - ], plugins: [ // https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-files // required to lint *.vue files 'vue', - ], globals: { @@ -50,12 +50,11 @@ module.exports = { __QUASAR_SSR_PWA__: 'readonly', process: 'readonly', Capacitor: 'readonly', - chrome: 'readonly' + chrome: 'readonly', }, // add your custom rules here rules: { - // allow async-await 'generator-star-spacing': 'off', // allow paren-less arrow functions @@ -72,7 +71,7 @@ module.exports = { 'import/extensions': 'off', 'import/no-unresolved': 'off', 'import/no-extraneous-dependencies': 'off', - + 'prefer-promise-reject-errors': 'off', 'no-multiple-template-root': 'off', @@ -82,6 +81,6 @@ module.exports = { 'vue/no-v-for-template-key': 'warn', 'vue/multi-word-component-names': 'off', // allow debugger during development only - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' - } -} + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + }, +}; diff --git a/client/.prettierrc.js b/client/.prettierrc.js new file mode 100644 index 0000000..e340799 --- /dev/null +++ b/client/.prettierrc.js @@ -0,0 +1,3 @@ +module.exports = { + singleQuote: true, +}; diff --git a/client/babel.config.cjs b/client/babel.config.cjs index 063ef53..3f718b8 100644 --- a/client/babel.config.cjs +++ b/client/babel.config.cjs @@ -1,14 +1,14 @@ /* eslint-disable */ -module.exports = api => { +module.exports = (api) => { return { presets: [ [ '@quasar/babel-preset-app', - api.caller(caller => caller && caller.target === 'node') + api.caller((caller) => caller && caller.target === 'node') ? { targets: { node: 'current' } } - : {} - ] - ] - } -} + : {}, + ], + ], + }; +}; diff --git a/client/package-lock.json b/client/package-lock.json index 9bb427f..cc6b9ce 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -50,6 +50,7 @@ "postcss-nested": "^6.0.1", "postcss-preset-env": "^9.2.0", "postcss-simple-vars": "^7.0.1", + "prettier": "^3.3.2", "sass-loader": "^13.3.2", "vue-loader": "^17.3.0" }, @@ -12808,6 +12809,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-error": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz", @@ -24507,6 +24523,12 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, + "prettier": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", + "dev": true + }, "pretty-error": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz", diff --git a/client/package.json b/client/package.json index 5c8e106..62d3f52 100644 --- a/client/package.json +++ b/client/package.json @@ -59,6 +59,7 @@ "postcss-nested": "^6.0.1", "postcss-preset-env": "^9.2.0", "postcss-simple-vars": "^7.0.1", + "prettier": "^3.3.2", "sass-loader": "^13.3.2", "vue-loader": "^17.3.0" }, diff --git a/client/quasar.config.js b/client/quasar.config.js index 5dc6962..fecf4b0 100644 --- a/client/quasar.config.js +++ b/client/quasar.config.js @@ -1,7 +1,9 @@ -const path = require('path'); -const webpack = require('webpack'); +const path = require("path"); +const webpack = require("webpack"); const nodeExternals = require("webpack-node-externals"); -const env = require('dotenv').config({ path: `.env.${process.env.NODE_ENV.toLowerCase()}` }).parsed; +const env = require("dotenv").config({ + path: `.env.${process.env.NODE_ENV.toLowerCase()}`, +}).parsed; /* eslint-env node */ /* @@ -12,8 +14,8 @@ const env = require('dotenv').config({ path: `.env.${process.env.NODE_ENV.toLowe // Configuration for your app // https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js -const ESLintPlugin = require('eslint-webpack-plugin') -const { configure } = require('quasar/wrappers') +const ESLintPlugin = require("eslint-webpack-plugin"); +const { configure } = require("quasar/wrappers"); module.exports = configure(function (ctx) { return { // https://v2.quasar.dev/quasar-cli-webpack/supporting-ts @@ -26,9 +28,9 @@ module.exports = configure(function (ctx) { // --> boot files are part of "main.js" // https://v2.quasar.dev/quasar-cli-webpack/boot-files boot: [ - 'main', - 'directive', - { path: 'store', server: false }, + "main", + "directive", + { path: "store", server: false }, //{ path: 'directive', server: false }, //'axios' ], @@ -47,16 +49,15 @@ module.exports = configure(function (ctx) { // 'themify', // 'line-awesome', // 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both! - // 'roboto-font', // optional, you are not bound to it // 'material-icons' // optional, you are not bound to it ], // Full list of options: https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js#Property%3A-build build: { - vueRouterMode: 'history', // available values: 'hash', 'history' + vueRouterMode: "history", // available values: 'hash', 'history' env: { - ...process.env + ...process.env, }, // transpile: false, // publicPath: '/', @@ -78,56 +79,59 @@ module.exports = configure(function (ctx) { // https://v2.quasar.dev/quasar-cli-webpack/handling-webpack // "chain" is a webpack-chain object https://github.com/neutrinojs/webpack-chain - chainWebpack (chain) { - chain.plugin('eslint-webpack-plugin') - .use(ESLintPlugin, [{ extensions: ['js', 'vue'] }]) - // chain.plugin('normal-module-replacement').use( - // new webpack.NormalModuleReplacementPlugin(/settings$/, function(resource) { - // resource.request = resource.request.replace(/settings$/, `settings/${process.env.NODE_ENV}`); - // }) - // ) + chainWebpack(chain) { + chain + .plugin("eslint-webpack-plugin") + .use(ESLintPlugin, [{ extensions: ["js", "vue"] }]); + // chain.plugin('normal-module-replacement').use( + // new webpack.NormalModuleReplacementPlugin(/settings$/, function(resource) { + // resource.request = resource.request.replace(/settings$/, `settings/${process.env.NODE_ENV}`); + // }) + // ) // require = require('esm')(module); // const settings = require(`./src/settings`); // chain.plugin('robotstxt-webpack-plugin') // .use(new RobotstxtPlugin(settings.robotsTxt)) - - chain.module.rule('images') + + chain.module + .rule("images") .test(/\.(png|jpe?g|gif|svg|webp|avif|ico)(\?.*)?$/) - .type('javascript/auto') - .use('url-loader') - .loader('url-loader') + .type("javascript/auto") + .use("url-loader") + .loader("url-loader") .options({ esModule: false, limit: 16384, - name: `assets/img/[name].[hash:8].[ext]` - }) - chain.module.rule('videos') - .test(/\.(mp4|webm|mov)(\?.*)?$/) - .type('javascript/auto') - .use('url-loader') - .loader('url-loader') - .options({ - esModule: false, - limit: 32768, - name: `assets/media/[name].[hash:8].[ext]` - }) + name: `assets/img/[name].[hash:8].[ext]`, + }); + chain.module + .rule("videos") + .test(/\.(mp4|webm|mov)(\?.*)?$/) + .type("javascript/auto") + .use("url-loader") + .loader("url-loader") + .options({ + esModule: false, + limit: 32768, + name: `assets/media/[name].[hash:8].[ext]`, + }); }, - extendWebpack (cfg) { + extendWebpack(cfg) { cfg.resolve.alias = { ...cfg.resolve.alias, - '@': path.resolve(__dirname, './src'), + "@": path.resolve(__dirname, "./src"), }; }, - devtool: 'source-map' + devtool: "source-map", }, // Full list of options: https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js#Property%3A-devServer devServer: { server: { - type: 'http' + type: "http", }, port: 5173, - open: false // opens browser window automatically + open: false, // opens browser window automatically }, // https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js#Property%3A-framework @@ -135,7 +139,7 @@ module.exports = configure(function (ctx) { config: {}, // iconSet: 'material-icons', // Quasar icon set - lang: 'ru', // Quasar language pack + lang: "ru", // Quasar language pack // For special cases outside of where the auto-import strategy can have an impact // (like functional components as one of the examples), @@ -145,7 +149,7 @@ module.exports = configure(function (ctx) { // directives: [], // Quasar plugins - plugins: ['Meta'] + plugins: ["Meta"], }, // animations: 'all', // --- includes all animations @@ -188,66 +192,68 @@ module.exports = configure(function (ctx) { maxAge: 1000 * 60 * 60 * 24 * 30, // Tell browser when a file from the server should expire from cache (in ms) - chainWebpackWebserver (chain) { - chain.plugin('eslint-webpack-plugin') - .use(ESLintPlugin, [{ extensions: ['js'] }]) + chainWebpackWebserver(chain) { + chain + .plugin("eslint-webpack-plugin") + .use(ESLintPlugin, [{ extensions: ["js"] }]); }, middlewares: [ - ctx.prod ? 'compression' : '', - 'render' // keep this as last one - ] + ctx.prod ? "compression" : "", + "render", // keep this as last one + ], }, // https://v2.quasar.dev/quasar-cli-webpack/developing-pwa/configuring-pwa pwa: { - workboxPluginMode: 'GenerateSW', // 'GenerateSW' or 'InjectManifest' + workboxPluginMode: "GenerateSW", // 'GenerateSW' or 'InjectManifest' workboxOptions: {}, // only for GenerateSW // for the custom service worker ONLY (/src-pwa/custom-service-worker.[js|ts]) // if using workbox in InjectManifest mode - chainWebpackCustomSW (chain) { - chain.plugin('eslint-webpack-plugin') - .use(ESLintPlugin, [{ extensions: ['js'] }]) + chainWebpackCustomSW(chain) { + chain + .plugin("eslint-webpack-plugin") + .use(ESLintPlugin, [{ extensions: ["js"] }]); }, manifest: { - name: 'Tugan App', - short_name: 'Tugan App', - description: 'A Tugan project', - display: 'standalone', - orientation: 'portrait', - background_color: '#ffffff', - theme_color: '#027be3', + name: "Tugan App", + short_name: "Tugan App", + description: "A Tugan project", + display: "standalone", + orientation: "portrait", + background_color: "#ffffff", + theme_color: "#027be3", icons: [ { - src: 'icons/icon-128x128.png', - sizes: '128x128', - type: 'image/png' + src: "icons/icon-128x128.png", + sizes: "128x128", + type: "image/png", }, { - src: 'icons/icon-192x192.png', - sizes: '192x192', - type: 'image/png' + src: "icons/icon-192x192.png", + sizes: "192x192", + type: "image/png", }, { - src: 'icons/icon-256x256.png', - sizes: '256x256', - type: 'image/png' + src: "icons/icon-256x256.png", + sizes: "256x256", + type: "image/png", }, { - src: 'icons/icon-384x384.png', - sizes: '384x384', - type: 'image/png' + src: "icons/icon-384x384.png", + sizes: "384x384", + type: "image/png", }, { - src: 'icons/icon-512x512.png', - sizes: '512x512', - type: 'image/png' - } - ] - } + src: "icons/icon-512x512.png", + sizes: "512x512", + type: "image/png", + }, + ], + }, }, // Full list of options: https://v2.quasar.dev/quasar-cli-webpack/developing-cordova-apps/configuring-cordova @@ -257,22 +263,20 @@ module.exports = configure(function (ctx) { // Full list of options: https://v2.quasar.dev/quasar-cli-webpack/developing-capacitor-apps/configuring-capacitor capacitor: { - hideSplashscreen: true + hideSplashscreen: true, }, // Full list of options: https://v2.quasar.dev/quasar-cli-webpack/developing-electron-apps/configuring-electron electron: { - bundler: 'packager', // 'packager' or 'builder' + bundler: "packager", // 'packager' or 'builder' packager: { // https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options - // OS X / Mac App Store // appBundleId: '', // appCategoryType: '', // osxSign: '', // protocol: 'myapp://path', - // Windows only // win32metadata: { ... } }, @@ -280,21 +284,22 @@ module.exports = configure(function (ctx) { builder: { // https://www.electron.build/configuration/configuration - appId: 'tugan' + appId: "tugan", }, // "chain" is a webpack-chain object https://github.com/neutrinojs/webpack-chain - chainWebpackMain (chain) { - chain.plugin('eslint-webpack-plugin') - .use(ESLintPlugin, [{ extensions: ['js'] }]) + chainWebpackMain(chain) { + chain + .plugin("eslint-webpack-plugin") + .use(ESLintPlugin, [{ extensions: ["js"] }]); }, - chainWebpackPreload (chain) { - chain.plugin('eslint-webpack-plugin') - .use(ESLintPlugin, [{ extensions: ['js'] }]) - } - - } - } -}) + chainWebpackPreload(chain) { + chain + .plugin("eslint-webpack-plugin") + .use(ESLintPlugin, [{ extensions: ["js"] }]); + }, + }, + }; +}); diff --git a/client/src/services/audio.js b/client/src/services/audio.js index 42ff479..203b23f 100644 --- a/client/src/services/audio.js +++ b/client/src/services/audio.js @@ -1,65 +1,68 @@ -import {urlPathAudio as settings} from '@/settings'; -import {REST, RESTError} from './rest'; -import {urlPathAudio} from "@/settings"; +import { urlPathAudio as settings } from '@/settings'; +import { REST, RESTError } from './rest'; +import { urlPathAudio } from '@/settings'; export default class extends REST { - static get settings() { - return settings; - } - - init(){ - const sseBaseUri = `${settings}/api/live/nowplaying/sse`; - const sseUriParams = new URLSearchParams({ - cf_connect: JSON.stringify({ - subs: { - "station:it-radio": { recover: true }, - }, - }), - }); - this.connection = new EventSource(sseBaseUri + "?" + sseUriParams.toString()); - } - - removePlay(){ - this.connection.close() - } - songs(){ - this.connection.onmessage = (e) => { - const jsonData = JSON.parse(e.data); - // if ("connect" in jsonData) { - // const connectData = jsonData.connect; - // - // if ("data" in connectData) { - // // Legacy SSE data - // connectData.data.forEach((initialRow) => handleSseData(initialRow)); - // } else { - // // New Centrifugo time format - // if ("time" in connectData) { - // } - // - // // New Centrifugo cached NowPlaying initial push. - // for (const subName in connectData.subs) { - // const sub = connectData.subs[subName]; - // if ("publications" in sub && sub.publications.length > 0) { - // sub.publications.forEach((initialRow) => handleSseData(initialRow, false)); - // } - // } - // } - // } else if ("pub" in jsonData) { - // handleSseData(jsonData.pub); - // } - }; - - } - - onHandler(event){ - this.connection.onmessage = event - } - static getPlayList(station, params) { - // return this._get(`station/${station}/playlists`, params, {}).then((data) => { - return this._get(`radio.mp3`, params, {}).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении плейлистов'); - }); - } + static get settings() { + return settings; + } + + init() { + const sseBaseUri = `${settings}/api/live/nowplaying/sse`; + const sseUriParams = new URLSearchParams({ + cf_connect: JSON.stringify({ + subs: { + 'station:it-radio': { recover: true }, + }, + }), + }); + this.connection = new EventSource( + sseBaseUri + '?' + sseUriParams.toString(), + ); + } + + removePlay() { + this.connection.close(); + } + songs() { + this.connection.onmessage = (e) => { + const jsonData = JSON.parse(e.data); + // if ("connect" in jsonData) { + // const connectData = jsonData.connect; + // + // if ("data" in connectData) { + // // Legacy SSE data + // connectData.data.forEach((initialRow) => handleSseData(initialRow)); + // } else { + // // New Centrifugo time format + // if ("time" in connectData) { + // } + // + // // New Centrifugo cached NowPlaying initial push. + // for (const subName in connectData.subs) { + // const sub = connectData.subs[subName]; + // if ("publications" in sub && sub.publications.length > 0) { + // sub.publications.forEach((initialRow) => handleSseData(initialRow, false)); + // } + // } + // } + // } else if ("pub" in jsonData) { + // handleSseData(jsonData.pub); + // } + }; + } + + onHandler(event) { + this.connection.onmessage = event; + } + static getPlayList(station, params) { + // return this._get(`station/${station}/playlists`, params, {}).then((data) => { + return this._get(`radio.mp3`, params, {}) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении плейлистов'); + }); + } }