我尝试在 Firebase Cloud Functions 上使用 puppeteer 截取包含表情符号的页面的屏幕截图,但表情符号在保存的屏幕截图中未正确显示。
Cloud Functions 上的 Puppeteer 似乎没有表情符号字体,因此我尝试通过 @font-face 设置表情符号字体,但不能。
这是我的云函数代码。我在一些 HTTPS 云函数内部调用屏幕截图函数。
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();
const storage = admin.storage();
const puppeteer = require('puppeteer');
function screenshot() {
(async () => {
const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] });
const page = await browser.newPage();
await page.setUserAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36');
await page.evaluate(() => {
const style = document.createElement('style') …Run Code Online (Sandbox Code Playgroud)javascript node.js firebase google-cloud-functions puppeteer