样式修改完成,待测试

This commit is contained in:
rain
2026-07-07 17:07:34 +08:00
parent 0f6ed0cad3
commit 8a6a8acab7
32 changed files with 2097 additions and 505 deletions
+113
View File
@@ -148,6 +148,70 @@ const CommonUtil = {
return '会员';
},
getExpertState(user = {}) {
const truthy = (value) =>
value === true ||
value === 1 ||
value === '1' ||
String(value).toLowerCase() === 'true';
const firstPresent = (...values) => {
for (const value of values) {
if (value !== undefined && value !== null && value !== '') return value;
}
return '';
};
const statusText = String(
firstPresent(
user.expertStatus,
user.expert_status,
user.expertApplyStatus,
user.expert_apply_status,
user.applyStatus,
user.apply_status,
user.auditStatus,
user.audit_status,
user.expertAuditStatus,
user.expert_audit_status
)
).toLowerCase();
const isExpert =
truthy(user.regularExpert) ||
truthy(user.isRegularExpert) ||
truthy(user.is_regular_expert) ||
truthy(user.formalExpert) ||
truthy(user.isFormalExpert) ||
truthy(user.internExpert) ||
truthy(user.isInternExpert) ||
truthy(user.is_intern_expert) ||
truthy(user.trialExpert) ||
truthy(user.isTrialExpert) ||
truthy(user.is_expert) ||
truthy(user.isExpert) ||
truthy(user.expert) ||
/实习|正式|intern|trial|regular|formal|expert/.test(statusText);
const isApplying =
!isExpert &&
([
'0',
'pending',
'reviewing',
'review',
'audit',
'auditing',
'apply',
'applying',
'submitted',
'wait',
'waiting',
].includes(statusText) ||
/审核|待审|申请中|pending|review|audit|applying|waiting/.test(statusText));
return {
isExpert,
isApplying,
status: statusText,
};
},
getUserLevelTextLegacy(user = {}) {
if (user.regularExpert || user.isExpert === '1' || user.expertStatus === 'regular') {
return '正式专家';
@@ -1752,6 +1816,55 @@ const CommonUtil = {
$tempContainer.remove();
},
renderTrendOpenCode(openCode, options = {}) {
const value = String(openCode === undefined || openCode === null ? '' : openCode).trim();
if (!value) return '<span class="trend-open-empty">--</span>';
const mode = options.mode || 'red';
const splitTokens = (text) =>
String(text || '')
.split(/[,\s、,]+/)
.map((item) => item.trim())
.filter(Boolean);
const splitDigits = (text) => {
const tokens = splitTokens(text);
if (tokens.length > 1) return tokens;
return String(text || '')
.replace(/[^\d]/g, '')
.split('')
.filter(Boolean);
};
const pad = (num, shouldPad = true) => (shouldPad && /^\d$/.test(num) ? `0${num}` : num);
const renderNum = (num, className, shouldPad = true) =>
`<span class="trend-open-number ${className}">${this.escapeHtml(pad(String(num), shouldPad))}</span>`;
const renderGroup = (list, className, shouldPad = true) =>
list.map((num) => renderNum(num, className, shouldPad)).join('');
const renderPlus = () => '<span class="trend-open-separator">+</span>';
const parts = value.split('+');
let body = '';
if (mode === 'ssq' || mode === 'dlt' || mode === 'qlc') {
const front = splitTokens(parts[0]);
let back = parts.slice(1).flatMap(splitTokens);
const frontLimit = mode === 'ssq' ? 6 : mode === 'dlt' ? 5 : 7;
if (!back.length && front.length > frontLimit) back = front.splice(frontLimit);
body = renderGroup(front, 'trend-open-red');
if (back.length) body += renderPlus() + renderGroup(back, 'trend-open-blue');
} else if (mode === 'qxc') {
const nums = splitDigits(value);
const front = nums.slice(0, 6);
const back = nums.slice(6);
body = renderGroup(front, 'trend-open-red', false);
if (back.length) body += renderPlus() + renderGroup(back, 'trend-open-blue', false);
} else if (mode === 'position') {
body = renderGroup(splitDigits(value), 'trend-open-red', false);
} else {
body = renderGroup(splitTokens(value), 'trend-open-red');
}
return `<span class="trend-open-code">${body || this.escapeHtml(value)}</span>`;
},
sanitizeHTML(html) {
if (!html) return '';
const parser = new DOMParser();