From 5c8ea8a26b48cb81bfae628c5ecd2e5e1eedd490 Mon Sep 17 00:00:00 2001 From: liugang9704 <2745340733@qq.com> Date: Wed, 10 Sep 2025 16:30:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=90=8C=E6=BA=90?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PackageStructureKit/hvigorfile.ts | 50 +++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/PackageStructureKit/hvigorfile.ts b/PackageStructureKit/hvigorfile.ts index f3cb9f1a..e1edb358 100644 --- a/PackageStructureKit/hvigorfile.ts +++ b/PackageStructureKit/hvigorfile.ts @@ -1,6 +1,50 @@ -import { appTasks } from '@ohos/hvigor-ohos-plugin'; +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// [Start hvigorfile] +import { hapTasks, OhosPluginId } from '@ohos/hvigor-ohos-plugin'; +import { hapPlugin } from '@hadss/hmrouter-plugin'; +import { hvigor } from '@ohos/hivgor'; +import fs from 'fs'; +import path from 'path'; + +// Callback function after node evaluation +hvigor.afterNodeEvaluate((hvigorNode) => { + // Ensure this directory exists + const resourcesDir = path.join(__dirname, 'src/main/resources/rawfile'); + if (!fs.existsSync(resourcesDir)) { + fs.mkdirSync(resourcesDir, { recursive: true }); + } + + // Write the build time into the JSON file + const now = new Date(); + const buildTime = now.getFullYear() + '-' + + String(now.getMonth() + 1).padStart(2, '0') + '-' + + String(now.getDate()).padStart(2, '0') + '' + + String(now.getHours()).padStart(2, '0') + ':' + + String(now.getMinutes()).padStart(2, '0') + ':' + + String(now.getSeconds()).padStart(2, '0'); + const buildInfo = { 'buildTime': buildTime }; + fs.writeFileSync( + path.join(resourceDir, 'build_info.json'), + JSON.stringify(buildInfo, null, 2) + ); +}) export default { - system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ - plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [hapPlugin()] /* Custom plugin to extend the functionality of Hvigor. */ } +// [End hvigorfile] \ No newline at end of file -- Gitee