This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

重构vm部分

old
宇天 2017-12-19 10:41:13 +08:00
parent 4abf8bb43b
commit 6c7c96cddd
9 changed files with 13569 additions and 44 deletions

13
build.dev.js Normal file → Executable file
View File

@ -19,10 +19,19 @@ const cssOpt = {
} }
const compileJs = (entry, output) => { const compileJs = (entry, output) => {
if (/touch\.patch/.test(entry)) {
return
}
let t1 = Date.now() let t1 = Date.now()
const { code } = babel.transformFileSync(entry, jsOpt) if (/anot/.test(entry)) {
setTimeout(() => {
fs.cp(entry, output)
}, 100)
} else {
const { code } = babel.transformFileSync(entry, jsOpt)
fs.echo(code, output)
}
log('编译JS: %s, 耗时 %d ms', entry, Date.now() - t1) log('编译JS: %s, 耗时 %d ms', entry, Date.now() - t1)
fs.echo(code, output)
} }
const compileCss = (entry, output) => { const compileCss = (entry, output) => {

10
build.prod.js Normal file → Executable file
View File

@ -18,8 +18,15 @@ const cssOpt = {
} }
const compileJs = (entry, output) => { const compileJs = (entry, output) => {
if (/touch\.patch/.test(entry)) {
return
}
let t1 = Date.now() let t1 = Date.now()
const { code } = babel.transformFileSync(entry, jsOpt) let tmpOpt = jsOpt
if (/anot/.test(entry)) {
tmpOpt = Object.assign({}, jsOpt, { plugins: [] })
}
const { code } = babel.transformFileSync(entry, tmpOpt)
log('编译JS: %s, 耗时 %d ms', entry, Date.now() - t1) log('编译JS: %s, 耗时 %d ms', entry, Date.now() - t1)
fs.echo(code, output) fs.echo(code, output)
} }
@ -90,4 +97,3 @@ jsFiles.forEach(file => {
} }
} }
}) })

7058
src/js/anot-touch.shim.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -6342,4 +6342,4 @@ yua.noConflict = function(deep) {
window.yua = yua window.yua = yua
export default yua

6459
src/js/anot.shim.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,27 +5,24 @@
* *
*/ */
"use strict"; 'use strict'
// 1216fc0c668c09ade029ceae6db87f97cf560e21 // 1216fc0c668c09ade029ceae6db87f97cf560e21
define(function(){ define(function() {
var Avatar = function() {
var Avatar = function(){ this.sum = function(arr) {
this.sum = function(arr){ var sum = 0
var sum = 0; arr.forEach(function(it) {
arr.forEach(function(it){ sum -= -it
sum -= -it })
}) }
} }
};
Avatar.prototype = { Avatar.prototype = {
get: function(hash, size){ get: function(hash, size) {
if(!hash) if (!hash) return this.defafultImg
return this.defafultImg;
if(!size || size < 100){ if (!size || size < 100) {
size = 100 size = 100
} }
@ -37,49 +34,46 @@ define(function(){
lens = hash.slice(0, 8).match(/([\w]{1})/g), lens = hash.slice(0, 8).match(/([\w]{1})/g),
pos1 = hash.slice(8, 16).match(/([\w]{1})/g), pos1 = hash.slice(8, 16).match(/([\w]{1})/g),
pos2 = hash.slice(16, 24).match(/([\w]{1})/g), pos2 = hash.slice(16, 24).match(/([\w]{1})/g),
step = size / 10; step = size / 10
cv.width = size
cv.height = size
cv.width = size;
cv.height = size;
lens = lens.map(c => { lens = lens.map(c => {
c = parseInt(c, 16); c = parseInt(c, 16)
return c % 8 return c % 8
}) })
pos1 = pos1.map(c => { pos1 = pos1.map(c => {
c = parseInt(c, 16); c = parseInt(c, 16)
return c % 4 return c % 4
}) })
pos2 = pos2.map(c => { pos2 = pos2.map(c => {
c = parseInt(c, 16); c = parseInt(c, 16)
return c % 4 return c % 4
}) })
fixColor = this.sum(lens) > 32 ? bg : color; fixColor = this.sum(lens) > 32 ? bg : color
ct.fillStyle = '#' + bg; ct.fillStyle = '#' + bg
ct.fillRect(0, 0, size, size) ct.fillRect(0, 0, size, size)
for(var i = 1; i < 9; i++){ for (var i = 1; i < 9; i++) {
var xl = lens[i - 1],
xp1 = pos1[i - 1],
xp2 = pos2[i - 1]
var xl = lens[i-1], if (xl + xp1 > 8) {
xp1 = pos1[i-1],
xp2 = pos2[i-1];
if(xl + xp1 > 8){
xl = 8 - xp1 xl = 8 - xp1
} }
ct.fillStyle = '#' + color; ct.fillStyle = '#' + color
ct.fillRect((xp1 + 1) * step, i * step, xl * step, step) ct.fillRect((xp1 + 1) * step, i * step, xl * step, step)
ct.fillStyle = '#' + color; ct.fillStyle = '#' + color
ct.fillRect((9 - xp1 - xl) * step, i * step, xl * step, step) ct.fillRect((9 - xp1 - xl) * step, i * step, xl * step, step)
ct.fillStyle = '#' + fixColor; ct.fillStyle = '#' + fixColor
ct.fillRect((xp2 + 1) * step, i * step, step, step) ct.fillRect((xp2 + 1) * step, i * step, step, step)
ct.fillStyle = '#' + fixColor; ct.fillStyle = '#' + fixColor
ct.fillRect((8 - xp2) * step, i * step, step, step) ct.fillRect((8 - xp2) * step, i * step, step, step)
} }
@ -88,5 +82,4 @@ define(function(){
} }
return new Avatar() return new Avatar()
}) })

0
test.js Normal file
View File