mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 07:19:26 +00:00
Panel store added.
This commit is contained in:
parent
887080efa6
commit
8ba7689c39
1 changed files with 34 additions and 4 deletions
|
|
@ -1,24 +1,54 @@
|
|||
import { appUrl } from '@/services/ApiService'
|
||||
import { AuthCall } from '@/services/EncryptService'
|
||||
import axios from 'axios'
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export const usePanelStore = defineStore('panel', () => {
|
||||
const current = ref({
|
||||
dir: false,
|
||||
name: false,
|
||||
description: false,
|
||||
aspectRatio: false,
|
||||
macros: false,
|
||||
thumb: false,
|
||||
html: false,
|
||||
style: false,
|
||||
})
|
||||
|
||||
const list = ref([])
|
||||
|
||||
const getPanels = async () => {
|
||||
console.log(list.value.length)
|
||||
const get = async (dir) => {
|
||||
const data = AuthCall({ dir: dir })
|
||||
// alert(JSON.stringify(data))
|
||||
const resp = await axios.post(appUrl() + '/panel/get', data)
|
||||
|
||||
if (!resp.data && !current.value.html) return false
|
||||
|
||||
current.value.name = resp.data.name
|
||||
current.value.description = resp.data.description
|
||||
current.value.aspectRatio = resp.data.aspectRatio
|
||||
current.value.macros = resp.data.macros
|
||||
current.value.thumb = resp.data.thumb
|
||||
current.value.html = resp.data.html
|
||||
current.value.style = resp.data.style
|
||||
|
||||
return current.value
|
||||
}
|
||||
|
||||
const getList = async () => {
|
||||
if (list.value.length > 0) return list.value
|
||||
|
||||
const resp = await axios.post(appUrl() + '/panel/list')
|
||||
list.value = resp.data.data
|
||||
list.value = resp.data
|
||||
|
||||
return list.value
|
||||
}
|
||||
|
||||
return {
|
||||
current,
|
||||
list,
|
||||
getPanels,
|
||||
get,
|
||||
getList,
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue