插件开发使用报错
2020-12-14 20:58:36
  • 访问次数: 2
  • 注册日期: 2020-12-14
  • 最后登录: 2020-12-14
{ 
                      "name": 
                      "xuanxuan-ext", 
                      "displayName": 
                      "
                      群消息置顶
                      ", 
                      "version": 
                      "1.0.0", 
                      "description": 
                      "
                      允许在群消息中选择某条消息置顶
                      ", 
                      "main": 
                      "index.js", 
                      "publisher": 
                      "Samuel Studio", 
                      "scripts": { 
                      "test": 
                      "npm run test" 
                       }, 
                      "repository": { 
                      "type": 
                      "git", 
                      "url": 
                      "http://180.178.55.164:8099/samuel/xuanxuanExt.git" 
                       }, 
                      "keywords": [ 
                      "xuanxuanim" 
                       ], 
                      "author": 
                      "Samuel", 
                      "license": 
                      "WTFPL", 
                      "xext" : { 
                      "type" : 
                      "plugin", 
                      "hot": 
                      true 
                       }, 
                      "engines": { 
                      "xuanxuan": 
                      "^3.0", 
                      "platform": 
                      "electron,nwjs" 
                       }, 
                      "usesPermissions" : [ 
                      "components", 
                      "contextmenu" 
                       ]
}

这个是package.json的配置. 


                      const 
                      Modal = require(
                      'xext/components/Modal'); 
                      let 
                      timerTask;
module.
                      exports = { 
                      onAttach:(ext) => { 
                      console.
                      log(
                      `samuel project attached....`) 
                      timerTask = 
                      setTimeout(() => { 
                      Modal.
                      alert(
                      '
                      扩展加载完成已经
                       10 
                      秒钟了,刚刚加载等扩展名称是:
                      ' + ext.
                      displayName);
        }, 
                      10 * 
                      1000);
    }, 
                      contextMenuCreators : [
        { 
                      match : 
                      'message.text', 
                      create: context =>{ 
                      const {
                      message} = context; 
                      const 
                      messageContent = 
                      message.
                      content; 
                      return [
                    { 
                      icon: 
                      'mdi-start', 
                      label : 
                      "
                      在对话框显示消息
                      ", 
                      click : ()=>{ 
                      console.
                      log(
                      `samuel project 
                      在对话框显示消息
                      ....`) 
                      Modal.
                      alert(
                      messageContent)
                        }
                    }
                ]
            }
        }
    ]
}


这个是index.js的内容

开发板暄暄加载后弹出权限确认界面, 点击确认后成功安装本地插件.  但是在刷新之后载入的时候使用报错:


Call extension api "components.Modal" failed, because the extension "xuanxuan-ext" has not permission to access the api.


我明明已经授权了啊, 为什么还会有这个错误.


沙发
2020-12-18 17:27:02
喧喧-Bee
  • 访问次数: 234
  • 注册日期: 2019-08-28
  • 最后登录: 2023-10-24

应该已经在交流群沟通过了,这块有个权限控制的:

https://www.xuanim.com/book/dev/257.html

扩展 API 根据权限的不同划分为 7 个等级,等级越高的 API 拥有的权限更高,能够实现更复杂的功能。在 “基础版” 授权中客户端扩展可以使用 等级 5  及小于等级 5 下的所有 API,在 “增强版” 和 “OEM” 版本中客户端扩展可以使用所有等级的扩展 API。


1/1