-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15590 from handsomeliuyang/main
Harmony-hybird的request的实现优化,request的h5版本复用taro-h5的实现,同时通过接口参数,业务可以灵活选择实现机制
- Loading branch information
Showing
12 changed files
with
477 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/taro-platform-harmony-hybrid/src/api/apis/base/debug/getLogManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Taro from '@tarojs/api' | ||
|
||
/** | ||
* 获取日志管理器对象 | ||
* | ||
* @canUse getLogManager | ||
* @null_implementation | ||
*/ | ||
export const getLogManager: typeof Taro.getLogManager = () => { | ||
return new LogManager() | ||
} | ||
|
||
/** | ||
* 日志管理器 | ||
* | ||
* @canUse LogManager | ||
* @null_implementation | ||
*/ | ||
class LogManager implements Taro.LogManager { | ||
debug (): void { | ||
|
||
} | ||
|
||
info (): void { | ||
|
||
} | ||
|
||
log (): void { | ||
|
||
} | ||
|
||
warn (): void { | ||
|
||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
packages/taro-platform-harmony-hybrid/src/api/apis/base/debug/getRealtimeLogManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import Taro from '@tarojs/api' | ||
|
||
/** | ||
* 获取实时日志管理器对象 | ||
* | ||
* @canUse getRealtimeLogManager | ||
* @null_implementation | ||
*/ | ||
export const getRealtimeLogManager: typeof Taro.getRealtimeLogManager = () => { | ||
return new RealtimeLogManager() | ||
} | ||
|
||
/** | ||
* 实时日志管理器 | ||
* | ||
* @canUse RealtimeLogManager | ||
* @null_implementation | ||
*/ | ||
class RealtimeLogManager implements Taro.RealtimeLogManager { | ||
addFilterMsg (): void { | ||
|
||
} | ||
|
||
error (): void { | ||
|
||
} | ||
|
||
in (): void { | ||
|
||
} | ||
|
||
info (): void { | ||
|
||
} | ||
|
||
setFilterMsg (): void { | ||
|
||
} | ||
|
||
tag (tagName: string): RealtimeTagLogManager { | ||
return new RealtimeTagLogManager(tagName) | ||
} | ||
|
||
warn (): void { | ||
|
||
} | ||
} | ||
|
||
/** | ||
* 给定标签的实时日志管理器 | ||
* | ||
* @canUse RealtimeTagLogManager | ||
* @null_implementation | ||
*/ | ||
class RealtimeTagLogManager implements Taro.RealtimeTagLogManager { | ||
_tagName: string | ||
|
||
constructor (tagName: string) { | ||
this._tagName = tagName | ||
} | ||
|
||
addFilterMsg (_msg): void { | ||
|
||
} | ||
|
||
error (_key, _value): void { | ||
|
||
} | ||
|
||
info (_key, _value): void { | ||
|
||
} | ||
|
||
setFilterMsg (_msg): void { | ||
|
||
} | ||
|
||
warn (_key, _value): void { | ||
|
||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/taro-platform-harmony-hybrid/src/api/apis/base/debug/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 设置是否打开调试开关 | ||
export * from './setEnableDebug' | ||
|
||
// 获取实时日志管理器对象 | ||
export * from './getRealtimeLogManager' | ||
|
||
// 获取日志管理器对象 | ||
export * from './getLogManager' | ||
|
||
/** | ||
* 向调试面板中打印日志。console 是一个全局对象,可以直接访问。 | ||
* | ||
* @canUse console | ||
* @__class [debug, error, group, groupEnd, info, log, warn] | ||
*/ |
37 changes: 37 additions & 0 deletions
37
packages/taro-platform-harmony-hybrid/src/api/apis/base/debug/setEnableDebug.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Taro from '@tarojs/api' | ||
|
||
import { shouldBeObject } from '../../utils' | ||
import { MethodHandler } from '../../utils/handler' | ||
|
||
/** | ||
* 设置是否打开调试开关 | ||
* | ||
* @canUse setEnableDebug | ||
* @null_implementation | ||
*/ | ||
export const setEnableDebug: typeof Taro.setEnableDebug = (options) => { | ||
const name = 'setEnableDebug' | ||
|
||
return new Promise((resolve, reject) => { | ||
// options must be an Object | ||
const isObject = shouldBeObject(options) | ||
if (!isObject.flag) { | ||
const res = { errMsg: `${name}:fail ${isObject.msg}` } | ||
console.error(res.errMsg) | ||
return reject(res) | ||
} | ||
const { success, fail, complete } = options as Exclude<typeof options, undefined> | ||
const handle = new MethodHandler<{ | ||
errMsg?: string | ||
}>({ name, success, fail, complete }) | ||
try { | ||
handle.success({ | ||
errMsg: 'ok' | ||
}, { resolve, reject }) | ||
} catch (error) { | ||
handle.fail({ | ||
errMsg: 'fail' | ||
}, { resolve, reject }) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.