Skip to content

Commit

Permalink
重构了前端页面
Browse files Browse the repository at this point in the history
  • Loading branch information
star7th committed Feb 19, 2018
1 parent d4b4e2a commit 9e4467f
Show file tree
Hide file tree
Showing 900 changed files with 182,350 additions and 20 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
Application/Runtime/
server/Application/Runtime/

web_src/.DS_Store
web_src/node_modules/
web_src/dist/
web_src/npm-debug.log*
web_src/yarn-debug.log*
web_src/yarn-error.log*
web_src//test/unit/coverage/
web_src//test/e2e/reports/
web_src/selenium-debug.log

# Editor directories and files
web_src/.idea
web_src/.vscode
web_src/*.suo
web_src/*.ntvs*
web_src/*.njsproj
web_src/*.sln
5 changes: 5 additions & 0 deletions Application/Home/Controller/IndexController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ public function index(){
header("location:./install");
exit();
}

//跳转到web目录
header("location:./web/#/");
exit();

$this->checkLogin(false);
$login_user = session("login_user");
$this->assign("login_user" ,$login_user);
Expand Down
10 changes: 10 additions & 0 deletions Application/Home/Controller/ItemController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ItemController extends BaseController {
public function index(){
$login_user = $this->checkLogin();

//跳转到web目录
header("location:./web/#/item/index");
exit();

$share_url = get_domain().__APP__.'/uid/'.$login_user['uid'];

Expand Down Expand Up @@ -49,13 +52,20 @@ public function show(){
$item_id = I("item_id/d");
$item_domain = I("item_domain/s");
$current_page_id = I("page_id/d");

//判断个性域名
if ($item_domain) {
$item = D("Item")->where("item_domain = '%s'",array($item_domain))->find();
if ($item['item_id']) {
$item_id = $item['item_id'] ;
}
}

//跳转到web目录
header("location:./web/#/".$item_id."?page_id=".$current_page_id);
exit();


$login_user = session("login_user");
$uid = $login_user['uid'] ? $login_user['uid'] : 0 ;

Expand Down
7 changes: 6 additions & 1 deletion Application/Home/Controller/PageController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ public function index(){

//展示单个页面
public function single(){
import("Vendor.Parsedown.Parsedown");
$page_id = I("page_id/d");

//跳转到web目录
header("location:./web/#/page/".$page_id);
exit();

import("Vendor.Parsedown.Parsedown");
$page = D("Page")->where(" page_id = '$page_id' ")->find();
$login_user = $this->checkLogin(false);
if (!$this->checkItemVisit($login_user['uid'] , $page['item_id'],$_SERVER['REQUEST_URI'])) {
Expand Down
11 changes: 11 additions & 0 deletions Application/Home/Controller/UserController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ class UserController extends BaseController {

//注册
public function register(){

//跳转到web目录
header("location:./web/#/user/register");
exit();

if (!IS_POST) {
$this->assign('CloseVerify',C('CloseVerify'));
$this->display ();
Expand Down Expand Up @@ -44,6 +49,12 @@ public function register(){
//登录
public function login()
{

//跳转到web目录
header("location:./web/#/user/login");
exit();


if (!IS_POST) {
//如果有cookie记录,则自动登录
$cookie_token = cookie('cookie_token');
Expand Down
18 changes: 18 additions & 0 deletions install/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
function user_sqlite(){
clear_runtime();//清除缓存
write_home_config();
write_js_lang();
$config =
<<<EOD
<?php
Expand Down Expand Up @@ -128,3 +129,20 @@ function write_home_config(){
$ret = file_put_contents("../Application/Home/Conf/config.php", $config);

}

function write_js_lang(){
$lang = $_REQUEST['lang'] ? $_REQUEST['lang'] :"zh";
if ($lang == 'en') {
replace_file_content("../web/index.html","zh-cn","en") ;
replace_file_content("../web_src/index.html","zh-cn","en") ;
}

}

function replace_file_content($file , $from ,$to ){
$content = file_get_contents($file);
$content2 = str_replace($from,$to,$content);
if ($content2) {
file_put_contents($file,$content2);
}
}
10 changes: 10 additions & 0 deletions install/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
$go = 0;
}

if(!new_is_writeable("../web/index.html")){
echo L("not_writable_web_docconfig").'<br>';
$go = 0;
}

if(!new_is_writeable("../web_src/index.html")){
echo L("not_writable_web_src_docconfig").'<br>';
$go = 0;
}

//检查扩展
if(!extension_loaded("gd")){
echo '请安装php-gd<br>';
Expand Down
2 changes: 2 additions & 0 deletions install/lang.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"not_writable_home_config"=>'File Application/Home/Conf/config.php is not writable !',
"not_writable_sqlite"=>'Directory Sqlite is not writable !',
"not_writable_sqlite_db"=>'File Sqlite/showdoc.db.php is not writable !',
"not_writable_web_docconfig"=>'File web/index.html is not writable !',
"not_writable_web_src_docconfig"=>'File web_src/index.html is not writable !',
"install_success"=>'Installation success!Please delete the /install directory, avoid the script to be executed again',
"install_config_not_writable"=>'Fail to write config file ',
"db_wrong"=>'Database connection error',
Expand Down
2 changes: 2 additions & 0 deletions install/lang.zh.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"not_writable_home_config"=>'请赋予 Application/Home/Conf/config.php 文件以可写权限!<br>(如果你确定赋予了文件权限但却一直看到此信息,则可考虑关闭selinux试试)',
"not_writable_sqlite"=>'请赋予 Sqlite 目录以可写权限!',
"not_writable_sqlite_db"=>'请赋予 Sqlite/showdoc.db.php 以可写权限!',
"not_writable_web_docconfig"=>'请赋予 web/index.html 以可写权限!',
"not_writable_web_src_docconfig"=>'请赋予 web_src/index.html 以可写权限!',
"install_success"=>'安装成功!建议删除install目录,以免安装脚本被再次执行。',
"install_config_not_writable"=>'安装失败,配置文件写入错误!',
"db_wrong"=>'数据库链接错误,请检查配置信息是否填写正确',
Expand Down
9 changes: 8 additions & 1 deletion server/Application/Api/Controller/BaseController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
class BaseController extends Controller {

public function checkLogin($redirect = true){

//debug
//$login_user = D("User")->where("username = 'showdoc' ")->find();
//session("login_user" , $login_user);

if ( ! session("login_user")) {
$cookie_token = cookie('cookie_token');
if ($cookie_token) {
Expand Down Expand Up @@ -37,7 +42,9 @@ protected function sendResult($array){
$result['error_code'] = 0 ;
$result['data'] = $array ;
}
//header('Access-Control-Allow-Origin: *');//允许跨域请求
//header('Access-Control-Allow-Origin: http://127.0.0.1:8080');//允许跨域请求
//header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie');
//header('Access-Control-Allow-Credentials : true');//允许跨域请求
echo json_encode($result);

//如果开启API调试模式,则记录请求参数和返回结果
Expand Down
100 changes: 91 additions & 9 deletions server/Application/Api/Controller/CatalogController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ public function catList(){
if ($ret) {
$this->sendResult($ret);
}else{
$return['error_code'] = 10103 ;
$return['error_message'] = 'request fail' ;
$this->sendResult($return);
$this->sendResult(array());
}
}

Expand All @@ -37,9 +35,42 @@ public function secondCatList(){
if ($ret) {
$this->sendResult($ret);
}else{
$return['error_code'] = 10103 ;
$return['error_message'] = 'request fail' ;
$this->sendResult($return);
$this->sendResult(array());
}
}

//获取目录列表
public function catListGroup(){
$login_user = $this->checkLogin();
$item_id = I("item_id/d");
if (!$this->checkItemVisit($login_user['uid'] , $item_id)) {
$this->sendError(10103);
return ;
}
if ($item_id > 0 ) {
$ret = D("Catalog")->where(" item_id = '$item_id' and level = 2 ")->order(" s_number, addtime asc ")->select();
if (!empty($ret)) {
foreach ($ret as $key => &$value) {
$value['addtime'] = date("Y-m-d H:i:s",$value['addtime']) ;
$ret2 = D("Catalog")->where(" parent_cat_id = '$value[cat_id]' ")->order(" s_number, addtime asc ")->select();
if (empty($ret2)) {
$value['sub'] = array() ;
}else{
foreach ($ret2 as $key2 => $value2) {
$ret2[$key2]['addtime'] = date("Y-m-d H:i:s",$value2['addtime']) ;
}
$value['sub'] = $ret2 ;
}


}
}

}
if ($ret) {
$this->sendResult($ret);
}else{
$this->sendResult(array());
}
}

Expand All @@ -52,9 +83,7 @@ public function childCatList(){
if ($ret) {
$this->sendResult($ret);
}else{
$return['error_code'] = 10103 ;
$return['error_message'] = 'request fail' ;
$this->sendResult($return);
$this->sendResult(array());
}
}

Expand Down Expand Up @@ -139,4 +168,57 @@ public function delete(){
$this->sendResult($return);
}
}

//编辑页面时,自动帮助用户选中目录
//选中的规则是:编辑页面则选中该页面目录,复制页面则选中目标页面目录;
// 如果是恢复历史页面则使用历史页面的目录,如果都没有则选中用户上次使用的目录
public function getDefaultCat(){
$login_user = $this->checkLogin();
$page_id = I("page_id/d");
$item_id = I("item_id/d");
$page_history_id = I("page_history_id/d");
$copy_page_id = I("copy_page_id/d");

if ($page_id > 0 ) {
if ($page_history_id) {
$page = D("PageHistory")->where(" page_history_id = '$page_history_id' ")->find();
}else{
$page = M("Page")->where(" page_id = '$page_id' ")->find();
}
$default_cat_id = $page['cat_id'];
}
//如果是复制接口
elseif ($copy_page_id) {
$copy_page = M("Page")->where(" page_id = '$copy_page_id' ")->find();
$page['item_id'] = $copy_page['item_id'];
$default_cat_id = $copy_page['cat_id'];

}else{
//查找用户上一次设置的目录
$last_page = D("Page")->where(" author_uid ='$login_user[uid]' and item_id = '$item_id' ")->order(" addtime desc ")->limit(1)->find();
$default_cat_id = $last_page['cat_id'];


}

$item_id = $page['item_id'] ?$page['item_id'] :$item_id;


if (!$this->checkItemPermn($login_user['uid'] , $item_id)) {
$this->message(L('no_permissions'));
return;
}

$Catalog = D("Catalog")->where(" cat_id = '$default_cat_id' ")->find();
if ($Catalog['parent_cat_id']) {
$default_cat_id2 = $Catalog['parent_cat_id'];
$default_cat_id3 = $default_cat_id;

}else{
$default_cat_id2 = $default_cat_id;
}
$this->sendResult(array("default_cat_id2"=>$default_cat_id2 , "default_cat_id3"=>$default_cat_id3));
}


}
Loading

0 comments on commit 9e4467f

Please sign in to comment.