V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  s609926202  ›  全部回复第 82 页 / 共 87 页
回复总数  1738
1 ... 74  75  76  77  78  79  80  81  82  83 ... 87  
Tks.
@searene 回复无法修改默认格式的,,
@mingzu 其实我调用的接口返回给我的就是普通的数据表记录值,然后我在前端处理成这样的 children,,
@loveyu 哈哈,我算法不行,而且我是前端+后端,标准码农一枚…
@SO647898 评论楼中楼,,,这不知道吗,,,
@adspe 我不知啊,,
2017-12-04 22:03:45 +08:00
回复了 s609926202 创建的主题 问与答 关于 Javascript 递归问题,我懵逼了,,,
这是我最后的解决方案,无奈只能用两个函数来实现:
```
const getSonsTree = function (obj, data) {
var children = new Array();

for (var i = 0; i < data.length; i++) {
if (data[i].parent == obj.id) {
getSonsTree(data[i], data);
children.push(data[i]);
}
}

if (children.length > 0) {
obj.children = children;
}

return obj;
}

const buildTree = function (data = {}) {
var ptree = [];

for (var i = 0; i < data.length; i++) {
if (data[i].parent === 0) {
var o = getSonsTree(data[i], data);
ptree.push(o);
}
}

return ptree;
}
```

然后把后端返回 json 放进 buildTree 里就行了:
```
console.log(buildTree(data));
```

实现了
。。。
2017-12-04 09:54:19 +08:00
回复了 s609926202 创建的主题 问与答 关于 Javascript 递归问题,我懵逼了,,,
@lwbjing 确实,,如果是 php 就好了,,还有引用
2017-12-03 20:08:29 +08:00
回复了 s609926202 创建的主题 问与答 关于 Javascript 递归问题,我懵逼了,,,
@luguokong 改成[]也报同样的错,,,
2017-12-03 18:10:02 +08:00
回复了 s609926202 创建的主题 问与答 关于 Javascript 递归问题,我懵逼了,,,
@per 不会出现这种情况的,我这个源数据是评论数据,,只有要么是顶级数据,要是是节点下的回复数据,也就是说 parent 不为 0
走代理
@ysc3839 我这个是负载均衡,只在其中一台机器上出现,所以是随机出现的。。。
@Aliencn 你 F12 看一下,Google 浏览器版本 62,64 位
2017-11-20 17:38:07 +08:00
回复了 s609926202 创建的主题 问与答 如何使用 Gmail SMTP 发送邮箱?
@viosey Ok 了
2017-11-20 17:05:40 +08:00
回复了 s609926202 创建的主题 问与答 如何使用 Gmail SMTP 发送邮箱?
这是一些信息:
2017-11-20 09:05:00 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP z7sm6797750qtz.40 - gsmtp
2017-11-20 09:05:00 CLIENT -> SERVER: EHLO www.trueniu.com
2017-11-20 09:05:00 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [54.172.19.40]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
2017-11-20 09:05:00 CLIENT -> SERVER: AUTH LOGIN
2017-11-20 09:05:00 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2017-11-20 09:05:00 CLIENT -> SERVER: czYwOTkyNjIwMkBnbWFpbC5jb20=
2017-11-20 09:05:00 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2017-11-20 09:05:00 CLIENT -> SERVER: U3gxOTkyMTEyOSFAIw==
2017-11-20 09:05:01 SERVER -> CLIENT: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbur
534-5.7.14 S_l4jy-EJKrK2IupSssBOYwZxRzVjqeSGKl0zGfsV_yiLTfQvDOhAWkMDVSsro03uALvef
534-5.7.14 Q0nDJO07pej2wkUtbyVNPtMtBGdWUJTj0aGgDs9hv-Hv8bea3HfMAl0iq5jOw9u5Z4wP4d
534-5.7.14 9UkmIkgLjY-DmS3BF-fCdXZ3Y2pq6mYisBsOkGY5tVFIkhJ218EUXlvtu02SHRFpXdJXe7
534-5.7.14 FnDUtB8ofSuAZdrWEtRK0k9gJbpGU> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 z7sm6797750qtz.40 - gsmtp
2017-11-20 09:05:01 SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbur
534-5.7.14 S_l4jy-EJKrK2IupSssBOYwZxRzVjqeSGKl0zGfsV_yiLTfQvDOhAWkMDVSsro03uALvef
534-5.7.14 Q0nDJO07pej2wkUtbyVNPtMtBGdWUJTj0aGgDs9hv-Hv8bea3HfMAl0iq5jOw9u5Z4wP4d
534-5.7.14 9UkmIkgLjY-DmS3BF-fCdXZ3Y2pq6mYisBsOkGY5tVFIkhJ218EUXlvtu02SHRFpXdJXe7
534-5.7.14 FnDUtB8ofSuAZdrWEtRK0k9gJbpGU> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 z7sm6797750qtz.40 - gsmtp
2017-11-20 09:05:01 SMTP Error: Could not authenticate.
2017-11-20 09:05:01 CLIENT -> SERVER: QUIT
2017-11-20 09:05:01 SERVER -> CLIENT: 221 2.0.0 closing connection z7sm6797750qtz.40 - gsmtp
2017-11-20 09:05:01 SMTP Error: Could not authenticate.
2017-11-14 23:22:58 +08:00
回复了 s609926202 创建的主题 问与答 Nginx 云服务器反向代理受什么限制?
哦,对了,我这是香港节点的服务器,2 核 4G,10M 带宽,,据客服说到国内是 10%的带宽。。
2017-11-14 23:21:19 +08:00
回复了 s609926202 创建的主题 问与答 Nginx 云服务器反向代理受什么限制?
@gstqc
刚刚 ab 测试了下,并发 100,1000 次访问的数据如下:

```
[root@VM_23_169_centos ~]# ab -n 1000 -c 100 http://eladxxxxxxxxxm/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking eladeanode.trueniu.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software: nginx/1.9.9
Server Hostname: eladeanode.trueniu.com
Server Port: 80

Document Path: /
Document Length: 60888 bytes

Concurrency Level: 100
Time taken for tests: 300.551 seconds
Complete requests: 1000
Failed requests: 499
(Connect: 0, Receive: 0, Length: 499, Exceptions: 0)
Write errors: 0
Total transferred: 61788973 bytes
HTML transferred: 61491379 bytes
Requests per second: 3.33 [#/sec] (mean)
Time per request: 30055.138 [ms] (mean)
Time per request: 300.551 [ms] (mean, across all concurrent requests)
Transfer rate: 200.77 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 49 966 902.7 716 7084
Processing: 1289 26399 21672.7 23701 83029
Waiting: 462 22630 22199.1 13952 80911
Total: 1343 27364 21651.8 23830 83341

Percentage of the requests served within a certain time (ms)
50% 23830
66% 45242
75% 48600
80% 50180
90% 54099
95% 55818
98% 58098
99% 63462
100% 83341 (longest request)
```

速度感人,,,我把火狐更新到最高版并把玩了一会还在测试,,哈哈,,,求解这个反向代理怎么拯救。。。
2017-11-14 21:31:52 +08:00
回复了 s609926202 创建的主题 问与答 Nginx 云服务器反向代理受什么限制?
@iamdsy。。。。我忘说了一个重要的信息,,代理的不仅有美东的资源,还有 AWS 尚 S3 的图片等资源。。。
2017-11-14 09:57:55 +08:00
回复了 dynaguy 创建的主题 问与答 nginx 反代问题
我没看懂为何加了 B 服务器就访问不了 a、b 子域名了,,,,
2017-11-13 17:30:58 +08:00
回复了 jmc891205 创建的主题 程序员 双十一买的内存居然跟主板不兼容。。。点不亮
看看去腊了没,,有些内存上面涂腊了
1 ... 74  75  76  77  78  79  80  81  82  83 ... 87  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2889 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 28ms · UTC 09:03 · PVG 17:03 · LAX 01:03 · JFK 04:03
Developed with CodeLauncher
♥ Do have faith in what you're doing.