mirror of
https://github.com/vastxie/99AI.git
synced 2025-11-13 20:23:43 +08:00
v4.3.0
This commit is contained in:
22
admin/plop-templates/page/index.hbs
Executable file
22
admin/plop-templates/page/index.hbs
Executable file
@@ -0,0 +1,22 @@
|
||||
{{#if isFilesystem}}
|
||||
<route lang="yaml">
|
||||
meta:
|
||||
title: 页面标题
|
||||
</route>
|
||||
|
||||
{{/if}}
|
||||
<script setup lang="ts">
|
||||
defineOptions({
|
||||
name: '{{ properCase componentName }}',
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- 布局 -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
// 样式
|
||||
</style>
|
||||
60
admin/plop-templates/page/prompt.js
Executable file
60
admin/plop-templates/page/prompt.js
Executable file
@@ -0,0 +1,60 @@
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
|
||||
function getFolder(path) {
|
||||
const components = []
|
||||
const files = fs.readdirSync(path)
|
||||
files.forEach((item) => {
|
||||
const stat = fs.lstatSync(`${path}/${item}`)
|
||||
if (stat.isDirectory() === true && item !== 'components') {
|
||||
components.push(`${path}/${item}`)
|
||||
components.push(...getFolder(`${path}/${item}`))
|
||||
}
|
||||
})
|
||||
return components
|
||||
}
|
||||
|
||||
export default {
|
||||
description: '创建页面',
|
||||
prompts: [
|
||||
{
|
||||
type: 'list',
|
||||
name: 'path',
|
||||
message: '请选择页面创建目录',
|
||||
choices: getFolder('src/views'),
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: '请输入文件名',
|
||||
validate: (v) => {
|
||||
if (!v || v.trim === '') {
|
||||
return '文件名不能为空'
|
||||
}
|
||||
else {
|
||||
return true
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'isFilesystem',
|
||||
message: '是否为基于文件系统的路由页面',
|
||||
default: false,
|
||||
},
|
||||
],
|
||||
actions: (data) => {
|
||||
const relativePath = path.relative('src/views', data.path)
|
||||
const actions = [
|
||||
{
|
||||
type: 'add',
|
||||
path: `${data.path}/{{dotCase name}}.vue`,
|
||||
templateFile: 'plop-templates/page/index.hbs',
|
||||
data: {
|
||||
componentName: `${relativePath} ${data.name}`,
|
||||
},
|
||||
},
|
||||
]
|
||||
return actions
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user