修復打包問題
This commit is contained in:
96
scripts/fix-stuunionleague.py
Normal file
96
scripts/fix-stuunionleague.py
Normal file
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""一次性修复 stuunionleague/index.vue 中所有乱码为正确中文"""
|
||||
path = 'src/views/stuwork/stuunionleague/index.vue'
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
s = f.read()
|
||||
|
||||
# 按上下文唯一性从长到短替换,避免短串误替换
|
||||
replacements = [
|
||||
# 模板 - 注释与标题
|
||||
('<!-- ?????? -->', '<!-- 搜索表单卡片 -->'),
|
||||
('<!-- ???? -->', '<!-- 内容卡片 -->'),
|
||||
('<!-- ?? -->', '<!-- 表格 -->'),
|
||||
('<!-- ?? -->', '<!-- 分页 -->'),
|
||||
('<!-- ??/?????? -->', '<!-- 新增/编辑表单弹窗 -->'),
|
||||
('<!-- ???? -->', '<!-- 导入弹窗 -->'),
|
||||
('??????', '学生团员列表'),
|
||||
('????', '筛选条件'),
|
||||
('将文件拖到此处,<em>点击上传</em>', '将文件拖到此处,<em>点击上传</em>'), # 已正确则不动
|
||||
('????????<em>????</em>', '将文件拖到此处,<em>点击上传</em>'),
|
||||
('???? xlsx/xls ??', '只能上传 xlsx/xls 文件'),
|
||||
# 表单项 label / placeholder
|
||||
('label="??" prop="classCode"', 'label="班级" prop="classCode"'),
|
||||
('placeholder="?????" \n clearable\n filterable', 'placeholder="请选择班级" \n clearable\n filterable'),
|
||||
('label="??" prop="classNo"', 'label="班号" prop="classNo"'),
|
||||
('placeholder="?????" \n clearable\n style="width: 200px" />', 'placeholder="请输入班号" \n clearable\n style="width: 200px" />'),
|
||||
('label="??" prop="realName"', 'label="姓名" prop="realName"'),
|
||||
('placeholder="?????" \n clearable\n style="width: 200px" />\n </el-form-item>\n <el-form-item label="????" prop="serNo"', 'placeholder="请输入姓名" \n clearable\n style="width: 200px" />\n </el-form-item>\n <el-form-item label="团员编号" prop="serNo"'),
|
||||
('placeholder="???????" \n clearable\n style="width: 200px" />\n </el-form-item>\n <el-form-item label="????" prop="grade"', 'placeholder="请输入团员编号" \n clearable\n style="width: 200px" />\n </el-form-item>\n <el-form-item label="入学年份" prop="grade"'),
|
||||
('placeholder="???????" \n clearable\n style="width: 200px">', 'placeholder="请选择入学年份" \n clearable\n style="width: 200px">'),
|
||||
# 按钮
|
||||
('@click="getDataList">??</el-button>', '@click="getDataList">查询</el-button>'),
|
||||
('@click="handleReset">??</el-button>', '@click="handleReset">重置</el-button>'),
|
||||
('@click="formDialogRef.openDialog()">\n ??\n </el-button>', '@click="formDialogRef.openDialog()">\n 新增\n </el-button>'),
|
||||
('@click="handleImport">\n ??\n </el-button>', '@click="handleImport">\n 导入\n </el-button>'),
|
||||
('@click="handleExport">\n ??\n </el-button>', '@click="handleExport">\n 导出\n </el-button>'),
|
||||
('content="???" placement="top"', 'content="列设置" placement="top"'),
|
||||
('label="??" width="70"', 'label="序号" width="70"'),
|
||||
("col.prop !== '??'", "col.prop !== '操作'"),
|
||||
('<!-- ????????? -->\n <template v-if="col.prop === \'enterTime\'"', '<!-- 入团时间列特殊模板 -->\n <template v-if="col.prop === \'enterTime\'"'),
|
||||
('<!-- ????????? -->\n <template v-else-if="col.prop === \'position\'"', '<!-- 团内职务列特殊模板 -->\n <template v-else-if="col.prop === \'position\'"'),
|
||||
('<el-table-column label="??" width="150"', '<el-table-column label="操作" width="150"'),
|
||||
('<span style="margin-left: 4px">??</span>\n </template>\n <template #default="scope">\n <el-button \n icon="Edit"', '<span style="margin-left: 4px">操作</span>\n </template>\n <template #default="scope">\n <el-button \n icon="Edit"'),
|
||||
('@click="handleEdit(scope.row)">\n ??\n </el-button>', '@click="handleEdit(scope.row)">\n 编辑\n </el-button>'),
|
||||
('@click="handleDelete(scope.row)">\n ??\n </el-button>', '@click="handleDelete(scope.row)">\n 删除\n </el-button>'),
|
||||
('title="????" \n v-model="importDialogVisible"', 'title="导入团员" \n v-model="importDialogVisible"'),
|
||||
('importDialogVisible = false">??</el-button>', 'importDialogVisible = false">取消</el-button>'),
|
||||
('handleImportSubmit" :loading="importLoading">??</el-button>', 'handleImportSubmit" :loading="importLoading">确定</el-button>'),
|
||||
# script - 注释
|
||||
('// ??????', '// 定义变量内容'),
|
||||
('// ??????', '// 表格列配置'),
|
||||
('// ????????????', '// 列配置映射(用于图标显示)'),
|
||||
('// ???????hook', '// 使用表格列控制hook'),
|
||||
('// ????', '// 表格样式'),
|
||||
('// ?? useTable', '// 配置 useTable'),
|
||||
('// ??\nconst handleReset', '// 重置\nconst handleReset'),
|
||||
('// ??\nconst handleEdit', '// 编辑\nconst handleEdit'),
|
||||
('// ??\nconst handleDelete', '// 删除\nconst handleDelete'),
|
||||
('// ??\nconst handleImport', '// 导入\nconst handleImport'),
|
||||
('// ????\nconst handleFileChange', '// 文件变化\nconst handleFileChange'),
|
||||
('// ??????\nconst handleExceed', '// 文件超出限制\nconst handleExceed'),
|
||||
('// ????\nconst handleImportSubmit', '// 提交导入\nconst handleImportSubmit'),
|
||||
('// ??\nconst handleExport', '// 导出\nconst handleExport'),
|
||||
('// ??????\nconst getClassListData', '// 获取班级列表\nconst getClassListData'),
|
||||
('// ????????\nconst getGradeListData', '// 获取入学年份列表\nconst getGradeListData'),
|
||||
('// ???\nonMounted', '// 初始化\nonMounted'),
|
||||
# script - tableColumns labels
|
||||
("label: '????', minWidth: 150", "label: '系部名称', minWidth: 150"),
|
||||
("label: '??', width: 120", "label: '班号', width: 120"),
|
||||
("label: '??', width: 120", "label: '学号', width: 120"),
|
||||
("label: '??', width: 100", "label: '姓名', width: 100"),
|
||||
("label: '???', width: 120", "label: '手机号', width: 120"),
|
||||
("label: '????', width: 120", "label: '入团时间', width: 120"),
|
||||
("label: '????', width: 120", "label: '团员编号', width: 120"),
|
||||
("label: '????', width: 120", "label: '团内职务', width: 120"),
|
||||
# script - 文案
|
||||
("confirm('???????????')", "confirm('确定要删除这条记录吗?')"),
|
||||
("useMessage().success('????')", "useMessage().success('删除成功')"),
|
||||
("err.msg || '????'", "err.msg || '删除失败'"),
|
||||
("useMessage().warning('????????')", "useMessage().warning('只能上传一个文件')"),
|
||||
("useMessage().warning('?????????')", "useMessage().warning('请选择要上传的文件')"),
|
||||
("useMessage().warning('?????')", "useMessage().warning('文件不存在')"),
|
||||
("useMessage().success('????')\n importDialogVisible", "useMessage().success('导入成功')\n importDialogVisible"),
|
||||
("err.msg || '????')\n } finally", "err.msg || '导入失败')\n } finally"),
|
||||
("link.download = `??_${", "link.download = `团员_${"),
|
||||
("useMessage().success('????')\n } catch (err: any) {\n useMessage().error(err.msg || '????')\n }\n}\n\n// ??????", "useMessage().success('导出成功')\n } catch (err: any) {\n useMessage().error(err.msg || '导出失败')\n }\n}\n\n// 获取班级列表"),
|
||||
]
|
||||
|
||||
# 避免重复替换已正确内容
|
||||
for old, new in replacements:
|
||||
if old in s and old != new:
|
||||
s = s.replace(old, new, 1)
|
||||
|
||||
with open(path, 'w', encoding='utf-8') as f:
|
||||
f.write(s)
|
||||
print('Done')
|
||||
Reference in New Issue
Block a user