From 5fd0a69ebedb4c6707a80e809d3a3d03abc6f072 Mon Sep 17 00:00:00 2001 From: JieGG <947295340@qq.com> Date: Mon, 14 Oct 2019 13:27:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0Json=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=8F=8A=E5=85=B6=E6=A8=A1=E6=9D=BF=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Native.Csharp/App/Core/LibExport.cs | 38 ++++++------ Native.Csharp/App/Core/MenuExport.cs | 46 ++++++++++---- Native.Csharp/App/Core/StatusExport.cs | 26 ++++---- Native.Csharp/Native.Csharp.json | 83 ++++++++++++++------------ 4 files changed, 112 insertions(+), 81 deletions(-) diff --git a/Native.Csharp/App/Core/LibExport.cs b/Native.Csharp/App/Core/LibExport.cs index e92c520a..3fd37740 100644 --- a/Native.Csharp/App/Core/LibExport.cs +++ b/Native.Csharp/App/Core/LibExport.cs @@ -57,7 +57,7 @@ private static string AppInfo () { // ���������޸� // - Common.AppName = "��Q����Ӧ�� for C#"; + Common.AppName = "��Q����Ӧ��"; Common.AppVersion = Version.Parse ("1.0.0"); // @@ -223,25 +223,25 @@ private static void ResolveAppbackcall () } /* - * Id: 8 + * Id: 11 * Name: �������������� */ if (Common.UnityContainer.IsRegistered ("��������������") == true) { - ReceiveFriendAdd_8 = Common.UnityContainer.Resolve ("��������������").ReceiveFriendAddRequest; + ReceiveFriendAdd_11 = Common.UnityContainer.Resolve ("��������������").ReceiveFriendAddRequest; } /* - * Id: 9 + * Id: 12 * Name: Ⱥ���������� */ if (Common.UnityContainer.IsRegistered ("Ⱥ����������") == true) { - ReceiveAddGroupRequest_9 = Common.UnityContainer.Resolve ("Ⱥ����������").ReceiveAddGroupRequest; + ReceiveAddGroupRequest_12 = Common.UnityContainer.Resolve ("Ⱥ����������").ReceiveAddGroupRequest; } if (Common.UnityContainer.IsRegistered ("Ⱥ����������") == true) { - ReceiveAddGroupBeInvitee_9 = Common.UnityContainer.Resolve ("Ⱥ����������").ReceiveAddGroupBeInvitee; + ReceiveAddGroupBeInvitee_12 = Common.UnityContainer.Resolve ("Ⱥ����������").ReceiveAddGroupBeInvitee; } /* @@ -536,50 +536,50 @@ private static int Evnet__eventFriend_Add (int subType, int sendTime, long fromQ } /* - * Id: 8 + * Id: 11 * Type: 301 * Name: �������������� * Function: _eventRequest_AddFriend */ - public static event EventHandler ReceiveFriendAdd_8; + public static event EventHandler ReceiveFriendAdd_11; [DllExport (ExportName = "_eventRequest_AddFriend", CallingConvention = CallingConvention.StdCall)] private static int Evnet__eventRequest_AddFriend (int subType, int sendTime, long fromQQ, IntPtr msg, string responseFlag) { - CqAddFriendRequestEventArgs args = new CqAddFriendRequestEventArgs (8, "��������������", sendTime.ToDateTime (), fromQQ, msg.ToString (_defaultEncoding), responseFlag); + CqAddFriendRequestEventArgs args = new CqAddFriendRequestEventArgs (11, "��������������", sendTime.ToDateTime (), fromQQ, msg.ToString (_defaultEncoding), responseFlag); if (subType == 1) { - if (ReceiveFriendAdd_8 != null) + if (ReceiveFriendAdd_11 != null) { - ReceiveFriendAdd_8 (null, args); + ReceiveFriendAdd_11 (null, args); } } return Convert.ToInt32 (args.Handler); } /* - * Id: 9 + * Id: 12 * Type: 302 * Name: Ⱥ���������� * Function: _eventRequest_AddGroup */ - public static event EventHandler ReceiveAddGroupRequest_9; - public static event EventHandler ReceiveAddGroupBeInvitee_9; + public static event EventHandler ReceiveAddGroupRequest_12; + public static event EventHandler ReceiveAddGroupBeInvitee_12; [DllExport (ExportName = "_eventRequest_AddGroup", CallingConvention = CallingConvention.StdCall)] private static int Evnet__eventRequest_AddGroup (int subType, int sendTime, long fromGroup, long fromQQ, IntPtr msg, string responseFlag) { - CqAddGroupRequestEventArgs args = new CqAddGroupRequestEventArgs (9, "Ⱥ����������", sendTime.ToDateTime (), fromGroup, fromQQ, msg.ToString (_defaultEncoding), responseFlag); + CqAddGroupRequestEventArgs args = new CqAddGroupRequestEventArgs (12, "Ⱥ����������", sendTime.ToDateTime (), fromGroup, fromQQ, msg.ToString (_defaultEncoding), responseFlag); if (subType == 1) { - if (ReceiveAddGroupRequest_9 != null) + if (ReceiveAddGroupRequest_12 != null) { - ReceiveAddGroupRequest_9 (null, args); + ReceiveAddGroupRequest_12 (null, args); } } else if (subType == 2) { - if (ReceiveAddGroupBeInvitee_9 != null) + if (ReceiveAddGroupBeInvitee_12 != null) { - ReceiveAddGroupBeInvitee_9 (null, args); + ReceiveAddGroupBeInvitee_12 (null, args); } } return Convert.ToInt32 (args.Handler); diff --git a/Native.Csharp/App/Core/MenuExport.cs b/Native.Csharp/App/Core/MenuExport.cs index 7864a7bd..56999928 100644 --- a/Native.Csharp/App/Core/MenuExport.cs +++ b/Native.Csharp/App/Core/MenuExport.cs @@ -32,12 +32,21 @@ static MenuExport () private static void ResolveAppbackcall () { /* - * Name: �򿪿���̨ - * Function: _eventOpenConsole + * Name: ����A + * Function: _menuA */ - if (Common.UnityContainer.IsRegistered ("�򿪿���̨") == true) + if (Common.UnityContainer.IsRegistered ("����A") == true) { - Menu__eventOpenConsole = Common.UnityContainer.Resolve ("�򿪿���̨").CallMenu; + Menu__menuA = Common.UnityContainer.Resolve ("����A").CallMenu; + } + + /* + * Name: ����B + * Function: _menuB + */ + if (Common.UnityContainer.IsRegistered ("����B") == true) + { + Menu__menuB = Common.UnityContainer.Resolve ("����B").CallMenu; } @@ -46,16 +55,31 @@ private static void ResolveAppbackcall () #region --��������-- /* - * Name: �򿪿���̨ - * Function: _eventOpenConsole + * Name: ����A + * Function: _menuA + */ + public static event EventHandler Menu__menuA; + [DllExport (ExportName = "_menuA", CallingConvention = CallingConvention.StdCall)] + private static int Evnet__menuA () + { + if (Menu__menuA != null) + { + Menu__menuA (null, new CqCallMenuEventArgs ("����A")); + } + return 0; + } + + /* + * Name: ����B + * Function: _menuB */ - public static event EventHandler Menu__eventOpenConsole; - [DllExport (ExportName = "_eventOpenConsole", CallingConvention = CallingConvention.StdCall)] - private static int Evnet__eventOpenConsole () + public static event EventHandler Menu__menuB; + [DllExport (ExportName = "_menuB", CallingConvention = CallingConvention.StdCall)] + private static int Evnet__menuB () { - if (Menu__eventOpenConsole != null) + if (Menu__menuB != null) { - Menu__eventOpenConsole (null, new CqCallMenuEventArgs ("�򿪿���̨")); + Menu__menuB (null, new CqCallMenuEventArgs ("����B")); } return 0; } diff --git a/Native.Csharp/App/Core/StatusExport.cs b/Native.Csharp/App/Core/StatusExport.cs index d9076f44..f4cd99f2 100644 --- a/Native.Csharp/App/Core/StatusExport.cs +++ b/Native.Csharp/App/Core/StatusExport.cs @@ -32,12 +32,12 @@ static StatusExport () private static void ResolveAppbackcall () { /* - * Name: CPUʹ���� - * Function: _statusCPU + * Name: ����ʱ�� + * Function: _statusUptime */ - if (Common.UnityContainer.IsRegistered ("CPUʹ����") == true) + if (Common.UnityContainer.IsRegistered ("����ʱ��") == true) { - Status_CPU = Common.UnityContainer.Resolve ("CPUʹ����").CqStatus; + Status_UPTIME = Common.UnityContainer.Resolve ("����ʱ��").CqStatus; } @@ -47,19 +47,19 @@ private static void ResolveAppbackcall () #region --��������-- /* * Id: 1 - * Name: CPUʹ���� - * Title: CPU - * Function: _statusCPU + * Name: ����ʱ�� + * Title: UPTIME + * Function: _statusUptime * Period: 1000 */ - public static event EventHandler Status_CPU; - [DllExport (ExportName = "_statusCPU", CallingConvention = CallingConvention.StdCall)] - private static string Evnet__statusCPU () + public static event EventHandler Status_UPTIME; + [DllExport (ExportName = "_statusUptime", CallingConvention = CallingConvention.StdCall)] + private static string Evnet__statusUptime () { - CqStatusEventArgs args = new CqStatusEventArgs (1, "CPUʹ����", "CPU", 1000); - if (Status_CPU != null) + CqStatusEventArgs args = new CqStatusEventArgs (1, "����ʱ��", "UPTIME", 1000); + if (Status_UPTIME != null) { - Status_CPU (null, args); + Status_UPTIME (null, args); } return args.FloatWindowData; } diff --git a/Native.Csharp/Native.Csharp.json b/Native.Csharp/Native.Csharp.json index 44c148be..192026fd 100644 --- a/Native.Csharp/Native.Csharp.json +++ b/Native.Csharp/Native.Csharp.json @@ -1,21 +1,22 @@ // 酷Q 的Json文件支持以 // 开头的注释。 -// 打包前,应用的 .dll, .json 的文件名须以appid命名,应用AppInfo返回的内容须改为appid -// 如 appid=com.example.demo, 则dll及json文件需分别命名为 com.example.demo.dll、com.example.demo.json +// 开发模式下,应用的 app.dll 及 app.json 文件须放在 dev/[appid]/ 目录下,应用 AppInfo 函数返回的内容须改为 appid +// 如 appid=com.example.demo, 则dll及json文件需分别放在 dev/com.example.demo/app.dll、dev/com.example.demo/app.json +// [重要] appid 规则见 https://cqp.im/v9/appid { "ret": 1, // 返回码,固定为1 "apiver": 9, // Api版本,本SDK为9 - "name": "酷Q样例应用 for C#", // 应用名称 + "name": "酷Q样例应用", // 应用名称 "version": "1.0.0", // 应用版本 "version_id": 1, // 应用顺序版本(每次发布时至少+1) - "author": "JieGG", // 应用作者 - "description": "酷Q样例应用 for C# (V9应用机制)", + "author": "Example", // 应用作者 + "description": "酷Q样例应用(V9应用机制)", "event": [ // 事件列表,同一事件类型可重复定义(发布前请删除无用事件) { "id": 1, // 事件ID "type": 21, // 事件类型 "name": "私聊消息处理", // 事件名称 "function": "_eventPrivateMsg", // 事件对应函数 - "priority": 30000 // 事件优先级(参见 cq.im/deveventpriority) + "priority": 30000 // 事件优先级(参见 https://cqp.im/deveventpriority ) }, { "id": 2, @@ -74,14 +75,14 @@ "priority": 30000 }, { - "id": 8, + "id": 11, "type": 301, "name": "好友添加请求处理", "function": "_eventRequest_AddFriend", "priority": 30000 }, { - "id": 9, + "id": 12, "type": 302, "name": "群添加请求处理", "function": "_eventRequest_AddGroup", @@ -118,42 +119,48 @@ ], "menu": [ // 设置菜单(发布前请删除无用菜单,如果无需设置菜单请全部删除) { - "name": "打开控制台", // 菜单名称 - "function": "_eventOpenConsole" // 菜单对应函数 + "name": "设置A", //菜单名称 + "function": "_menuA" //菜单对应函数 + }, + { + "name": "设置B", + "function": "_menuB" } ], - "status": [ // 悬浮窗状态 + "status": [ // 悬浮窗状态(见 com.example.status 样例) { "id": 1, // 悬浮窗ID - "name": "CPU使用率", // 名称 (显示在酷Q菜单中的名称) - "title": "CPU", // 悬浮窗标题 - "function": "_statusCPU", // 回调函数 - "period": "1000" // 刷新时间 (单位: ms, 目前只能 1000ms 一次) + "name": "运行时间", // 名称 + "title": "UPTIME", // 英文名称 + "function": "_statusUptime", // 数据更新对应函数 + "period": "1000" // 更新间隔(单位ms(毫秒),目前仅支持1000ms(1秒)) } ], "auth": [ // 应用权限(发布前请删除无用权限) - //20, //[敏感]取Cookies getCookies / getCsrfToken - //30, //接收语音 getRecord - 101, //发送群消息 sendGroupMsg - 103, //发送讨论组消息 sendDiscussMsg - 106, //发送私聊消息 sendPrivateMsg - 110, //发送赞 sendLike - 120, //置群员移除 setGroupKick - 121, //置群员禁言 setGroupBan - 122, //置群管理员 setGroupAdmin - 123, //置全群禁言 setGroupWholeBan - 124, //置匿名群员禁言 setGroupAnonymousBan - 125, //置群匿名设置 setGroupAnonymous - 126, //置群成员名片 setGroupCard - //127, //[敏感]置群退出 setGroupLeave - 128, //置群成员专属头衔 setGroupSpecialTitle - 130, //取群成员信息 getGroupMemberInfoV2 / getGroupMemberInfo - 131, //取陌生人信息 getStrangerInfo - 140, //置讨论组退出 setDiscussLeave - 150, //置好友添加请求 setFriendAddRequest - 151, //置群添加请求 setGroupAddRequest - 160, //取群成员列表 getGroupMemberList - 161, //取群列表 getGroupList - 180 //撤回消息 deleteMsg + //20, //[敏感]取Cookies getCookies / getCsrfToken + //30, //接收语音 getRecord + 101, //发送群消息 sendGroupMsg + 103, //发送讨论组消息 sendDiscussMsg + 106, //发送私聊消息 sendPrivateMsg + //110, //[敏感]发送赞 sendLike + 120, //置群员移除 setGroupKick + 121, //置群员禁言 setGroupBan + 122, //置群管理员 setGroupAdmin + 123, //置全群禁言 setGroupWholeBan + 124, //置匿名群员禁言 setGroupAnonymousBan + 125, //置群匿名设置 setGroupAnonymous + 126, //置群成员名片 setGroupCard + //127, //[敏感]置群退出 setGroupLeave + 128, //置群成员专属头衔 setGroupSpecialTitle + 130, //取群成员信息 getGroupMemberInfo + 131, //取陌生人信息 getStrangerInfo + 132, //取群信息 getGroupInfo + 140, //置讨论组退出 setDiscussLeave + 150, //置好友添加请求 setFriendAddRequest + 151, //置群添加请求 setGroupAddRequest + 160, //取群成员列表 getGroupMemberList + 161, //取群列表 getGroupList + 162, //取好友列表 getFriendList + 180 //撤回消息 deleteMsg ] }