初始化代码
This commit is contained in:
20
node_modules/base-64/LICENSE-MIT.txt
generated
vendored
Normal file
20
node_modules/base-64/LICENSE-MIT.txt
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
112
node_modules/base-64/README.md
generated
vendored
Normal file
112
node_modules/base-64/README.md
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
# base64 [](https://travis-ci.org/mathiasbynens/base64) [](https://coveralls.io/r/mathiasbynens/base64)
|
||||
|
||||
_base64_ is a robust base64 encoder/decoder that is fully compatible with [`atob()` and `btoa()`](https://html.spec.whatwg.org/multipage/webappapis.html#atob), written in JavaScript. The base64-encoding and -decoding algorithms it uses are fully [RFC 4648](https://tools.ietf.org/html/rfc4648#section-4) compliant.
|
||||
|
||||
## Installation
|
||||
|
||||
Via [npm](https://www.npmjs.com/):
|
||||
|
||||
```bash
|
||||
npm install base-64
|
||||
```
|
||||
|
||||
In a browser:
|
||||
|
||||
```html
|
||||
<script src="base64.js"></script>
|
||||
```
|
||||
|
||||
In [Narwhal](http://narwhaljs.org/), [Node.js](https://nodejs.org/), and [RingoJS](http://ringojs.org/):
|
||||
|
||||
```js
|
||||
var base64 = require('base-64');
|
||||
```
|
||||
|
||||
In [Rhino](http://www.mozilla.org/rhino/):
|
||||
|
||||
```js
|
||||
load('base64.js');
|
||||
```
|
||||
|
||||
Using an AMD loader like [RequireJS](http://requirejs.org/):
|
||||
|
||||
```js
|
||||
require(
|
||||
{
|
||||
'paths': {
|
||||
'base64': 'path/to/base64'
|
||||
}
|
||||
},
|
||||
['base64'],
|
||||
function(base64) {
|
||||
console.log(base64);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `base64.version`
|
||||
|
||||
A string representing the semantic version number.
|
||||
|
||||
### `base64.encode(input)`
|
||||
|
||||
This function takes a byte string (the `input` parameter) and encodes it according to base64. The input data must be in the form of a string containing only characters in the range from U+0000 to U+00FF, each representing a binary byte with values `0x00` to `0xFF`. The `base64.encode()` function is designed to be fully compatible with [`btoa()` as described in the HTML Standard](https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-btoa).
|
||||
|
||||
```js
|
||||
var encodedData = base64.encode(input);
|
||||
```
|
||||
|
||||
To base64-encode any Unicode string, [encode it as UTF-8 first](https://github.com/mathiasbynens/utf8.js#utf8encodestring):
|
||||
|
||||
```js
|
||||
var base64 = require('base-64');
|
||||
var utf8 = require('utf8');
|
||||
|
||||
var text = 'foo © bar 𝌆 baz';
|
||||
var bytes = utf8.encode(text);
|
||||
var encoded = base64.encode(bytes);
|
||||
console.log(encoded);
|
||||
// → 'Zm9vIMKpIGJhciDwnYyGIGJheg=='
|
||||
```
|
||||
|
||||
### `base64.decode(input)`
|
||||
|
||||
This function takes a base64-encoded string (the `input` parameter) and decodes it. The return value is in the form of a string containing only characters in the range from U+0000 to U+00FF, each representing a binary byte with values `0x00` to `0xFF`. The `base64.decode()` function is designed to be fully compatible with [`atob()` as described in the HTML Standard](https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-atob).
|
||||
|
||||
```js
|
||||
var decodedData = base64.decode(encodedData);
|
||||
```
|
||||
|
||||
To base64-decode UTF-8-encoded data back into a Unicode string, [UTF-8-decode it](https://github.com/mathiasbynens/utf8.js#utf8decodebytestring) after base64-decoding it:
|
||||
|
||||
```js
|
||||
var encoded = 'Zm9vIMKpIGJhciDwnYyGIGJheg==';
|
||||
var bytes = base64.decode(encoded);
|
||||
var text = utf8.decode(bytes);
|
||||
console.log(text);
|
||||
// → 'foo © bar 𝌆 baz'
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
_base64_ is designed to work in at least Node.js v0.10.0, Narwhal 0.3.2, RingoJS 0.8-0.9, PhantomJS 1.9.0, Rhino 1.7RC4, as well as old and modern versions of Chrome, Firefox, Safari, Opera, and Internet Explorer.
|
||||
|
||||
## Unit tests & code coverage
|
||||
|
||||
After cloning this repository, run `npm install` to install the dependencies needed for development and testing. You may want to install Istanbul _globally_ using `npm install istanbul -g`.
|
||||
|
||||
Once that’s done, you can run the unit tests in Node using `npm test` or `node tests/tests.js`. To run the tests in Rhino, Ringo, Narwhal, and web browsers as well, use `grunt test`.
|
||||
|
||||
To generate the code coverage report, use `grunt cover`.
|
||||
|
||||
## Author
|
||||
|
||||
| [](https://twitter.com/mathias "Follow @mathias on Twitter") |
|
||||
|---|
|
||||
| [Mathias Bynens](https://mathiasbynens.be/) |
|
||||
|
||||
## License
|
||||
|
||||
_base64_ is available under the [MIT](https://mths.be/mit) license.
|
164
node_modules/base-64/base64.js
generated
vendored
Normal file
164
node_modules/base-64/base64.js
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
/*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */
|
||||
;(function(root) {
|
||||
|
||||
// Detect free variables `exports`.
|
||||
var freeExports = typeof exports == 'object' && exports;
|
||||
|
||||
// Detect free variable `module`.
|
||||
var freeModule = typeof module == 'object' && module &&
|
||||
module.exports == freeExports && module;
|
||||
|
||||
// Detect free variable `global`, from Node.js or Browserified code, and use
|
||||
// it as `root`.
|
||||
var freeGlobal = typeof global == 'object' && global;
|
||||
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
var InvalidCharacterError = function(message) {
|
||||
this.message = message;
|
||||
};
|
||||
InvalidCharacterError.prototype = new Error;
|
||||
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
||||
|
||||
var error = function(message) {
|
||||
// Note: the error messages used throughout this file match those used by
|
||||
// the native `atob`/`btoa` implementation in Chromium.
|
||||
throw new InvalidCharacterError(message);
|
||||
};
|
||||
|
||||
var TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
// http://whatwg.org/html/common-microsyntaxes.html#space-character
|
||||
var REGEX_SPACE_CHARACTERS = /[\t\n\f\r ]/g;
|
||||
|
||||
// `decode` is designed to be fully compatible with `atob` as described in the
|
||||
// HTML Standard. http://whatwg.org/html/webappapis.html#dom-windowbase64-atob
|
||||
// The optimized base64-decoding algorithm used is based on @atk’s excellent
|
||||
// implementation. https://gist.github.com/atk/1020396
|
||||
var decode = function(input) {
|
||||
input = String(input)
|
||||
.replace(REGEX_SPACE_CHARACTERS, '');
|
||||
var length = input.length;
|
||||
if (length % 4 == 0) {
|
||||
input = input.replace(/==?$/, '');
|
||||
length = input.length;
|
||||
}
|
||||
if (
|
||||
length % 4 == 1 ||
|
||||
// http://whatwg.org/C#alphanumeric-ascii-characters
|
||||
/[^+a-zA-Z0-9/]/.test(input)
|
||||
) {
|
||||
error(
|
||||
'Invalid character: the string to be decoded is not correctly encoded.'
|
||||
);
|
||||
}
|
||||
var bitCounter = 0;
|
||||
var bitStorage;
|
||||
var buffer;
|
||||
var output = '';
|
||||
var position = -1;
|
||||
while (++position < length) {
|
||||
buffer = TABLE.indexOf(input.charAt(position));
|
||||
bitStorage = bitCounter % 4 ? bitStorage * 64 + buffer : buffer;
|
||||
// Unless this is the first of a group of 4 characters…
|
||||
if (bitCounter++ % 4) {
|
||||
// …convert the first 8 bits to a single ASCII character.
|
||||
output += String.fromCharCode(
|
||||
0xFF & bitStorage >> (-2 * bitCounter & 6)
|
||||
);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
// `encode` is designed to be fully compatible with `btoa` as described in the
|
||||
// HTML Standard: http://whatwg.org/html/webappapis.html#dom-windowbase64-btoa
|
||||
var encode = function(input) {
|
||||
input = String(input);
|
||||
if (/[^\0-\xFF]/.test(input)) {
|
||||
// Note: no need to special-case astral symbols here, as surrogates are
|
||||
// matched, and the input is supposed to only contain ASCII anyway.
|
||||
error(
|
||||
'The string to be encoded contains characters outside of the ' +
|
||||
'Latin1 range.'
|
||||
);
|
||||
}
|
||||
var padding = input.length % 3;
|
||||
var output = '';
|
||||
var position = -1;
|
||||
var a;
|
||||
var b;
|
||||
var c;
|
||||
var buffer;
|
||||
// Make sure any padding is handled outside of the loop.
|
||||
var length = input.length - padding;
|
||||
|
||||
while (++position < length) {
|
||||
// Read three bytes, i.e. 24 bits.
|
||||
a = input.charCodeAt(position) << 16;
|
||||
b = input.charCodeAt(++position) << 8;
|
||||
c = input.charCodeAt(++position);
|
||||
buffer = a + b + c;
|
||||
// Turn the 24 bits into four chunks of 6 bits each, and append the
|
||||
// matching character for each of them to the output.
|
||||
output += (
|
||||
TABLE.charAt(buffer >> 18 & 0x3F) +
|
||||
TABLE.charAt(buffer >> 12 & 0x3F) +
|
||||
TABLE.charAt(buffer >> 6 & 0x3F) +
|
||||
TABLE.charAt(buffer & 0x3F)
|
||||
);
|
||||
}
|
||||
|
||||
if (padding == 2) {
|
||||
a = input.charCodeAt(position) << 8;
|
||||
b = input.charCodeAt(++position);
|
||||
buffer = a + b;
|
||||
output += (
|
||||
TABLE.charAt(buffer >> 10) +
|
||||
TABLE.charAt((buffer >> 4) & 0x3F) +
|
||||
TABLE.charAt((buffer << 2) & 0x3F) +
|
||||
'='
|
||||
);
|
||||
} else if (padding == 1) {
|
||||
buffer = input.charCodeAt(position);
|
||||
output += (
|
||||
TABLE.charAt(buffer >> 2) +
|
||||
TABLE.charAt((buffer << 4) & 0x3F) +
|
||||
'=='
|
||||
);
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
var base64 = {
|
||||
'encode': encode,
|
||||
'decode': decode,
|
||||
'version': '1.0.0'
|
||||
};
|
||||
|
||||
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
||||
// like the following:
|
||||
if (
|
||||
typeof define == 'function' &&
|
||||
typeof define.amd == 'object' &&
|
||||
define.amd
|
||||
) {
|
||||
define(function() {
|
||||
return base64;
|
||||
});
|
||||
} else if (freeExports && !freeExports.nodeType) {
|
||||
if (freeModule) { // in Node.js or RingoJS v0.8.0+
|
||||
freeModule.exports = base64;
|
||||
} else { // in Narwhal or RingoJS v0.7.0-
|
||||
for (var key in base64) {
|
||||
base64.hasOwnProperty(key) && (freeExports[key] = base64[key]);
|
||||
}
|
||||
}
|
||||
} else { // in Rhino or a web browser
|
||||
root.base64 = base64;
|
||||
}
|
||||
|
||||
}(this));
|
71
node_modules/base-64/package.json
generated
vendored
Normal file
71
node_modules/base-64/package.json
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"_from": "base-64",
|
||||
"_id": "base-64@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==",
|
||||
"_location": "/base-64",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "base-64",
|
||||
"name": "base-64",
|
||||
"escapedName": "base-64",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmmirror.com/base-64/-/base-64-1.0.0.tgz",
|
||||
"_shasum": "09d0f2084e32a3fd08c2475b973788eee6ae8f4a",
|
||||
"_spec": "base-64",
|
||||
"_where": "F:\\广告项目\\橘猫去水印",
|
||||
"author": {
|
||||
"name": "Mathias Bynens",
|
||||
"url": "https://mathiasbynens.be/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mathiasbynens/base64/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "A robust base64 encoder/decoder that is fully compatible with `atob()` and `btoa()`, written in JavaScript.",
|
||||
"devDependencies": {
|
||||
"coveralls": "^2.11.4",
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-cli": "^1.3.2",
|
||||
"grunt-shell": "^1.1.2",
|
||||
"grunt-template": "^0.2.3",
|
||||
"istanbul": "^0.4.0",
|
||||
"mocha": "^6.2.0",
|
||||
"regenerate": "^1.2.1"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE-MIT.txt",
|
||||
"base64.js"
|
||||
],
|
||||
"homepage": "https://mths.be/base64",
|
||||
"keywords": [
|
||||
"codec",
|
||||
"decoder",
|
||||
"encoder",
|
||||
"base64",
|
||||
"atob",
|
||||
"btoa"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "base64.js",
|
||||
"name": "base-64",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mathiasbynens/base64.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "grunt build",
|
||||
"test": "mocha tests/tests.js"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
3
node_modules/image-tools/.vscode/settings.json
generated
vendored
Normal file
3
node_modules/image-tools/.vscode/settings.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"javascript.format.insertSpaceAfterKeywordsInControlFlowStatements": true
|
||||
}
|
76
node_modules/image-tools/README.md
generated
vendored
Normal file
76
node_modules/image-tools/README.md
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
# image-tools
|
||||
图像转换工具,可用于如下环境:uni-app、微信小程序、5+APP、浏览器(需允许跨域)
|
||||
|
||||
## 使用方式
|
||||
|
||||
### NPM
|
||||
|
||||
```
|
||||
npm i image-tools --save
|
||||
```
|
||||
|
||||
```js
|
||||
import { pathToBase64, base64ToPath } from 'image-tools'
|
||||
```
|
||||
|
||||
### 直接下载
|
||||
|
||||
```js
|
||||
// 以下路径需根据项目实际情况填写
|
||||
import { pathToBase64, base64ToPath } from '../../js/image-tools/index.js'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### pathToBase64
|
||||
|
||||
从图像路径转换为base64,uni-app、微信小程序和5+APP使用的路径不支持网络路径,如果是网络路径需要先使用下载API下载下来。
|
||||
|
||||
```js
|
||||
pathToBase64(path)
|
||||
.then(base64 => {
|
||||
console.log(base64)
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
})
|
||||
```
|
||||
|
||||
### base64ToPath
|
||||
|
||||
将图像base64保存为文件,返回文件路径。
|
||||
|
||||
```js
|
||||
base64ToPath(base64)
|
||||
.then(path => {
|
||||
console.log(path)
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
})
|
||||
```
|
||||
|
||||
## 提示
|
||||
|
||||
可以利用promise来串行和并行的执行多个任务
|
||||
|
||||
```js
|
||||
// 并行
|
||||
Promise.all(paths.map(path => pathToBase64(path)))
|
||||
.then(res => {
|
||||
console.log(res)
|
||||
// [base64, base64...]
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
})
|
||||
// 串行
|
||||
paths.reduce((promise, path) => promise.then(res => pathToBase64(path).then(base64 => (res.push(base64), res))), Promise.resolve([]))
|
||||
.then(res => {
|
||||
console.log(res)
|
||||
// [base64, base64...]
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
})
|
||||
```
|
196
node_modules/image-tools/index.js
generated
vendored
Normal file
196
node_modules/image-tools/index.js
generated
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
function getLocalFilePath(path) {
|
||||
if (path.indexOf('_www') === 0 || path.indexOf('_doc') === 0 || path.indexOf('_documents') === 0 || path.indexOf('_downloads') === 0) {
|
||||
return path
|
||||
}
|
||||
if (path.indexOf('file://') === 0) {
|
||||
return path
|
||||
}
|
||||
if (path.indexOf('/storage/emulated/0/') === 0) {
|
||||
return path
|
||||
}
|
||||
if (path.indexOf('/') === 0) {
|
||||
var localFilePath = plus.io.convertAbsoluteFileSystem(path)
|
||||
if (localFilePath !== path) {
|
||||
return localFilePath
|
||||
} else {
|
||||
path = path.substr(1)
|
||||
}
|
||||
}
|
||||
return '_www/' + path
|
||||
}
|
||||
|
||||
function dataUrlToBase64(str) {
|
||||
var array = str.split(',')
|
||||
return array[array.length - 1]
|
||||
}
|
||||
|
||||
var index = 0
|
||||
function getNewFileId() {
|
||||
return Date.now() + String(index++)
|
||||
}
|
||||
|
||||
function biggerThan(v1, v2) {
|
||||
var v1Array = v1.split('.')
|
||||
var v2Array = v2.split('.')
|
||||
var update = false
|
||||
for (var index = 0; index < v2Array.length; index++) {
|
||||
var diff = v1Array[index] - v2Array[index]
|
||||
if (diff !== 0) {
|
||||
update = diff > 0
|
||||
break
|
||||
}
|
||||
}
|
||||
return update
|
||||
}
|
||||
|
||||
export function pathToBase64(path) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (typeof window === 'object' && 'document' in window) {
|
||||
if (typeof FileReader === 'function') {
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.open('GET', path, true)
|
||||
xhr.responseType = 'blob'
|
||||
xhr.onload = function() {
|
||||
if (this.status === 200) {
|
||||
let fileReader = new FileReader()
|
||||
fileReader.onload = function(e) {
|
||||
resolve(e.target.result)
|
||||
}
|
||||
fileReader.onerror = reject
|
||||
fileReader.readAsDataURL(this.response)
|
||||
}
|
||||
}
|
||||
xhr.onerror = reject
|
||||
xhr.send()
|
||||
return
|
||||
}
|
||||
var canvas = document.createElement('canvas')
|
||||
var c2x = canvas.getContext('2d')
|
||||
var img = new Image
|
||||
img.onload = function() {
|
||||
canvas.width = img.width
|
||||
canvas.height = img.height
|
||||
c2x.drawImage(img, 0, 0)
|
||||
resolve(canvas.toDataURL())
|
||||
canvas.height = canvas.width = 0
|
||||
}
|
||||
img.onerror = reject
|
||||
img.src = path
|
||||
return
|
||||
}
|
||||
if (typeof plus === 'object') {
|
||||
plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), function(entry) {
|
||||
entry.file(function(file) {
|
||||
var fileReader = new plus.io.FileReader()
|
||||
fileReader.onload = function(data) {
|
||||
resolve(data.target.result)
|
||||
}
|
||||
fileReader.onerror = function(error) {
|
||||
reject(error)
|
||||
}
|
||||
fileReader.readAsDataURL(file)
|
||||
}, function(error) {
|
||||
reject(error)
|
||||
})
|
||||
}, function(error) {
|
||||
reject(error)
|
||||
})
|
||||
return
|
||||
}
|
||||
if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) {
|
||||
wx.getFileSystemManager().readFile({
|
||||
filePath: path,
|
||||
encoding: 'base64',
|
||||
success: function(res) {
|
||||
resolve('data:image/png;base64,' + res.data)
|
||||
},
|
||||
fail: function(error) {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
reject(new Error('not support'))
|
||||
})
|
||||
}
|
||||
|
||||
export function base64ToPath(base64) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (typeof window === 'object' && 'document' in window) {
|
||||
base64 = base64.split(',')
|
||||
var type = base64[0].match(/:(.*?);/)[1]
|
||||
var str = atob(base64[1])
|
||||
var n = str.length
|
||||
var array = new Uint8Array(n)
|
||||
while (n--) {
|
||||
array[n] = str.charCodeAt(n)
|
||||
}
|
||||
return resolve((window.URL || window.webkitURL).createObjectURL(new Blob([array], { type: type })))
|
||||
}
|
||||
var extName = base64.split(',')[0].match(/data\:\S+\/(\S+);/)
|
||||
if (extName) {
|
||||
extName = extName[1]
|
||||
} else {
|
||||
reject(new Error('base64 error'))
|
||||
}
|
||||
var fileName = getNewFileId() + '.' + extName
|
||||
if (typeof plus === 'object') {
|
||||
var basePath = '_doc'
|
||||
var dirPath = 'uniapp_temp'
|
||||
var filePath = basePath + '/' + dirPath + '/' + fileName
|
||||
if (!biggerThan(plus.os.name === 'Android' ? '1.9.9.80627' : '1.9.9.80472', plus.runtime.innerVersion)) {
|
||||
plus.io.resolveLocalFileSystemURL(basePath, function(entry) {
|
||||
entry.getDirectory(dirPath, {
|
||||
create: true,
|
||||
exclusive: false,
|
||||
}, function(entry) {
|
||||
entry.getFile(fileName, {
|
||||
create: true,
|
||||
exclusive: false,
|
||||
}, function(entry) {
|
||||
entry.createWriter(function(writer) {
|
||||
writer.onwrite = function() {
|
||||
resolve(filePath)
|
||||
}
|
||||
writer.onerror = reject
|
||||
writer.seek(0)
|
||||
writer.writeAsBinary(dataUrlToBase64(base64))
|
||||
}, reject)
|
||||
}, reject)
|
||||
}, reject)
|
||||
}, reject)
|
||||
return
|
||||
}
|
||||
var bitmap = new plus.nativeObj.Bitmap(fileName)
|
||||
bitmap.loadBase64Data(base64, function() {
|
||||
bitmap.save(filePath, {}, function() {
|
||||
bitmap.clear()
|
||||
resolve(filePath)
|
||||
}, function(error) {
|
||||
bitmap.clear()
|
||||
reject(error)
|
||||
})
|
||||
}, function(error) {
|
||||
bitmap.clear()
|
||||
reject(error)
|
||||
})
|
||||
return
|
||||
}
|
||||
if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) {
|
||||
var filePath = wx.env.USER_DATA_PATH + '/' + fileName
|
||||
wx.getFileSystemManager().writeFile({
|
||||
filePath: filePath,
|
||||
data: dataUrlToBase64(base64),
|
||||
encoding: 'base64',
|
||||
success: function() {
|
||||
resolve(filePath)
|
||||
},
|
||||
fail: function(error) {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
reject(new Error('not support'))
|
||||
})
|
||||
}
|
53
node_modules/image-tools/package.json
generated
vendored
Normal file
53
node_modules/image-tools/package.json
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"_from": "image-tools",
|
||||
"_id": "image-tools@1.4.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-TKtvJ6iUwM0mfaD4keMnk1ENHFC470QEjBfA3IlvKdEOufzvWbjbaoNcoyYq6HlViF8+d5tOS1ooE6j7CHf1lQ==",
|
||||
"_location": "/image-tools",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "image-tools",
|
||||
"name": "image-tools",
|
||||
"escapedName": "image-tools",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#DEV:/",
|
||||
"#USER"
|
||||
],
|
||||
"_resolved": "https://registry.npmmirror.com/image-tools/-/image-tools-1.4.0.tgz",
|
||||
"_shasum": "66aacbafad677af7f3fd7f32f8fa1e0881b83783",
|
||||
"_spec": "image-tools",
|
||||
"_where": "F:\\MySDProject\\橘猫去水印【广告版】",
|
||||
"author": {
|
||||
"name": "Shengqiang Guo"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/zhetengbiji/image-tools/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "图像转换工具,可用于如下环境:uni-app、微信小程序、5+APP、浏览器",
|
||||
"devDependencies": {
|
||||
"@types/html5plus": "^1.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/zhetengbiji/image-tools#readme",
|
||||
"keywords": [
|
||||
"base64"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"name": "image-tools",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/zhetengbiji/image-tools.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"version": "1.4.0"
|
||||
}
|
Reference in New Issue
Block a user