fix pinia error

This commit is contained in:
jb-alvarado 2023-05-15 14:08:40 +02:00
parent 5c37a260df
commit 3c48ce09e0
4 changed files with 1481 additions and 6 deletions

1463
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,6 @@ const { timeToSeconds } = stringFormatter()
import { useAuth } from '~/stores/auth' import { useAuth } from '~/stores/auth'
import { useIndex } from '~/stores/index' import { useIndex } from '~/stores/index'
const authStore = useAuth()
const indexStore = useIndex()
interface GuiConfig { interface GuiConfig {
id: number id: number
@ -81,6 +79,8 @@ export const useConfig = defineStore('config', {
}, },
async nuxtClientInit() { async nuxtClientInit() {
const authStore = useAuth()
authStore.inspectToken() authStore.inspectToken()
if (authStore.isLogin) { if (authStore.isLogin) {
@ -91,6 +91,9 @@ export const useConfig = defineStore('config', {
}, },
async getGuiConfig() { async getGuiConfig() {
const authStore = useAuth()
const indexStore = useIndex()
let statusCode = 0 let statusCode = 0
await fetch('/api/channels', { await fetch('/api/channels', {
method: 'GET', method: 'GET',
@ -136,6 +139,7 @@ export const useConfig = defineStore('config', {
}, },
async setGuiConfig(obj: GuiConfig): Promise<any> { async setGuiConfig(obj: GuiConfig): Promise<any> {
const authStore = useAuth()
const stringObj = _.cloneDeep(obj) const stringObj = _.cloneDeep(obj)
const contentType = { 'content-type': 'application/json;charset=UTF-8' } const contentType = { 'content-type': 'application/json;charset=UTF-8' }
let response let response
@ -175,6 +179,8 @@ export const useConfig = defineStore('config', {
}, },
async getPlayoutConfig() { async getPlayoutConfig() {
const authStore = useAuth()
const indexStore = useIndex()
const channel = this.configGui[this.configID].id const channel = this.configGui[this.configID].id
await fetch(`/api/playout/config/${channel}`, { await fetch(`/api/playout/config/${channel}`, {
@ -203,6 +209,7 @@ export const useConfig = defineStore('config', {
}, },
async setPlayoutConfig(obj: any) { async setPlayoutConfig(obj: any) {
const authStore = useAuth()
const channel = this.configGui[this.configID].id const channel = this.configGui[this.configID].id
const contentType = { 'content-type': 'application/json;charset=UTF-8' } const contentType = { 'content-type': 'application/json;charset=UTF-8' }
@ -216,6 +223,8 @@ export const useConfig = defineStore('config', {
}, },
async getUserConfig() { async getUserConfig() {
const authStore = useAuth()
await fetch('/api/user', { await fetch('/api/user', {
method: 'GET', method: 'GET',
headers: authStore.authHeader, headers: authStore.authHeader,
@ -228,6 +237,7 @@ export const useConfig = defineStore('config', {
}, },
async setUserConfig(obj: any) { async setUserConfig(obj: any) {
const authStore = useAuth()
const contentType = { 'content-type': 'application/json;charset=UTF-8' } const contentType = { 'content-type': 'application/json;charset=UTF-8' }
const update = await fetch(`/api/user/${obj.id}`, { const update = await fetch(`/api/user/${obj.id}`, {

View File

@ -2,8 +2,6 @@ import { defineStore } from 'pinia'
import { useAuth } from '~/stores/auth' import { useAuth } from '~/stores/auth'
import { useConfig } from '~/stores/config' import { useConfig } from '~/stores/config'
const authStore = useAuth()
const configStore = useConfig()
export const useMedia = defineStore('media', { export const useMedia = defineStore('media', {
state: () => ({ state: () => ({
@ -17,6 +15,8 @@ export const useMedia = defineStore('media', {
getters: {}, getters: {},
actions: { actions: {
async getTree(path: string, foldersOnly: boolean = false) { async getTree(path: string, foldersOnly: boolean = false) {
const authStore = useAuth()
const configStore = useConfig()
const contentType = { 'content-type': 'application/json;charset=UTF-8' } const contentType = { 'content-type': 'application/json;charset=UTF-8' }
const channel = configStore.configGui[configStore.configID].id const channel = configStore.configGui[configStore.configID].id
const crumbs: Crumb[] = [] const crumbs: Crumb[] = []

View File

@ -10,8 +10,6 @@ dayjs.extend(timezone)
import { useAuth } from '~/stores/auth' import { useAuth } from '~/stores/auth'
import { useConfig } from '~/stores/config' import { useConfig } from '~/stores/config'
const authStore = useAuth()
const configStore = useConfig()
const { timeToSeconds } = stringFormatter() const { timeToSeconds } = stringFormatter()
const { processPlaylist } = playlistOperations() const { processPlaylist } = playlistOperations()
@ -37,6 +35,8 @@ export const usePlaylist = defineStore('playlist', {
}, },
async getPlaylist(date: string) { async getPlaylist(date: string) {
const authStore = useAuth()
const configStore = useConfig()
const timeInSec = timeToSeconds(dayjs().utcOffset(configStore.utcOffset).format('HH:mm:ss')) const timeInSec = timeToSeconds(dayjs().utcOffset(configStore.utcOffset).format('HH:mm:ss'))
const channel = configStore.configGui[configStore.configID].id const channel = configStore.configGui[configStore.configID].id
let dateToday = dayjs().utcOffset(configStore.utcOffset).format('YYYY-MM-DD') let dateToday = dayjs().utcOffset(configStore.utcOffset).format('YYYY-MM-DD')
@ -63,6 +63,8 @@ export const usePlaylist = defineStore('playlist', {
}, },
async playoutStat() { async playoutStat() {
const authStore = useAuth()
const configStore = useConfig()
const channel = configStore.configGui[configStore.configID].id const channel = configStore.configGui[configStore.configID].id
await fetch(`/api/control/${channel}/media/current`, { await fetch(`/api/control/${channel}/media/current`, {