refactor(license): 统一离线授权判断并优化在线绑定交互

- 在线/离线 Tab 套用 setting-component-item,提交按钮固定到底部,与其它设置子页一致
- 抽出 offlineValid 统一「有效离线授权」口径(非试用、sn/mac 匹配本机),用于默认 Tab 切换与替换确认,替代原先仅判断 license 非空的宽松逻辑
- 将替换有效离线授权的二次确认前置到发送验证码(流程起点),登录/试用不再重复确认
- 邮箱输入沿用 setting/email 的内联发送按钮样式

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
kuaifan 2026-06-23 11:20:37 +00:00
parent 889aca311a
commit bc8a2c9ded

View File

@ -334,16 +334,14 @@ export default {
return 'license-online-cache::' + (typeof window !== 'undefined' ? window.location.host : '');
},
// 线 = license 线
offlineBound() {
return !this.onlineActive && !!String(this.formData.license || '').trim();
},
// 线线
// 线 license
// / 3 people 1~3 sn/mac
offlineReplaceNeedConfirm() {
if (!this.offlineBound) {
// 线线 license
// / 3 people 1~3 sn/mac
// 线 Tab线线
offlineValid() {
if (this.onlineActive) {
return false;
}
if (!String(this.formData.license || '').trim()) {
return false;
}
const info = this.formData.info || {};
@ -416,12 +414,12 @@ export default {
this.formData = data;
this.formData_bak = $A.cloneJSON(this.formData);
this.writeOnlineCache(data.online); // 线
// Tab线 线线线 线 线线
// Tab线 线线线 线 线线
if (!this.tabInited) {
this.tabInited = true;
if (data.online && data.online.mode === 'online') {
this.mode = 'online';
} else if (String(data.license || '').trim()) {
} else if (this.offlineValid) {
this.mode = 'offline';
}
}
@ -538,7 +536,7 @@ export default {
// 线线线
confirmReplaceOffline(onOk) {
if (this.offlineReplaceNeedConfirm) {
if (this.offlineValid) {
$A.modalConfirm({
title: '绑定在线授权',
content: '当前已绑定离线授权,绑定在线后将替换当前授权,是否继续?',
@ -549,7 +547,8 @@ export default {
}
},
// 60s
// 60s
// 线线
emailSend() {
if (this.codeCountdown > 0) {
return;
@ -558,66 +557,66 @@ export default {
$A.messageError('请输入邮箱');
return;
}
// 仿 setting/emailsearch + spinner loading
this.$store.dispatch("call", {
url: 'license/email/send',
data: {email: this.onlineForm.email},
method: 'post',
spinner: true,
}).then(({data}) => {
this.codeSent = true;
this.maskedEmail = data?.email || '';
this.startCodeCountdown();
}).catch(({msg}) => {
$A.messageError(msg);
this.confirmReplaceOffline(() => {
// 仿 setting/emailsearch + spinner loading
this.$store.dispatch("call", {
url: 'license/email/send',
data: {email: this.onlineForm.email},
method: 'post',
spinner: true,
}).then(({data}) => {
this.codeSent = true;
this.maskedEmail = data?.email || '';
this.startCodeCountdown();
}).catch(({msg}) => {
$A.messageError(msg);
});
});
},
// 线emailSend
onlineLogin() {
if (!this.onlineForm.email || !this.onlineForm.code) {
$A.messageError('请输入邮箱和验证码');
return;
}
this.confirmReplaceOffline(() => {
this.onlineAction = 'login';
this.onlineCall('license/login', {
email: this.onlineForm.email,
code: this.onlineForm.code,
}, '授权成功').then(_ => {
this.resetOnlineForm();
this.systemSetting();
}).catch(() => {
//
//
this.onlineForm.code = '';
this.clearCodeTimer();
}).finally(() => {
this.onlineAction = '';
});
this.onlineAction = 'login';
this.onlineCall('license/login', {
email: this.onlineForm.email,
code: this.onlineForm.code,
}, '授权成功').then(_ => {
this.resetOnlineForm();
this.systemSetting();
}).catch(() => {
//
//
this.onlineForm.code = '';
this.clearCodeTimer();
}).finally(() => {
this.onlineAction = '';
});
},
// 线emailSend
trialSubmit() {
if (!this.onlineForm.email || !this.onlineForm.code) {
$A.messageError('请输入邮箱和验证码');
return;
}
this.confirmReplaceOffline(() => {
this.onlineAction = 'trial';
this.onlineCall('license/trial', {
email: this.onlineForm.email,
code: this.onlineForm.code,
}, '试用已开通').then(_ => {
this.resetOnlineForm();
this.systemSetting();
}).catch(() => {
//
//
this.onlineForm.code = '';
this.clearCodeTimer();
}).finally(() => {
this.onlineAction = '';
});
this.onlineAction = 'trial';
this.onlineCall('license/trial', {
email: this.onlineForm.email,
code: this.onlineForm.code,
}, '试用已开通').then(_ => {
this.resetOnlineForm();
this.systemSetting();
}).catch(() => {
//
//
this.onlineForm.code = '';
this.clearCodeTimer();
}).finally(() => {
this.onlineAction = '';
});
},