mirror of
https://github.com/EvolutionAPI/evolution-manager.git
synced 2025-12-24 21:27:44 -06:00
add doc
This commit is contained in:
@@ -85,7 +85,8 @@ export const useAppStore = defineStore('app', {
|
||||
this.instancesList = []
|
||||
this.instancesKeys = {}
|
||||
this.connectionsList = []
|
||||
window.localStorage.clear();
|
||||
this.saveLocalStorage()
|
||||
|
||||
},
|
||||
|
||||
async reconnect() {
|
||||
|
||||
65
src/store/doc.js
Normal file
65
src/store/doc.js
Normal file
@@ -0,0 +1,65 @@
|
||||
// Utilities
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
|
||||
export const useDocStore = defineStore('doc', {
|
||||
getters: {
|
||||
lang: (state) => state.language,
|
||||
},
|
||||
state: () => ({
|
||||
language: 'pt_br',
|
||||
languages: [],
|
||||
docs: {},
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async setLang(lang) {
|
||||
this.language = lang;
|
||||
},
|
||||
async loadDocs() {
|
||||
try {
|
||||
const { languages, docs } = getFileTree();
|
||||
this.languages = languages;
|
||||
this.docs = docs;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
async loadDoc(path) {
|
||||
try {
|
||||
debugger;
|
||||
const { language } = this;
|
||||
const doc = this.docs[path]
|
||||
const content = await doc[language]();
|
||||
return {
|
||||
content,
|
||||
language,
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw new Error('Documento não encontrado');
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Function to get the file tree from @doc
|
||||
function getFileTree() {
|
||||
const tree = import.meta.glob('@docs/**/*.{md,mdx}', { as: 'raw'})
|
||||
const docsFiles = {}
|
||||
const languages = new Set()
|
||||
|
||||
Object.entries(tree).forEach(([path, imprt]) => {
|
||||
const [, , lang, ...rest] = path.split('/')
|
||||
languages.add(lang)
|
||||
|
||||
const filename = rest.join('/').replace(/\.mdx?$/, '')
|
||||
docsFiles[filename] = docsFiles[filename] || {}
|
||||
docsFiles[filename][lang] = imprt
|
||||
})
|
||||
|
||||
return {
|
||||
languages: Array.from(languages),
|
||||
docs: docsFiles,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user