hankzhang 11 miesięcy temu
rodzic
commit
88c7bba3c1
4 zmienionych plików z 162 dodań i 45 usunięć
  1. 1 1
      config/config.js
  2. 1 1
      destroy/readme.md
  3. 43 43
      project.config.json
  4. 117 0
      upload.py

+ 1 - 1
config/config.js

@@ -476,7 +476,7 @@ const appInfoObj = {
 };
 
 // @config 确定使用的小程序appid
-const current_appid = 'wxa7a33088566e1292';
+const current_appid = "wx60db1bff60cd771c";
 export const apple = {
     ...appInfoObj[current_appid],
     appKey: "49TBR8Z1rA7PyqD30FV0v48AU",

+ 1 - 1
destroy/readme.md

@@ -9,7 +9,7 @@
 // 单个小程序执行
 npm run upload --  --t=2 --a=蓝晶帧溯视界 --v=1.7.4 --d=优化一些问题
 // 批量化执行
-npm run upload --  --t=1  --v=1.7.4 --d=优化一些问题
+npm run upload --  --t=1  --v=1.8.0 --d=优化一些问题
 ```
 1. 复制批量化功能代码文件到项目目录destroy(没有则创建)
    2. destroy/upload.wx.js 单个小程序上传

+ 43 - 43
project.config.json

@@ -1,46 +1,46 @@
 {
-  "compileType": "miniprogram",
-  "packOptions": {
-    "ignore": [
-      {
-        "value": "/minitest",
-        "type": "folder"
-      }
-    ],
-    "include": []
-  },
-  "setting": {
-    "coverView": true,
-    "es6": true,
-    "postcss": true,
-    "minified": true,
-    "enhance": true,
-    "showShadowRootInWxmlPanel": true,
-    "packNpmRelationList": [],
-    "babelSetting": {
-      "ignore": [],
-      "disablePlugins": [],
-      "outputPath": ""
+    "compileType": "miniprogram",
+    "packOptions": {
+        "ignore": [
+            {
+                "value": "/minitest",
+                "type": "folder"
+            }
+        ],
+        "include": []
     },
-    "compileWorklet": false,
-    "uglifyFileName": false,
-    "uploadWithSourceMap": true,
-    "packNpmManually": false,
-    "minifyWXSS": true,
-    "minifyWXML": true,
-    "localPlugins": false,
-    "disableUseStrict": false,
-    "useCompilerPlugins": false,
-    "condition": false,
-    "swc": false,
-    "disableSWC": true
-  },
-  "editorSetting": {
-    "tabIndent": "auto",
-    "tabSize": 2
-  },
-  "appid": "wxa7a33088566e1292",
-  "testRoot": "minitest/",
-  "libVersion": "trial",
-  "simulatorPluginLibVersion": {}
+    "setting": {
+        "coverView": true,
+        "es6": true,
+        "postcss": true,
+        "minified": true,
+        "enhance": true,
+        "showShadowRootInWxmlPanel": true,
+        "packNpmRelationList": [],
+        "babelSetting": {
+            "ignore": [],
+            "disablePlugins": [],
+            "outputPath": ""
+        },
+        "compileWorklet": false,
+        "uglifyFileName": false,
+        "uploadWithSourceMap": true,
+        "packNpmManually": false,
+        "minifyWXSS": true,
+        "minifyWXML": true,
+        "localPlugins": false,
+        "disableUseStrict": false,
+        "useCompilerPlugins": false,
+        "condition": false,
+        "swc": false,
+        "disableSWC": true
+    },
+    "editorSetting": {
+        "tabIndent": "auto",
+        "tabSize": 2
+    },
+    "appid": "wx60db1bff60cd771c",
+    "testRoot": "minitest/",
+    "libVersion": "trial",
+    "simulatorPluginLibVersion": {}
 }

+ 117 - 0
upload.py

@@ -0,0 +1,117 @@
+# _*_ coding: utf-8 _*_
+# @Time : 2025/7/24 17:15
+# @Author : Hank 
+# @Version:V 0.1
+# @File : mini_interface.py
+# @desc :
+import os
+import re
+import time
+import subprocess
+import sys
+import platform
+
+# ----------------------- 执行说明 -------------------------
+# 单个更新
+# python update.py 1 wx1234567890abcdef
+# 批量更新,修改update_list
+# python update.py 2
+# ----------------------- 执行说明 -------------------------
+
+update_list = []
+# 更新列表
+update_list_hank = [
+    "wxa7a33088566e1292","wxdabfa5e02785fe9b","wxa13166979d7011c4","wx8a8aae7f462df482","wx1344c35820ac688e","wx8bd40e8ce9deb2b6","wx9e90adce31181f7f","wx9d93825db1c7dcbe","wx3fe2e6c200ec7133","wx3800bb2ed4a326c5","wx60db1bff60cd771c"
+    ]
+
+update_list.extend(update_list_hank)
+
+update_list_alex = [
+    "wxc5e6b24889027032","wxef68681d5044ca05","wx706acdc696d025ad","wx8288d587b717897e","wx54a8d0e7b33c48c8","wx0138dee6d680c705","wx4420e2d55b0ede27","wx6b11ce533c3aca92","wx5d607cf4fa663c72","wxbece4f28b6b71271","wxdd1bde4de9f6a6a0","wxbf40c735c0d263a5","wx3f464072571c1fd3","wx092045bdfe26a5ee","wx6c4bb5ef1e6c1e70"
+]
+# update_list.extend(update_list_alex)
+# print(update_list)
+
+# 配置文件路径
+config_file = 'config/config.js'
+project_file = 'project.config.json'
+project_path = os.getcwd()
+
+# 根据平台设置 CLI 路径
+system = platform.system()
+if system == "Windows":
+    cli_tool_path = r"C:\Users\hank\software\微信web开发者工具\cli.bat"
+    # windows 项目路径
+    project_path = r"C:\Users\hank\Git\mini_read_space_front"
+elif system == "Darwin":  # macOS
+    cli_tool_path = "/Applications/wechatwebdevtools.app/Contents/MacOS/cli"
+else:
+    print(f"[ERROR] 不支持的操作系统: {system}")
+    sys.exit(1)
+
+
+def replace_in_file(file_path, pattern, replacement):
+    with open(file_path, 'r', encoding='utf-8') as file:
+        content = file.read()
+
+    new_content, count = re.subn(pattern, replacement, content)
+
+    if count > 0:
+        with open(file_path, 'w', encoding='utf-8') as file:
+            file.write(new_content)
+    else:
+        print(f"[WARN] No matches found in {file_path} for pattern: {pattern}")
+
+
+def upload_project(appid, version, description):
+    print(f"[INFO] 更新 appid: {appid}")
+
+    replace_in_file(config_file, r'const current_appid = "[^"]*"', f'const current_appid = "{appid}"')
+    replace_in_file(project_file, r'"appid":\s*"[^"]*"', f'"appid": "{appid}"')
+
+    # 准备上传环境,清除 NODE_OPTIONS(兼容微信开发者工具 CLI)
+    env = os.environ.copy()
+    env.pop("NODE_OPTIONS", None)  # 删除 NODE_OPTIONS,如果存在
+
+    try:
+        subprocess.run([
+            cli_tool_path,
+            "upload",
+            "--project", project_path,
+            "-v", version,
+            "-d", description
+        ], check=True, env=env)
+        print(f"[SUCCESS] 上传完成: {appid}\n")
+    except subprocess.CalledProcessError as e:
+        print(f"[ERROR] 上传失败: {appid}\n{e}")
+
+
+def main(version,description):
+    if len(sys.argv) < 2:
+        print("用法: python update.py <模式> [appid]")
+        print("模式 1: 单个更新,需提供 appid")
+        print("模式 2: 批量更新,使用 update_list")
+        return
+
+    mode = sys.argv[1]
+
+    if mode == "1":
+        if len(sys.argv) < 3:
+            print("请提供 appid,例如: python update.py 1 wx1234567890abcdef")
+            return
+        appid = sys.argv[2]
+        upload_project(appid, version, description)
+    elif mode == "2":
+        for appid in update_list:
+            print(f"{appid} 开始更新")
+            upload_project(appid, version, description)
+            time.sleep(3)
+            print(f"{appid} 结束更新\n")
+    else:
+        print("无效模式,只能为 1 或 2")
+
+
+if __name__ == "__main__":
+    version  = "1.8.0"
+    description = "v1.8.0 优化一些问题"
+    main(version,description)