Browse Source

将身份照号码转为大写

Michael Wang 6 năm trước cách đây
mục cha
commit
9b26fa9823
1 tập tin đã thay đổi với 13 bổ sung0 xóa
  1. 13 0
      src/views/index.vue

+ 13 - 0
src/views/index.vue

@@ -85,6 +85,19 @@ function isImageFile(fileName) {
 
 //读取文件,返回网站路径. 只扫描当前文件夹,不递归扫描
 function readImageFiles(folderPath) {
+  try {
+    const filesToRename = fs.readdirSync(folderPath);
+    filesToRename
+      .filter(isImageFile)
+      .forEach(fileName =>
+        fs.renameSync(
+          folderPath + "/" + fileName,
+          folderPath + "/" + fileName.toUpperCase()
+        )
+      );
+  } catch (e) {
+    alert("将身份证号转为大写出错。");
+  }
   const files = fs.readdirSync(folderPath);
   return files
     .filter(isImageFile)