添加登录功能

This commit is contained in:
zpx committed 2026-11-20 15:13:11 +08:00
commit a3f61a29d0
120 files changed
+3974

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import { _decorator, Button, Component, Label, sys } from 'cc';
const { ccclass, property } = _decorator;
/** 法律链接单独绑定,不混入认证服务;缺地址时显示真实状态。 / Bind legal links separately from authentication and report missing URLs honestly. */
@ccclass('GuestLegalLinks')
export class GuestLegalLinks extends Component {
@property({ type: Button }) privacyButton: Button | null = null;
@property({ type: Button }) termsButton: Button | null = null;
@property({ type: Label }) notice: Label | null = null;
@property privacyUrl = '';
@property termsUrl = '';
onLoad(): void {
this.privacyButton?.node.on(Button.EventType.CLICK, this.openPrivacy, this);
this.termsButton?.node.on(Button.EventType.CLICK, this.openTerms, this);
}
private openPrivacy(): void { this.open(this.privacyUrl, 'Privacy policy is not available yet.'); }
private openTerms(): void { this.open(this.termsUrl, 'Terms of service are not available yet.'); }
private open(url: string, unavailable: string): void {
if (/^https:\/\/[^\s]+$/i.test(url)) { sys.openURL(url); return; }
// 未配置不伪造页面,也不启动登录或覆盖游客会话。 / Never invent a page, trigger login or overwrite the guest session when unconfigured.
if (this.notice) { this.notice.string = unavailable; this.notice.node.active = true; }
}
onDestroy(): void {
if (this.privacyButton?.isValid) this.privacyButton.node.off(Button.EventType.CLICK, this.openPrivacy, this);
if (this.termsButton?.isValid) this.termsButton.node.off(Button.EventType.CLICK, this.openTerms, this);
}
}