mirror of
https://github.com/openharmony/tools_previewer.git
synced 2026-07-19 22:33:34 -04:00
!146 去除多余的被mock的函数
Merge pull request !146 from 程顺/cherry-pick-1694771014
This commit is contained in:
@@ -27,6 +27,9 @@ import { getCallbackStatement, getReturnStatement } from './generateCommonUtil';
|
||||
* @returns
|
||||
*/
|
||||
export function generateExportFunction(functionEntity: FunctionEntity, sourceFile: SourceFile, mockApi: string): string {
|
||||
if (functionEntity.functionName !== 'getContext') {
|
||||
return '';
|
||||
}
|
||||
let functionBody = '';
|
||||
functionBody = `global.${functionEntity.functionName} = function (...args) {`;
|
||||
functionBody += `console.warn('The ${functionEntity.functionName} interface in the Previewer is a mocked implementation and may behave differently than on a real device.');\n`;
|
||||
|
||||
@@ -78,7 +78,11 @@ export function generateInterfaceDeclaration(rootName: string, interfaceEntity:
|
||||
|
||||
interfaceBody += '}\n';
|
||||
if (interfaceEntity.exportModifiers.includes(SyntaxKind.DeclareKeyword)) {
|
||||
interfaceBody += `global.${interfaceName} = ${interfaceName};\n`;
|
||||
interfaceBody += `
|
||||
if (!global.${interfaceName}) {
|
||||
global.${interfaceName} = ${interfaceName};\n
|
||||
}
|
||||
`;
|
||||
}
|
||||
return interfaceBody;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user