初始化项目:添加后端代码、ThinkPHP框架、前端资源

This commit is contained in:
amb
2026-09-03 12:42:39 +08:00
commit 482bece22e
3726 changed files with 416708 additions and 0 deletions
@@ -0,0 +1,193 @@
<?php
namespace app\admin\controller\channel;
use app\common\controller\Backend;
use ZipArchive;
/**
* 上传代码
*/
class Upload extends Backend
{
public function _initialize()
{
parent::_initialize();
}
/**
* 获取版本
* @return void
*/
public function getVersion(){
$this->success("获取成功",\think\Config::get('license'));
}
/**
* 提交版本
* @return void
*/
public function wechat(){
$version = input('version','1.0.0');
$desc = input('desc','');
$type = input('type','submit');
if(!$version){
$this->error("请完善版本号");
}
if(!$desc){
$this->error("请完善版本描述");
}
if(\app\common\library\Platform::getSystemType() == 'single'){
$domain = $this->request->domain() . '/';
}else{
$domain = $this->request->domain() . '/app/index.php';
}
$wxMiniProgramConfig = \app\common\model\config\System::getConfig('wxMiniProgram');
$appid = $wxMiniProgramConfig['app_id'];
$upload_key = $wxMiniProgramConfig['upload_key'];
if(!$appid || !$upload_key){
$this->error("请完善小程序配置信息");
}
set_time_limit(0);
try {
$client = \app\common\library\Client::getClient();
$response = $client->request("POST",'api/license/upload/wechat',[
'form_params'=>[
'version'=>$version,
'desc'=>$desc,
'key'=>$upload_key,
'appid'=>$appid,
'domain'=>$domain,
'uniacid'=>UNIACID,
'actiontype'=>$type
]
]);
$body = $response->getBody();
$data = $body->getContents();
} catch (TransferException $e) {
return false;
}
$data = json_decode($data,true);
if(!$data || !isset($data['code'])){
$this->error("连接服务器失败");
}
if($data['code'] != 1){
$this->error($data['msg'],$data['data']);
}
if($type == 'submit'){
$logModel = new \app\admin\model\channel\submit\Log();
$logModel->insert([
'uniacid'=>UNIACID,
'appid'=>$appid,
'platform'=>'wechat',
'version'=>$version,
'version_desc'=>$desc,
'system_verison'=>\think\Config::get('license.version'),
'createtime'=>time()
]);
}
$this->success("上传成功",$data['data']);
}
/**
* 提交版本
* @return void
*/
public function douyin(){
set_time_limit(0);
$version = input('version','1.0.0');
$desc = input('desc','');
$type = input('type','submit');
if(!$version){
$this->error("请完善版本号");
}
if(!$desc){
$this->error("请完善版本描述");
}
if(\app\common\library\Platform::getSystemType() == 'single'){
$domain = $this->request->domain() . '/';
}else{
$domain = $this->request->domain() . '/app/index.php';
}
$dyMiniProgramConfig = \app\common\model\config\System::getConfig('dyMiniProgram');
$appid = $dyMiniProgramConfig['appid'];
$token = $dyMiniProgramConfig['token'];
if(!$appid || !$token){
$this->error("请完善小程序配置信息");
}
try {
$client = \app\common\library\Client::getClient();
$response = $client->request("POST",'api/license/upload/douyin',[
'form_params'=>[
'version'=>$version,
'desc'=>$desc,
'token'=>$token,
'appid'=>$appid,
'domain'=>$domain,
'uniacid'=>UNIACID,
'actiontype'=>$type
]
]);
$body = $response->getBody();
$data = $body->getContents();
} catch (TransferException $e) {
return false;
}
$data = json_decode($data,true);
if(!$data || !isset($data['code'])){
$this->error("连接服务器失败");
}
if($data['code'] != 1){
$this->error($data['msg'],$data['data']);
}
if($type == 'submit'){
$logModel = new \app\admin\model\channel\submit\Log();
$logModel->insert([
'uniacid'=>UNIACID,
'appid'=>$appid,
'platform'=>'douyin',
'version'=>$version,
'version_desc'=>$desc,
'system_verison'=>\think\Config::get('license.version'),
'createtime'=>time()
]);
}
$this->success("上传成功",$data['data']);
}
}
@@ -0,0 +1,68 @@
<?php
namespace app\admin\controller\channel\submit;
use app\common\controller\Backend;
/**
* 小程序上传记录
*
* @icon fa fa-circle-o
*/
class Log extends Backend
{
/**
* Log模型对象
* @var \app\admin\model\channel\submit\Log
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\channel\submit\Log;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = false;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
}
$result = array("total" => $list->total(), "rows" => $list->items());
return $this->success("获取成功",$result);
}
}
@@ -0,0 +1,48 @@
<?php
namespace app\admin\controller\channel\wxapp;
use app\common\controller\Backend;
use ZipArchive;
/**
* 小鹅通
*/
class Package extends Backend
{
public function _initialize()
{
parent::_initialize();
}
/**
* 压缩
* @remark 递归将文件夹中的所有文件和子文件夹添加到压缩包中
* @param string $folderPath 文件夹路径
* @param ZipArchive $zip 压缩包实例
* @param string $parentFolder 父文件夹路径(用于保持相对路径)
*/
public function addFolderToZip($folderPath, $zip, $parentFolder = '') {
$handle = opendir($folderPath);
while (($file = readdir($handle)) !== false) {
if ($file != '.' && $file != '..') {
$filePath = $folderPath . '/' . $file;
if (is_file($filePath)) {
// 获取相对于父文件夹的路径
$relativePath = ltrim($parentFolder . '/' . $file, '/');
// 将文件添加到压缩包中,并使用相对路径作为在压缩包中的文件名
$zip->addFile($filePath, $relativePath);
} elseif (is_dir($filePath)) {
// 递归添加子文件夹中的文件和子文件夹
$this->addFolderToZip($filePath, $zip, $parentFolder . '/' . $file);
}
}
}
closedir($handle);
}
}
@@ -0,0 +1,187 @@
<?php
namespace app\admin\controller\channel\wxapp;
use app\common\controller\Backend;
use ZipArchive;
/**
* 版本管理
*/
class Version extends Backend
{
public function _initialize()
{
parent::_initialize();
}
/**
* 获取授权链接
* @return void
*/
public function getAuthUrl(){
if(\app\common\library\Platform::getSystemType() == 'single'){
$domain = $this->request->domain();
//thinkphp5获取系统的域名,如 baidu.com 去除 https或 http
}else{
$domain = $this->request->domain() . '/app/index.php';
}
$domain = preg_replace('/^(http|https):\/\//i', '', $domain);
try{
$data = \app\common\library\Client::request('api/wechat/auth/getAuthUrl',[
'domain'=>$domain
]);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("获取成功",$data);
}
/**
* 获取版本信息
* @return void
*/
public function getVersionInfo(){
//应该获取授权状态
//小程序版本
try{
$data = \app\common\library\Client::request('api/wechat/auth/versionInfo',[]);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("获取成功",$data);
}
/**
* 获取审核版本信息
* @return void
*/
public function getAuditVersionInfo(){
//应该获取授权状态
//小程序版本
try{
$data = \app\common\library\Client::request('api/wechat/auth/getLatestAuditStatus',[]);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("获取成功",$data);
}
/**
* 提交审核
* @return void
*/
public function submitAudit(){
//应该获取授权状态
//小程序版本
$version_desc = input('version_desc','');
try{
$data = \app\common\library\Client::request('api/wechat/auth/submitAudit',[
'version_desc'=>$version_desc
]);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("提交成功",$data);
}
/**
* 撤回审核
* @return void
*/
public function undoAudit(){
try{
$data = \app\common\library\Client::request('api/wechat/auth/undoAudit',[]);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("撤回审核成功");
}
/**
* 发布已通过审核版本
* @return void
*/
public function release(){
try{
\app\common\library\Client::request('api/wechat/auth/release',[]);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("发布版本成功");
}
/**
* 撤回审核
* @return void
*/
public function getQrcode(){
$path = input('path');
try{
$data = \app\common\library\Client::request('api/wechat/auth/getQrcode',[
'path'=>$path
]);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("操作成功",$data);
}
/**
* 解除小程序绑定
* @return void
*/
public function unbind(){
try{
$data = \app\common\library\Client::request('api/wechat/auth/unbind',[]);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("操作成功");
}
/**
* 获取授权信息
* @return void
*/
public function authorization()
{
try{
$data = \app\common\library\Client::request('api/wechat/auth/authorization',[]);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("获取成功",$data);
}
/**
* 提交代码到体验版
* @return false|void
*/
public function commit(){
try{
$data = \app\common\library\Client::request('api/wechat/auth/commit',[]);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("提交成功",$data);
}
}