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 { Button, Card, message, Progress, Space } from "antd"; | |
| import Axios, { CancelTokenSource } from "axios"; | |
| import contentDisposition from "content-disposition"; | |
| import React, { useCallback, useRef, useState } from "react"; | |
| interface DownloadProps {} | |
| const Download: React.FC<DownloadProps> = () => { | |
| const cancelSource = useRef<CancelTokenSource | null>(null); | |
| const [percentage, setPercentage] = useState<number>(0); |
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
| export class TestClass { | |
| someMethod(): number; | |
| someMethod(str: string): string; | |
| someMethod(str?: string) { | |
| if ( typeof str === 'string' ) { | |
| return str + '123'; | |
| } else { | |
| return Math.random(); | |
| } |
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 lastMonthData = [ | |
| { | |
| id: 1, | |
| name: "Alex", | |
| salary: 15662 | |
| }, | |
| { | |
| id: 2, | |
| name: "Tom", | |
| salary: 18672 |
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
| /** | |
| * tool for store data in global | |
| */ | |
| class GlobalStorage{ | |
| /** | |
| * init Global Storage | |
| * @param {string} globalKey key for store | |
| */ | |
| constructor(globalKey = "app") { | |
| this.globalKey = globalKey; |
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
| /** | |
| * 根据参数名获取参数值 | |
| * @param {string} name 参数名 | |
| * @param {string} [url] 地址 | |
| */ | |
| function getParameterByName(name, url) { | |
| if (!url) url = window.location.href; | |
| name = name.replace(/[\[\]]/g, "\\$&"); | |
| var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | |
| results = regex.exec(url); |
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 ArticleParser = require('article-parser'); | |
| var he = require('he'); | |
| var url = 'http://mp.weixin.qq.com/s/JJbZkcBoSMW0zPzmepUr1A'; | |
| ArticleParser.configure({ | |
| htmlRules:{ | |
| allowedTags: [ 'pre', 'p', 'img' ], | |
| allowedAttributes: { | |
| pre: ['style'], |
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 request = require('request') | |
| const cheerio = require('cheerio') | |
| const url = 'https://medium.com/@leighalexander/the-underground-world-of-magical-resistance-on-the-internet-6c854e567347'; | |
| const audioUrl = /https:\/\/cdn-audio.*m4a/g; | |
| const reqOpt = { | |
| url: url | |
| } | |
| request(reqOpt, (error, res, body) => { |
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
| /** | |
| * 定义一个函数,里面带有一个方法 | |
| * 在不修改该方法的条件下,获取到o中所有的属性名 | |
| */ | |
| var foo = (function(){ | |
| var o = { | |
| a: 1, | |
| b: 2, | |
| /**更多属性**/ | |
| }; |
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
| /** | |
| * 控制一个函数延后执行 | |
| * @param tick 休眠时间 | |
| */ | |
| function sleep(tick: number){ | |
| return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => { | |
| let method = descriptor.value; | |
| descriptor.value = (...args: any[]) =>{ | |
| setTimeout(()=>{ | |
| method.apply(target, args) |
NewerOlder