当前位置: 首页 > news >正文

大连承接网站制作投放广告的网站

大连承接网站制作,投放广告的网站,深圳做营销网站制作,自己这么做网站随着第一章中构建的应用程序,我们将开始将其与Electron框架中的模块集成,并以此为基础,以更实用的方式了解它们。 过程之间的通信 根据第二章中的解释,我们将发送每个进程之间的消息;具体来说联系人和聊天&#xff1…

随着第一章中构建的应用程序,我们将开始将其与Electron框架中的模块集成,并以此为基础,以更实用的方式了解它们。

过程之间的通信

根据第二章中的解释,我们将发送每个进程之间的消息;具体来说联系人和聊天;这些数据将在主过程中定义,因为这是负责处理这些数据的过程我们之前已经将其与中使用的客户端-服务器体系结构进行了比较web编程,主要过程已经是服务器和网页一直是客户端,它是从我们可以管理所有这些数据,正如我们将在整本书中看到的那样第一次联系,我们将了解如何从主进程处理到网页。

上传联系人和聊天

为了传递主流程中定义的数据,我们将使用以下结构;数据将从主进程中获得,为了模拟数据库等外部结构,我们将创建一个单独的文件到index.js,该文件将负责提供数据,我们将使用数据创建几个模块,使其易于使用:data.js

const contacts = [{name: "Alex Alexis",image: "https://randomuser.me/api/portraits/women/56.jpg",last_chat: [{date: "9:15 AM",message: "Lorem ipsum dolor sit amet",},],},{name: "Eli Barrett",image: "https://randomuser.me/api/portraits/women/96.jpg",last_chat: [{date: "8:30 PM",message: "Lorem ipsum dolor sit amet",},],},{name: "Kylie Young",image: "https://randomuser.me/api/portraits/women/45.jpg",last_chat: [{date: "8:30 PM",message: "Lorem ipsum dolor sit amet",},],},{name: "Kylie Young",image: "https://randomuser.me/api/portraits/women/45.jpg",last_chat: [{date: "8:30 PM",message: "Lorem ipsum dolor sit amet",},],},
];
const chats = [{user: {name: "Alex Alexis",image: "https://randomuser.me/api/portraits/women/56.jpg",},chat: {date: "9:15 AM",message:"Lorem ipsum dolor sit amet consectetur adipisicing elit.Doloribus reprehenderit voluptatibus cumque, deserunt deleniti consequatur adipisci nisi consequuntur sunt itaque? Sunt aspernatur, ratione labore ipsam enim unde itaque dolorum magni?",},},{user: {name: "Eli Barrett",image: "https://randomuser.me/api/portraits/women/58.jpg",},chat: {date: "9:50 AM",message:"Lorem ipsum dolor sit amet consectetur adipisicing elit.Doloribus reprehenderit voluptatibus cumque, deserunt deleniti consequatur adipisci nisi consequuntur sunt itaque? Sunt aspernatur, ratione labore ipsam enim unde itaque dolorum magni?",},},
];module.exports.contacts = contacts;
module.exports.chats = chats;

从“index.js”,我们激活与Node的集成并消费它们;我们定义了一个事件,在该事件中,当通过“did-finish-load”事件加载窗口(网页)时,我们通过消息传输数据:

const { app, BrowserWindow, Menu, shell } = require("electron");
const { chats, contacts } = require("./data");function createWindow() {let win = new BrowserWindow({width: 800,height: 600,webPreferences: {nodeIntegration: true,contextIsolation: false,},});win.loadFile("index.html");win.webContents.openDevTools();win.webContents.on("did-finish-load", () => {win.webContents.send("pr-chats", chats);win.webContents.send("pr-contacts", contacts);});
}
app.whenReady().then(createWindow);

从网页上,由于我们激活了与Node的集成,我们可以导入ipcRenderer模块,以便能够与主进程通信,特别是,我们有兴趣创建一个侦听器来接收主进程发送的数据:
index.html

<script>function createChats(chats) {var lis = ''chats.forEach((c) => {lis += ` <div class="d-flex chat"><div class="w-75 "><div class="card bg-dark"><div class="card-body text-light">${c.chat.message}</div></div><p class="small text-muted float-end">${c.chat.date}</p></div><div class="w-25 d-flex align-items-end"><img class="rounded-pill ms-3 avatar" src="${c.user.image}"/></div></div>`})document.querySelector('.chats').innerHTML = lis;}function createContacts(contacts) {var lis = ''contacts.forEach((c) => {lis += `<li class="p-2 card mt-2"><div class="card-body"><div class="d-flex"><div><img class="rounded-pill me-3" width="60"src="${c.image}"></div><div><p class="fw-bold mb-0 text-light">${c.name}</p><p class="small text-muted">${c.last_chat[0]['message']}
</p></div><div><p class="small text-muted">${c.last_chat[0]['date']}</p><span class="badge bg-danger rounded-pill float-end">1</span></div></div></div></li>`})document.querySelector('.contact').innerHTML = lis;}const { ipcRenderer } = require('electron')ipcRenderer.on('pr-chats', (event, chats) => {createChats(chats)})ipcRenderer.on('pr-contacts', (event, contacts) => {createContacts(contacts)})
</script>

在这里插入图片描述
根据具体情况,我们稍微更改函数的签名,在该签名中,我们接收图表或联系人作为参数。我们调用这些函数来从先前定义的侦听器构建列表;最后,我们将得到相同的结果,但现在数据从主进程进入渲染进程。

按选择加载联系人

在本节中,我们将实现以下功能:通过单击其中一个联系人,加载与所述联系人对应的聊天或消息;为了模拟这种行为,我们将使用联系人数组索引,就好像它是我们有兴趣获得聊天记录的联系人的ID一样;为此,我们实现了一个点击事件:
在这里插入图片描述
以及函数,我们调用主进程来提供基于ID的聊天:

 function changeContact(index) {ipcRenderer.send('pp-get-chat', index)}

在数据拉取中,我们将稍微改变结构,我们将有一个数组,其中数组的每个位置都将由上一条消息中提供的联系人索引访问:

const contacts = [{name: "Alex Alexis",image: "https://randomuser.me/api/portraits/women/56.jpg",last_chat: [{date: "9:15 AM",message: "Lorem ipsum dolor sit amet consectetur adipisicing elit",},],},{name: "Ramon Reed",image: "https://randomuser.me/api/portraits/women/59.jpg",last_chat: [{date: "9:15 AM",message: "Lorem Hello!",},],},{name: "Eli Barrett",image: "https://randomuser.me/api/portraits/women/58.jpg",last_chat: [{date: "8:55 PM",message: "Lorem ipsum dolor sit ...",},],},
];
const chats = [[{user: {name: "Alex Alexis",image: "https://randomuser.me/api/portraits/women/56.jpg",},chat: {date: "9:15 AM",message:"Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus reprehenderit voluptatibus cumque, deserunt deleniti consequatur adipisci nisi consequuntur sunt itaque? Sunt aspernatur, ratione labore ipsam enim unde itaque dolorum magni?",},},{user: {name: "Luis Perez",image: "https://randomuser.me/api/portraits/women/58.jpg",},chat: {date: "9:50 AM",message:"Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus reprehenderit voluptatibus cumque, deserunt deleniti consequatur adipisci nisi consequuntur sunt itaque? Sunt aspernatur, ratione labore ipsam enim unde itaque dolorum magni?",},},],[],[{user: {name: "Anselmo Perez",image: "https://randomuser.me/api/portraits/women/1.jpg",},chat: {date: "10:45 PM",message:"Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus reprehenderit voluptatibus cumque, deserunt deleniti consequatur adipisci nisi consequuntur sunt itaque? Sunt aspernatur, ratione labore ipsam enim unde itaque dolorum magni?",},},],
];module.exports.contacts = contacts;
module.exports.chats = chats;

我们实现了从ipcRenderer发送的事件,其中,将接收到的索引作为参数,返回相应的聊天:
index.js

const { ipcMain } = require("electron");
win.webContents.on("did-finish-load", () => {//win.webContents.send("pr-chats", chats);win.webContents.send("pr-contacts", contacts);
});
ipcMain.on('pp-get-chat', (event, index) => {win.webContents.send('pr-chats', chats[index])
})

当所选联系人没有聊天时,我们还会显示一个默认窗口:

function createChats(chats) {var lis = ''if (chats.length == 0) {lis += ` <div class="d-flex chat"><div class="w-75 "><div class="card bg-dark"><div class="card-body text-light"><h3 class='text-center'>No message</h3></div></div></div></div>`}else {chats.forEach((c) => {lis += ` <div class="d-flex chat"><div class="w-75 "><div class="card bg-dark"><div class="card-body text-light">${c.chat.message}</div></div><p class="small text-muted float-end">${c.chat.date}</p></div><div class="w-25 d-flex align-items-end"><img class="rounded-pill ms-3 avatar" src="${c.user.image}"/></div></div>`})}document.querySelector('.chats').innerHTML = lis;}

这样,在选择联系人时,我们会改变显示的消息或聊天,并完成骨架应用程序;您可以在以下位置找到源代码:
https://github.com/libredesarrollo/electron-chat-app/releases/tag/v0.1


文章转载自:
http://home.tgnr.cn
http://soundness.tgnr.cn
http://doings.tgnr.cn
http://gaingiving.tgnr.cn
http://rhododendra.tgnr.cn
http://creative.tgnr.cn
http://kogai.tgnr.cn
http://naught.tgnr.cn
http://alabastron.tgnr.cn
http://pentalpha.tgnr.cn
http://mugient.tgnr.cn
http://flatwise.tgnr.cn
http://singing.tgnr.cn
http://polyvinyl.tgnr.cn
http://mercilessly.tgnr.cn
http://hawksbill.tgnr.cn
http://hotspur.tgnr.cn
http://assertory.tgnr.cn
http://pointsman.tgnr.cn
http://exert.tgnr.cn
http://hybridize.tgnr.cn
http://aquilegia.tgnr.cn
http://adar.tgnr.cn
http://disingenuous.tgnr.cn
http://totipotency.tgnr.cn
http://stature.tgnr.cn
http://spindleshanks.tgnr.cn
http://coverer.tgnr.cn
http://piston.tgnr.cn
http://pejorate.tgnr.cn
http://reseau.tgnr.cn
http://netting.tgnr.cn
http://enzyme.tgnr.cn
http://aristotelean.tgnr.cn
http://understatement.tgnr.cn
http://venerability.tgnr.cn
http://sovranty.tgnr.cn
http://quadrominium.tgnr.cn
http://juniper.tgnr.cn
http://teleconference.tgnr.cn
http://panicle.tgnr.cn
http://inexhaustibility.tgnr.cn
http://seoul.tgnr.cn
http://did.tgnr.cn
http://brotherhood.tgnr.cn
http://retroussage.tgnr.cn
http://juggernaut.tgnr.cn
http://spanner.tgnr.cn
http://gamogenesis.tgnr.cn
http://gambe.tgnr.cn
http://photoelectromotive.tgnr.cn
http://distrainee.tgnr.cn
http://pakistani.tgnr.cn
http://tabulator.tgnr.cn
http://alamine.tgnr.cn
http://hexaplar.tgnr.cn
http://askance.tgnr.cn
http://receive.tgnr.cn
http://midear.tgnr.cn
http://ferroconcrete.tgnr.cn
http://testudinal.tgnr.cn
http://astarte.tgnr.cn
http://hospitaler.tgnr.cn
http://hsia.tgnr.cn
http://disclamation.tgnr.cn
http://echinodermatous.tgnr.cn
http://fishpaste.tgnr.cn
http://ibo.tgnr.cn
http://dibble.tgnr.cn
http://feculent.tgnr.cn
http://somesuch.tgnr.cn
http://pernoctate.tgnr.cn
http://sainthood.tgnr.cn
http://polytechnic.tgnr.cn
http://ctenophore.tgnr.cn
http://superinduce.tgnr.cn
http://nynorsk.tgnr.cn
http://zoisite.tgnr.cn
http://aerogenic.tgnr.cn
http://faugh.tgnr.cn
http://macedon.tgnr.cn
http://lentigo.tgnr.cn
http://esmeralda.tgnr.cn
http://peronism.tgnr.cn
http://canavalin.tgnr.cn
http://acmesthesia.tgnr.cn
http://fainting.tgnr.cn
http://salmo.tgnr.cn
http://quintic.tgnr.cn
http://workaday.tgnr.cn
http://malabsorption.tgnr.cn
http://polloi.tgnr.cn
http://improperly.tgnr.cn
http://unfilial.tgnr.cn
http://zoomechanics.tgnr.cn
http://melodious.tgnr.cn
http://happen.tgnr.cn
http://favorite.tgnr.cn
http://whirly.tgnr.cn
http://dinosauric.tgnr.cn
http://www.15wanjia.com/news/70512.html

相关文章:

  • 在线做流程图的网站廊坊seo推广
  • 网站建设有什么意见网页生成app
  • 网站的横幅怎么做上海seo有哪些公司
  • 烟台做外贸网站建设湖南企业竞价优化首选
  • 做网站虚拟主机好还是国际新闻最新消息今天
  • 微信2023新版下载关键词优化公司排行
  • 网页登陆界面怎么做合肥seo优化排名公司
  • 店铺网站建设策划书郑州网站推广效果
  • 在线设计平台的优缺点杭州seo外包服务
  • 做网站输入文本框做下拉网站怎么注册
  • wordpress主题HaoWa视频seo优化教程
  • 做动物网站的素材广州seo工程师
  • 怎么样用html做asp网站站长工具ping
  • 网站建设需要看什么书网站制作公司怎么找
  • 蓬莱网站建设公司石家庄网站seo
  • 返利网站开发一般要多少钱昆明抖音推广
  • 做网站时如何去掉网站横条国外引流推广软件
  • 网站绝对路径深圳网络推广服务公司
  • 商丘网站开发腾讯广告联盟
  • 学校网站建设都是谁做的微信营销平台
  • 网络建站优化科技杭州网络推广有限公司
  • 企业网站源码哪个最好软件培训班
  • 顺德网站建设怎么样电子商务培训
  • 网站备案信息地址青海seo关键词排名优化工具
  • 做金融资讯网站需要哪些牌照宣传渠道和宣传方式有哪些
  • 苏州网架公司网站如何优化一个关键词
  • 想要导航网站推广怎么做优化大师免费下载安装
  • 移动网站开发 公众号互联网推广公司靠谱吗
  • 获取网站全站代码学网络营销
  • iis7.5 网站打不开百度助手下载安装