This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lineConfig = { | |
channelAccessToken: 'XXXXXXXXXXX', | |
channelSecret: 'XXXXXXXXXXX' | |
}; | |
const crypto = require('crypto'); | |
const channelSecret = lineConfig.channelSecret; | |
app.post('/webhook', line.middleware(lineConfig), (req, res) => { | |
// 給 LINE 的 body 要是 string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 引用 axios | |
importScripts('../dist/axios.min.js'); | |
// 設定最大並行請求數限制 | |
const MAX_CONCURRENT_REQUESTS = 5; | |
let activeRequests = 0; | |
let queue = []; | |
self.onmessage = e => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const postmanApiKey = '請貼上 Postman API Key'; | |
const githubToken = '請貼上 GitHub Access Token'; | |
const repoOwner = '請貼上 GitHub 帳號名稱'; | |
// 以下請貼上要匯進 Postman Collection 的清單 | |
const repoList = [ | |
{ | |
repoName: 'postman-backup-demo', | |
filePath: 'Postman Collections/postman-backup-demo.json' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gitLabToken = '請貼上 GitHub Access Token'; | |
const postmanApiKey = '請貼上 Postman API Key'; | |
// 以下請貼上要匯進 Postman Collection 的清單 | |
const repoList = [ | |
{ | |
projectId: '48419806', | |
filePath: 'Postman_Collections/postman-backup-demo.json' | |
} | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 存進雲端 | |
function saveJsonToDrive({ name, json }) { | |
const today = getToday({ divider: '-' }); | |
const folderName = name; // 資料夾名稱 | |
const time = new Date().getTime(); | |
const fileName = `${time}_backup.json`; // 檔案名稱 | |
// 取得「備份」資料夾 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Let's Write", | |
"short_name": "Let's Write", | |
"description": "前端工程師 August 的學習筆記 — solving problems, in simple ways.", | |
"start_url": "./?utm_source=PWA&utm_medium=home_screen&utm_campaign=pwa", | |
"id": "/?utm_source=PWA&utm_medium=home_screen&utm_campaign=pwa", | |
"display": "standalone", | |
"background_color": "#FAFAFA", | |
"theme_color": "#00A7E5", | |
"orientation": "portrait-primary", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var preCacheFile = 'pre-v1.1.0'; // 存在 Cache Storage 的資料夾名,預存用 | |
var autoCacheFile = 'letswrite-v1.1.0'; // 存在 Cache Storage 的資料夾名稱,自動存用 | |
// 一定要存下的檔案清單 | |
// 比如 404.html、logo.svg,不會自動出現在每頁的 request 上,但當使用者是 offline 時又必要會看到的 | |
const assets = [ | |
'/?utm_source=PWA&utm_medium=home_screen&utm_campaign=pwa', | |
'/cdn/logo/72.png', | |
'/cdn/logo/96.png', | |
'/cdn/logo/128.png', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script async src="https://telegram.org/js/telegram-widget.js?14" | |
data-telegram-login="Telegram 機器人的「使用者名稱」" | |
data-size="large" | |
data-auth-url="要轉去哪個 URL 做後端處理" | |
data-request-access="write"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// new IntersectionObserver = 觀察器 | |
// new IntersectionObserver 的 callback 會產生 IntersectionObserverEntry,就是被獵物 | |
/* | |
3步驟: | |
1 建立觀察器(observer),如果觀察器的鏡頭(root)沒有指定,就是指 window: | |
const observer = new IntersectionObserver(callback, [option]) | |
2 指定觀察器要觀察的目標: observer.observe(el) | |
2 用callback看觀察目標進入到觀察器了沒? | |
entry[0].isIntersecting || !entry[0].isIntersecting | |
3 目標進入後,要不要停止觀察目標? observer.unobserve(el) |
NewerOlder