日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Nodejs扩展,实现消息弹窗

發布時間:2024/10/12 编程问答 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nodejs扩展,实现消息弹窗 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

參考https://github.com/olalonde/node-notify的實現

??

模塊的C++代碼 node_gtknotify.cc

#include <v8.h>

#include <node.h>

#include <string>

#include <gtkmm-3.0/gtkmm.h>

#include <libnotifymm.h>

??

using namespace v8;

??

class GtkNotify : node::ObjectWrap{

public:

GtkNotify(){}

~GtkNotify(){}

??

std::string title;

std::string icon;

??

static Persistent<FunctionTemplate> persistent_function_template;

??

static void Init(Handle<Object> target){

HandleScope scope;

Local<FunctionTemplate> local_function_template = FunctionTemplate::New(New);

GtkNotify::persistent_function_template = Persistent<FunctionTemplate>::New(local_function_template);

GtkNotify::persistent_function_template->InstanceTemplate()->SetInternalFieldCount(1);

GtkNotify::persistent_function_template->SetClassName(String::NewSymbol("Notification"));

GtkNotify::persistent_function_template->InstanceTemplate()->SetAccessor(String::New("title"), GetTitle, SetTitle);

GtkNotify::persistent_function_template->InstanceTemplate()->SetAccessor(String::New("icon"), GetIcon, SetIcon);

NODE_SET_PROTOTYPE_METHOD(GtkNotify::persistent_function_template, "send", Send);

target->Set(String::NewSymbol("notification"), GtkNotify::persistent_function_template->GetFunction());

}

??

static Handle<Value> New(const Arguments& args){

HandleScope scope;

GtkNotify* instance = new GtkNotify();

instance->title = "Node.js";

instance->icon = "terminal";

instance->Wrap(args.This());

return args.This();

}

??

static Handle<Value> Send(const Arguments& args){

HandleScope scope;

GtkNotify* instance = node::ObjectWrap::Unwrap<GtkNotify>(args.This());

String::Utf8Value v8str(args[0]);

//彈出消息框

Notify::init("Basic");

Notify::Notification n(instance->title.c_str(), *v8str, instance->icon.c_str());

n.show();

return Boolean::New(true);

}

??

static Handle<Value> GetTitle(Local<String> property, const AccessorInfo& info){

GtkNotify* instance = node::ObjectWrap::Unwrap<GtkNotify>(info.Holder());

return String::New(instance->title.c_str());

}

??

static Handle<Value> GetIcon(Local<String> property, const AccessorInfo& info){

GtkNotify* instance = node::ObjectWrap::Unwrap<GtkNotify>(info.Holder());

return String::New(instance->icon.c_str());

}

??

static void SetTitle(Local<String> property, Local<Value> value, const AccessorInfo& info) {

????????GtkNotify* instance = node::ObjectWrap::Unwrap<GtkNotify>(info.Holder());

????????String::Utf8Value v8str(value);

????????instance->title = *v8str;

}

??

static void SetIcon(Local<String> property, Local<Value> value, const AccessorInfo& info) {

GtkNotify* instance = node::ObjectWrap::Unwrap<GtkNotify>(info.Holder());

String::Utf8Value v8str(value);

instance->icon = *v8str;

}

};

??

Persistent<FunctionTemplate> GtkNotify::persistent_function_template;

??

extern "C"{

static void init(Handle<Object> target){

GtkNotify::Init(target);

}

NODE_MODULE(node_gtknotify, init);

}

??

node-gyp配置文件 binding.gyp

{

"targets": [

{

"target_name": "node_gtknotify",

"sources": [ "src/node_gtknotify.cc" ]

}

]

}

??

文件夾結構

??

執行命令

node-gyp configure

node-gyp build

??

假設沒有安裝對應的庫/路徑找不到。中間會出現頭文件找不到的錯誤;

笨拙的解決方法。在build以下的Makefile中加入

CXXFLAGS += -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/giomm-2.4 -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairomm-1.0 -I/usr/include/freetype2 -I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/atkmm-1.6 -I/usr/include/atk-1.0 -I/usr/include/libnotifymm-1.0

??

上述的庫是依據錯誤提示進行安裝的

??

Javascript測試代碼

var notify = require("./build/Release/node_gtknotify");

var notification = new notify.notification();

notification.title = "Notification title";

notification.icon = "emblem-default"; // see /usr/share/icons/gnome/16x16

notification.send("hello,world");

??

注意,執行時可能有錯誤提示:**符號找不到,這是由于沒有加入對應的共享鏈接庫

??

??

解決方法:在build/node_gtknotify.target.mk中加入

LIBS := -lglibmm-2.4 -lnotify -lnotifymm-1.0

??

執行效果

轉載于:https://www.cnblogs.com/gccbuaa/p/7252475.html

總結

以上是生活随笔為你收集整理的Nodejs扩展,实现消息弹窗的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产成人无码精品久久久久 | 黄色三级视屏 | 国内毛片毛片毛片毛片毛片 | 老头老太吃奶xb视频 | 国产区小视频 | 8x8x国产精品一区二区 | 天天av天天翘 | 人人插插 | 亚洲综合在线视频 | xxxxwwww国产| 免费黄色片网站 | av在线电影网 | 天天想你在线观看完整版电影免费 | 色综合狠狠爱 | 国产黄色av片 | 2019亚洲男人天堂 | 久久免费黄色 | 春色导航| 黄色av网站在线 | 免费黄色的网站 | 久草一本 | 五月婷婷国产 | 伊人加勒比 | 黄色av软件| 男女日日| 国产精品久久一区二区三区动 | 亚洲高清久久 | 日韩精品一区二区三区四区五区 | 国产在线一二区 | 亚洲日批视频 | 国产免费av片在线观看 | 韩国甜性涩爱 | 久久精品一日日躁夜夜躁 | 日韩精品成人免费观看视频 | 亚洲看片 | 国产一区二区三区视频在线观看 | 亚洲一区二区三区精品视频 | 精品人妻伦一区二区三区久久 | 91免费看国产 | 中文在线不卡 | 精品少妇人妻av一区二区 | 久久久精品视 | 成都电影免费大全 | 亚洲av日韩av高潮潮喷无码 | 香蕉钻洞视频 | 成人a级片 | 国产女人18毛片水18精 | 泷泽萝拉在线播放 | 亚洲热影院| 国产aⅴ片 | 超碰香蕉 | 国产调教在线观看 | 免费网站在线观看人数在哪动漫 | 久草视频免费看 | 高清视频在线免费观看 | 国产在线导航 | 中文字幕成人网 | 亚洲美女屁股眼交8 | 久久偷看各类wc女厕嘘嘘偷窃 | 午夜播放| 亚洲久久综合 | 国产aaa大片| 国产精品无码毛片 | 青草视频免费看 | 乌克兰做爰xxxⅹ性视频 | 午夜亚洲福利在线老司机 | 中文字幕日韩一区二区三区 | 天天插夜夜 | 日本免费在线观看视频 | 亚洲最色网站 | 爱情岛论坛永久入口 | 久久网址 | 我们俩电影网mp4动漫官网 | 综合亚洲网| 欧美经典一区 | 性生交大片免费看3p | 鲁丝片一区二区三区 | 日皮毛片 | 日韩在线精品视频一区二区涩爱 | 久热最新视频 | 青草伊人网 | 男人的天堂av女优 | 打屁屁日本xxxxx变态 | 久久国精品 | 日韩一级网站 | 免费久久| 久久久二区 | h视频在线观看网站 | 国产美女喷水视频 | 久久久久人妻一区精品 | 国产欧美一区二区三区免费看 | 三级视频网站在线观看 | 婷婷激情视频 | 美女精品一区二区 | 日本少妇激情舌吻 | 国产一区二区伦理 | 国产又粗又猛又爽又黄的视频小说 | av毛片一区 | 好男人网站 |