删除不再使用的文件,包括.gitignore、多个启动和配置指南文档,以及小程序相关的脚本和文档,简化项目结构以提高可维护性。

This commit is contained in:
乘风
2026-01-31 15:36:52 +08:00
parent 77a1c87678
commit ceac5b73ff
67 changed files with 1186 additions and 14635 deletions

View File

@@ -1,14 +1,10 @@
# Windows
[Dd]esktop.ini
Thumbs.db
$RECYCLE.BIN/
# 小程序上传密钥(敏感信息,请勿上传)
private.key
private.*.key
# macOS
# 预览二维码
preview.jpg
# 微信开发者工具生成的文件
.DS_Store
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
# Node.js
node_modules/

View File

@@ -23,21 +23,52 @@ Component({
pagePath: '/pages/match/match',
text: '找伙伴',
iconType: 'match',
isSpecial: true
isSpecial: true,
hidden: true // 默认隐藏,等配置加载后根据后台设置显示
},
{
pagePath: '/pages/my/my',
text: '我的',
iconType: 'user'
}
]
],
matchEnabled: false // 找伙伴功能开关(默认隐藏,等待后台配置加载)
},
attached() {
// 初始化时获取当前页面
this.loadFeatureConfig()
},
methods: {
// 加载功能配置
async loadFeatureConfig() {
try {
const app = getApp()
const res = await app.request('/api/db/config')
if (res.success && res.features) {
const matchEnabled = res.features.matchEnabled === true
this.setData({ matchEnabled })
// 更新list隐藏或显示找伙伴
const list = this.data.list.map(item => {
if (item.iconType === 'match') {
return { ...item, hidden: !matchEnabled }
}
return item
})
this.setData({ list })
console.log('[TabBar] 功能配置加载成功,找伙伴功能:', matchEnabled ? '开启' : '关闭')
}
} catch (e) {
console.log('[TabBar] 加载功能配置失败:', e)
// 失败时默认隐藏找伙伴与Web版保持一致
this.setData({ matchEnabled: false })
}
},
switchTab(e) {
const data = e.currentTarget.dataset
const url = data.path

View File

@@ -30,8 +30,8 @@
<view class="tab-bar-text" style="color: {{selected === 1 ? selectedColor : color}}">{{list[1].text}}</view>
</view>
<!-- 找伙伴 - 中间突出按钮 -->
<view class="tab-bar-item special-item" data-path="{{list[2].pagePath}}" data-index="2" bindtap="switchTab">
<!-- 找伙伴 - 中间突出按钮(可通过后台隐藏) -->
<view wx:if="{{matchEnabled}}" class="tab-bar-item special-item" data-path="{{list[2].pagePath}}" data-index="2" bindtap="switchTab">
<view class="special-button {{selected === 2 ? 'special-active' : ''}}">
<view class="icon-users">
<view class="user-circle user-1"></view>

144
miniprogram/upload.js Normal file
View File

@@ -0,0 +1,144 @@
/**
* 小程序自动上传脚本
* 使用前请先安装: npm install miniprogram-ci --save-dev
*/
const ci = require('miniprogram-ci')
const path = require('path')
// 配置信息
const config = {
// 小程序AppID
appid: 'wxb8bbb2b10dec74aa',
// 项目路径
projectPath: path.resolve(__dirname),
// 私钥路径(需要从微信公众平台下载)
// 下载地址:微信公众平台 -> 开发管理 -> 开发设置 -> 小程序代码上传密钥
privateKeyPath: path.resolve(__dirname, './private.key'),
// 版本号(请根据实际情况修改)
version: '1.0.0',
// 版本描述
desc: 'Soul创业派对 - 首次发布',
// 编译设置
setting: {
es6: true,
es7: true,
minifyJS: true,
minifyWXML: true,
minifyWXSS: true,
minify: true,
codeProtect: false,
autoPrefixWXSS: true
}
}
/**
* 上传小程序代码
*/
async function upload() {
console.log('🚀 开始上传小程序...')
console.log('📦 项目路径:', config.projectPath)
console.log('🆔 AppID:', config.appid)
console.log('📌 版本号:', config.version)
try {
// 创建项目实例
const project = new ci.Project({
appid: config.appid,
type: 'miniProgram',
projectPath: config.projectPath,
privateKeyPath: config.privateKeyPath,
ignores: ['node_modules/**/*']
})
console.log('✅ 项目实例创建成功')
// 上传代码
console.log('⏳ 正在上传代码...')
const uploadResult = await ci.upload({
project,
version: config.version,
desc: config.desc,
setting: config.setting,
onProgressUpdate: (info) => {
console.log('📊 上传进度:', info)
}
})
console.log('🎉 上传成功!')
console.log('📝 上传结果:', uploadResult)
console.log('')
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
console.log('✅ 代码已上传到微信公众平台')
console.log('📱 请前往微信公众平台提交审核:')
console.log(' https://mp.weixin.qq.com/')
console.log(' 登录 → 版本管理 → 开发版本 → 提交审核')
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
} catch (error) {
console.error('❌ 上传失败:', error.message)
if (error.message.includes('private.key')) {
console.log('')
console.log('⚠️ 缺少密钥文件 private.key')
console.log('📥 请按以下步骤获取:')
console.log(' 1. 访问 https://mp.weixin.qq.com/')
console.log(' 2. 登录小程序后台')
console.log(' 3. 开发管理 → 开发设置 → 小程序代码上传密钥')
console.log(' 4. 点击"生成",下载密钥文件')
console.log(' 5. 将 private.*.key 重命名为 private.key')
console.log(' 6. 放到 miniprogram 目录下')
}
process.exit(1)
}
}
/**
* 预览小程序
*/
async function preview() {
console.log('👀 生成预览二维码...')
try {
const project = new ci.Project({
appid: config.appid,
type: 'miniProgram',
projectPath: config.projectPath,
privateKeyPath: config.privateKeyPath,
ignores: ['node_modules/**/*']
})
const previewResult = await ci.preview({
project,
desc: config.desc,
setting: config.setting,
qrcodeFormat: 'terminal',
qrcodeOutputDest: path.resolve(__dirname, './preview.jpg'),
onProgressUpdate: (info) => {
console.log('📊 生成进度:', info)
}
})
console.log('✅ 二维码已生成:', './miniprogram/preview.jpg')
console.log('📱 使用微信扫码即可预览')
} catch (error) {
console.error('❌ 生成预览失败:', error.message)
process.exit(1)
}
}
// 命令行参数
const command = process.argv[2]
if (command === 'preview') {
preview()
} else {
upload()
}

View File

@@ -0,0 +1,296 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Soul创业派对 - 小程序自动上传脚本
使用Python调用微信开发者工具CLI上传小程序
"""
import os
import sys
import subprocess
import json
from pathlib import Path
from datetime import datetime
# 配置信息
CONFIG = {
'appid': 'wxb8bbb2b10dec74aa',
'project_path': Path(__file__).parent.absolute(),
'version': '1.0.0',
'desc': 'Soul创业派对 - 首次发布',
}
# 微信开发者工具CLI可能的路径
CLI_PATHS = [
r"D:\微信web开发者工具\cli.bat",
r"C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat",
r"C:\Program Files\Tencent\微信web开发者工具\cli.bat",
os.path.join(os.environ.get('LOCALAPPDATA', ''), '微信web开发者工具', 'cli.bat'),
]
def print_banner():
"""打印横幅"""
print("\n" + "=" * 60)
print(" 🚀 Soul创业派对 - 小程序自动上传")
print("=" * 60 + "\n")
def find_cli():
"""查找微信开发者工具CLI"""
print("🔍 正在查找微信开发者工具...")
for cli_path in CLI_PATHS:
if os.path.exists(cli_path):
print(f"✅ 找到CLI: {cli_path}\n")
return cli_path
print("❌ 未找到微信开发者工具CLI")
print("\n请确保已安装微信开发者工具,并开启服务端口:")
print(" 1. 打开微信开发者工具")
print(" 2. 设置 → 安全设置")
print(" 3. 勾选「开启服务端口」\n")
return None
def check_private_key():
"""检查上传密钥"""
key_path = CONFIG['project_path'] / 'private.key'
if not key_path.exists():
print("❌ 未找到上传密钥文件 private.key\n")
print("📥 请按以下步骤获取密钥:")
print(" 1. 访问 https://mp.weixin.qq.com/")
print(" 2. 登录小程序后台")
print(" 3. 开发管理 → 开发设置 → 小程序代码上传密钥")
print(" 4. 点击「生成」,下载密钥文件")
print(" 5. 将 private.*.key 重命名为 private.key")
print(f" 6. 放到目录: {CONFIG['project_path']}\n")
return False
print(f"✅ 找到密钥文件: private.key\n")
return True
def check_node_installed():
"""检查Node.js是否安装"""
try:
result = subprocess.run(['node', '--version'],
capture_output=True,
text=True)
if result.returncode == 0:
print(f"✅ Node.js版本: {result.stdout.strip()}")
return True
except FileNotFoundError:
pass
print("❌ 未找到Node.js")
print("\n请先安装Node.js: https://nodejs.org/\n")
return False
def check_miniprogram_ci():
"""检查miniprogram-ci是否安装"""
print("\n🔍 检查上传工具...")
node_modules = CONFIG['project_path'].parent / 'node_modules' / 'miniprogram-ci'
if node_modules.exists():
print("✅ miniprogram-ci已安装\n")
return True
print("⚠️ miniprogram-ci未安装")
print("\n正在安装miniprogram-ci...")
try:
# 切换到项目根目录安装
parent_dir = CONFIG['project_path'].parent
result = subprocess.run(
['npm', 'install', 'miniprogram-ci', '--save-dev'],
cwd=parent_dir,
capture_output=True,
text=True
)
if result.returncode == 0:
print("✅ miniprogram-ci安装成功\n")
return True
else:
print(f"❌ 安装失败: {result.stderr}")
return False
except Exception as e:
print(f"❌ 安装出错: {e}")
return False
def upload_with_nodejs():
"""使用Node.js脚本上传"""
print("📦 使用Node.js上传...")
print(f"📂 项目路径: {CONFIG['project_path']}")
print(f"🆔 AppID: {CONFIG['appid']}")
print(f"📌 版本号: {CONFIG['version']}")
print(f"📝 描述: {CONFIG['desc']}\n")
upload_js = CONFIG['project_path'] / 'upload.js'
if not upload_js.exists():
print(f"❌ 未找到上传脚本: {upload_js}")
return False
try:
print("⏳ 正在上传代码...\n")
result = subprocess.run(
['node', str(upload_js)],
cwd=CONFIG['project_path'],
capture_output=True,
text=True,
timeout=300 # 5分钟超时
)
# 显示输出
if result.stdout:
print(result.stdout)
if result.returncode == 0:
print("\n" + "=" * 60)
print("✅ 上传成功!")
print("=" * 60)
print("\n📱 下一步:")
print(" 1. 访问 https://mp.weixin.qq.com/")
print(" 2. 登录小程序后台")
print(" 3. 版本管理 → 开发版本 → 提交审核")
print("=" * 60 + "\n")
return True
else:
print(f"\n❌ 上传失败")
if result.stderr:
print(f"错误信息: {result.stderr}")
return False
except subprocess.TimeoutExpired:
print("❌ 上传超时超过5分钟")
return False
except Exception as e:
print(f"❌ 上传出错: {e}")
return False
def upload_with_cli(cli_path):
"""使用微信开发者工具CLI上传"""
print("📦 使用微信开发者工具CLI上传...")
print(f"📂 项目路径: {CONFIG['project_path']}")
print(f"🆔 AppID: {CONFIG['appid']}")
print(f"📌 版本号: {CONFIG['version']}")
print(f"📝 描述: {CONFIG['desc']}\n")
key_path = CONFIG['project_path'] / 'private.key'
try:
print("⏳ 正在上传代码...\n")
# 构建上传命令
cmd = [
cli_path,
'upload',
'--project', str(CONFIG['project_path']),
'--version', CONFIG['version'],
'--desc', CONFIG['desc'],
'--pkp', str(key_path)
]
result = subprocess.run(
cmd,
capture_output=True,
text=True,
timeout=300, # 5分钟超时
encoding='utf-8',
errors='ignore'
)
# 显示输出
if result.stdout:
print(result.stdout)
if result.returncode == 0 or '成功' in result.stdout:
print("\n" + "=" * 60)
print("✅ 上传成功!")
print("=" * 60)
print("\n📱 下一步:")
print(" 1. 访问 https://mp.weixin.qq.com/")
print(" 2. 登录小程序后台")
print(" 3. 版本管理 → 开发版本 → 提交审核")
print("=" * 60 + "\n")
return True
else:
print(f"\n❌ 上传失败")
if result.stderr:
print(f"错误信息: {result.stderr}")
return False
except subprocess.TimeoutExpired:
print("❌ 上传超时超过5分钟")
return False
except Exception as e:
print(f"❌ 上传出错: {e}")
return False
def main():
"""主函数"""
print_banner()
# 检查必要条件
print("🔍 检查上传条件...\n")
# 1. 检查密钥
if not check_private_key():
sys.exit(1)
# 2. 检查Node.js
has_node = check_node_installed()
# 3. 查找CLI
cli_path = find_cli()
# 如果没有Node.js也没有CLI退出
if not has_node and not cli_path:
print("❌ 无法上传需要Node.js或微信开发者工具CLI")
sys.exit(1)
print("\n" + "-" * 60 + "\n")
# 优先使用Node.js方式更稳定
if has_node:
if check_miniprogram_ci():
if upload_with_nodejs():
sys.exit(0)
else:
print("\n⚠️ Node.js上传失败尝试使用CLI...\n")
# 备选使用CLI
if cli_path:
if upload_with_cli(cli_path):
sys.exit(0)
print("\n❌ 所有上传方式都失败了")
print("\n💡 建议:")
print(" 1. 确保微信开发者工具已打开")
print(" 2. 确保已开启「服务端口」")
print(" 3. 确保private.key文件正确")
print(" 4. 或手动使用微信开发者工具上传\n")
sys.exit(1)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print("\n\n⚠️ 用户取消上传")
sys.exit(1)
except Exception as e:
print(f"\n❌ 发生错误: {e}")
import traceback
traceback.print_exc()
sys.exit(1)

View File

@@ -0,0 +1,29 @@
@echo off
chcp 65001 >nul
echo.
echo ========================================
echo Soul创业派对 - 快速上传小程序
echo ========================================
echo.
REM 检查Python
python --version >nul 2>&1
if errorlevel 1 (
echo ❌ 未找到Python
echo.
echo 请先安装Python: https://www.python.org/
echo.
pause
exit /b 1
)
echo ✅ Python已安装
echo.
REM 运行上传脚本
echo 🚀 开始上传...
echo.
python "%~dp0上传小程序.py"
echo.
pause