From 043e93824b5eb72b6116e4319cf51c8efef7b007 Mon Sep 17 00:00:00 2001 From: filesite Date: Mon, 29 Apr 2024 04:27:56 +0000 Subject: [PATCH] add function to init users data directory --- plugins/Common.php | 24 +++++++++++++++++++ .../tajian/controller/FrontapiController.php | 7 ++++-- themes/tajian/views/layout/main.php | 2 +- www/js/tajian.js | 5 +++- www/tajian/README.md | 4 ++-- www/tajian/README_title.txt | 2 +- 6 files changed, 37 insertions(+), 7 deletions(-) diff --git a/plugins/Common.php b/plugins/Common.php index 7ccf795..01e2d70 100644 --- a/plugins/Common.php +++ b/plugins/Common.php @@ -24,6 +24,30 @@ Class Common { } } + //初始化用户数据目录 + public static function initUserData($cellphone, $friends_code = '') { + $rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory']; + $userDir = "{$rootDir}{$cellphone}"; + if (is_dir($userDir)) { + return true; + } + + try { + mkdir("{$userDir}/data/", 0700, true); //分享视频目录 + mkdir("{$userDir}/tags/", 0700, true); //分类目录 + copy("{$rootDir}README.md", "{$userDir}/README.md"); + copy("{$rootDir}README_title.txt", "{$userDir}/README_title.txt"); + + if (!empty($friends_code)) { + file_put_contents("{$userDir}/README_friendscode.txt", $friends_code); + } + }catch(Exception $e) { + throw new Exception("创建用户数据目录失败:" . $e->getMessage()); + } + + return true; + } + //检查朋友的邀请码是否存在 public static function existFriendsCode($code) { if (self::isFriendsCode($code) == false) {return false;} diff --git a/themes/tajian/controller/FrontapiController.php b/themes/tajian/controller/FrontapiController.php index d5ffa96..862b2f2 100644 --- a/themes/tajian/controller/FrontapiController.php +++ b/themes/tajian/controller/FrontapiController.php @@ -451,6 +451,7 @@ eof; $code = 0; $msg = ''; $err = ''; + $shareUrl = ''; //用户提交的数据检查 $postParams = $this->post(); @@ -475,13 +476,15 @@ eof; $newUser = Common::saveUserIntoSession($cellphone, $friends_code); if (!empty($newUser)) { Common::saveFriendsCode($cellphone); + Common::initUserData($cellphone, $friends_code); + $shareUrl = "/{$cellphone}/"; } - $msg = "注册完成,开始收藏你喜欢的视频吧"; + $msg = "注册完成,开始收藏你喜欢的视频吧,正在为你跳转到专属网址..."; $code = 1; } } - return $this->renderJson(compact('code', 'msg', 'err')); + return $this->renderJson(compact('code', 'msg', 'err', 'shareUrl')); } //用户登录 diff --git a/themes/tajian/views/layout/main.php b/themes/tajian/views/layout/main.php index d5d6f6c..b411276 100644 --- a/themes/tajian/views/layout/main.php +++ b/themes/tajian/views/layout/main.php @@ -121,7 +121,7 @@ if (!empty($viewFile) && file_exists($viewFile)) { HeroUnion英雄联盟 提供技术支持
- 从GitHub下 Machete源码 快速克隆本站 + 从GitHub下 Machete源码 部署到本地 diff --git a/www/js/tajian.js b/www/js/tajian.js index 08ba16f..a141bbb 100644 --- a/www/js/tajian.js +++ b/www/js/tajian.js @@ -238,9 +238,12 @@ if ($('#register_form').get(0)) { }; publicAjax(taJian.apis.register, 'POST', datas, function (data) { btLoading.addClass('elementNone'); - if (data.code == 1) { + if (data.code == 1 && data.shareUrl) { btText.text('完成'); alert(data.msg); + setTimeout(function() { + location.href = data.shareUrl; + }, 100); } else { btText.text('注册'); bt.prop('disabled', false); diff --git a/www/tajian/README.md b/www/tajian/README.md index c75c0b8..aa8bd30 100644 --- a/www/tajian/README.md +++ b/www/tajian/README.md @@ -1,10 +1,10 @@ # Ta荐 - TaJian.tv -每天分享精彩视频,帮你精选来自抖音、快手、西瓜视频、B站-Bilibili的新鲜事实和观点。 +一个好用的视频收藏夹,帮你整理不同平台的好视频,还能轻松分享给朋友! 加我们的微信分享你的想法吧: -![TaJian - a theme of Filesite.io](./wx_jialuoma.jpeg) +![Wechat qr image of TaJian.tv](https://tajian.tv/tajian/wx_jialuoma.jpeg) ### 免责申明 diff --git a/www/tajian/README_title.txt b/www/tajian/README_title.txt index e287891..f666297 100644 --- a/www/tajian/README_title.txt +++ b/www/tajian/README_title.txt @@ -1 +1 @@ -Ta荐 - 分享喜欢的视频给朋友,帮他节省刷视频的时间 \ No newline at end of file +Ta荐:好用的视频收藏夹,帮你整理不同平台的好视频,轻松分享给朋友! \ No newline at end of file