feat(license): 在线授权前端与上报优化

- 替换离线授权二次确认:仅当离线为真实付费(people>3)且 sn/mac 匹配本机时才提示
- 上报 url 改用真实外网地址(RequestContext::replaceBaseUrl)、version 改用应用版本(Base::getVersion)
- trialSend 携带实例指纹,便于 appstore 发码前做试用资格校验

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
kuaifan 2026-06-22 15:52:01 +00:00
parent 4ca7fc10d1
commit 389cb6d709
2 changed files with 24 additions and 5 deletions

View File

@ -3,6 +3,7 @@
namespace App\Module;
use App\Exceptions\ApiException;
use App\Services\RequestContext;
use Carbon\Carbon;
use Illuminate\Support\Facades\Crypt;
@ -83,8 +84,10 @@ class OnlineLicense
return [
'sn' => Doo::dooSN(),
'macs' => implode(',', Doo::macs()),
'url' => (string)config('app.url'),
'version' => Doo::dooVersion(),
// 优先真实外网地址config('app.url') 若为 localhost 由 replaceBaseUrl 替换为缓存的访问地址
'url' => RequestContext::replaceBaseUrl((string)config('app.url')),
// DooTask 应用版本(非 doo.so 库版本)
'version' => Base::getVersion(),
];
}
@ -171,7 +174,8 @@ class OnlineLicense
*/
public static function trialSend(string $account, string $password): string
{
$r = self::call('trial/send', ['account' => $account, 'password' => $password]);
// 带上实例指纹sn/macs让 appstore 在发送验证码前即可做试用资格校验
$r = self::call('trial/send', array_merge(['account' => $account, 'password' => $password], self::fingerprint()));
if (!$r['ok']) {
throw new ApiException($r['message']);
}

View File

@ -248,6 +248,21 @@ export default {
offlineBound() {
return !this.onlineActive && !!String(this.formData.license || '').trim();
},
// 线线
// 线 license
// / 3 people 1~3 sn/mac
offlineReplaceNeedConfirm() {
if (!this.offlineBound) {
return false;
}
const info = this.formData.info || {};
const people = parseInt(info.people) || 0;
const isTrialThree = people >= 1 && people <= 3;
const snOk = this.existIntersection(this.formData.doo_sn, info.sn);
const macOk = this.existIntersection(this.formData.macs, info.mac);
return !isTrialThree && snOk && macOk;
},
},
methods: {
submitForm() {
@ -390,9 +405,9 @@ export default {
});
},
// 线线
// 线线线
confirmReplaceOffline(onOk) {
if (this.offlineBound) {
if (this.offlineReplaceNeedConfirm) {
$A.modalConfirm({
title: '绑定在线授权',
content: '当前已绑定离线授权,绑定在线后将替换当前授权,是否继续?',