Javascript 如何在手机浏览器中显示谷歌相册?
我正在开发客户端React应用程序。应用程序应该显示谷歌照片库中的照片。我正在使用Firebase存储相册的短url(f.e.)和相册标题。然后我请求url并通过正则表达式提取图像。在dekstop版本上,一切正常。当我在手机上运行它时,我无法获取任何照片。如果我在手机浏览器中直接输入相册的url,谷歌照片应用程序将打开。如果在移动设备上,我将切换到“桌面版”工作正常。 有什么方法可以推翻这种行为吗 我尝试将内容宽度设置为1024。这没有帮助Javascript 如何在手机浏览器中显示谷歌相册?,javascript,reactjs,mobile-browser,google-photos,Javascript,Reactjs,Mobile Browser,Google Photos,我正在开发客户端React应用程序。应用程序应该显示谷歌照片库中的照片。我正在使用Firebase存储相册的短url(f.e.)和相册标题。然后我请求url并通过正则表达式提取图像。在dekstop版本上,一切正常。当我在手机上运行它时,我无法获取任何照片。如果我在手机浏览器中直接输入相册的url,谷歌照片应用程序将打开。如果在移动设备上,我将切换到“桌面版”工作正常。 有什么方法可以推翻这种行为吗 我尝试将内容宽度设置为1024。这没有帮助 <meta name="viewport" c
<meta name="viewport" content="width=1024" />
class Album extends Component {
state = {
images: null,
fullscreen: false,
currentIndex: 0,
loading: false
}
async componentDidMount() {
await this.setImages();
}
async setImages() {
if (!this.currentAlbumId || this.currentAlbumId !== this.props.match.params.id) {
this.currentAlbumId = this.props.match.params.id;
if (!this.state.loading) {
this.setState({ loading: true });
}
const album = await this.getAlbum(this.props.match.params.id);
const links = this.extractPhotos(album);
if (links && links.length > 0) {
this.setState({
images: links.map((url) => ({
src: `${url}=w1024`,
width: 16,
height: 9
})),
})
}
this.setState({ loading: false });
}
}
async getAlbum(id) {
// https://google-photos-album-demo.glitch.me/{id}
const response = await Axios.get(`${'https://cors-anywhere.herokuapp.com/'}https://photos.app.goo.gl/${id}`);
return response.data;
}
extractPhotos(content) {
const regex = /\["(https:\/\/lh3\.googleusercontent\.com\/[a-zA-Z0-9\-_]*)"/g;
const links = new Set()
let match
while (match = regex.exec(content)) {
links.add(match[1])
}
return Array.from(links)
}