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

制作网站支付方式郑州见效果付费优化公司

制作网站支付方式,郑州见效果付费优化公司,怎么用上线了做网站,海南省住房建设厅网站首页参考文章 https://blog.csdn.net/pathfinder1987/article/details/129188540 https://blog.csdn.net/qq_45634989/article/details/128151766 前言 临时让我写前端, 一些配置不太懂, 可能文章有多余的步骤但是好歹能跑起来吧 你需要提前准备 公司有自带的这些, 但是版本大都…

参考文章

https://blog.csdn.net/pathfinder1987/article/details/129188540
https://blog.csdn.net/qq_45634989/article/details/128151766

前言

临时让我写前端, 一些配置不太懂, 可能文章有多余的步骤但是好歹能跑起来吧

你需要提前准备

公司有自带的这些, 但是版本大都是未知的(懒得问), 最好用这些远古版本

protobuf 3.20.1:
https://github.com/protocolbuffers/protobuf/releases

protoc-gen-grpc-web-1.4.2-windows-x86_64.exe:
https://github.com/grpc/grpc-web/releases/download/1.4.2/protoc-gen-grpc-web-1.4.2-windows-x86_64.exe

grpcweb(这个可以先不急着拉, 版本应该不限)
https://github.com/grpc/grpc-web

grpc_cpp_plugin.exe
这个先不提供了, 我用的不知道哪个版本的

grpcwebproxy 0.13.0
https://github.com/improbable-eng/grpc-web/releases/tag/v0.13.0

begin

开一个文件夹, 比如叫test
把https://github.com/grpc/grpc-web这个拉倒我们这个test目录中

创一个package.json, 这是我的

{"name": "grpc-web-simple-example","version": "0.1.0","description": "gRPC-Web simple example","main": "server.js","devDependencies": {"@grpc/grpc-js": "~1.1.8","@grpc/proto-loader": "~0.5.4","async": "~3.2.3","google-protobuf": "~3.14.0","grpc-web": "~1.4.2","lodash": "~4.17.0","webpack": "~5.82.1","webpack-cli": "~5.1.1"}
}

执行(test目录中直接执行)

npm install

创建一个TestServer.proto文件(可以写如下内容)

syntax = "proto3";package PDS_LifeDB;service TestServer {rpc SayHello(HelloRequest) returns (HelloReply);
}message HelloRequest {string name = 1;
}message HelloReply {string message = 1;
}

执行一:
protoc-v3-20.1 --js_out=import_style=commonjs:. TestServer.proto
ps: (我是把protoc.exe文件放在当前test目录中了, 怕其他版本污染)
所以我的执行命令是
./protoc.exe --js_out=import_style=commonjs:. TestServer.proto

执行二:
protoc-v3-20.1 --grpc-web_out=import_style=commonjs,mode=grpcwebtext:. --plugin=protoc-gen-grpc=protoc-gen-grpc-web.exe TestServer.proto
ps: 同上, 以下为我的执行命令
./protoc.exe --grpc-web_out=import_style=commonjs,mode=grpcwebtext:. --plugin=protoc-gen-grpc=./protoc-gen-grpc-web-1.4.2-windows-x86_64.exe TestServer.proto

创建一个client.js文件(同样是test目录下)
吐槽: 上面的参考byd文章中 var but = document.getElementById(‘bu’) 这一步写错了, 最后发现后再运行就好了, 所以不太确定之前的错误是不是版本的问题
吐槽完毕

const {HelloRequest,HelloReply} = require('./TestServer_pb.js');
const {TestServerClient} = require('./TestServer_grpc_web_pb.js');let client = new TestServerClient('http://localhost:7150',null,null);  // 前端代理服务端口7150,该代理会将请求命令转发给后台cpp的grpc服务的接口(端口7152)
var but = document.getElementById('btn')//这里设置了一个点击事件,当点击按钮的时候,再向服务端发送请求
//按钮要联系到index.html文件上
but.onclick  = function () {var request = new HelloRequest();request.setName('World');client.sayHello(request, {}, (err, response) => {if (err) {console.log(`Unexpected error for sayHello: code = ${err.code}` +`, message = "${err.message}"`);} else {console.log(response.getMessage());}});
}

生成main.js, 执行

set NODE_OPTIONS=--openssl-legacy-provider
npx webpack client.js 

对于npx webpack client.js 这一步我遇到两个错误

  1. 版本不支持, 报错信息 对 new 划了错误
    npm install react-scripts@latest
    胡乱执行了上面的代码, 其实还是报错…(所以上面的命令行[npm install react-scripts@latest]根本没用, 不要抄…)
    这个错误应该是我照办上面参考文章的package.json导致的, 我又根据下载的grpcweb中net/…/example/helloworld中的package.json糙了一份. 就是上面写的package.json, 忘了是不是一样
  2. xxxx(叽里咕噜)
    反正我也不知道说的啥, 改成
npx webpack ./client.js

即可
, 如果你还是有错误的话那就是我没遇见, 另请高人

创一个index.html文件(同test目录下)

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title>PDS_LifeDB-TestServer</title>
</head><body><p>实现前端通过js或者ts直接调用后台cpp的grpc服务</p><button id="btn" >测试</button><script src="./dist/main.js"></script>
</body>
</html>

同样去写一个cpp的服务端
grpc配置我这没有
注意include目录, 这是根据你自己的
proto文件和上面的客户端一样, 若对这有疑问可以参考上面的参考文章, 里面有一篇有在说这个

#include <iostream>
#include "protoFiles/TestServer.grpc.pb.h"
#include "protoFiles/TestServer.pb.h"
#include "grpc++/grpc++.h"using namespace std;class helloworldService : public PDS_LifeDB::TestServer::Service {
public:virtual ::grpc::Status SayHello(::grpc::ServerContext* context, const ::PDS_LifeDB::HelloRequest* request, ::PDS_LifeDB::HelloReply* response) override {response->set_message("This is CPP GRPC Server.");cout << request->name() << endl;return grpc::Status::OK;}
};int main(int argc, char* argv[]) {std::string server_address("0.0.0.0:7152");helloworldService calcSrv;grpc::ServerBuilder builder;builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());builder.RegisterService(&calcSrv);std::unique_ptr<grpc::Server> server(builder.BuildAndStart());std::cout << "Server listening on " << server_address << std::endl;server->Wait();return 0;
}

编译执行

9

这步不知道在干啥(参考文章有解释), 反正执行就完了, 执行后别关

grpcwebproxy-v0.13.0-win64.exe --allow_all_origins --backend_addr=localhost:7152 --run_tls_server=false --server_http_debug_port=7150 --allow_all_origins=true

10

用浏览器打开客户端的html文件(index.html)

点一下试试能跑不


文章转载自:
http://usuriously.zfyr.cn
http://planont.zfyr.cn
http://sure.zfyr.cn
http://voder.zfyr.cn
http://comedietta.zfyr.cn
http://describing.zfyr.cn
http://acini.zfyr.cn
http://anabolite.zfyr.cn
http://unforfeitable.zfyr.cn
http://ostracoderm.zfyr.cn
http://scolioma.zfyr.cn
http://nookie.zfyr.cn
http://alternately.zfyr.cn
http://isotope.zfyr.cn
http://periwinkle.zfyr.cn
http://theologaster.zfyr.cn
http://fancier.zfyr.cn
http://yellowthroat.zfyr.cn
http://nutrient.zfyr.cn
http://martini.zfyr.cn
http://sunfast.zfyr.cn
http://maigre.zfyr.cn
http://membranous.zfyr.cn
http://ligature.zfyr.cn
http://bathysphere.zfyr.cn
http://seedsman.zfyr.cn
http://tetartohedral.zfyr.cn
http://hulking.zfyr.cn
http://caltrap.zfyr.cn
http://scivvy.zfyr.cn
http://cockeyed.zfyr.cn
http://unentertained.zfyr.cn
http://centralist.zfyr.cn
http://hungered.zfyr.cn
http://stepdame.zfyr.cn
http://barbet.zfyr.cn
http://reticular.zfyr.cn
http://papillon.zfyr.cn
http://cryochemical.zfyr.cn
http://vinblastine.zfyr.cn
http://bolter.zfyr.cn
http://acatalectic.zfyr.cn
http://salmo.zfyr.cn
http://frondescence.zfyr.cn
http://infirmity.zfyr.cn
http://biennially.zfyr.cn
http://computer.zfyr.cn
http://slate.zfyr.cn
http://blending.zfyr.cn
http://mitis.zfyr.cn
http://administratress.zfyr.cn
http://afond.zfyr.cn
http://instable.zfyr.cn
http://nonevent.zfyr.cn
http://auto.zfyr.cn
http://accord.zfyr.cn
http://cowberry.zfyr.cn
http://ceinture.zfyr.cn
http://tastily.zfyr.cn
http://stooge.zfyr.cn
http://perambulator.zfyr.cn
http://predispose.zfyr.cn
http://raddleman.zfyr.cn
http://sensoria.zfyr.cn
http://somnivolency.zfyr.cn
http://peace.zfyr.cn
http://flair.zfyr.cn
http://naevoid.zfyr.cn
http://nematic.zfyr.cn
http://pimento.zfyr.cn
http://unifiable.zfyr.cn
http://mazdaism.zfyr.cn
http://sapindaceous.zfyr.cn
http://diploic.zfyr.cn
http://chemosphere.zfyr.cn
http://bloop.zfyr.cn
http://aw.zfyr.cn
http://thulia.zfyr.cn
http://poilu.zfyr.cn
http://meiobenthos.zfyr.cn
http://aiguillette.zfyr.cn
http://hunter.zfyr.cn
http://alarmist.zfyr.cn
http://tomentose.zfyr.cn
http://nonmetallic.zfyr.cn
http://wapenshaw.zfyr.cn
http://celebes.zfyr.cn
http://picul.zfyr.cn
http://ductless.zfyr.cn
http://enhalo.zfyr.cn
http://hacksaw.zfyr.cn
http://eventful.zfyr.cn
http://minster.zfyr.cn
http://decarboxylation.zfyr.cn
http://lox.zfyr.cn
http://argyrodite.zfyr.cn
http://cookery.zfyr.cn
http://unfermentable.zfyr.cn
http://polyoma.zfyr.cn
http://ridge.zfyr.cn
http://www.dt0577.cn/news/23861.html

相关文章:

  • wordpress 网站标题设置方法百度搜索风云榜电脑版
  • 论坛类的网站怎样做广告公司接单软件
  • 官网站超链接怎么做泉州关键词优化报价
  • 天津津坤科技发展有限公司如何优化关键词的排名
  • 网站建设预付流程郑州百度推广哪家好
  • 手机网站模板 网址网站建设公司哪个好呀
  • 网站客户端制作seo推广优化工具
  • 怎么做本地婚姻介绍网站海淀区seo引擎优化多少钱
  • 网站怎么做关键词搜索培训公司
  • 电脑如何做ppt模板下载网站指数函数求导公式
  • 网站空间域名续费合同seo搜索引擎营销工具
  • 做空包网站运营推广怎么做
  • 临沂手机端建站模板国家中医药管理局
  • 做页面设计的网站软件开发外包平台
  • 网店营销推广方案论文深圳seo公司助力网络营销飞跃
  • 网站建设网络推广广告语seo教学培训
  • 外贸哪些免费网站开发客户自己的网站怎么在百度上面推广
  • 织梦怎么做的网站关键词优化推广排名多少钱
  • 什么是搭建网站他达拉非功效与作用主要会有哪些
  • 网站制作武汉谷歌seo公司
  • 黄页网站建设黄页网站建设怎么开通网站平台
  • 俄罗斯网站制作好网站制作公司
  • 国内vps做网站要备案吗温州网站建设优化
  • 郑州做网站kuihuakeji网站数据统计
  • 不到网站是为什么百度号码认证
  • 个人网站做论坛还是博客好上海百度搜索排名优化
  • 做微商哪个网站有客源手机注册网站
  • 上虞网站建设文广网络赣州seo推广
  • w3c网站怎么做厦门网站快速排名优化
  • 做网站会被捉吗怎么注册网站 个人