Skip to content

Commit

Permalink
fix: 修复无法删除函数的问题;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Aug 4, 2021
1 parent b664266 commit ff0d855
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
26 changes: 14 additions & 12 deletions packages/devops-admin/src/views/development/functions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@

<script>
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import { db } from '@/api/cloud'
import { db } from '../../api/cloud'
const defaultCode = `
import cloud from '@/cloud-sdk'
Expand All @@ -183,17 +183,10 @@ exports.main = async function (ctx) {
// 数据库操作
const db = cloud.database()
const db_res = await db.collection('admins').get()
console.log(db_res)
const r = await db.collection('admins').get()
console.log(r)
// 网络操作
const res = await cloud.fetch("https://www.v2ex.com/api/topics/hot.json")
console.log(res.status)
return {
data: db_res.data,
fetch: res.data
}
return r.data
}
`
Expand Down Expand Up @@ -416,9 +409,18 @@ export default {
async handleDelete(row, index) {
await this.$confirm('确认要删除此数据?', '删除确认')
if(row.status) {
return this.$message.error('请先停用函数,再删除!')
}
const $ = db.command
// 执行删除请求
const r = await db.collection('__functions')
.where({ _id: row._id })
.where({
_id: row._id,
status: 0,
reserved: $.neq(true)
})
.remove()
if (!r.ok) {
Expand Down
8 changes: 1 addition & 7 deletions packages/devops-server/src/router/sys_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ export default {
0
]
},
"reserved": {
"required": true,
"default": false,
"in": [
false
]
}
"reserved": "$value !== true"
}
},
"count": "$has('function.read')"
Expand Down

0 comments on commit ff0d855

Please sign in to comment.