Skip to content

Instantly share code, notes, and snippets.

View littledian's full-sized avatar
🤒
Out sick

littledian

🤒
Out sick
View GitHub Profile
function generateRandomPassword() {
const randomChar = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
const randomNum = '0123456789'
const randomSymbol = '!@#$%^&*()'
const getRandomChar = () => randomChar[Math.floor(Math.random() * randomChar.length)]
const getRandomNum = () => randomNum[Math.floor(Math.random() * randomNum.length)]
const getRandomSymbol = () => randomSymbol[Math.floor(Math.random() * randomSymbol.length)]
const passwordLength = 8
const getUserInfo = (function() {
let userInfo = null
let promise = null
return function(cb) {
if (!userInfo && !promise) {
promise = new Promise(resolve => {
setTimeout(() => {
userInfo = {username: 'littledian'}
resolve()
cb && cb(userInfo)
class Set {
static _next = 0
constructor (...args) {
this.values = {}
this.n = 0
this.add.apply(this, args)
}
function inherit (p) {
if (p == null) throw new TypeError()
if (Object.create) return Object.create(p)
const t = typeof p
if (t !== 'object' && t !== 'function') throw new TypeError()
function f () {}
f.prototype = p
$element-separator: '__';
$modifier-separator: '--';
$state-prefix: 'is-';
@function selectorToString($selector) {
$selector: inspect($selector);
$selector: str-slice($selector, 2, -2);
@return $selector;
}
module.exports = {
configureWebpack: config => {
if (process.env.NODE_ENV === 'development') {
config.devtool = 'eval-source-map'
}
config.output.devtoolModuleFilenameTemplate = info => {
let $filename = 'sources://' + info.resourcePath
if (info.resourcePath.match(/\.vue$/) && !info.identifier.match(/type=script/)) {
$filename = 'webpack-generated:///' + info.identifier + '?' + info.hash
export function drag (
{
mouseDownEvent,
element,
once = false,
mouseDownCallback = () => {},
mouseMoveCallback = () => {},
mouseUpCallback = () => {}
}) {
if (!mouseDownEvent && !element) {
createForeignObjectSVG = (
width: number,
height: number,
x: number,
y: number,
node: Node
) => {
const xmlns = 'http://www.w3.org/2000/svg';
const svg = document.createElementNS(xmlns, 'svg');
const foreignObject = document.createElementNS(xmlns, 'foreignObject');
const Client = require('ssh2').Client
const fs = require('fs')
const path = require('path')
function downloadFile (source, target, option) {
return new Promise((resolve, reject) => {
const conn = new Client()
conn.on('ready', () => {
conn.sftp((err, sftp) => {
if (err) return reject(err)
const path = require('path')
const PrerenderSPAPlugin = require('prerender-spa-plugin')
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer
module.exports = {
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
// 为生产环境修改配置...
config.plugins.push(
new PrerenderSPAPlugin({