Signed-off-by: lizhouze <lizhouze@huawei.com>
This commit is contained in:
lizhouze
2022-05-31 15:32:30 +08:00
parent ea01a3c3a1
commit 70b2b4195e
3 changed files with 45 additions and 20 deletions
+10
View File
@@ -159,6 +159,7 @@ function setAbilityPages(projectConfig) {
const moduleJson = JSON.parse(fs.readFileSync(projectConfig.aceModuleJsonPath).toString());
abilityPages = readAbilityEntrance(moduleJson);
setAbilityFile(projectConfig, abilityPages);
setBundleModuleInfo(projectConfig, moduleJson);
}
}
@@ -194,6 +195,15 @@ function setStageTestRunnerFile(projectConfig) {
}
}
function setBundleModuleInfo(projectConfig, moduleJson) {
if (moduleJson.module) {
projectConfig.moduleName = moduleJson.module.name;
}
if (moduleJson.app) {
projectConfig.bundleName = moduleJson.app.bundleName;
}
}
function setAbilityFile(projectConfig, abilityPages) {
abilityPages.forEach(abilityPath => {
const projectAbilityPath = path.resolve(projectConfig.projectPath, '../', abilityPath);
+2
View File
@@ -162,6 +162,8 @@ export const RESOURCE_RAWFILE: string = '$rawfile';
export const RESOURCE_NAME_ID: string = 'id';
export const RESOURCE_NAME_TYPE: string = 'type';
export const RESOURCE_NAME_PARAMS: string = 'params';
export const RESOURCE_NAME_BUNDLE: string = 'bundle';
export const RESOURCE_NAME_MODULE: string = 'mdoule';
export const RESOURCE_TYPE = {
color: 10001,
float: 10002,
+33 -20
View File
@@ -33,6 +33,8 @@ import {
RESOURCE_NAME_TYPE,
RESOURCE_NAME_PARAMS,
RESOURCE_RAWFILE,
RESOURCE_NAME_BUNDLE,
RESOURCE_NAME_MODULE,
ATTRIBUTE_ANIMATETO,
GLOBAL_CONTEXT,
CHECK_COMPONENT_EXTEND_DECORATOR,
@@ -65,7 +67,7 @@ import {
localStorageLinkCollection,
localStoragePropCollection
} from './validate_ui_syntax';
import { resources } from '../main';
import { projectConfig, resources } from '../main';
import { createCustomComponentNewExpression, createViewCreate } from './process_component_member';
export const transformLog: FileLog = new FileLog();
@@ -293,26 +295,37 @@ function processResourceData(node: ts.CallExpression): ts.Node {
function createResourceParam(resourceValue: number, resourceType: number, argsArr: ts.Expression[]):
ts.ObjectLiteralExpression {
const propertyArray: Array[ts.PropertyAssignment] = [
ts.factory.createPropertyAssignment(
ts.factory.createStringLiteral(RESOURCE_NAME_ID),
ts.factory.createNumericLiteral(resourceValue)
),
ts.factory.createPropertyAssignment(
ts.factory.createStringLiteral(RESOURCE_NAME_TYPE),
ts.factory.createNumericLiteral(resourceType)
),
ts.factory.createPropertyAssignment(
ts.factory.createIdentifier(RESOURCE_NAME_PARAMS),
ts.factory.createArrayLiteralExpression(argsArr, false)
)
];
if (projectConfig.bundleName) {
propertyArray.push(ts.factory.createPropertyAssignment(
ts.factory.createStringLiteral(RESOURCE_NAME_BUNDLE),
ts.factory.createStringLiteral(projectConfig.bundleName)
));
}
if (projectConfig.moduleName) {
propertyArray.push(ts.factory.createPropertyAssignment(
ts.factory.createStringLiteral(RESOURCE_NAME_MODULE),
ts.factory.createStringLiteral(projectConfig.moduleName)
));
}
const resourceParams: ts.ObjectLiteralExpression = ts.factory.createObjectLiteralExpression(
[
ts.factory.createPropertyAssignment(
ts.factory.createStringLiteral(RESOURCE_NAME_ID),
ts.factory.createNumericLiteral(resourceValue)
),
ts.factory.createPropertyAssignment(
ts.factory.createStringLiteral(RESOURCE_NAME_TYPE),
ts.factory.createNumericLiteral(resourceType)
),
ts.factory.createPropertyAssignment(
ts.factory.createIdentifier(RESOURCE_NAME_PARAMS),
ts.factory.createArrayLiteralExpression(
argsArr,
false
)
)
],
false
);
propertyArray, false);
return resourceParams;
}