feat: permissions

This commit is contained in:
JaguarJack
2022-12-07 19:28:57 +08:00
parent a1d9468a91
commit 8c537e6656
45 changed files with 1030 additions and 372 deletions

View File

@@ -1,14 +1,26 @@
import http from '/admin/support/http'
import { Ref, ref } from 'vue'
import { isFunction } from '../../support/helper'
export function useShow(path: string, id: string | number) {
return new Promise((resolve, reject) => {
http
.get(path + '/' + id)
.then(response => {
resolve(response.data)
})
.catch(e => {
reject(e)
})
const loading = ref<boolean>(true)
const data = ref<object>()
// 后置钩子
const afterShow = ref()
export function useShow(path: string, id: string | number, fillData: null | Ref = null) {
http.get(path + '/' + id).then(r => {
loading.value = false
data.value = r.data.data
if (fillData) {
fillData.value = r.data.data
if (isFunction(afterShow.value)) {
afterShow.value(fillData)
}
}
})
return { data, loading, afterShow }
}