Sfoglia il codice sorgente

Merge pull request #946 from visuddhinanda/laravel

wbw edit 标题显示channel名和用户名
visuddhinanda 3 anni fa
parent
commit
7621c2aafa

+ 70 - 0
app/Http/Controllers/ChannelController.php

@@ -0,0 +1,70 @@
+<?php
+
+namespace App\Http\Controllers;
+
+require_once __DIR__.'/../../../public/app/ucenter/function.php';
+
+use App\Models\Channel;
+use Illuminate\Http\Request;
+
+class ChannelController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+		$channel = Channel::where("uid",$id)->select(['name','owner_uid'])->first();
+		$userinfo = new \UserInfo();
+		$channel->owner_info = $userinfo->getName($channel->owner_uid);
+		return $this->ok($channel);
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\Models\Channel  $channel
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, Channel $channel)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\Models\Channel  $channel
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(Channel $channel)
+    {
+        //
+    }
+}

+ 19 - 0
public/app/studio/js/editor.js

@@ -273,6 +273,7 @@ function editor_windowsInit() {
 		case "openchannal":
 		case "openchannel":
 			editor_openChannal(g_book, g_para, g_channal);
+			render_channel_info(g_channal);
 			break;
 		case "import":
 			if (g_filename.length > 0) {
@@ -4099,6 +4100,24 @@ function editor_openChannal(book, para, channal) {
 		}
 	);
 }
+
+function render_channel_info(channel_id){
+	fetch('/api/v2/channel/'+channel_id,{
+        method: 'GET',
+        credentials: 'include',
+        headers: {
+            'Content-Type': 'application/json'
+        }
+    })
+  .then(response => response.json())
+  .then(function(data){
+      console.log(data);
+		let result = data.data;
+		if(data.ok==true){
+			$("#editor_doc_title").html("/" + data.data.owner_info.nickname + "/" + data.data.name);
+		}
+  });
+}
 //open project begin
 var editor_openProjectXmlHttp = null;
 function editor_openProject(strFileId, filetype) {

+ 2 - 0
routes/api.php

@@ -13,6 +13,7 @@ use App\Http\Controllers\ViewController;
 use App\Http\Controllers\LikeController;
 use App\Http\Controllers\SentHistoryController;
 use App\Http\Controllers\PaliTextController;
+use App\Http\Controllers\ChannelController;
 
 
 /*
@@ -43,5 +44,6 @@ Route::group(['prefix' => 'v2'],function(){
     Route::apiResource('like',LikeController::class);
     Route::apiResource('sent_history',SentHistoryController::class);
     Route::apiResource('palitext',PaliTextController::class);
+    Route::apiResource('channel',ChannelController::class);
 
 });