bug修复

这个提交包含在:
徐勤民 2024-09-24 17:52:59 +08:00
父节点 9887a552c4
当前提交 b0a8f124eb
共有 4 个文件被更改,包括 37 次插入10 次删除

查看文件

@ -2,8 +2,8 @@
* Use these variables when you tailor your ArkTS code. They must be of the const type. * Use these variables when you tailor your ArkTS code. They must be of the const type.
*/ */
export const HAR_VERSION = '1.0.2'; export const HAR_VERSION = '1.0.2';
export const BUILD_MODE_NAME = 'release'; export const BUILD_MODE_NAME = 'debug';
export const DEBUG = false; export const DEBUG = true;
export const TARGET_NAME = 'default'; export const TARGET_NAME = 'default';
/** /**

查看文件

@ -74,9 +74,9 @@ export class HttpHelper {
// "Accept": "application/json", // "Accept": "application/json",
...params.headers ...params.headers
} }
console.log('>>>>>', 'POST:', params.url)
// console.log('>>>>>', '接口请求', JSON.stringify(header)) // console.log('>>>>>', '接口请求', JSON.stringify(header))
// console.log('>>>>>', '接口请求', data) // console.log('>>>>>', '接口请求', data)
console.log('>>>>>', 'POST:', params.url)
httpRequest.request(this.getUrl(params.url, params.query), { httpRequest.request(this.getUrl(params.url, params.query), {
method: http.RequestMethod.POST, method: http.RequestMethod.POST,

查看文件

@ -3,20 +3,33 @@
*/ */
export class AppStorageHelper { export class AppStorageHelper {
/** /**
* 缓存string * 缓存
* @param key * @param key
* @param value * @param value
*/ */
public static save<T>(key: string, value: T|undefined) { public static save<T>(key: string, value: T | undefined) {
PersistentStorage.persistProp(key, value) if (!value) {
PersistentStorage.deleteProp(key)
} else {
PersistentStorage.persistProp(key, value)
}
} }
/** /**
* 获取已缓存的string * 删除缓存
* @param key
* @param value
*/
public static delete(key: string) {
PersistentStorage.deleteProp(key)
}
/**
* 获取已缓存的内容
* @param key * @param key
* @returns * @returns
*/ */
public static get<T>(key: string):T|undefined { public static get<T>(key: string): T | undefined {
return AppStorage.get<T>(key) return AppStorage.get<T>(key)
} }
} }

查看文件

@ -1,11 +1,15 @@
import preferences from '@ohos.data.preferences'; import preferences from '@ohos.data.preferences';
export class PreferencesHelper { export class PreferencesHelper {
public static async put(key: string, value: preferences.ValueType|undefined) { public static async put(key: string, value: preferences.ValueType | undefined) {
const pref = await preferences.getPreferences(getContext(), 'PreferencesHelper') const pref = await preferences.getPreferences(getContext(), 'PreferencesHelper')
// 写入数据 // 写入数据
await pref.put(key, value) if (value) {
await pref.put(key, value)
} else {
await pref.delete(key)
}
// 刷盘 // 刷盘
await pref.flush() await pref.flush()
} }
@ -20,4 +24,14 @@ export class PreferencesHelper {
}) })
} }
public static async delete(key: string): Promise<void> {
return new Promise(async (resolve, reject) => {
const pref = await preferences.getPreferences(getContext(), 'PreferencesHelper')
pref.delete(key).then(() => {
resolve()
})
})
}
} }