Skip to content

Commit

Permalink
Version_0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
censujiang committed Jul 13, 2023
1 parent d5f6bf7 commit 0b81dd3
Show file tree
Hide file tree
Showing 74 changed files with 1,044 additions and 491 deletions.
56 changes: 55 additions & 1 deletion dist/index.aio.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* galanga 0.2.0 (https://github.com/censujiang/galanga)
* galanga 0.2.1 (https://github.com/censujiang/galanga)
* API https://galanga.censujiang.com/api/
* Copyright 2014-2023 censujiang. All Rights Reserved
* Licensed under Apache License 2.0 (https://github.com/censujiang/galanga/blob/master/LICENSE)
Expand Down Expand Up @@ -70,6 +70,7 @@
}
};

const chars62 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// 检查输入的值是否为空
function checkNull(val) {
if (val === null || val === undefined || val === '' || typeof val === 'number' && isNaN(val)) {
Expand Down Expand Up @@ -171,6 +172,51 @@
const reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
return reg.test(email);
}
//一个62进制的加密函数,将十进制数字转换为62进制字符串
function encode62(num) {
let radix = chars62.length;
let arr = []; // specify the type of arr as string[]
do {
let mod = num % radix;
num = (num - mod) / radix;
arr.unshift(chars62[mod]);
} while (num);
return arr.join('');
}
//一个62进制的解密函数,将62进制字符串转换为十进制数字
function decode62(str) {
if (typeof str == 'number') {
str = str.toString();
}
let radix = chars62.length;
let len = str.length;
let i = 0;
let origin = 0;
while (i < len) {
origin += Math.pow(radix, i++) * chars62.indexOf(str.charAt(len - i) || '0');
}
return Number(origin);
}
//从一个URL字符串中获取文件名
function getFileNameFromURL(url) {
let arr = url.split('/');
return arr[arr.length - 1];
}
//从一个字符串中获取文件后缀格式
function getFileExtFromString(str) {
let arr = str.split('.');
return arr[arr.length - 1];
}
//拼接一个站点的标题,会有一个json对象作为参数输入到此函数,对象中有四个属性,分别是标题(默认为none),站点名称(默认为Galanga),分隔符(默认为-),是否反转(默认为false)
function spliceSiteTitle({ title = 'none', siteName = 'Galanga', separator = '-', reverse = false } = {}) {
separator = ' ' + separator + ' ';
if (reverse) {
return siteName + separator + title;
}
else {
return title + separator + siteName;
}
}

const url = {
getQuery(name) {
Expand Down Expand Up @@ -599,6 +645,8 @@
}
}

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

//import * as packageJson from '../package.json'
//导出自己的名字
const info = {
Expand All @@ -616,15 +664,21 @@
exports.checkPassword = checkPassword;
exports.clipboard = clipboard;
exports.clipboardPermission = clipboardPermission;
exports.decode62 = decode62;
exports.encode62 = encode62;
exports.filterUniqueByProperty = filterUniqueByProperty;
exports.formatBytes = formatBytes;
exports.formatNumber = formatNumber;
exports.getFileExtFromString = getFileExtFromString;
exports.getFileNameFromURL = getFileNameFromURL;
exports.getPreURL = getPreURL;
exports.info = info;
exports.localCookie = localCookie;
exports.locationPermission = locationPermission;
exports.notificationPermission = notificationPermission;
exports.shakeObject = shakeObject;
exports.sleep = sleep;
exports.spliceSiteTitle = spliceSiteTitle;
exports.strLength = strLength;
exports.updateObjectFromImport = updateObjectFromImport;
exports.url = url;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.aio.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0b81dd3

Please sign in to comment.