config.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { defineStore } from "pinia";
  2. export const useConfigStore = defineStore("config", {
  3. state: (): {
  4. cookie: string;
  5. sitename: string;
  6. recaptcha: {
  7. enabled: boolean;
  8. key: string;
  9. };
  10. githubAuthentication: boolean;
  11. messages: Record<string, string>;
  12. christmas: boolean;
  13. footerLinks: Record<string, string | boolean>;
  14. shortcutOverrides: Record<string, any>;
  15. registrationDisabled: boolean;
  16. mailEnabled: boolean;
  17. discogsEnabled: boolean;
  18. experimental: {
  19. changable_listen_mode: string[] | boolean;
  20. media_session: boolean;
  21. disable_youtube_search: boolean;
  22. station_history: boolean;
  23. soundcloud: boolean;
  24. spotify: boolean;
  25. };
  26. } => ({
  27. cookie: "musareSID",
  28. sitename: MUSARE_SITENAME,
  29. recaptcha: {
  30. enabled: false,
  31. key: ""
  32. },
  33. githubAuthentication: false,
  34. messages: {
  35. accountRemoval:
  36. "Your account will be deactivated instantly and your data will shortly be deleted by an admin."
  37. },
  38. christmas: false,
  39. footerLinks: {},
  40. shortcutOverrides: {},
  41. registrationDisabled: false,
  42. mailEnabled: true,
  43. discogsEnabled: true,
  44. experimental: {
  45. changable_listen_mode: [],
  46. media_session: false,
  47. disable_youtube_search: false,
  48. station_history: false,
  49. soundcloud: false,
  50. spotify: false
  51. }
  52. }),
  53. actions: {
  54. get(query: string) {
  55. let config = JSON.parse(JSON.stringify(this.$state));
  56. query.split(".").forEach(property => {
  57. config = config[property];
  58. });
  59. return config;
  60. }
  61. },
  62. getters: {
  63. urls() {
  64. const { protocol, host } = document.location;
  65. const secure = protocol !== "http:";
  66. const client = `${protocol}//${host}`;
  67. const api = `${client}/backend`;
  68. const ws = `${secure ? "wss" : "ws"}://${host}/backend/ws`;
  69. return { client, api, ws, host, secure };
  70. }
  71. }
  72. });