1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import {
- getAllConfig,
- } from "@/api/user";
- import {
- getArticle
- } from "@/api/article.js";
- import {
- formatRich
- } from "@/core/app.js";
- import {
- ref
- } from "vue";
- export const useReqConfig = () => {
- const configData = ref(null)
- const articleData = ref(null)
- const getAllConfigData = async (parmas) => {
- let res = await getAllConfig(parmas)
- if (res) {
- configData.value = res.data
- return configData.value
- }
- }
- const getConfig = (list = configData.value, name, key) => {
- let res = ''
- if (list && list.length > 0) res = list.find(item => item.name == name)
- if (res[key]) res = res[key]
- else res = ''
- return res
- }
- // 单个文章
- const getArticleDetails = async (parmas) => {
- let res = await getArticle(parmas)
- if (res) {
- articleData.value = res.data
- articleData.value.content = formatRich(res.data.content)
- return articleData.value
- }
- }
- return {
- configData,
- articleData,
- getAllConfigData,
- getArticleDetails,
- getConfig
- }
- }
|