feat: 未授权时在卡密输入框下方显示本机机器码(带一键复制)v1.8.2
解决用户找不到机器码的问题:去商城购买/手动激活/联系客服都需要提供机器码,现在未授权(试用/体验/异常)状态直接显示并可一键复制;已授权用户不显示,避免界面杂乱。
This commit is contained in:
1 parent
69b110ec78
commit
51fd1bc1b4
7 files changed
+100
-7
No files matched your search
@@ -644,6 +644,27 @@ class AutoCommentManager {
|
||||
});
|
||||
}
|
||||
|
||||
// 机器码一键复制(未授权时展示在卡密输入框下方)
|
||||
const machineCopyBtn = document.getElementById('machine-code-copy');
|
||||
if (machineCopyBtn) {
|
||||
machineCopyBtn.addEventListener('click', async () => {
|
||||
const codeEl = document.getElementById('machine-code-text');
|
||||
const code = (codeEl ? codeEl.textContent : '').trim();
|
||||
if (!code) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(code);
|
||||
} catch (error) {
|
||||
const ta = document.createElement('textarea');
|
||||
ta.value = code;
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
document.execCommand('copy');
|
||||
ta.remove();
|
||||
}
|
||||
this.showActionStatus(true, '✓ 机器码已复制,去商城购买或手动激活时粘贴即可');
|
||||
});
|
||||
}
|
||||
|
||||
// 后台复验或购买激活后自动刷新
|
||||
chrome.storage.onChanged.addListener((changes, namespace) => {
|
||||
if (namespace !== 'local') return;
|
||||
@@ -695,6 +716,9 @@ class AutoCommentManager {
|
||||
detail.textContent = '授权状态异常,请重新打开侧边栏';
|
||||
this.hideCouponBar();
|
||||
}
|
||||
|
||||
// 未授权(试用/体验/异常)时在卡密输入框下方展示机器码,便于去商城购买或手动激活时提供
|
||||
this.renderMachineCode(s.state !== 'authorized');
|
||||
} catch (error) {
|
||||
console.error('获取授权状态失败:', error);
|
||||
badge.classList.add('locked');
|
||||
@@ -703,6 +727,28 @@ class AutoCommentManager {
|
||||
}
|
||||
}
|
||||
|
||||
// 机器码展示(未授权时显示在卡密输入框下方,可一键复制)
|
||||
async renderMachineCode(show) {
|
||||
const row = document.getElementById('machine-code-row');
|
||||
const text = document.getElementById('machine-code-text');
|
||||
if (!row || !text) return;
|
||||
if (!show) {
|
||||
row.hidden = true;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { deviceId } = await chrome.storage.local.get(['deviceId']);
|
||||
if (!deviceId) {
|
||||
row.hidden = true;
|
||||
return;
|
||||
}
|
||||
text.textContent = deviceId;
|
||||
row.hidden = false;
|
||||
} catch (error) {
|
||||
row.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 试用倒计时(精确到秒,每秒刷新)
|
||||
startTrialCountdown(endAt, status) {
|
||||
this.stopTrialCountdown();
|
||||
|
||||
Reference in new issue
Block a user