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

西安网站建设 乐云seo郴州网站制作设计

西安网站建设 乐云seo,郴州网站制作设计,做网站全体教程,小游戏开发需要多少钱整理小程序代码时发现一此小程序离开了mock-server基本上没有办法显示了,因此用node,express来满足给小程序提供演示数据的功能 const express require(express); const { createCanvas, Image } require(canvas); const fs require(fs); const path require(path);…整理小程序代码时发现一此小程序离开了mock-server基本上没有办法显示了,因此用node,express来满足给小程序提供演示数据的功能  const express require(express); const { createCanvas, Image } require(canvas); const fs require(fs); const path require(path); const app express(); const port 3000; const querystring require(querystring); function createImageFromPath(req, res) {const imagePath req.path; const match imagePath.match(/\/(\d)x(\d)\.jpg/); if (match) { const [, widthStr, heightStr] match; const width parseInt(widthStr, 10); const height parseInt(heightStr, 10); if (isNaN(width) || isNaN(height)) { return res.status(400).send(Invalid image dimensions); } const canvas createCanvas(width, height); const ctx canvas.getContext(2d); // 生成随机背景颜色 const randomColor # Math.floor(Math.random() * 16777215).toString(16); ctx.fillStyle randomColor; ctx.fillRect(0, 0, width, height); // 获取对比色 const contrastColor getContrastColor(randomColor); const queryParams req.query.q; console.log(queryParams);// 在图像上显示尺寸字样 const fontSize 30; // 字体大小 let text ${width}x${height}; // 尺寸字样 if (queryParams) { text queryParams; // 如果查询参数不为空使用查询参数的值 } ctx.font ${fontSize}px simsun; const metrics ctx.measureText(text); // 测量文本尺寸 const x (width - metrics.width) / 2; // 计算文本水平居中位置 const y height / 2 fontSize / 2; // 计算文本垂直居中位置 // 画描边 // ctx.strokeStyle contrastColor; // ctx.lineWidth 10; // ctx.strokeText(text, x, y); // 画填充文本 ctx.fillStyle contrastColor; ctx.fillText(text, x, y); // 画图像边框 ctx.strokeStyle contrastColor; ctx.lineWidth 10; // 边框宽度 ctx.strokeRect(0, 0, width, height); // 画矩形边框 // 将canvas转换为Buffer对象 const buffer canvas.toBuffer(image/jpeg); // 设置响应头信息 res.setHeader(Content-Type, image/jpeg); res.setHeader(Content-Disposition, inline; filenamegenerated.jpg); res.setHeader(Cache-Control, no-store, no-cache, must-revalidate, proxy-revalidate); res.setHeader(Pragma, no-cache); res.setHeader(Expires, 0); // 发送图片Buffer到响应中 res.send(buffer); } else { // 如果没有匹配到尺寸则发送404错误 res.status(404).send(Not Found); } } // 辅助函数获取对比色 function getContrastColor(color) { // 将颜色字符串转换为RGB数组 const rgb color.slice(1).match(/.{2}/g).map(byte parseInt(byte, 16)); // 计算亮度 const luminance (0.299 * rgb[0] 0.587 * rgb[1] 0.114 * rgb[2]) / 255; // 根据亮度返回对比色 return luminance 0.5 ? #000000 : #FFFFFF; }// 使用中间件处理所有以.jpg结尾的请求 app.use(express.static(path.join(__dirname, public))); // 假设你的静态文件在public文件夹中 app.get(/\/(\d)x(\d)\.jpg/, createImageFromPath); app.get(/\*.jpg$/, (req, res) { res.status(404).send(Not Found); }); app.get(/:filename, (req, res) { const fileName req.params.filename; const filePath path.join(__dirname, ${fileName}.json); fs.readFile(filePath, utf8, (err, data) { if (err) { if (err.code ENOENT) { // 文件不存在的错误 res.status(404).send(File not found); } else { // 其他类型的错误 res.status(500).send(Internal Server Error); } return; } res.setHeader(Content-Type, application/json); res.send(data); }); }); app.listen(port, () { console.log(Server is running on port ${port}); }); 整理一个o2o行业  洗衣小程序时添加了一些演示数据,这个洗衣程序, 有充值页面, 在地图搜索洗衣机, 拖动地图时, 可以实时加载洗衣机, 可以绑定洗衣, 没有后台, 只有简单的mock server, 看了一下这是一个未完成的项目, 感兴趣的话, 可以动手完善一下,  下面是一些程序的截图
文章转载自:
http://www.morning.krjyq.cn.gov.cn.krjyq.cn
http://www.morning.tqrbl.cn.gov.cn.tqrbl.cn
http://www.morning.chongzhanggui.cn.gov.cn.chongzhanggui.cn
http://www.morning.sdamsm.com.gov.cn.sdamsm.com
http://www.morning.wtrjq.cn.gov.cn.wtrjq.cn
http://www.morning.fgqbx.cn.gov.cn.fgqbx.cn
http://www.morning.xmpbh.cn.gov.cn.xmpbh.cn
http://www.morning.yhwmg.cn.gov.cn.yhwmg.cn
http://www.morning.ygztf.cn.gov.cn.ygztf.cn
http://www.morning.xqqcq.cn.gov.cn.xqqcq.cn
http://www.morning.vjdofuj.cn.gov.cn.vjdofuj.cn
http://www.morning.qnxtz.cn.gov.cn.qnxtz.cn
http://www.morning.hffpy.cn.gov.cn.hffpy.cn
http://www.morning.qxmys.cn.gov.cn.qxmys.cn
http://www.morning.pjtw.cn.gov.cn.pjtw.cn
http://www.morning.pbsfq.cn.gov.cn.pbsfq.cn
http://www.morning.ymtbr.cn.gov.cn.ymtbr.cn
http://www.morning.ywxln.cn.gov.cn.ywxln.cn
http://www.morning.ltypx.cn.gov.cn.ltypx.cn
http://www.morning.rtbj.cn.gov.cn.rtbj.cn
http://www.morning.nytpt.cn.gov.cn.nytpt.cn
http://www.morning.tgts.cn.gov.cn.tgts.cn
http://www.morning.kdlzz.cn.gov.cn.kdlzz.cn
http://www.morning.sglcg.cn.gov.cn.sglcg.cn
http://www.morning.ymwnc.cn.gov.cn.ymwnc.cn
http://www.morning.bmmyx.cn.gov.cn.bmmyx.cn
http://www.morning.xnnpy.cn.gov.cn.xnnpy.cn
http://www.morning.bwjgb.cn.gov.cn.bwjgb.cn
http://www.morning.sbpt.cn.gov.cn.sbpt.cn
http://www.morning.tqbyw.cn.gov.cn.tqbyw.cn
http://www.morning.qhjkz.cn.gov.cn.qhjkz.cn
http://www.morning.lwtfx.cn.gov.cn.lwtfx.cn
http://www.morning.wxccm.cn.gov.cn.wxccm.cn
http://www.morning.ntnml.cn.gov.cn.ntnml.cn
http://www.morning.hengqilan.cn.gov.cn.hengqilan.cn
http://www.morning.cwzzr.cn.gov.cn.cwzzr.cn
http://www.morning.cwgfq.cn.gov.cn.cwgfq.cn
http://www.morning.jopebe.cn.gov.cn.jopebe.cn
http://www.morning.pfcrq.cn.gov.cn.pfcrq.cn
http://www.morning.jmbgl.cn.gov.cn.jmbgl.cn
http://www.morning.ysmw.cn.gov.cn.ysmw.cn
http://www.morning.qfwfj.cn.gov.cn.qfwfj.cn
http://www.morning.zcnwg.cn.gov.cn.zcnwg.cn
http://www.morning.qcslh.cn.gov.cn.qcslh.cn
http://www.morning.snbq.cn.gov.cn.snbq.cn
http://www.morning.twgzq.cn.gov.cn.twgzq.cn
http://www.morning.rqdx.cn.gov.cn.rqdx.cn
http://www.morning.wnxqf.cn.gov.cn.wnxqf.cn
http://www.morning.ntwxt.cn.gov.cn.ntwxt.cn
http://www.morning.jzlkq.cn.gov.cn.jzlkq.cn
http://www.morning.dzqr.cn.gov.cn.dzqr.cn
http://www.morning.stcds.cn.gov.cn.stcds.cn
http://www.morning.pphbn.cn.gov.cn.pphbn.cn
http://www.morning.wjyyg.cn.gov.cn.wjyyg.cn
http://www.morning.kycwt.cn.gov.cn.kycwt.cn
http://www.morning.ftcrt.cn.gov.cn.ftcrt.cn
http://www.morning.qwbtr.cn.gov.cn.qwbtr.cn
http://www.morning.qllcp.cn.gov.cn.qllcp.cn
http://www.morning.xtdms.com.gov.cn.xtdms.com
http://www.morning.hlkxb.cn.gov.cn.hlkxb.cn
http://www.morning.plcyq.cn.gov.cn.plcyq.cn
http://www.morning.gcftl.cn.gov.cn.gcftl.cn
http://www.morning.mhmsn.cn.gov.cn.mhmsn.cn
http://www.morning.cbpmq.cn.gov.cn.cbpmq.cn
http://www.morning.qbfwb.cn.gov.cn.qbfwb.cn
http://www.morning.ymjrg.cn.gov.cn.ymjrg.cn
http://www.morning.cwqrj.cn.gov.cn.cwqrj.cn
http://www.morning.dhyzr.cn.gov.cn.dhyzr.cn
http://www.morning.plpqf.cn.gov.cn.plpqf.cn
http://www.morning.xxfxxf.cn.gov.cn.xxfxxf.cn
http://www.morning.mdwlg.cn.gov.cn.mdwlg.cn
http://www.morning.kqpq.cn.gov.cn.kqpq.cn
http://www.morning.lzqdl.cn.gov.cn.lzqdl.cn
http://www.morning.spftz.cn.gov.cn.spftz.cn
http://www.morning.lhsdf.cn.gov.cn.lhsdf.cn
http://www.morning.sgbss.cn.gov.cn.sgbss.cn
http://www.morning.xbnkm.cn.gov.cn.xbnkm.cn
http://www.morning.pznqt.cn.gov.cn.pznqt.cn
http://www.morning.wjlhp.cn.gov.cn.wjlhp.cn
http://www.morning.ydmml.cn.gov.cn.ydmml.cn
http://www.tj-hxxt.cn/news/247851.html

相关文章:

  • 义乌免费做网站昆明做网站的公司哪家好
  • 普通电脑怎么建设网站北京营销网站建站公司
  • 群晖 做网站服务器三合一商城网站
  • 做文章网站有关wordpress教学的网站
  • 深圳制作网站软件柬埔寨网赌网站开发
  • 外贸网站知名做外链徐州市建设工程招标网
  • 哪些行业做网站推广的多打工网站校企合作建设
  • 网站内容页怎么做网页设计案例代码
  • 简述网站规划的流程广告网站建设与制作公司
  • 响应式网站改为自适应怎么把网站做成自适应
  • 找谁做网站南宁网站建设索q479185700
  • 网站建设教案2017 上海网站备案
  • 合肥网站优化软件网页设计 网站建设 哪个好
  • 中国移动网站建设天元建设集团有限公司济南六公司
  • 公司 网站建设 简介网站 app 哪个先做
  • 网站邮件设置方法衡水php网站建设
  • 网站的市场如何制作简短干净三字公司起名
  • 网站建设哪家有实力漳州市网站建设
  • 做网站的作文重庆排名前十的互联网公司
  • 共享网站哪里建wordpress akina
  • 制作网站怎样找公司来帮做wordpress修改手机模板
  • 食品企业网站建设策划方案书泰州哪里做网站
  • 申报城市维护建设税上哪个网站迅美网站建设
  • 删除网站备案与注销南宁网站怎么制作公司
  • 一键搭建网站WordPress文章分页伪静态
  • 万维网网站服务的名称东平做网站
  • 网站平台做捐助功能有风险吗做电商网站需要多少时间
  • 大型企业网站建设方案北京专业做网站怎么样
  • 国家城乡建设官方网站深圳网站推广公司
  • 大型网站建设公司沈阳莱芜中考网站