zhibo/Zhibo/admin/create-views.ps1

187 lines
7.2 KiB
PowerShell
Raw Normal View History

2025-12-21 16:08:52 +08:00
# 批量创建前端页面脚本
# PowerShell脚本 - 为新增菜单创建基础Vue页面
$modules = @(
@{path="giftnum"; name="礼物数量管理"; component="GiftNumManage"},
@{path="interact"; name="互动管理"; component="InteractManage"},
@{path="task"; name="任务管理"; component="TaskManage"},
@{path="help"; name="帮助中心"; component="HelpCenter"},
@{path="activity"; name="平台活动管理"; component="ActivityManage"},
@{path="lottery"; name="抽奖管理"; component="LotteryManage"},
@{path="headwear"; name="头饰管理"; component="HeadwearManage"},
@{path="mount"; name="坐骑管理"; component="MountManage"},
@{path="report"; name="举报反馈管理"; component="ReportManage"},
@{path="invite"; name="邀请管理"; component="InviteManage"},
@{path="family"; name="家族管理"; component="FamilyManage"},
@{path="couple"; name="夫妻相管理"; component="CoupleManage"},
@{path="agent"; name="代理管理"; component="AgentManage"},
@{path="chatpay"; name="聊天付费配置"; component="ChatPayConfig"},
@{path="coinexchange"; name="金币兑换钻石配置"; component="CoinExchangeConfig"},
@{path="chatphrase"; name="聊天常用语"; component="ChatPhraseManage"},
@{path="noble"; name="贵族等级管理"; component="NobleManage"},
@{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"}
)
$baseDir = ".\src\views"
foreach ($module in $modules) {
$dirPath = Join-Path $baseDir $module.path
$filePath = Join-Path $dirPath "index.vue"
# 创建目录
if (!(Test-Path $dirPath)) {
New-Item -ItemType Directory -Path $dirPath -Force | Out-Null
Write-Host "创建目录: $dirPath" -ForegroundColor Green
}
# 创建Vue文件
$content = @"
<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;
// TODO: 调用API接口
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>
"@
$content | Out-File -FilePath $filePath -Encoding UTF8
Write-Host "创建文件: $filePath" -ForegroundColor Cyan
}
Write-Host "`n所有页面创建完成!" -ForegroundColor Yellow
Write-Host "共创建 $($modules.Count) 个模块页面" -ForegroundColor Yellow