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 downloadCSV = data => { | |
let csvContent = ''; | |
Array.prototype.forEach.call(data, d => { | |
let dataString = d.join(',') + '\n'; | |
csvContent += dataString; | |
}) | |
// 下載的檔案名稱 | |
let fileName = '下載資料_' + (new Date()).getTime() + '.csv'; |
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 buildData = data => { | |
return new Promise((resolve, reject) => { | |
// 最後所有的資料會存在這 | |
let arrayData = []; | |
// 取 data 的第一個 Object 的 key 當表頭 | |
let arrayTitle = Object.keys(data[0]); | |
arrayData.push(arrayTitle); |
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 apiUri = "https://api.github.com/repos/letswritetw/letswrite-github-issue-create/issues/1/comments"; | |
const headers = new Headers(); | |
headers.append("Accept", "application/vnd.github.v3+json"); | |
headers.append("Authorization", "Bearer 取得的Token"); | |
headers.append("Content-Type", "application/json"); | |
let data = JSON.stringify({ | |
"body": "這邊填寫 Comment 的內文" | |
}); |
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 apiUri = "https://api.github.com/repos/letswritetw/letswrite-github-issue-create/issues"; | |
const headers = new Headers(); | |
headers.append("Accept", "application/vnd.github.v3+json"); | |
headers.append("Authorization", "Bearer 取得的Token"); | |
headers.append("Content-Type", "application/json"); | |
let data = JSON.stringify({ | |
"title": "這邊填寫 Issue 的標題", | |
"body": "這邊填寫 Issue 的內文" |
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
<!-- html --> | |
<div id="app"> | |
<div v-html="markdownToHtml(issue.body)"></div> | |
</div> | |
<!-- JS --> | |
<script> | |
import marked from 'marked' | |
new Vue({ |
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 uri = 'https://api.github.com/repos/letswritetw/letswrite-github-api-issues-get/issues/1'; | |
const headers = new Headers(); | |
headers.append('Accept', 'application/vnd.github.v3+json'); | |
const config = { | |
method: 'GET', | |
headers: headers, | |
redirect: 'follow' | |
} |
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 first = dayjs().subtract(1, 'month').startOf('month').format('YYYY-MM-DD'); | |
console.log(first); // 2021-03-01 | |
// 上個月最後一天 | |
const end = dayjs().subtract(1, 'month').endOf('month').format('YYYY-MM-DD'); | |
console.log(end) // 2021-03-31 |
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
firebase.auth() | |
.getRedirectResult() | |
.then((result) => { | |
if (result.credential) { | |
var credential = result.credential; | |
var token = credential.accessToken; | |
} | |
var user = result.user; | |
}).catch((error) => { | |
var errorCode = error.code; |
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 providerGithub = new firebase.auth.GithubAuthProvider(); | |
firebase.auth() | |
.signInWithPopup(providerGithub) | |
.then((result) => { | |
let credential = result.credential; | |
let token = credential.accessToken; | |
let user = result.user; | |
}).catch((error) => { | |
let errorCode = error.code; | |
let errorMessage = error.message; |
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
<template lang="pug"> | |
a.btn.btn-main(:href="uri" target="_blank") {{ title }} | |
</template> | |
<script> | |
export default { | |
data: () => { | |
return {} | |
}, | |
props: ['title', 'uri'] |