Browse Source

支持指定channel,edit mode

visuddhinanda 2 năm trước cách đây
mục cha
commit
29e5cd7fe9
1 tập tin đã thay đổi với 18 bổ sung8 xóa
  1. 18 8
      app/Http/Resources/TermResource.php

+ 18 - 8
app/Http/Resources/TermResource.php

@@ -38,17 +38,27 @@ class TermResource extends JsonResource
             "updated_at"=> $this->updated_at,
         ];
 
-        if(!empty($this->channal)){
-            $channelId = $this->channal;
-            $data["channel"] = ChannelApi::getById($this->channal);
+
+        if($request->has('channel')){
+            $channels = explode('_',$request->get('channel')) ;
         }else{
-            $channelId = ChannelApi::getSysChannel('_community_translation_'.$this->language.'_');
-            if(empty($channelId)){
-                $channelId = ChannelApi::getSysChannel('_community_translation_zh-hans_');
+            if(!empty($this->channal)){
+                $channelId = $this->channal;
+                $data["channel"] = ChannelApi::getById($this->channal);
+            }else{
+                $channelId = ChannelApi::getSysChannel('_community_translation_'.$this->language.'_');
+                if(empty($channelId)){
+                    $channelId = ChannelApi::getSysChannel('_community_translation_zh-hans_');
+                }
+            }
+            if(!empty($channelId)){
+                $channels = [$channelId];
+            }else{
+               $channels = [];
             }
         }
-        if(!empty($this->note) && !empty($channelId)){
-            $data["html"] = MdRender::render($this->note,[$channelId],null,'read');
+        if(!empty($this->note)){
+            $data["html"] = MdRender::render($this->note,$channels,null,$request->get('mode','read'));
         }
         $user = AuthApi::current($request);
         if(!$user){