asong 最近的时间轴更新
asong

asong

V2EX 第 160607 号会员,加入于 2016-02-25 23:50:29 +08:00
asong 最近回复了
107 天前
回复了 Outshine 创建的主题 分享创造 为了练手做的一个导航站~
+1, +1

一个导航,域名看完就忘不掉😏

https://yigedaohang.com/

目前收集了一些自己常用的在线网站。

部署在 vercel ,免费白嫖中😄
107 天前
回复了 dc2002007 创建的主题 React react ui 组件库选择
在这个帖子里,发现了很多有意思的库😄
不得不说,很强👍
156 天前
回复了 zhuzhiqiang 创建的主题 推广 号卡分销平台,招募代理一单返佣 80-200
@ldlywt 同问 🤔
165 天前
回复了 railsboy 创建的主题 分享创造 分享个抖音视频去水印的
@railsboy @DreamingCTW 请问一下这种小程序会被封吗?另外会被 抖音/快手/小红书 告吗 😂
这里也有一个

https://yigedaohang.com/
172 天前
回复了 xapp 创建的主题 分享创造 推荐一个观影刷剧的小工具
@cxsz 请问 tvbox 是哪个软件,方便给个下载地址吗?刚在 GitHub 上没有搜到。🤣
2023-01-26 17:13:36 +08:00
回复了 lxiian 创建的主题 微信 请问微信小程序的 request 怎么拦截 302 重定向啊
小程序怎么拦截不太清楚,但是之前是在浏览器环境中遇到过类型的问题,是通过 fetch 和 xhr 配合到一起处理的。

不知道能不能对你有所帮助,代码逻辑如下:

```js
/**
* 获取重定向的 URL
*/
const getRedirectURL = (url, options) => {
return new Promise((resolve) => {
const xhr = new XMLHttpRequest();
xhr.open("GET", url);
const { headers = {} } = options;
// 设置请求头
Reflect.ownKeys(headers).forEach((key) => {
xhr.setRequestHeader(key, headers[key]);
});
xhr.send();
xhr.onreadystatechange = function () {
if (this.readyState === this.DONE) {
// 在这里判断 responseURL 是否 和 原始 URL 一致( this.responseURL 也有可能为空)
if (this.responseURL && this.responseURL !== url) {
// 如果不一致,则终止请求
resolve(this.responseURL);
// 终止请求之后,this.responseURL 的值会被置空,所以需要在最后调用。
this.abort();
return;
}
console.log("未发生重定向,responseUR 的值为:", this.responseUR);
resolve();
}
};
xhr.onerror = function (e) {
console.log("请求失败", e);
resolve();
};
});
};

/**
* 封装处理 重定向 的 Fetch
*/
const request = (url, options) => {
return fetch(url, options).then(async (response) => {
// 手动处理 HTTP 重定向时,type 的值为 "opaqueredirect"
if (response.type === "opaqueredirect") {
const redirectURL = await getRedirectURL(url, options);
if (!redirectURL) {
throw new Error("未获取到重定向 URL");
}
// 自动对重定向的 URL 发起请求
return request(redirectURL, options);
}
return response.json();
});
};


(async () => {
// 发请求
const result = await request("/api/user/list", {
headers: { Authorization: `Bearer xxxxxxxxx`, foo: "bar" },
redirect: "manual",
});
console.log(result);
})();
```

具体思路,可以参考这里:

https://github.com/mrlmx/blogs/issues/2
2020-07-21 18:17:57 +08:00
回复了 endosome 创建的主题 iPhone 如何下载 twitter 上的视频,并保存于 iPhone ?
有个微信小程序叫做「 Twitter 视频下载」,可以试试。
2018-06-08 13:56:51 +08:00
回复了 a554340466 创建的主题 程序员 求推荐阅读计算机类电子书籍的设备
@maemolee 什么把手 😂
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2589 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 15ms · UTC 01:43 · PVG 09:43 · LAX 18:43 · JFK 21:43
Developed with CodeLauncher
♥ Do have faith in what you're doing.