zhibo/Zhibo/admin/batch-create-pages.js

168 lines
5.8 KiB
JavaScript
Raw Permalink Normal View History

2025-12-21 16:08:52 +08:00
// 批量创建页面脚本 - Node.js版本
const fs = require('fs');
const path = require('path');
const modules = [
{path:'dynamic', name:'动态管理', component:'DynamicManage'},
{path:'blacklist', name:'黑名单管理', component:'BlacklistManage'},
{path:'certification', name:'认证管理', component:'CertificationManage'},
{path:'charm', name:'魅力值管理', component:'CharmManage'},
{path:'member', name:'会员管理', component:'MemberManage'},
{path:'withdraw', name:'提现管理', component:'WithdrawManage'},
{path:'appeal', name:'申诉管理', component:'AppealManage'},
{path:'banner', name:'轮播图管理', component:'BannerManage'},
{path:'comment', name:'评论管理', component:'CommentManage'},
{path:'newtask', name:'新手任务管理', component:'NewTaskManage'},
{path:'sensitive', name:'敏感词管理', component:'SensitiveManage'},
{path:'fans', name:'粉丝团管理', component:'FansManage'},
{path:'session', name:'会话管理', component:'SessionManage'},
{path:'detail', name:'明细管理', component:'DetailManage'},
{path:'mountpurchase', name:'购买坐骑管理', component:'MountPurchaseManage'},
{path:'version', name:'客户端版本管理', component:'VersionManage'},
{path:'giftreward', name:'礼物打赏管理', component:'GiftRewardManage'},
{path:'follow', name:'关注管理', component:'FollowManage'},
{path:'exchange', name:'兑换管理', component:'ExchangeManage'},
{path:'sysconfig', name:'配置管理', component:'SysConfigManage'}
];
const templateVue = (module) => `<template>
<div class="divBox">
<el-card shadow="never" class="ivu-mt">
<div class="padding-add">
<el-page-header @back="goBack" content="${module.name}"></el-page-header>
<div class="mt20">
<el-form inline size="small" :model="searchForm" class="mb20">
<el-form-item label="关键词:">
<el-input v-model="searchForm.keywords" placeholder="请输入关键词" clearable class="selWidth" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">搜索</el-button>
<el-button @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
<div class="mb20">
<el-button type="primary" size="small" @click="handleAdd">新增</el-button>
</div>
<el-table :data="tableData" v-loading="loading" border>
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="id" label="ID" width="80" align="center" />
<el-table-column prop="name" label="名称" min-width="120" />
<el-table-column label="状态" width="100" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.status ? 'success' : 'danger'">
{{ scope.row.status ? '启用' : '禁用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="200" align="center" fixed="right">
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleEdit(scope.row)">编辑</el-button>
<el-button type="text" size="small" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="acea-row row-right page mt20">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="searchForm.page"
:page-sizes="[10, 20, 50, 100]"
:page-size="searchForm.limit"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
></el-pagination>
</div>
</div>
</div>
</el-card>
</div>
</template>
<script>
export default {
name: '${module.component}',
data() {
return {
searchForm: { keywords: '', page: 1, limit: 20 },
tableData: [],
total: 0,
loading: false,
};
},
mounted() {
this.getList();
},
methods: {
getList() {
this.loading = true;
setTimeout(() => {
this.tableData = [];
this.total = 0;
this.loading = false;
}, 500);
},
handleSearch() {
this.searchForm.page = 1;
this.getList();
},
handleReset() {
this.searchForm = { keywords: '', page: 1, limit: 20 };
this.getList();
},
handleAdd() {
this.$message.info('新增功能待开发');
},
handleEdit(row) {
this.$message.info('编辑功能待开发');
},
handleDelete(row) {
this.$confirm('确定要删除吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
this.$message.success('删除成功');
this.getList();
}).catch(() => {});
},
handleSizeChange(val) {
this.searchForm.limit = val;
this.getList();
},
handleCurrentChange(val) {
this.searchForm.page = val;
this.getList();
},
goBack() {
this.$router.back();
},
},
};
</script>
<style scoped lang="scss">
.selWidth {
width: 200px;
}
</style>
`;
const baseDir = path.join(__dirname, 'src', 'views');
modules.forEach(module => {
const dirPath = path.join(baseDir, module.path);
const filePath = path.join(dirPath, 'index.vue');
// 创建目录
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true });
console.log(`✓ 创建目录: ${module.path}`);
}
// 创建Vue文件
fs.writeFileSync(filePath, templateVue(module), 'utf8');
console.log(`✓ 创建文件: ${module.path}/index.vue`);
});
console.log(`\n✅ 共创建 ${modules.length} 个模块页面!`);