048f25f580
Show privacy popup on launch, gate login on legal consent, and link user agreement and privacy policy pages in the mini program. Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
928 B
JavaScript
45 lines
928 B
JavaScript
const CONSENT_KEY = 'tkmind_legal_consent';
|
|
const CONSENT_VERSION = '1.0';
|
|
|
|
function getStoredConsent() {
|
|
try {
|
|
const stored = wx.getStorageSync(CONSENT_KEY);
|
|
if (stored && typeof stored === 'object') {
|
|
return stored;
|
|
}
|
|
} catch {
|
|
// Ignore storage read errors.
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function hasAcceptedLegalConsent() {
|
|
const stored = getStoredConsent();
|
|
return stored?.accepted === true && stored?.version === CONSENT_VERSION;
|
|
}
|
|
|
|
function saveLegalConsent() {
|
|
wx.setStorageSync(CONSENT_KEY, {
|
|
accepted: true,
|
|
version: CONSENT_VERSION,
|
|
acceptedAt: new Date().toISOString(),
|
|
});
|
|
}
|
|
|
|
function clearLegalConsent() {
|
|
wx.removeStorageSync(CONSENT_KEY);
|
|
}
|
|
|
|
function shouldSkipLoginConsent() {
|
|
return hasAcceptedLegalConsent();
|
|
}
|
|
|
|
module.exports = {
|
|
CONSENT_VERSION,
|
|
getStoredConsent,
|
|
hasAcceptedLegalConsent,
|
|
saveLegalConsent,
|
|
clearLegalConsent,
|
|
shouldSkipLoginConsent,
|
|
};
|