Browse Source

Merge pull request #2466 from visuddhinanda/development

Development
visuddhinanda 5 days ago
parent
commit
60727e1fc2

+ 20 - 2
api-v13/app/Http/Api/MdRender.php

@@ -402,8 +402,26 @@ class MdRender
                 $nissayaWord = [];
                 if (is_array($json)) {
                     foreach ($json as $word) {
-                        if (count($word->sn) === 1) {
-                            // 只输出第一层级
+                        if (isset($word->original)) {
+                            // 对齐后的 nissaya json 格式:
+                            // {original, translation, note, confidence}
+                            // translation 用 ">" 分隔多层意思,转成 wiki 模版使用的 "=" 分隔符
+                            $str = '{{nissaya|';
+                            $str .= $word->original;
+                            $str .= '|';
+                            $str .= str_replace(
+                                '>',
+                                '=',
+                                isset($word->translation) ? $word->translation : ''
+                            );
+                            $str .= '}}';
+                            $nissayaWord[] = $str;
+
+                            if (! empty($word->note)) {
+                                $nissayaWord[] = '{{note|'.$word->note.'|[nt]}}';
+                            }
+                        } elseif (isset($word->sn) && count($word->sn) === 1) {
+                            // 逐词解析 wbw json 格式,只输出第一层级
                             $str = '{{nissaya|';
                             if (isset($word->word->value)) {
                                 $str .= $word->word->value;

+ 9 - 13
api-v13/app/Services/PaliContentService.php

@@ -330,19 +330,15 @@ class PaliContentService
                                     "/sent/{$channelId}/{$ids}/{$format}",
                                     config('mint.cache.expire'),
                                     function () use ($row, $mode, $format) {
-                                        if ($row->content_type === 'markdown') {
-                                            return MdRender::render(
-                                                $row->content,
-                                                [$row->channel_uid],
-                                                null,
-                                                $mode,
-                                                'nissaya',
-                                                $row->content_type,
-                                                $format
-                                            );
-                                        } else {
-                                            return null;
-                                        }
+                                        return MdRender::render(
+                                            $row->content,
+                                            [$row->channel_uid],
+                                            null,
+                                            $mode,
+                                            'nissaya',
+                                            $row->content_type,
+                                            $format
+                                        );
                                     }
                                 );
                                 break;

+ 4 - 2
dashboard-v6/src/components/navigation/MainMenu.tsx

@@ -7,6 +7,8 @@ import {
   FileOutlined,
   SettingOutlined,
   PlusOutlined,
+  ToolOutlined,
+  TeamOutlined,
 } from "@ant-design/icons";
 import { useNavigate, useMatches, type UIMatch } from "react-router";
 import {
@@ -281,7 +283,7 @@ const Widget = ({ onSearch }: Props) => {
     },
     {
       key: "/workspace/tools",
-      icon: <CourseOutLinedIcon />,
+      icon: <ToolOutlined />,
       label: intl.formatMessage({ id: "labels.tools" }),
       children: [
         {
@@ -309,7 +311,7 @@ const Widget = ({ onSearch }: Props) => {
     },
     {
       key: "/workspace/collaboration",
-      icon: <CourseOutLinedIcon />,
+      icon: <TeamOutlined />,
       label: intl.formatMessage({ id: "labels.collaboration" }),
       children: [
         {

+ 2 - 2
dashboard-v6/src/components/users/SignIn.tsx

@@ -5,7 +5,7 @@ import { useNavigate, useSearchParams } from "react-router";
 import { EyeInvisibleOutlined, EyeTwoTone } from "@ant-design/icons";
 
 import { useAppDispatch } from "../../hooks";
-import { type IUser, signIn, TO_HOME } from "../../reducers/current-user";
+import { type IUser, signIn, TO_WORKSPACE } from "../../reducers/current-user";
 import { get, post } from "../../request";
 import { useState } from "react";
 import { set } from "../../reducers/session";
@@ -65,7 +65,7 @@ const Widget = () => {
                 if (url) {
                   window.location.href = atob(url);
                 } else {
-                  navigate(TO_HOME);
+                  navigate(TO_WORKSPACE);
                 }
               } else {
                 setError("用户名或密码错误");

+ 7 - 3
dashboard-v6/src/pages/workspace/channel/show.tsx

@@ -1,5 +1,5 @@
 import { useEffect, useState } from "react";
-import { useParams } from "react-router";
+import { useNavigate, useParams } from "react-router";
 import { useIntl } from "react-intl";
 import { Button, Card, Tabs } from "antd";
 import { TeamOutlined } from "@ant-design/icons";
@@ -17,6 +17,7 @@ import TermList from "../../../components/term/TermList";
 
 const Widget = () => {
   const { channelId } = useParams(); //url 参数
+  const navigate = useNavigate();
   const [title, setTitle] = useState<string>();
   const intl = useIntl();
   const channelTitle = intl.formatMessage({
@@ -73,8 +74,11 @@ const Widget = () => {
                         : "";
                       window.open(fullUrl(url), "_blank");
                     } else {
-                      //setParam(chapter);
-                      //setArticleOpen(true);
+                      let url = articlePath(chapter.type, chapter.articleId);
+                      url += chapter?.channelId
+                        ? `?channel=${chapter.channelId}`
+                        : "";
+                      navigate(url);
                     }
                   }}
                 />

+ 1 - 0
dashboard-v6/src/reducers/current-user.ts

@@ -9,6 +9,7 @@ export const ROLE_ADMINISTRATOR = "administrator";
 export const TO_SIGN_IN = "/anonymous/sign-in";
 export const TO_PROFILE = "/dashboard/users/logs";
 export const TO_HOME = "/";
+export const TO_WORKSPACE = "/workspace";
 
 const KEY = "token";
 const STUDIO_KEY = "studio";