fix: 首页和我的应用排序按 seq 排列

This commit is contained in:
2026-07-29 20:27:36 +08:00
parent 8c9613044c
commit ec6a5dd956
35 changed files with 18361 additions and 17013 deletions

View File

@@ -21,11 +21,33 @@ import {
} from '@/config/cache';
import Cache from '@/utils/cache';
/**
* 不依赖 atob 的 base64 解码(小程序环境不提供 atob)
*/
function base64Decode(str) {
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
var output = '';
var i = 0;
str = String(str).replace(/[^A-Za-z0-9+/=]/g, '');
while (i < str.length) {
var b1 = chars.indexOf(str.charAt(i++));
var b2 = chars.indexOf(str.charAt(i++));
var b3 = chars.indexOf(str.charAt(i++));
var b4 = chars.indexOf(str.charAt(i++));
output += String.fromCharCode((b1 << 2) | (b2 >> 4));
if (b3 !== 64) output += String.fromCharCode(((b2 & 15) << 4) | (b3 >> 2));
if (b4 !== 64) output += String.fromCharCode(((b3 & 3) << 6) | b4);
}
return output;
}
const state = {
token: Cache.get(LOGIN_STATUS) || false,
backgroundColor: "#fff",
userInfo: Cache.get(USER_INFO) || {},
uid: Cache.get(UID) || 0,
openid: Cache.get('OPENID') || '',
unionid: Cache.get('UNIONID') || '',
homeActive: false,
phoneStatus: true,
autoplay: Cache.get(NON_WIFI_AUTOPLAY) || false,
@@ -89,11 +111,46 @@ const mutations = {
LOGIN(state, opt) {
state.token = opt.token;
Cache.set(LOGIN_STATUS, opt.token, opt.time);
// 登录时自动提取 openid 缓存起来
if (opt.token) {
try {
let parts = opt.token.split('.');
if (parts.length !== 3) {
console.warn('[LOGIN] token 不是 JWT 格式,parts=' + parts.length);
} else {
let payload = parts[1]
.replace(/-/g, '+')
.replace(/_/g, '/');
while (payload.length % 4 !== 0) payload += '=';
const data = JSON.parse(base64Decode(payload));
if (data.openid) {
state.openid = data.openid;
Cache.set('OPENID', data.openid);
console.log('[LOGIN] openid 已缓存:', data.openid);
} else {
console.warn('[LOGIN] JWT payload 无 openid 字段:', JSON.stringify(data));
}
if (data.unionid) {
state.unionid = data.unionid;
Cache.set('UNIONID', data.unionid);
console.log('[LOGIN] unionid 已缓存:', data.unionid);
}
}
} catch (e) {
console.error('[LOGIN] JWT 解码失败:', e.message, 'token前20位:', opt.token.substring(0, 20));
}
}
},
SETUID(state, val) {
state.uid = val;
Cache.set(UID, val);
},
SET_OPENID(state, val) {
state.openid = val || '';
},
SET_UNIONID(state, val) {
state.unionid = val || '';
},
UPDATE_LOGIN(state, token) {
state.token = token;
},
@@ -102,8 +159,12 @@ const mutations = {
Cache.clear(UID);
Cache.clear(USER_INFO);
Cache.clear('newcomerGift');
Cache.clear('OPENID');
Cache.clear('UNIONID');
state.token = undefined;
state.uid = undefined
state.uid = undefined;
state.openid = '';
state.unionid = '';
state.userInfo = {}
},
BACKGROUND_COLOR(state, color) {