2024-12-19 16:01:45 +08:00
|
|
|
import { getStorageUni, removeStorageUni, setStorageUni } from './uni/storage'
|
|
|
|
|
import { getStorageWeb, removeStorageWeb, setStorageWeb } from './web/storage'
|
2024-12-19 17:34:15 +08:00
|
|
|
import requestUni from './uni/request'
|
|
|
|
|
import requestWeb from './web/request'
|
2024-12-19 16:01:45 +08:00
|
|
|
import starCloudInstance from './star-cloud'
|
2024-12-20 19:04:23 +08:00
|
|
|
import { uniBuildNumber, uniVersion, webBuildNumber, webVersion } from './env'
|
2024-12-19 16:01:45 +08:00
|
|
|
|
|
|
|
|
export const setStorage = (key, value) => {
|
2024-12-19 17:40:59 +08:00
|
|
|
if (starCloudInstance.platform === 1) {
|
2024-12-20 17:36:14 +08:00
|
|
|
return setStorageUni(key, value)
|
|
|
|
|
}
|
|
|
|
|
if (starCloudInstance.platform === 2) {
|
|
|
|
|
return setStorageWeb(key, value)
|
2024-12-19 16:01:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getStorage = key => {
|
2024-12-19 17:40:59 +08:00
|
|
|
if (starCloudInstance.platform === 1) {
|
2024-12-20 17:36:14 +08:00
|
|
|
return getStorageUni(key)
|
2024-12-19 17:40:59 +08:00
|
|
|
}
|
2024-12-19 16:01:45 +08:00
|
|
|
if (starCloudInstance.platform === 2) {
|
2024-12-20 17:36:14 +08:00
|
|
|
return getStorageWeb(key)
|
2024-12-19 16:01:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const removeStorage = key => {
|
2024-12-19 17:40:59 +08:00
|
|
|
if (starCloudInstance.platform === 1) {
|
2024-12-20 17:36:14 +08:00
|
|
|
return removeStorageUni(key)
|
2024-12-19 17:40:59 +08:00
|
|
|
}
|
2024-12-19 16:01:45 +08:00
|
|
|
if (starCloudInstance.platform === 2) {
|
2024-12-20 17:36:14 +08:00
|
|
|
return removeStorageWeb(key)
|
2024-12-19 16:01:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const request = async params => {
|
2024-12-19 17:40:59 +08:00
|
|
|
if (starCloudInstance.platform === 1) {
|
|
|
|
|
return await requestUni(params)
|
|
|
|
|
}
|
2024-12-19 16:01:45 +08:00
|
|
|
if (starCloudInstance.platform === 2) {
|
|
|
|
|
return await requestWeb(params)
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-20 19:04:23 +08:00
|
|
|
|
|
|
|
|
export const version = () => {
|
|
|
|
|
if (starCloudInstance.platform === 1) {
|
|
|
|
|
return uniVersion
|
|
|
|
|
}
|
|
|
|
|
if (starCloudInstance.platform === 2) {
|
|
|
|
|
return webVersion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const buildNumber = () => {
|
|
|
|
|
if (starCloudInstance.platform === 1) {
|
|
|
|
|
return uniBuildNumber
|
|
|
|
|
}
|
|
|
|
|
if (starCloudInstance.platform === 2) {
|
|
|
|
|
return webBuildNumber
|
|
|
|
|
}
|
|
|
|
|
}
|