This file contains hidden or 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 os = require("os"); | |
const protocol = "https"; | |
const port = "8080"; | |
// 运行端口host打印 | |
const interfaces = os.networkInterfaces(); | |
// 处理 IPV4 | |
Object.keys(interfaces).forEach((key) => { | |
(interfaces[key] || []) |
This file contains hidden or 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 { exec } = require("child_process"); | |
const dotenv = require("dotenv"); | |
const env = {}; | |
const mode = process.env.MODE; | |
const files = [".env", `.env.${mode}`]; | |
files.forEach((file) => { | |
const { parsed } = dotenv.config({ path: `${__dirname}/${file}` }); |
This file contains hidden or 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 video = document.getElementsByTagName("video")[0]; | |
video.currentTime = video.duration; |
This file contains hidden or 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
import 'package:flutter/foundation.dart'; | |
import 'dart:async'; | |
class Debounce { | |
final int milliseconds; | |
VoidCallback action; | |
Timer _timer; | |
Debounce({this.milliseconds}); |
This file contains hidden or 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
import XLSX from "xlsx"; | |
/** | |
* 更换data的key为map里面的value | |
* 比如说data是这样子的: [ name: 'perter' ] | |
* map是这样子的: [ name: '姓名' ] | |
* 经过这个方法转换之后就会变成 [ '姓名': 'peter' ] | |
* 这样到 `XLSX.utils.json_to_sheet` 方法运行的时候 | |
* 就能解析出正确的表头 | |
* @param { data } array JSON 数组 { key: value }[] |


This file contains hidden or 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
import XLSX from "xlsx"; | |
/** | |
* 转换Json为Excel文件并下载 | |
* @param {data} array JSON 数组 { 名字: 值 }[] | |
* @param {header} array excel 表格的名字 | |
* @param {sheet} string 工作簿 | |
* @param {filename} string 文件名 | |
*/ | |
export function exportJson({ data, header, sheet, filename }) { | |
const wb = XLSX.utils.book_new(); |
This file contains hidden or 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
isElementInViewport = (el) => { | |
let rect = el.getBoundingClientRect(); | |
return ( | |
rect.top >= 0 && | |
rect.left >= 0 && | |
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && | |
rect.right <= (window.innerWidth || document.documentElement.clientWidth) | |
); | |
} |
This file contains hidden or 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
/* | |
* Easing Functions - inspired from http://gizma.com/easing/ | |
* only considering the t value for the range [0, 1] => [0, 1] | |
*/ | |
EasingFunctions = { | |
// no easing, no acceleration | |
linear: function (t) { return t }, | |
// accelerating from zero velocity | |
easeInQuad: function (t) { return t*t }, | |
// decelerating to zero velocity |
NewerOlder