APP文件新增

This commit is contained in:
geht
2026-07-20 14:10:39 +08:00
parent 99987d9d2e
commit 395a52b4c6
710 changed files with 227084 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import fs from 'fs-extra'
import path from 'path'
export function copyNativeRes() {
const waitPath = path.resolve(__dirname, '../src/nativeResources')
const buildPath = path.resolve(
__dirname,
'../dist',
process.env.NODE_ENV === 'production' ? 'build' : 'dev',
process.env.UNI_PLATFORM!,
'nativeResources',
)
return {
enforce: 'post',
async writeBundle() {
try {
// 检查源目录是否存在
const sourceExists = await fs.pathExists(waitPath)
if (!sourceExists) {
console.warn(`[copyNativeRes] 警告:源目录 "${waitPath}" 不存在,跳过复制操作。`)
return
}
// 确保目标目录及中间目录存在
await fs.ensureDir(buildPath)
console.log(`[copyNativeRes] 确保目标目录存在:${buildPath}`)
// 执行文件夹复制
await fs.copy(waitPath, buildPath)
console.log(
`[copyNativeRes] 成功将 nativeResources 目录中的资源移动到构建目录:${buildPath}`,
)
} catch (error) {
console.error(`[copyNativeRes] 复制资源失败:`, error)
}
},
}
}

View File

@@ -0,0 +1,42 @@
import { Plugin } from 'vite'
import fs from 'node:fs'
import path from 'node:path'
export function generateComponentTypes(): Plugin {
return {
name: 'generate-component-types',
async buildStart() {
const componentsDir = path.resolve(process.cwd(), 'src/components')
const dtsPath = path.resolve(process.cwd(), 'src/components/components.d.ts')
// Get immediate subdirectories only
const directories = fs
.readdirSync(componentsDir, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
// Generate type definitions only for valid components
const typeDefinitions = directories
.filter((dir) => {
// Check if ComponentName/ComponentName.vue exists
const componentFile = path.join(componentsDir, dir, `${dir}.vue`)
return fs.existsSync(componentFile)
})
.map((dir) => {
return `${dir}: typeof import('./${dir}/${dir}.vue')['default']`
})
// Create the type definition file content
const content = `declare module 'vue' {
export interface GlobalComponents {
${typeDefinitions.join('\n')}
}
}
export {}`
// Write the type definition file
fs.writeFileSync(dtsPath, content, 'utf-8')
},
}
}