chore: initial import

This commit is contained in:
liangjian
2026-06-29 09:42:53 +08:00
commit 9fea127de1
241 changed files with 82767 additions and 0 deletions

47
utils/messages.js Normal file
View File

@@ -0,0 +1,47 @@
const MESSAGE_DETAIL_KEY = 'messageDetailPayload'
const MESSAGE_LIST_KEY = 'messageListSnapshot'
function normalizeLookupValue(value = '') {
return String(value || '').trim()
}
function getMessageStorageKey(baseKey, language = '') {
const normalizedLanguage = String(language || '').trim().toLowerCase() === 'en' ? 'en' : 'zh'
return `${baseKey}_${normalizedLanguage}`
}
export function saveMessageDetailPayload(payload = {}, language = '') {
uni.setStorageSync(getMessageStorageKey(MESSAGE_DETAIL_KEY, language), payload || {})
return payload || {}
}
export function getMessageDetailPayload(language = '') {
return uni.getStorageSync(getMessageStorageKey(MESSAGE_DETAIL_KEY, language)) || {}
}
export function saveMessageListSnapshot(list = [], language = '') {
const nextList = Array.isArray(list) ? list : []
uni.setStorageSync(getMessageStorageKey(MESSAGE_LIST_KEY, language), nextList)
return nextList
}
export function getMessageListSnapshot(language = '') {
const list = uni.getStorageSync(getMessageStorageKey(MESSAGE_LIST_KEY, language))
return Array.isArray(list) ? list : []
}
export function findMessageDetailPayload(id = '', code = '', language = '') {
const targetId = normalizeLookupValue(id)
const targetCode = normalizeLookupValue(code)
const list = getMessageListSnapshot(language)
return list.find(item => {
const currentId = normalizeLookupValue(item && item.id)
const currentCode = normalizeLookupValue(item && item.code)
return (targetId && currentId === targetId) || (targetCode && currentCode === targetCode)
}) || {}
}
export function clearMessageDetailPayload(language = '') {
uni.removeStorageSync(getMessageStorageKey(MESSAGE_DETAIL_KEY, language))
}