Commit 5bde7359 authored by hewenhao's avatar hewenhao

feat: base58

parent 310ba674
{ {
"board-bg-float.png": { "board-bg-float.png": {
"u": "https://cdn.jkwljy.com/pk-math/e5K5azr5HM84UUDfi4K6M1ajPQ8_/164x140", "u": "https://cdn.jkwljy.com/pk-math/2irQDt3fGBdeUKTjbKWMbjn5eeKY/164x140",
"w": 164, "w": 164,
"h": 140, "h": 140,
"ossName": "/pk-math/e5K5azr5HM84UUDfi4K6M1ajPQ8_/164x140" "ossName": "/pk-math/2irQDt3fGBdeUKTjbKWMbjn5eeKY/164x140"
} }
} }
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
"@typescript-eslint/eslint-plugin": "^5.20.0", "@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0", "@typescript-eslint/parser": "^5.20.0",
"babel-preset-taro": "3.6.2", "babel-preset-taro": "3.6.2",
"base-x": "^4.0.0",
"copy-dir": "^1.3.0", "copy-dir": "^1.3.0",
"cos-nodejs-sdk-v5": "^2.11.4", "cos-nodejs-sdk-v5": "^2.11.4",
"default-gateway": "^6.0.3", "default-gateway": "^6.0.3",
...@@ -71,17 +72,17 @@ ...@@ -71,17 +72,17 @@
"fast-glob": "^3.2.7", "fast-glob": "^3.2.7",
"http-proxy-middleware": "^2.0.0", "http-proxy-middleware": "^2.0.0",
"husky": "^4.2.5", "husky": "^4.2.5",
"image-size": "^0.5.0",
"json-templater": "^1.2.0", "json-templater": "^1.2.0",
"lint-staged": "^13.0.3", "lint-staged": "^13.0.3",
"miniprogram-ci": "^1.9.5", "miniprogram-ci": "^1.9.5",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
"image-size": "^0.5.0",
"postcss": "^8.4.18", "postcss": "^8.4.18",
"stylelint": "9.3.0", "stylelint": "9.3.0",
"temp": "^0.9.4", "temp": "^0.9.4",
"typescript": "^4.1.0", "typescript": "^4.1.0",
"webpack": "5.69.0", "validate-commit-msg": "^2.14.0",
"validate-commit-msg": "^2.14.0" "webpack": "5.69.0"
}, },
"husky": { "husky": {
"hooks": { "hooks": {
......
...@@ -20,6 +20,9 @@ const config = { ...@@ -20,6 +20,9 @@ const config = {
Bucket: 'frontend-bkt-1257124244' // 'test-1257124244' Bucket: 'frontend-bkt-1257124244' // 'test-1257124244'
} }
const BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
const bs58 = require('base-x')(BASE58)
const cos = new COS({ const cos = new COS({
SecretId: config.SecretId, SecretId: config.SecretId,
SecretKey: config.SecretKey SecretKey: config.SecretKey
...@@ -149,13 +152,13 @@ function uploadFile ({ fileName, filePath, ContentType, ossName, dimensions }) { ...@@ -149,13 +152,13 @@ function uploadFile ({ fileName, filePath, ContentType, ossName, dimensions }) {
} }
function getFileName (relativePath, absolutPath, dimensions) { function getFileName (relativePath, absolutPath, dimensions) {
const str = require('crypto') const buffer = require('crypto')
.createHash('sha1') .createHash('sha1')
.update('geek-cos-upload') .update('geek-cos-upload')
.update('\0__1') .update('\0__1')
.update(relativePath) .update(relativePath)
.update(fs.readFileSync(absolutPath, { encoding: 'binary' })) .update(fs.readFileSync(absolutPath, { encoding: 'binary' }))
.digest('base64') .digest()
.replace(/\.|-|=|\+|\//g, '_') const key = bs58.encode(buffer)
return `/pk-math/${str}/${dimensions.width}x${dimensions.height}` return `/pk-math/${key}/${dimensions.width}x${dimensions.height}`
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* eslint-disable quote-props */ /* eslint-disable quote-props */
export default { export default {
"board-bg-float.png": { "board-bg-float.png": {
"u": "https://cdn.jkwljy.com/pk-math/e5K5azr5HM84UUDfi4K6M1ajPQ8_/164x140", "u": "https://cdn.jkwljy.com/pk-math/2irQDt3fGBdeUKTjbKWMbjn5eeKY/164x140",
"w": 164, "w": 164,
"h": 140 "h": 140
} }
......
...@@ -4541,6 +4541,11 @@ balanced-match@^1.0.0: ...@@ -4541,6 +4541,11 @@ balanced-match@^1.0.0:
resolved "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" resolved "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
base-x@^4.0.0:
version "4.0.0"
resolved "http://git.jksxb.cn:8081/repository/geek/base-x/-/base-x-4.0.0.tgz#d0e3b7753450c73f8ad2389b5c018a4af7b2224a"
integrity sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==
base64-js@^1.3.0, base64-js@^1.3.1: base64-js@^1.3.0, base64-js@^1.3.1:
version "1.5.1" version "1.5.1"
resolved "https://registry.npmmirror.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" resolved "https://registry.npmmirror.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
...@@ -8528,7 +8533,7 @@ ignore@^5.1.1, ignore@^5.1.8, ignore@^5.1.9, ignore@^5.2.0: ...@@ -8528,7 +8533,7 @@ ignore@^5.1.1, ignore@^5.1.8, ignore@^5.1.9, ignore@^5.2.0:
resolved "https://registry.npmmirror.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" resolved "https://registry.npmmirror.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324"
integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==
image-size@~0.5.0: image-size@^0.5.0, image-size@~0.5.0:
version "0.5.5" version "0.5.5"
resolved "https://registry.npmmirror.com/image-size/-/image-size-0.5.5.tgz#09dfd4ab9d20e29eb1c3e80b8990378df9e3cb9c" resolved "https://registry.npmmirror.com/image-size/-/image-size-0.5.5.tgz#09dfd4ab9d20e29eb1c3e80b8990378df9e3cb9c"
integrity sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ== integrity sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment