fix(frontend): 统一计数缩写口径并将流水号改为订单号
前台各处评论、浏览、点赞、收藏、已售数量统一走 aksrt_format_number() 缩写(≥10000 → 1.2W+,≥1000 → 1.5K), 缩写后缀统一为大写 K,与既有 W+ 保持一致。PHP 渲染缩写文本的 同时保留 data-base-count 原始整数,JS 增量计算不受影响; article.js / comment-ajax.js 内的 formatStatCount / formatCount 与 PHP 规则保持同一套,避免点赞收藏后文本回跳成全量数字。 文章详情页购买信息卡、用户中心创作者收益明细、后台分成与提现 管理页、支付设置页以及四封订单/提现邮件模板中,面向用户展示的 「流水号」字样统一改为「订单号」;代码注释、内部错误码与 WP_Error 文案保留原表述。 验证:node --test "tests/*/*.test.cjs" 508 项全部通过; php -l 检查全部改动文件无语法错误;重新构建 admin SPA 与 前台 runtime bundle。
This commit is contained in:
@@ -59,8 +59,8 @@ test('orders have no independent flow page or visible flow number', () => {
|
||||
assert.equal(fs.existsSync(path.join(root, 'src/Finance/FinancialFlowQuery.php')), false)
|
||||
assert.match(payOrders, /订单明细/)
|
||||
assert.doesNotMatch(payOrders, /账本流水号|资金流水号/)
|
||||
assert.match(read('src/Admin/Native/PayWithdrawals.php'), /esc_html__\('流水号'/)
|
||||
assert.doesNotMatch(read('src/Admin/Native/PayWithdrawals.php'), /提现单号/)
|
||||
assert.match(read('src/Admin/Native/PayWithdrawals.php'), /esc_html__\('订单号'/)
|
||||
assert.doesNotMatch(read('src/Admin/Native/PayWithdrawals.php'), /esc_html__\('流水号'|提现单号/)
|
||||
// 前台订单详情只展示公开订单号,账本流水号不下发也不展示。
|
||||
assert.match(read('assets/js/order-center.js'), /\["订单号", order\.order_number\]/)
|
||||
assert.doesNotMatch(read('assets/js/order-center.js'), /flow_number|账本流水号/)
|
||||
|
||||
@@ -40,8 +40,8 @@ test('paid article and sidebar widget use the Zibll purchase-card DOM', () => {
|
||||
assert.match(pay, /function aksrt_get_paid_box_html/);
|
||||
assert.match(pay, /pay-box zib-widget paid-box order-type-/);
|
||||
assert.match(pay, /flex ac jb-green padding-10 em09/);
|
||||
assert.match(pay, /流水号/);
|
||||
assert.doesNotMatch(pay, /'订单号'/);
|
||||
assert.match(pay, /订单号/);
|
||||
assert.doesNotMatch(pay, /'流水号'/);
|
||||
assert.match(pay, /支付时间/);
|
||||
assert.match(pay, /支付金额/);
|
||||
assert.match(pay, /hidden-box show/);
|
||||
|
||||
@@ -745,6 +745,10 @@ test('single post more menu has one accessible runtime and an in-flow author anc
|
||||
assert.match(components, /aria-haspopup="true"/);
|
||||
assert.match(single, /aksrt_get_single_meta_box\(\$post_id\)/);
|
||||
assert.doesNotMatch(components, /\$direction/);
|
||||
assert.match(components, /\$count_label = function_exists\('aksrt_format_number'\) \? aksrt_format_number\(\$count\) : number_format_i18n\(\$count\)/);
|
||||
assert.match(components, /\$likes_label = function_exists\('aksrt_format_number'\) \? aksrt_format_number\(\$likes\) : number_format_i18n\(\$likes\)/);
|
||||
assert.match(components, /esc_html\(\(string\) \$count_label\)/);
|
||||
assert.match(components, /esc_html\(\(string\) \$likes_label\)/);
|
||||
assert.match(authorBar, /class="single-meta-row"/);
|
||||
assert.doesNotMatch(authorBar, /single-metabox abs-right/);
|
||||
assert.match(singleRender, /'meta_html'\s*=>\s*\(string\) \(\$ctx\['meta_box_html'\] \?\? ''\)/);
|
||||
@@ -754,6 +758,66 @@ test('single post more menu has one accessible runtime and an in-flow author anc
|
||||
assert.match(styles, /\.article-header:has\(\.post-drop-meta\.is-open\)\s*\{[^}]*z-index:\s*30;/s);
|
||||
});
|
||||
|
||||
test('single post like, favorite and comment counts abbreviate everywhere', () => {
|
||||
const actionsRender = read('inc/helpers/aksrt-single-render.php');
|
||||
const tabbar = read('inc/helpers/template-tags/pagination-permissions.php');
|
||||
const article = read('assets/js/core/article.js');
|
||||
|
||||
assert.match(actionsRender, /\$like_label = function_exists\('aksrt_format_number'\) \? aksrt_format_number\(\$like_count\) : number_format_i18n\(\$like_count\)/);
|
||||
assert.match(actionsRender, /\$favorite_label = function_exists\('aksrt_format_number'\) \? aksrt_format_number\(\$favorite_count\) : number_format_i18n\(\$favorite_count\)/);
|
||||
assert.match(actionsRender, /data-stat-count="likes" data-base-count="<\?php echo esc_attr\(\(string\) \$like_count\); \?>"><\?php echo esc_html\(\(string\) \$like_label\);/);
|
||||
assert.match(actionsRender, /data-stat-count="favorites" data-base-count="<\?php echo esc_attr\(\(string\) \$favorite_count\); \?>"><\?php echo esc_html\(\(string\) \$favorite_label\);/);
|
||||
|
||||
assert.match(tabbar, /\$like_label = function_exists\('aksrt_format_number'\) \? aksrt_format_number\(\$like_count\) : number_format_i18n\(\$like_count\)/);
|
||||
assert.match(tabbar, /\$favorite_label = function_exists\('aksrt_format_number'\) \? aksrt_format_number\(\$favorite_count\) : number_format_i18n\(\$favorite_count\)/);
|
||||
assert.match(tabbar, /\$comment_label = function_exists\('aksrt_format_number'\) \? aksrt_format_number\(\$comment_count\) : number_format_i18n\(\$comment_count\)/);
|
||||
assert.match(tabbar, /echo esc_html\(\(string\) \$like_label\)/);
|
||||
assert.match(tabbar, /echo esc_html\(\(string\) \$favorite_label\)/);
|
||||
assert.match(tabbar, /echo esc_html\(\(string\) \$comment_label\)/);
|
||||
|
||||
assert.match(article, /function formatStatCount\(count\)/);
|
||||
assert.match(article, /safeCount >= 10000[\s\S]*?"W\+"/);
|
||||
assert.match(article, /safeCount >= 1000[\s\S]*?"K"/);
|
||||
assert.match(article, /var label = formatStatCount\(count\);/);
|
||||
});
|
||||
|
||||
test('abbreviated counts use uppercase unit suffixes everywhere', () => {
|
||||
const frontendTags = read('inc/helpers/aksrt-frontend-tags.php');
|
||||
const article = read('assets/js/core/article.js');
|
||||
const commentAjax = read('assets/js/comment-ajax.js');
|
||||
|
||||
const formatNumber = frontendTags.match(/function aksrt_format_number\([\s\S]*?\nendif;/)[0];
|
||||
assert.match(formatNumber, /round\(\$num \/ 10000, 1\) \. 'W\+'/);
|
||||
assert.match(formatNumber, /round\(\$num \/ 1000, 1\) \. 'K'/);
|
||||
assert.doesNotMatch(formatNumber, /\. 'k'/);
|
||||
|
||||
assert.doesNotMatch(article, /"k"/);
|
||||
assert.match(article, /"K"/);
|
||||
assert.match(commentAjax, /function formatCount\(count\)/);
|
||||
assert.match(commentAjax, /safeCount >= 10000[\s\S]*?'W\+'/);
|
||||
assert.match(commentAjax, /safeCount >= 1000[\s\S]*?'K'/);
|
||||
assert.doesNotMatch(commentAjax, /'k'/);
|
||||
});
|
||||
|
||||
test('article page sales counts and comment likes abbreviate', () => {
|
||||
const pay = read('inc/helpers/aksrt-pay.php');
|
||||
const downloadBox = read('templates/parts/resource-download-box.php');
|
||||
const commentItem = read('inc/helpers/comments/item.php');
|
||||
|
||||
// 付费盒(文章页 + 侧栏小工具)「已售」徽章。
|
||||
assert.match(pay, /\$sales_label = function_exists\('aksrt_format_number'\) \? aksrt_format_number\(\$sales\) : number_format_i18n\(\$sales\)/);
|
||||
assert.doesNotMatch(pay, /sprintf\(__\('已售 %s', 'aksrt'\), \$sales\)/);
|
||||
|
||||
// 资源下载盒「已售」徽章。
|
||||
assert.match(downloadBox, /\$sales_label = function_exists\('aksrt_format_number'\) \? aksrt_format_number\(\$display_count\) : number_format_i18n\(\$display_count\)/);
|
||||
assert.match(downloadBox, /printf\(esc_html__\('已售 %s', 'aksrt'\), \$sales_label\)/);
|
||||
assert.doesNotMatch(downloadBox, /number_format_i18n\(\$display_count\)\);/);
|
||||
|
||||
// 评论区点赞数。
|
||||
assert.match(commentItem, /\$like_label = function_exists\('aksrt_format_number'\) \? aksrt_format_number\(\$like_count\) : number_format_i18n\(\$like_count\)/);
|
||||
assert.match(commentItem, /esc_html\(\(string\) \$like_label\)/);
|
||||
});
|
||||
|
||||
test('single post has no word-count or estimated-reading-time chain', () => {
|
||||
const chain = join([
|
||||
'inc/helpers/aksrt-single.php',
|
||||
|
||||
Reference in New Issue
Block a user