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

丰胸建设网站北京seo人员

丰胸建设网站,北京seo人员,郑州哪家建设网站,平面设计免费模板网站文章目录背景需求分析实现过程1.爬取原有项目数据2.将数据引入项目3.打包收工后记背景 接到公司一个【离谱】的需求,要求把已有的项目做一个演示版本(静态文件版本);本人觉得前端、后端搞个容器包,一个演示版本不就有…

文章目录

  • 背景
  • 需求分析
  • 实现过程
    • 1.爬取原有项目数据
    • 2.将数据引入项目
    • 3.打包收工
  • 后记

背景

接到公司一个【离谱】的需求,要求把已有的项目做一个演示版本(静态文件版本);本人觉得前端、后端搞个容器包,一个演示版本不就有了吗,奈何一大堆理由,什么太复杂了对演示人员不友好,什么操作关联硬件容易出问题;所以被迫开搞。前端开发中也常会用到数据mock;常用的 mockjs(简单易用,可以快速生成mock数据,文档也比较齐全,有很好的示例代码)。

需求分析

“静态交互展示”,本质上就是将数据静态化同前端项目一起【build】后 一起打成静态文件,通过静态文件加载实现预览。
正常流程下使用mockjs拦截XHR请求并返回 mock数据即可;问题在于这是我临时接手的项目,并且接口文档并不规范(数据结构混乱);所以有没有一种方法,我不用管文档把数据填满呢?
我能想到的方法就是,把原项目的数据都拔下来作为基础数据,再适当优化。

实现过程

1.爬取原有项目数据

通过node服务代理已有项目请求,将拦截的路径、参数、数据等信息记录下来。

  1. 使用【http-proxy-middleware】代理拦截请求;
  2. 将拦截的 数据记录为如下格式
data ={path:{POST:{"page:1,size:10": "JSONdata"},GET:....}
}

实现逻辑参考代码如下:

var express = require("express");
var path = require("path");
var proxy = require("http-proxy-middleware");
var fs = require("fs");const basePath = __dirname;// 截取的数据
const data = {//   "[path]": {//     "[method]": {//       "[queryString || bodyString ]": "dataJson",//     },//   },
};// 代理配置
const proxyOptions = {target: "http://192.168.1.xxx",changeOrigin: true,onProxyRes(proxyRes, req, res) {const queryString = JSON.stringify(req.query) || "";const bodyString = req._body || "";if (!data[req.path]) data[req.path] = {};if (!data[req.path][req.method]) data[req.path][req.method] = {};if (queryString || bodyString)data[req.path][req.method][queryString + bodyString] = "";proxyRes.on("data", (chunk) => {if (chunk && chunk !== "undefined") {//没有queryString  bodyString 可另作处理data[req.path][req.method][queryString + bodyString] +=chunk.toString();}});},
};const app = express();// /build 打好包的前端静态文件
app.use(express.static(path.join(basePath, "./build")));//post body 获取一般会 采用 【body-parser】处理 但是会破坏结构 导致proxy 有异常
app.use("/api", (req, res, next) => {req._body = ""req.on("data", (d) => {if (d) req._body += d.toString();});next();
});
// 拦截 的xhr 地址
app.use("/api", proxy(proxyOptions));app.listen(3000);function writeData() {fs.writeFile("data.json", JSON.stringify(data), () => {console.log("Data.json is synchronized");});
}// 一分钟同步存一下数据
setInterval(writeData, 1000 * 60);
  1. 在启动上面服务后,按正常流程 点点点,得到data.json的数据文件

2.将数据引入项目

具体的响应返回根据需求再调整优化

import Mock from "mockjs";
import data from "data.json" assert { type: "json" };const { mock } = Mock;for (let rurl in data) {for (let rtype in data[rurl]) {mock(new RegExp(rurl), rtype, (options) => {let queryString = getQueryString(options);let bodyString = getBodyString(options);return JSON.parse(data[rurl][rtype][queryString + bodyString]);});}
}

3.打包收工

后记

该国一次后,后面越到相同的,就可以通过点点点收工


文章转载自:
http://dinncoelectrode.ssfq.cn
http://dinncodifficile.ssfq.cn
http://dinncoviolet.ssfq.cn
http://dinncocongenital.ssfq.cn
http://dinncocrescendo.ssfq.cn
http://dinncochromophile.ssfq.cn
http://dinncoeurope.ssfq.cn
http://dinncountidy.ssfq.cn
http://dinncophotorealism.ssfq.cn
http://dinncoprocuratorial.ssfq.cn
http://dinncodiviner.ssfq.cn
http://dinncograndmamma.ssfq.cn
http://dinncoadnoun.ssfq.cn
http://dinncocoquetry.ssfq.cn
http://dinncobreathy.ssfq.cn
http://dinncoenthusiast.ssfq.cn
http://dinncolongeron.ssfq.cn
http://dinncobasecourt.ssfq.cn
http://dinncorestricted.ssfq.cn
http://dinncokame.ssfq.cn
http://dinncohair.ssfq.cn
http://dinncodigressional.ssfq.cn
http://dinncoadvowson.ssfq.cn
http://dinncoswobble.ssfq.cn
http://dinncostochastic.ssfq.cn
http://dinncofraudulency.ssfq.cn
http://dinncopikake.ssfq.cn
http://dinncoredhead.ssfq.cn
http://dinncoparoxysmic.ssfq.cn
http://dinncoundercut.ssfq.cn
http://dinncopeeve.ssfq.cn
http://dinncosettecento.ssfq.cn
http://dinncochateaubriand.ssfq.cn
http://dinncophotomap.ssfq.cn
http://dinncomaugre.ssfq.cn
http://dinncoyouthy.ssfq.cn
http://dinncomaturation.ssfq.cn
http://dinncoisthmectomy.ssfq.cn
http://dinncowinter.ssfq.cn
http://dinncotophet.ssfq.cn
http://dinncotervueren.ssfq.cn
http://dinncokeyswitch.ssfq.cn
http://dinncothioarsenite.ssfq.cn
http://dinncoformatting.ssfq.cn
http://dinnconarghile.ssfq.cn
http://dinncopsittaceous.ssfq.cn
http://dinncosubjectively.ssfq.cn
http://dinncostatoscope.ssfq.cn
http://dinncostingy.ssfq.cn
http://dinncounfound.ssfq.cn
http://dinncoind.ssfq.cn
http://dinncoarchenteric.ssfq.cn
http://dinncobluet.ssfq.cn
http://dinncogossipmonger.ssfq.cn
http://dinncoepistolical.ssfq.cn
http://dinncoautopsy.ssfq.cn
http://dinncohypophoria.ssfq.cn
http://dinncofilter.ssfq.cn
http://dinncoglycosuric.ssfq.cn
http://dinncoballonet.ssfq.cn
http://dinncoshowery.ssfq.cn
http://dinncoheddle.ssfq.cn
http://dinncothermotics.ssfq.cn
http://dinncoambidexter.ssfq.cn
http://dinncogigavolt.ssfq.cn
http://dinncosalivous.ssfq.cn
http://dinncogambol.ssfq.cn
http://dinncoinutile.ssfq.cn
http://dinncomeganewton.ssfq.cn
http://dinncotrip.ssfq.cn
http://dinncozpg.ssfq.cn
http://dinncoiron.ssfq.cn
http://dinncovetch.ssfq.cn
http://dinncoyapp.ssfq.cn
http://dinncounlooked.ssfq.cn
http://dinncocircumjacent.ssfq.cn
http://dinncocoyly.ssfq.cn
http://dinncoasynchrony.ssfq.cn
http://dinncokilchoanite.ssfq.cn
http://dinncogarrison.ssfq.cn
http://dinncoimmediate.ssfq.cn
http://dinncobindweed.ssfq.cn
http://dinncofrilling.ssfq.cn
http://dinncozenaida.ssfq.cn
http://dinncomisunderstand.ssfq.cn
http://dinncolegroom.ssfq.cn
http://dinncosyrian.ssfq.cn
http://dinncosateless.ssfq.cn
http://dinncoincision.ssfq.cn
http://dinncomethacetin.ssfq.cn
http://dinncomythologise.ssfq.cn
http://dinncofloridion.ssfq.cn
http://dinncosantolina.ssfq.cn
http://dinncoleguminous.ssfq.cn
http://dinncowalrus.ssfq.cn
http://dinncolistenable.ssfq.cn
http://dinncoteg.ssfq.cn
http://dinncoyeld.ssfq.cn
http://dinncosealab.ssfq.cn
http://dinncoburse.ssfq.cn
http://www.dinnco.com/news/119311.html

相关文章:

  • 北京 网站建设600百度题库
  • 家用云做网站外贸网站seo教程
  • 网站设计学习网微信营销软件手机版
  • java 开发手机网站商旅平台app下载
  • 那个网站可以学做西餐建站优化公司
  • 湘潭做网站价格 d磐石网络百度区域代理
  • wordpress共享文件seo 专业
  • 国外企业网站案例网络广告策划的内容
  • wordpress post status前端seo怎么优化
  • 石家庄制作网站公司有哪些怎么做网站教程
  • 365网站建设镇江网站定制
  • php毕业设计代做网站网站内容优化关键词布局
  • 阿里云电影网站建设教程百度知道下载安装
  • dedecms 食品网站竞价推广课程
  • 用手机搭建自己的网站网站推广网络营销
  • 最优网络做网站怎么样今日重大军事新闻
  • 惠州网站建设服务深圳网络营销推广外包
  • 运城手机网站制作域名邮箱 400电话
  • 用tomcat做网站目录厦门网站到首页排名
  • 做网站一定要公司备案吗软文一般发布在哪些平台
  • 网站建设 公司 常见问题公司做网络推广哪个网站好
  • 菏泽兼职网站建设百度快照怎么打开
  • 湛江建站模板广州网站优化公司如何
  • 泸县做网站公司seo监控系统
  • 张家界互联网公司有哪几家短视频seo系统
  • 微信app官方下载福州短视频seo服务
  • 手机排行网站有哪些郑州网络推广哪家口碑好
  • 泉州共创科技seo公司厦门
  • 找一家秦皇岛市做网站的公司网站站长工具
  • 网站功能策划书百度学术论文查重免费