Bladeren bron

[server][add][server]

zhangwei 3 jaren geleden
bovenliggende
commit
1d7c277b29
7 gewijzigde bestanden met toevoegingen van 179 en 34 verwijderingen
  1. 3 1
      .gitignore
  2. 1 1
      index.html
  3. 2 1
      package.json
  4. BIN
      server/1.png
  5. 135 0
      server/main.py
  6. 1 1
      src/App.vue
  7. 37 30
      src/components/HelloWorld.vue

+ 3 - 1
.gitignore

@@ -3,4 +3,6 @@ node_modules
 dist
 dist-ssr
 *.local
-.vscode
+.vscode
+
+longVideoFactory

+ 1 - 1
index.html

@@ -4,7 +4,7 @@
     <meta charset="UTF-8" />
     <link rel="icon" href="/favicon.ico" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>Vite App</title>
+    <title>微信小程序</title>
   </head>
   <body>
     <div id="app"></div>

+ 2 - 1
package.json

@@ -7,10 +7,11 @@
     "serve": "vite preview"
   },
   "dependencies": {
+    "element-plus": "^1.1.0-beta.20",
     "vue": "^3.2.16"
   },
   "devDependencies": {
     "@vitejs/plugin-vue": "^1.9.3",
     "vite": "^2.6.4"
   }
-}
+}

BIN
server/1.png


+ 135 - 0
server/main.py

@@ -0,0 +1,135 @@
+import os
+import requests
+import json
+
+# current_path
+current_path = os.getcwd()
+
+# 1.小程序打包
+def build_mini_program():
+    command_str = (
+    "git clone https://git.yishihui.com/weapp/longVideoFactory.git;"
+    "cd longVideoFactory;"
+    "git pull;"
+    "git checkout dev;"
+    "git pull;"
+    "n 8;"
+    "cnpm install && npm install ;"
+    "npm run build && npm run build:other;"
+    )
+    
+    if os.system(command_str) == 0:
+        print("1.打包成功")
+        # create_preview()
+    else:
+        print("1.打包失败")
+    
+# 2.微信编译图片
+def create_preview():
+    # 小程序 cli path for mac
+    wx_cli ="/Applications/wechatwebdevtools.app/Contents/MacOS/cli"
+    
+    dist_path =  os.path.join(current_path,'longVideoFactory/dist/vlog')
+    code_img_path =  os.path.join(current_path,'1.png')
+    f_read = os.popen(wx_cli+" preview  --project "+dist_path+" --qr-output "+code_img_path+" --qr-format image").read()
+    if "[error]" in f_read:
+        print(f_read)
+    else:
+        print("2.微信小程序编译成功")
+
+# create_preview()
+
+# https://open.feishu.cn/open-apis/bot/v2/hook/a924b6a5-86ef-4c76-a7e4-eb42056f70cc
+
+def upload_img_by_feishu(token):
+    key = ""
+    url = "https://open.feishu.cn/open-apis/im/v1/images"
+    files = {
+        "image_type":(None,"message"),
+        "image":('1.png',open(os.path.join(current_path,"1.png"),"rb"),"image/png")
+    }
+    headers = {
+        "Authorization":"Bearer "+token,
+    }
+    res = requests.post(url,headers=headers,files=files,verify = False).json()
+    if res["code"] == 0:
+        key = res["data"]["image_key"]
+    else:
+        print("飞书上传图片失败")
+        
+    return key
+
+def tenant_access_token_by_feishu():
+    token = ""
+    url = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal"
+    params = {
+        "app_id":"cli_a1ec07458838d00c",
+        "app_secret":"Ngm0kfaLkZnpM2T2DH7L8cM5hdAqY0hI"
+    }
+    res = requests.post(url,data=params,verify = False).json()
+    if res["code"] == 0:
+        token = res["tenant_access_token"]
+    else:
+        print("获取飞书签名失败")
+
+    return token
+
+def send_msg_by_feishu(token,img_key):
+    # webhook
+    webhook_url = "https://open.feishu.cn/open-apis/bot/v2/hook/a924b6a5-86ef-4c76-a7e4-eb42056f70cc"
+    headers = {
+        "Authorization":"Bearer "+token,
+        "Content-Type": "application/json;charset=UTF-8"
+    }
+    params = {
+        "msg_type": "post",
+        "content": {
+            "post": {
+            "zh_cn": {
+                "title": "Vlog小程序预览码",
+                "content": [
+                    # [
+                    #     {
+                    #         "tag": "text",
+                    #         "text": "第二行 :"
+                    #     },
+                    #     {
+                    #         "tag": "text",
+                    #         "text": "文本测试"
+                    #     }
+                    # ],
+                    [
+                        {
+                            "tag": "img",
+                            "image_key": "img_v2_223c3413-488a-4af6-bd36-6563a9ef185g",
+                            "width": 500,
+                            "height": 500
+                        }
+                    ]]
+                }
+            }
+        }
+    }
+    
+    res = requests.post(webhook_url,headers=headers,data=json.dumps(params),verify = False).json()
+    if res["StatusCode"] == 0:
+        print("飞书消息发送成功")
+    else:
+        print("飞书消息发送失败")
+
+
+
+# ------- 微信打包 ------
+# 1.小程序打包
+build_mini_program()
+# 2.微信编译图片
+create_preview()
+
+
+# -------- 飞书 --------
+# 1.获取签名 
+token = tenant_access_token_by_feishu()
+# 2.获取imgKey
+img_key = upload_img_by_feishu(token)
+# 3.飞书发送消息
+send_msg_by_feishu(token,img_key)

+ 1 - 1
src/App.vue

@@ -6,7 +6,7 @@ import HelloWorld from './components/HelloWorld.vue'
 
 <template>
   <img alt="Vue logo" src="./assets/logo.png" />
-  <HelloWorld msg="Hello Vue 3 + Vite" />
+  <HelloWorld  />
 </template>
 
 <style>

+ 37 - 30
src/components/HelloWorld.vue

@@ -1,40 +1,47 @@
 <script setup>
-import { ref } from 'vue'
-
-defineProps({
-  msg: String
-})
+import { ref, reactive } from 'vue'
 
 const count = ref(0)
+const data = reactive({
+  platform: [{
+    value: 'vlog',
+    label: '票圈vlog',
+  }, {
+    value: 'video',
+    label: '票圈video'
+  }, {
+    value: 'shortVideo',
+    label: '票圈短视频'
+  }, {
+    value: 'longVideo',
+    label: '票圈长视频'
+  }, {
+    value: 'iMove',
+    label: '票圈爱电影'
+  }, {
+    value: 'iFunny',
+    label: '票圈最搞笑'
+  }, {
+    value: 'amazed',
+    label: '票圈最惊奇'
+  }],
+  Env: [{
+    value: 'test',
+    label: '测试'
+  }, {
+    value: 'pre',
+    label: '预发布'
+  }, {
+    value: 'prod',
+    label: '线上'
+  }]
+})
 </script>
 
-<template>
-  <h1>{{ msg }}</h1>
-
-  <p>
-    Recommended IDE setup:
-    <a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
-    +
-    <a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
-  </p>
-
-  <p>
-    <a href="https://vitejs.dev/guide/features.html" target="_blank">
-      Vite Documentation
-    </a>
-    |
-    <a href="https://v3.vuejs.org/" target="_blank">Vue 3 Documentation</a>
-  </p>
-
-  <button type="button" @click="count++">count is: {{ count }}</button>
-  <p>
-    Edit
-    <code>components/HelloWorld.vue</code> to test hot module replacement.
-  </p>
-</template>
+<template></template>
 
 <style scoped>
 a {
   color: #42b983;
 }
-</style>
+</style>