我是第一次做前端工作、trapi 和 javascript 的开发人员。我希望有人能同情我并提供一个如何通过 bootstrap.js 脚本设置公共角色权限的示例。node.js v10.16.0
Strapi v3.0.0-next.11
Graphql 14.3.1
MongoDB:3.6
全部在 Windows 10 上
在 Strapi UI 中,它是公共角色的角色和权限
我想将这些框设置为 CHECKED

另一位开发人员使用 bootstrap.js 文件向我们创建的服务(菜单)添加项目。我不知道如何返回关于角色权限的最基本信息。我的函数被称为 test() 我搜索了一些例子,我在stackoverflow上找到了最好的: Strapi Plugin Route Default Permission:
strapi.plugins['users-permissions'].models.role.find
Run Code Online (Sandbox Code Playgroud)
但我不知道如何使用它:
WORKING
function add_widgets_from_sheet(sheet_name, model_object){
console.log(`adding ${sheet_name}`)
let xlsxSheet = Sheets[sheet_name]
const widgets = XLSX.utils.sheet_to_json(xlsxSheet)
widgets.forEach(function (widget) {
//See if the object is already in the db before adding it
model_object.count(widget)
.then(result => {
if (result == 0) {
console.log('Adding '+sheet_name+': ' + JSON.stringify(widget))
return model_object.add(widget) …Run Code Online (Sandbox Code Playgroud)