初始化

This commit is contained in:
魏啾
2024-03-21 15:33:26 +08:00
parent 179418e65f
commit 53afc38e76
3486 changed files with 792466 additions and 1 deletions

33
framework/12-resource.js Normal file
View File

@@ -0,0 +1,33 @@
class RepositoryBase {
constructor(resource) {
this.resource = resource
}
list(query) {
return uni.api.get(this.resource, query)
}
item(id) {
const url = this.resource + '/' + id
return uni.api.get(url)
}
add(newItem) {
return uni.api.post(this.resource, newItem, true)
}
save(id, data) {
const url = this.resource + '/' + id
return uni.api.post(url, data, true, 'PUT')
}
remove(id) {
const url = this.resource + '/' + id
return uni.api.post(url, {}, true, 'DELETE')
}
}
uni.resource = (resource) => {
return new RepositoryBase(resource)
}