diff --git a/app.dev.yaml b/app.dev.yaml index ce69c99..a651576 100644 --- a/app.dev.yaml +++ b/app.dev.yaml @@ -1,5 +1,5 @@ -script: node ./app.js +script: bun ./app.js cwd: ./ watch: true name: stats:23333 diff --git a/lib/svg.js b/lib/svg.js index 45bb179..2927349 100644 --- a/lib/svg.js +++ b/lib/svg.js @@ -24,7 +24,7 @@ function text({ color, name, pc, idx }) { ` } -function pie(langs = [], sum = 0, height, mobile) { +function pie(langs = [], sum = 0, width, height, mobile) { let per = 0.25 let deg = per * 2 * Math.PI // 从90度开始计算 // 圆心坐标,半径 @@ -38,6 +38,11 @@ function pie(langs = [], sum = 0, height, mobile) { radius = ~~((height - 64) / 2) - (langs.length > 10 ? 24 : 0) // 最小半径 cx = langs.length > 12 ? 520 : langs.length <= 6 ? 384 : 464 cy = radius + (langs.length > 10 ? 64 : 48) + + let _cx = width - radius * Math.pow(1.05, langs.length) + if (_cx - cx > 10) { + cx = _cx - 10 + } } return langs @@ -80,7 +85,7 @@ export function render( } if (langs.length < 5) { - width -= 304 + width -= 256 } else if (langs.length > 4 && langs.length < 7) { width -= 240 } else if (langs.length > 6 && langs.length <= 12) { @@ -143,7 +148,7 @@ export function render( .join('')} - ${pie(langs, sum, height, mobile)} + ${pie(langs, sum, width, height, mobile)} ` }