فهرست منبع

Merge branch 'laravel' of https://github.com/iapt-platform/mint into laravel

bhikkhu-kosalla-china 4 سال پیش
والد
کامیت
c23295f65b
75فایلهای تغییر یافته به همراه1529 افزوده شده و 75 حذف شده
  1. 1 0
      app/Http/Controllers/DhammaTermController.php
  2. 1 0
      app/Http/Kernel.php
  3. 39 0
      app/Http/Middleware/EnableCrossRequestMiddleware.php
  4. 1 5
      dashboard/.umirc.ts
  5. 55 67
      dashboard/src/pages/demo/day-4.tsx
  6. 13 0
      material-ui/.gitignore
  7. 13 0
      material-ui/README.md
  8. 77 0
      material-ui/package.json
  9. BIN
      material-ui/public/favicon.ico
  10. 43 0
      material-ui/public/index.html
  11. BIN
      material-ui/public/logo192.png
  12. BIN
      material-ui/public/logo512.png
  13. 25 0
      material-ui/public/manifest.json
  14. 3 0
      material-ui/public/robots.txt
  15. 10 0
      material-ui/src/404.tsx
  16. 22 0
      material-ui/src/components/form.tsx
  17. 5 0
      material-ui/src/hooks.ts
  18. 4 0
      material-ui/src/index.css
  19. 51 0
      material-ui/src/index.tsx
  20. 65 0
      material-ui/src/layouts/Copyright.tsx
  21. 40 0
      material-ui/src/layouts/application/index.tsx
  22. 5 0
      material-ui/src/layouts/dashboard/index.tsx
  23. 28 0
      material-ui/src/locales/en-US.ts
  24. 30 0
      material-ui/src/locales/index.ts
  25. 5 0
      material-ui/src/locales/zh-Hans.ts
  26. 5 0
      material-ui/src/locales/zh-Hant.ts
  27. 2 0
      material-ui/src/logo.svg
  28. 32 0
      material-ui/src/plugins/demo/index.tsx
  29. 6 0
      material-ui/src/plugins/demo/posts/edit.tsx
  30. 6 0
      material-ui/src/plugins/demo/posts/index.tsx
  31. 6 0
      material-ui/src/plugins/demo/posts/new.tsx
  32. 6 0
      material-ui/src/plugins/demo/topics/edit.tsx
  33. 6 0
      material-ui/src/plugins/demo/topics/index.tsx
  34. 6 0
      material-ui/src/plugins/demo/topics/new.tsx
  35. 16 0
      material-ui/src/plugins/index.tsx
  36. 25 0
      material-ui/src/plugins/nut/home.tsx
  37. 36 0
      material-ui/src/plugins/nut/index.tsx
  38. 130 0
      material-ui/src/plugins/nut/install.tsx
  39. 103 0
      material-ui/src/plugins/nut/users/NonSignInLayout.tsx
  40. 33 0
      material-ui/src/plugins/nut/users/confirm.tsx
  41. 33 0
      material-ui/src/plugins/nut/users/forgot-password.tsx
  42. 6 0
      material-ui/src/plugins/nut/users/logs.tsx
  43. 6 0
      material-ui/src/plugins/nut/users/reset-password.tsx
  44. 43 0
      material-ui/src/plugins/nut/users/sign-in.tsx
  45. 70 0
      material-ui/src/plugins/nut/users/sign-up.tsx
  46. 33 0
      material-ui/src/plugins/nut/users/unlock.tsx
  47. 6 0
      material-ui/src/plugins/nut/users/update-profile.tsx
  48. 1 0
      material-ui/src/react-app-env.d.ts
  49. 40 0
      material-ui/src/reducers/current-user.ts
  50. 35 0
      material-ui/src/reducers/site-info.ts
  51. 15 0
      material-ui/src/reportWebVitals.ts
  52. 1 0
      material-ui/src/request.ts
  53. 5 0
      material-ui/src/setupTests.ts
  54. 17 0
      material-ui/src/store.ts
  55. 26 0
      material-ui/tsconfig.json
  56. 161 1
      public/app/term/note.js
  57. 19 2
      public/app/term/term.css
  58. 3 0
      public/app/users_guide/zh-cn/grammar_my_abl1.md
  59. 3 0
      public/app/users_guide/zh-cn/grammar_my_abl2.md
  60. 3 0
      public/app/users_guide/zh-cn/grammar_my_abl3.md
  61. 3 0
      public/app/users_guide/zh-cn/grammar_my_abs.md
  62. 3 0
      public/app/users_guide/zh-cn/grammar_my_acc1.md
  63. 3 0
      public/app/users_guide/zh-cn/grammar_my_acc2.md
  64. 3 0
      public/app/users_guide/zh-cn/grammar_my_dat1.md
  65. 3 0
      public/app/users_guide/zh-cn/grammar_my_dat2.md
  66. 3 0
      public/app/users_guide/zh-cn/grammar_my_gen1.md
  67. 4 0
      public/app/users_guide/zh-cn/grammar_my_gen2.md
  68. 3 0
      public/app/users_guide/zh-cn/grammar_my_inst1.md
  69. 3 0
      public/app/users_guide/zh-cn/grammar_my_inst2.md
  70. 4 0
      public/app/users_guide/zh-cn/grammar_my_inst3.md
  71. 3 0
      public/app/users_guide/zh-cn/grammar_my_loc1.md
  72. 3 0
      public/app/users_guide/zh-cn/grammar_my_loc2.md
  73. 5 0
      public/app/users_guide/zh-cn/grammar_my_nom1.md
  74. 3 0
      public/app/users_guide/zh-cn/grammar_my_nom2.md
  75. 3 0
      public/app/users_guide/zh-cn/grammar_my_nom3.md

+ 1 - 0
app/Http/Controllers/DhammaTermController.php

@@ -51,6 +51,7 @@ class DhammaTermController extends Controller
 									->where('word', $request->get("word"))
 									->orderBy('created_at','desc')
 									->get();
+                $count = count($result);
 				break;
             case 'hot-meaning':
                 $key='term/hot_meaning';

+ 1 - 0
app/Http/Kernel.php

@@ -21,6 +21,7 @@ class Kernel extends HttpKernel
         \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
         \App\Http\Middleware\TrimStrings::class,
         \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
+        \App\Http\Middleware\EnableCrossRequestMiddleware::class,
     ];
 
     /**

+ 39 - 0
app/Http/Middleware/EnableCrossRequestMiddleware.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+use Illuminate\Http\Request;
+
+class EnableCrossRequestMiddleware
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse)  $next
+     * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
+     */
+    public function handle(Request $request, Closure $next)
+    {
+                $response = $next($request);
+        $origin = $request->server('HTTP_ORIGIN') ? $request->server('HTTP_ORIGIN') : '';
+        $allow_origin = [
+            env("CROSS_REQUEST_ALLOW_ORIGIN",'http://localhost:8001'),
+        ];
+        if (in_array($origin, $allow_origin)) {
+            $response->header('Access-Control-Allow-Origin', $origin);
+            $response->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Cookie, X-CSRF-TOKEN, Accept, Authorization, X-XSRF-TOKEN');
+            $response->header('Access-Control-Expose-Headers', 'Authorization, authenticated');
+            $response->header('Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, OPTIONS');
+            $response->header('Access-Control-Allow-Credentials', 'true');
+        }
+        /*
+        ————————————————
+        原文作者:qbhy
+        转自链接:https://learnku.com/articles/6504/laravel-cross-domain-solution
+        版权声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请保留以上作者信息和原文链接。
+        */
+        return $next($request);
+    }
+}

+ 1 - 5
dashboard/.umirc.ts

@@ -6,9 +6,5 @@ export default defineConfig({
 	},
 	base: '/my/',
 	fastRefresh: {},
-	layout: {
-		name: 'wikipali',
-		locale: true,
-		layout: 'side',
-	}
+
 });

+ 55 - 67
dashboard/src/pages/demo/day-4.tsx

@@ -13,62 +13,24 @@ const { Link } = Anchor;
 message.config({
 	maxCount: 4
 });
-//表数据
-const dataSource = [
-	{
-		key: '1',
-		name: 'name1',
-		age: 32,
-		adress: "西湖南路"
-	},
-	{
-		key: '2',
-		name: 'name2',
-		age: 34,
-		adress: '西湖公园'
-	},
-	{
-		key: '3',
-		name: 'name1',
-		age: 32,
-		adress: "西湖南路"
-	},
-	{
-		key: '4',
-		name: 'name2',
-		age: 34,
-		adress: '西湖公园'
-	},
-	{
-		key: '5',
-		name: 'name1',
-		age: 32,
-		adress: "西湖南路"
-	},
-	{
-		key: '6',
-		name: 'name2',
-		age: 34,
-		adress: '西湖公园'
-	}
-]
+
 //表头
 const columns = [
 	{
-		title: 'Id',
-		dataIndex: 'id',
-		key: 'id',
+		title: 'word',
+		dataIndex: 'word',
+		key: 'word',
 		render: text => <a>{text}</a>,
 	},
 	{
-		title: 'user_id',
-		dataIndex: 'user_id',
-		key: 'user_id',
+		title: '意思',
+		dataIndex: 'meaning',
+		key: 'meaning',
 	},
 	{
-		title: "title",
-		dataIndex: 'title',
-		key: 'title',
+		title: "其他意思",
+		dataIndex: 'other_meaning',
+		key: 'other_meaning',
 	}
 ]
 
@@ -101,15 +63,17 @@ export default () => {
 	const [tableData, setTableData] = useState();
 
 
-	function getTableData(){
-		fetch('https://gorest.co.in/public-api/posts')
+	function getTableData(e){
+        //let url='https://gorest.co.in/public-api/posts';
+        let url='http://127.0.0.1:8000/api/v2/terms?view=word&word=dhamma';
+		fetch(url)
 			.then(function (response) {
 				console.log("ajex:", response);
 				return response.json();
 			})
 			.then(function (myJson) {
 				console.log("ajex",myJson.data);
-				setTableData(myJson.data);
+				setTableData(myJson.data.rows);
 			});		
 	}
 	function pageChange(page: number, pagesize?: number | undefined) {
@@ -125,14 +89,15 @@ export default () => {
 			<Header className="header">
 				<div className="logo" />
 
-				<Menu onClick={handleClick} theme="dark" mode="horizontal" defaultSelectedKeys={['2']}>
+				<Menu onClick={handleClick} theme="dark" mode="horizontal" defaultSelectedKeys={['1']}>
 					<Menu.Item key="0">
 						<WidgetCommitNofifiction time={commitTime} message={commitMsg} successful={commitStatus} />
 					</Menu.Item>
-					<Menu.Item key="1" onClick={getTableData}>Palicanon</Menu.Item>
-					<Menu.Item key="2">Course</Menu.Item>
-					<Menu.Item key="3">nav 3</Menu.Item>
-					<SubMenu key="submenu" icon={<UserOutlined />} title="Others">
+					<Menu.Item key="1" >圣典</Menu.Item>
+					<Menu.Item key="2">课程</Menu.Item>
+					<Menu.Item key="3">字典</Menu.Item>
+					<Menu.Item key="3">文集</Menu.Item>
+					<SubMenu key="submenu" icon={<UserOutlined />} title="更多">
 						<Menu.ItemGroup title="group1">
 							<Menu.Item key="4">option1</Menu.Item>
 							<Menu.Item key="5">option2</Menu.Item>
@@ -148,24 +113,47 @@ export default () => {
 			</Header>
 			<Layout>
 				<Affix offsetTop={top}>
-					<Sider className="site-layout-background">
+					<Sider 
+                        className="site-layout-background"
+                        breakpoint="lg"
+                        collapsedWidth="0"
+                        onBreakpoint={broken => {
+                            console.log(broken);
+                        }}
+                        onCollapse={(collapsed, type) => {
+                            console.log(collapsed, type);
+                        }}
+                    >
 						<Menu
 							mode="inline"
 							defaultSelectedKeys={['1']}
 							defaultOpenKeys={['sub1']}
 							style={{ height: '100%', borderRight: 0 }}
+                            onClick={getTableData}
 						>
-							<SubMenu key="sub1" icon={<UserOutlined />} title="subnav 1">
-								<Menu.Item key="1">option1</Menu.Item>
-								<Menu.Item key="2">option2</Menu.Item>
-								<Menu.Item key="3">option3</Menu.Item>
-								<Menu.Item key="4">option4</Menu.Item>
+							<SubMenu key="sutta" icon={<UserOutlined />} title="经藏">
+								<Menu.Item key="dn">长部</Menu.Item>
+								<Menu.Item key="mn">中部</Menu.Item>
+								<Menu.Item key="sn">相应部</Menu.Item>
+								<Menu.Item key="an">增支部</Menu.Item>
+								<Menu.Item key="kn">小部</Menu.Item>
+							</SubMenu>
+							<SubMenu key="vinaya" icon={<UserOutlined />} title="律藏">
+								<Menu.Item key="6">分别</Menu.Item>
+								<Menu.Item key="7">篇章</Menu.Item>
+								<Menu.Item key="8">附录</Menu.Item>
+							</SubMenu>
+							<SubMenu key="abhidhamma" icon={<UserOutlined />} title="阿毗达摩藏">
+								<Menu.Item key="9">法集论</Menu.Item>
+								<Menu.Item key="10">option2</Menu.Item>
+								<Menu.Item key="11">option3</Menu.Item>
+								<Menu.Item key="12">option4</Menu.Item>
 							</SubMenu>
-							<SubMenu key="sub2" icon={<UserOutlined />} title="subnav 2">
-								<Menu.Item key="5">option1</Menu.Item>
-								<Menu.Item key="6">option2</Menu.Item>
-								<Menu.Item key="7">option3</Menu.Item>
-								<Menu.Item key="8">option4</Menu.Item>
+							<SubMenu key="others" icon={<UserOutlined />} title="其他">
+								<Menu.Item key="9">法集论</Menu.Item>
+								<Menu.Item key="10">option2</Menu.Item>
+								<Menu.Item key="11">option3</Menu.Item>
+								<Menu.Item key="12">option4</Menu.Item>
 							</SubMenu>
 						</Menu>
 					</Sider>

+ 13 - 0
material-ui/.gitignore

@@ -0,0 +1,13 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules/
+/yarn.lock
+
+# testing
+
+# production
+/build/
+
+# misc
+/.env.*.local

+ 13 - 0
material-ui/README.md

@@ -0,0 +1,13 @@
+# Dashboard
+
+## Install dependencies
+
+```bash
+yarn install
+```
+
+### `yarn start`
+
+Runs the app in the development mode. Open [http://localhost:3000/my/](http://localhost:3000/my/) to view it in the browser.
+
+The page will reload if you make edits. You will also see any lint errors in the console.

+ 77 - 0
material-ui/package.json

@@ -0,0 +1,77 @@
+{
+    "name": "iapt",
+    "version": "0.1.0",
+    "private": true,
+    "homepage": "/my/",
+    "dependencies": {
+        "@emotion/react": "^11.8.2",
+        "@emotion/styled": "^11.8.1",
+        "@fontsource/roboto": "^4.5.3",
+        "@loadable/component": "^5.15.2",
+        "@mui/icons-material": "^5.5.0",
+        "@mui/material": "^5.5.0",
+        "@reduxjs/toolkit": "^1.8.0",
+        "@testing-library/jest-dom": "^5.14.1",
+        "@testing-library/react": "^12.0.0",
+        "@testing-library/user-event": "^13.2.1",
+        "@types/jest": "^27.0.1",
+        "@types/loadable__component": "^5.13.4",
+        "@types/node": "^16.7.13",
+        "@types/react": "^17.0.20",
+        "@types/react-dom": "^17.0.9",
+        "@types/react-redux": "^7.1.23",
+        "dinero.js": "^2.0.0-alpha.8",
+        "emoji-mart": "^3.0.1",
+        "google-map-react": "^2.1.10",
+        "js-cookie": "^3.0.1",
+        "jwt-decode": "^3.1.2",
+        "material-design-icons": "^3.0.1",
+        "moment": "^2.29.1",
+        "moment-timezone": "^0.5.34",
+        "qrcode.react": "^2.0.0",
+        "react": "^17.0.2",
+        "react-color": "^2.19.3",
+        "react-copy-to-clipboard": "^5.0.4",
+        "react-dom": "^17.0.2",
+        "react-dropzone": "^12.0.4",
+        "react-helmet-async": "^1.2.3",
+        "react-highlight-words": "^0.17.0",
+        "react-hook-form": "^7.27.1",
+        "react-intl": "^5.24.6",
+        "react-json-view": "^1.21.3",
+        "react-markdown": "^8.0.0",
+        "react-quill": "^2.0.0-beta.4",
+        "react-redux": "^7.2.6",
+        "react-router-dom": "6",
+        "react-scripts": "5.0.0",
+        "react-sparklines": "^1.7.0",
+        "react-syntax-highlighter": "^15.4.5",
+        "typescript": "^4.4.2",
+        "video.js": "^7.17.0",
+        "web-vitals": "^2.1.0"
+    },
+    "scripts": {
+        "start": "react-scripts start",
+        "build": "react-scripts build",
+        "test": "react-scripts test",
+        "eject": "react-scripts eject"
+    },
+    "eslintConfig": {
+        "extends": [
+            "react-app",
+            "react-app/jest"
+        ]
+    },
+    "browserslist": {
+        "production": [
+            ">0.2%",
+            "not dead",
+            "not op_mini all"
+        ],
+        "development": [
+            "last 1 chrome version",
+            "last 1 firefox version",
+            "last 1 safari version"
+        ]
+    }
+}

BIN
material-ui/public/favicon.ico


+ 43 - 0
material-ui/public/index.html

@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8" />
+    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
+    <meta name="viewport" content="width=device-width, initial-scale=1" />
+    <meta name="theme-color" content="#000000" />
+    <meta
+      name="description"
+      content="Web site created using create-react-app"
+    />
+    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
+    <!--
+      manifest.json provides metadata used when your web app is installed on a
+      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
+    -->
+    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
+    <!--
+      Notice the use of %PUBLIC_URL% in the tags above.
+      It will be replaced with the URL of the `public` folder during the build.
+      Only files inside the `public` folder can be referenced from the HTML.
+
+      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
+      work correctly both with client-side routing and a non-root public URL.
+      Learn how to configure a non-root public URL by running `npm run build`.
+    -->
+    <title>React App</title>
+  </head>
+  <body>
+    <noscript>You need to enable JavaScript to run this app.</noscript>
+    <div id="root"></div>
+    <!--
+      This HTML file is a template.
+      If you open it directly in the browser, you will see an empty page.
+
+      You can add webfonts, meta tags, or analytics to this file.
+      The build step will place the bundled scripts into the <body> tag.
+
+      To begin the development, run `npm start` or `yarn start`.
+      To create a production bundle, use `npm run build` or `yarn build`.
+    -->
+  </body>
+</html>

BIN
material-ui/public/logo192.png


BIN
material-ui/public/logo512.png


+ 25 - 0
material-ui/public/manifest.json

@@ -0,0 +1,25 @@
+{
+  "short_name": "React App",
+  "name": "Create React App Sample",
+  "icons": [
+    {
+      "src": "favicon.ico",
+      "sizes": "64x64 32x32 24x24 16x16",
+      "type": "image/x-icon"
+    },
+    {
+      "src": "logo192.png",
+      "type": "image/png",
+      "sizes": "192x192"
+    },
+    {
+      "src": "logo512.png",
+      "type": "image/png",
+      "sizes": "512x512"
+    }
+  ],
+  "start_url": ".",
+  "display": "standalone",
+  "theme_color": "#000000",
+  "background_color": "#ffffff"
+}

+ 3 - 0
material-ui/public/robots.txt

@@ -0,0 +1,3 @@
+# https://www.robotstxt.org/robotstxt.html
+User-agent: *
+Disallow:

+ 10 - 0
material-ui/src/404.tsx

@@ -0,0 +1,10 @@
+import { useIntl } from "react-intl";
+
+import Layout from "./layouts/application";
+
+function Widget() {
+  const intl = useIntl();
+  return <Layout title={intl.formatMessage({ id: "404.title" })}>aaa</Layout>;
+}
+
+export default Widget;

+ 22 - 0
material-ui/src/components/form.tsx

@@ -0,0 +1,22 @@
+export const REAL_NAME_VALIDATOR = {
+  required: true,
+  minLength: 2,
+  maxLength: 32,
+};
+export const NICK_NAME_VALIDATOR = {
+  required: true,
+  minLength: 2,
+  maxLength: 32,
+  pattern: /[\\.\w-]{6,32}/,
+};
+export const EMAIL_VALIDATOR = {
+  required: true,
+  minLength: 6,
+  maxLength: 255,
+  pattern: /^[\\.a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
+};
+export const PASSWORD_VALIDATOR = {
+  required: true,
+  minLength: 6,
+  maxLength: 64,
+};

+ 5 - 0
material-ui/src/hooks.ts

@@ -0,0 +1,5 @@
+import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";
+import type { RootState, AppDispatch } from "./store";
+
+export const useAppDispatch = () => useDispatch<AppDispatch>();
+export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;

+ 4 - 0
material-ui/src/index.css

@@ -0,0 +1,4 @@
+body {
+  margin: 0;
+  padding: 0;
+}

+ 51 - 0
material-ui/src/index.tsx

@@ -0,0 +1,51 @@
+import "@fontsource/roboto/300.css";
+import "@fontsource/roboto/400.css";
+import "@fontsource/roboto/500.css";
+import "@fontsource/roboto/700.css";
+import "material-design-icons/iconfont/material-icons.css";
+import "react-quill/dist/quill.snow.css";
+
+import "./index.css";
+
+import React from "react";
+import ReactDOM from "react-dom";
+import { IntlProvider } from "react-intl";
+import { BrowserRouter, Route, Routes } from "react-router-dom";
+import { Provider } from "react-redux";
+import CachedOutlinedIcon from "@mui/icons-material/CachedOutlined";
+import loadable from "@loadable/component";
+
+import plugins from "./plugins";
+import { get as getLocale, messages as getMessages } from "./locales";
+import NotFound from "./404";
+import reportWebVitals from "./reportWebVitals";
+import store from "./store";
+
+const lang = getLocale();
+const messages = getMessages(lang);
+
+ReactDOM.render(
+  <React.StrictMode>
+    <Provider store={store}>
+      <IntlProvider messages={messages} locale={lang}>
+        <BrowserRouter basename="/my/">
+          <Routes>
+            {plugins.routes.map((it) => {
+              const W = loadable(it.component, {
+                fallback: <CachedOutlinedIcon />,
+              });
+              return <Route key={it.path} path={it.path} element={<W />} />;
+            })}
+            <Route path="*" element={<NotFound />} />
+          </Routes>
+        </BrowserRouter>
+      </IntlProvider>
+    </Provider>
+  </React.StrictMode>,
+  document.getElementById("root")
+);
+
+// If you want to start measuring performance in your app, pass a function
+// to log results (for example: reportWebVitals(console.log))
+// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
+reportWebVitals();

+ 65 - 0
material-ui/src/layouts/Copyright.tsx

@@ -0,0 +1,65 @@
+import Typography from "@mui/material/Typography";
+import Link from "@mui/material/Link";
+import GitHubIcon from "@mui/icons-material/GitHub";
+import HomeIcon from "@mui/icons-material/Home";
+import { FormattedMessage } from "react-intl";
+import Stack from "@mui/material/Stack";
+import { Helmet } from "react-helmet-async";
+
+import { refresh, selectSiteInfo } from "../reducers/site-info";
+import { useAppSelector, useAppDispatch } from "../hooks";
+import { set as setLocale } from "../locales";
+
+interface IProps {
+    title: string;
+}
+
+const Widget = (props: IProps) => {
+    const site = useAppSelector(selectSiteInfo);
+    const dispatch = useAppDispatch();
+    if (site.languages.length === 0) {
+        dispatch(
+            refresh({
+                title: "demo",
+                subhead: "test",
+                copyright: `${new Date().getFullYear()}`,
+                languages: ["en-US"],
+            })
+        );
+    }
+    return (
+        <Stack spacing={2} direction="row">
+            <Helmet>
+                <title>
+                    {props.title} | {site.title}
+                </title>
+            </Helmet>
+            <Typography variant="body2" color="text.secondary" align="center">
+                ©{site.copyright}
+            </Typography>
+            <Link
+                color="inherit"
+                target="_blank"
+                href="https://github.com/iapt-platform/mint"
+            >
+                <GitHubIcon />
+            </Link>
+            <Link color="inherit" target="_blank" href="/">
+                <HomeIcon />
+            </Link>
+            {site.languages.map((it) => (
+                <Link
+                    onClick={() => {
+                        setLocale(it);
+                        window.location.reload();
+                    }}
+                    key={it}
+                >
+                    <FormattedMessage id={`languages.${it}`} />
+                </Link>
+            ))}
+        </Stack>
+    );
+};
+
+export default Widget;

+ 40 - 0
material-ui/src/layouts/application/index.tsx

@@ -0,0 +1,40 @@
+import { ReactNode } from "react";
+import CssBaseline from "@mui/material/CssBaseline";
+import Box from "@mui/material/Box";
+import Container from "@mui/material/Container";
+import { createTheme, ThemeProvider } from "@mui/material/styles";
+import { HelmetProvider } from "react-helmet-async";
+
+import Copyright from "../Copyright";
+
+const theme = createTheme();
+
+interface IProps {
+  title: string;
+  children: ReactNode;
+}
+
+function Widget({ title, children }: IProps) {
+  return (
+    <HelmetProvider>
+      <ThemeProvider theme={theme}>
+        <Container component="main" maxWidth="xs">
+          <CssBaseline />
+          <Box
+            sx={{
+              marginTop: 8,
+              display: "flex",
+              flexDirection: "column",
+              alignItems: "center",
+            }}
+          >
+            {children}
+          </Box>
+          <Copyright title={title} />
+        </Container>
+      </ThemeProvider>
+    </HelmetProvider>
+  );
+}
+
+export default Widget;

+ 5 - 0
material-ui/src/layouts/dashboard/index.tsx

@@ -0,0 +1,5 @@
+function Widget() {
+  return <div>dashboard layout</div>;
+}
+
+export default Widget;

+ 28 - 0
material-ui/src/locales/en-US.ts

@@ -0,0 +1,28 @@
+const items = {
+  "buttons.search": "Search",
+  "buttons.submit": "Submit",
+
+  "fields.email": "Email address",
+  "fields.real-name": "Real name",
+  "fields.nick-name": "Nick name",
+  "fields.password": "Password",
+  "fields.password-confirmation": "Password confirmation",
+  "fields.body": "Body",
+
+  "helpers.real-name": "Real-name's length should between 2~32",
+  "helpers.email": "Please entry a valid email address",
+  "helpers.password": "Password's length should between 6~64",
+  "helpers.password-confirmation": "Passwords not match",
+
+  "404.title": "Not found",
+
+  "nut.install.title": "Install",
+  "nut.users.sign-in.title": "Sign in",
+  "nut.users.sign-up.title": "Sign Up",
+  "nut.users.confirm.title": "Resend confirmation instructions",
+  "nut.users.unlock.title": "Resend unlock instructions",
+  "nut.users.forgot-password.title": "Forgot your password?",
+  "nut.leave-words.new.title": "Leave us a message",
+};
+
+export default items;

+ 30 - 0
material-ui/src/locales/index.ts

@@ -0,0 +1,30 @@
+import enUS from "./en-US";
+import zhHans from "./zh-Hans";
+import zhHant from "./zh-Hant";
+
+const KEY = "locale";
+
+export const get = (): string => {
+  return localStorage.getItem(KEY) || "en-US";
+};
+
+export const set = (lang: string) => {
+  localStorage.setItem(KEY, lang);
+};
+
+const languages = {
+  "languages.en-US": "English",
+  "languages.zh-Hans": "简体中文",
+  "languages.zh-Hant": "繁體中文",
+};
+
+export const messages = (lang: string): any => {
+  switch (lang) {
+    case "zh-Hans":
+      return { ...languages, ...zhHans };
+    case "zh-Hant":
+      return { ...languages, ...zhHant };
+    default:
+      return { ...languages, ...enUS };
+  }
+};

+ 5 - 0
material-ui/src/locales/zh-Hans.ts

@@ -0,0 +1,5 @@
+const items = {
+  "buttons.search": "搜索",
+};
+
+export default items;

+ 5 - 0
material-ui/src/locales/zh-Hant.ts

@@ -0,0 +1,5 @@
+const items = {
+  "buttons.search": "檢索",
+};
+
+export default items;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 2 - 0
material-ui/src/logo.svg


+ 32 - 0
material-ui/src/plugins/demo/index.tsx

@@ -0,0 +1,32 @@
+import { IPlugin } from "..";
+
+export const plugin: IPlugin = {
+    routes: [
+        {
+            path: "/demo/topics/new",
+            component: () => import("./topics/new"),
+        },
+        {
+            path: "/demo/topics/edit",
+            component: () => import("./topics/edit"),
+        },
+        {
+            path: "/demo/topics",
+            component: () => import("./topics/index"),
+        },
+        {
+            path: "/demo/posts/new",
+            component: () => import("./posts/new"),
+        },
+        {
+            path: "/demo/posts/edit",
+            component: () => import("./posts/edit"),
+        },
+        {
+            path: "/demo/posts",
+            component: () => import("./posts/index"),
+        },
+    ],
+};
+
+export default plugin;

+ 6 - 0
material-ui/src/plugins/demo/posts/edit.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo posts edit</div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/demo/posts/index.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo posts index </div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/demo/posts/new.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo posts new</div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/demo/topics/edit.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo topics edit</div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/demo/topics/index.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo topics index</div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/demo/topics/new.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo topics new</div>;
+}
+
+export default Widget;

+ 16 - 0
material-ui/src/plugins/index.tsx

@@ -0,0 +1,16 @@
+import nut from "./nut";
+import demo from "./demo";
+
+export interface IRoute {
+    path: string;
+    component: any;
+}
+
+export interface IPlugin {
+    routes: IRoute[];
+}
+
+const plugin: IPlugin = {
+    routes: [...demo.routes, ...nut.routes],
+};
+export default plugin;

+ 25 - 0
material-ui/src/plugins/nut/home.tsx

@@ -0,0 +1,25 @@
+import { FormattedMessage } from "react-intl";
+import { Link } from "react-router-dom";
+
+function Widget() {
+  // TODO
+  return (
+    <div>
+      home of <FormattedMessage id="languages.zh-Hant" />
+      <ol>
+        <li>
+          <Link to="/users/sign-in">Sign In</Link>
+        </li>
+        <li>
+          <Link to="/users/sign-up">Sign up</Link>
+        </li>
+        <li>
+          <Link to="/install">install</Link>
+        </li>
+        <li></li>
+      </ol>
+    </div>
+  );
+}
+
+export default Widget;

+ 36 - 0
material-ui/src/plugins/nut/index.tsx

@@ -0,0 +1,36 @@
+import { IPlugin } from "..";
+
+const plugin: IPlugin = {
+    routes: [
+        {
+            path: "/users/forgot-password",
+            component: () => import("./users/forgot-password"),
+        },
+        {
+            path: "/users/unlock",
+            component: () => import("./users/unlock"),
+        },
+        {
+            path: "/users/confirm",
+            component: () => import("./users/confirm"),
+        },
+        {
+            path: "/users/sign-in",
+            component: () => import("./users/sign-in"),
+        },
+        {
+            path: "/users/sign-up",
+            component: () => import("./users/sign-up"),
+        },
+        {
+            path: "/install",
+            component: () => import("./install"),
+        },
+        {
+            path: "/",
+            component: () => import("./home"),
+        },
+    ],
+};
+
+export default plugin;

+ 130 - 0
material-ui/src/plugins/nut/install.tsx

@@ -0,0 +1,130 @@
+import TextField from "@mui/material/TextField";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+import { useForm, Controller, SubmitHandler } from "react-hook-form";
+import { useIntl } from "react-intl";
+
+import Layout from "./users/NonSignInLayout";
+import {
+  REAL_NAME_VALIDATOR,
+  EMAIL_VALIDATOR,
+  PASSWORD_VALIDATOR,
+} from "../../components/form";
+
+interface IFormData {
+  realName: string;
+  email: string;
+  password: string;
+  passwordConfirmation: string;
+}
+
+const Widget = () => {
+  const intl = useIntl();
+  const {
+    control,
+    formState: { errors },
+    handleSubmit,
+  } = useForm<IFormData>({
+    defaultValues: {
+      realName: "",
+      email: "",
+      password: "",
+      passwordConfirmation: "",
+    },
+  });
+  const onSubmit: SubmitHandler<IFormData> = (data) => {
+    // TODO
+    console.log(data);
+  };
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.install.title" })}
+      handleSubmit={handleSubmit(onSubmit)}
+    >
+      <Grid item xs={12}>
+        <Controller
+          name="realName"
+          control={control}
+          rules={REAL_NAME_VALIDATOR}
+          render={({ field }) => (
+            <TextField
+              required
+              fullWidth
+              label={intl.formatMessage({ id: "fields.real-name" })}
+              error={errors.realName !== undefined}
+              helperText={
+                errors.realName &&
+                intl.formatMessage({ id: "helpers.real-name" })
+              }
+              {...field}
+            />
+          )}
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <Controller
+          name="email"
+          rules={EMAIL_VALIDATOR}
+          control={control}
+          render={({ field }) => (
+            <TextField
+              required
+              fullWidth
+              label={intl.formatMessage({ id: "fields.email" })}
+              type="email"
+              error={errors.email !== undefined}
+              helperText={
+                errors.email && intl.formatMessage({ id: "helpers.email" })
+              }
+              {...field}
+            />
+          )}
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <Controller
+          name="password"
+          rules={PASSWORD_VALIDATOR}
+          control={control}
+          render={({ field }) => (
+            <TextField
+              required
+              fullWidth
+              label={intl.formatMessage({ id: "fields.password" })}
+              type="password"
+              error={errors.password !== undefined}
+              helperText={
+                errors.password &&
+                intl.formatMessage({ id: "helpers.password" })
+              }
+              {...field}
+            />
+          )}
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <Controller
+          name="passwordConfirmation"
+          control={control}
+          render={({ field }) => (
+            <TextField
+              required
+              fullWidth
+              label={intl.formatMessage({ id: "fields.password-confirmation" })}
+              type="password"
+              error={errors.passwordConfirmation !== undefined}
+              helperText={
+                errors.passwordConfirmation &&
+                intl.formatMessage({ id: "helpers.password-confirmation" })
+              }
+              {...field}
+            />
+          )}
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 103 - 0
material-ui/src/plugins/nut/users/NonSignInLayout.tsx

@@ -0,0 +1,103 @@
+import { ReactNode } from "react";
+import Button from "@mui/material/Button";
+import Grid from "@mui/material/Grid";
+import Box from "@mui/material/Box";
+import Avatar from "@mui/material/Avatar";
+import Typography from "@mui/material/Typography";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+import PersonPinOutlinedIcon from "@mui/icons-material/PersonPinOutlined";
+import PersonAddAltOutlinedIcon from "@mui/icons-material/PersonAddAltOutlined";
+import ConfirmationNumberOutlinedIcon from "@mui/icons-material/ConfirmationNumberOutlined";
+import PasswordOutlinedIcon from "@mui/icons-material/PasswordOutlined";
+import ListItemIcon from "@mui/material/ListItemIcon";
+import ListItemText from "@mui/material/ListItemText";
+import List from "@mui/material/List";
+import ListItem from "@mui/material/ListItem";
+import ListItemButton from "@mui/material/ListItemButton";
+import { useNavigate } from "react-router-dom";
+import { FormattedMessage } from "react-intl";
+
+import Layout from "../../../layouts/application";
+
+const shared_links = [
+    {
+        to: "/users/sign-in",
+        label: "nut.users.sign-in.title",
+        icon: <PersonPinOutlinedIcon />,
+    },
+    {
+        to: "/users/sign-up",
+        label: "nut.users.sign-up.title",
+        icon: <PersonAddAltOutlinedIcon />,
+    },
+    {
+        to: "/users/confirm",
+        label: "nut.users.confirm.title",
+        icon: <ConfirmationNumberOutlinedIcon />,
+    },
+    {
+        to: "/users/unlock",
+        label: "nut.users.unlock.title",
+        icon: <LockOutlinedIcon />,
+    },
+    {
+        to: "/users/forgot-password",
+        label: "nut.users.forgot-password.title",
+        icon: <PasswordOutlinedIcon />,
+    },
+];
+interface IProps {
+    title: string;
+    children: ReactNode;
+    logo: ReactNode;
+    handleSubmit: (event: React.FormEvent<HTMLFormElement>) => void;
+}
+
+function Widget({ title, logo, children, handleSubmit }: IProps) {
+    // const onSubmit = (event: React.FormEvent<HTMLFormElement>) => {
+    //   event.preventDefault();
+    //   const data = new FormData(event.currentTarget);
+    //   handleSubmit(data);
+    // };
+    const navigate = useNavigate();
+    return (
+        <Layout title={title}>
+            <Avatar sx={{ bgcolor: "secondary.main" }}>{logo}</Avatar>
+            <Typography component="h1" variant="h5">
+                {title}
+            </Typography>
+            <Box component="form" noValidate onSubmit={handleSubmit}>
+                <Grid container spacing={2}>
+                    {children}
+                    <Grid item>
+                        <Button type="submit" fullWidth variant="contained">
+                            <FormattedMessage id="buttons.submit" />
+                        </Button>
+                    </Grid>
+                    <Grid item>
+                        <List>
+                            {shared_links.map((it) => (
+                                <ListItem key={it.to} disablePadding>
+                                    <ListItemButton
+                                        onClick={() => navigate(it.to)}
+                                    >
+                                        <ListItemIcon>{it.icon}</ListItemIcon>
+                                        <ListItemText
+                                            primary={
+                                                <FormattedMessage
+                                                    id={it.label}
+                                                />
+                                            }
+                                        />
+                                    </ListItemButton>
+                                </ListItem>
+                            ))}
+                        </List>
+                    </Grid>
+                </Grid>
+            </Box>
+        </Layout>
+    );
+}
+
+export default Widget;

+ 33 - 0
material-ui/src/plugins/nut/users/confirm.tsx

@@ -0,0 +1,33 @@
+import TextField from "@mui/material/TextField";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+
+import Layout from "./NonSignInLayout";
+import { useIntl } from "react-intl";
+
+const Widget = () => {
+  const handleSubmit = () => {
+    // TODO
+    // console.log(data.get("email"));
+  };
+  const intl = useIntl();
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.users.confirm.title" })}
+      handleSubmit={handleSubmit}
+    >
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="email"
+          label={intl.formatMessage({ id: "fields.email" })}
+          name="email"
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 33 - 0
material-ui/src/plugins/nut/users/forgot-password.tsx

@@ -0,0 +1,33 @@
+import TextField from "@mui/material/TextField";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+
+import Layout from "./NonSignInLayout";
+import { useIntl } from "react-intl";
+
+const Widget = () => {
+  const handleSubmit = () => {
+    // TODO
+    // console.log(data.get("email"));
+  };
+  const intl = useIntl();
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.users.forgot-password.title" })}
+      handleSubmit={handleSubmit}
+    >
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="email"
+          label={intl.formatMessage({ id: "fields.email" })}
+          name="email"
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/nut/users/logs.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+  // TODO
+  return <div>logs</div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/nut/users/reset-password.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+  // TODO
+  return <div>reset password</div>;
+}
+
+export default Widget;

+ 43 - 0
material-ui/src/plugins/nut/users/sign-in.tsx

@@ -0,0 +1,43 @@
+import TextField from "@mui/material/TextField";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+
+import Layout from "./NonSignInLayout";
+import { useIntl } from "react-intl";
+
+const Widget = () => {
+  const handleSubmit = () => {
+    // TODO
+    // console.log(data.get("email"));
+  };
+  const intl = useIntl();
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.users.sign-in.title" })}
+      handleSubmit={handleSubmit}
+    >
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="email"
+          label={intl.formatMessage({ id: "fields.email" })}
+          name="email"
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          name="password"
+          label={intl.formatMessage({ id: "fields.password" })}
+          type="password"
+          id="password"
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 70 - 0
material-ui/src/plugins/nut/users/sign-up.tsx

@@ -0,0 +1,70 @@
+import TextField from "@mui/material/TextField";
+import FormControlLabel from "@mui/material/FormControlLabel";
+import Checkbox from "@mui/material/Checkbox";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+import { useIntl } from "react-intl";
+
+import Layout from "./NonSignInLayout";
+
+const Widget = () => {
+  const handleSubmit = () => {
+    // TODO
+    // console.log(data.get("email"));
+  };
+  const intl = useIntl();
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.users.sign-up.title" })}
+      handleSubmit={handleSubmit}
+    >
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="realName"
+          label={intl.formatMessage({ id: "fields.real-name" })}
+          name="lastName"
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="email"
+          label={intl.formatMessage({ id: "fields.email" })}
+          name="email"
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          name="password"
+          label={intl.formatMessage({ id: "fields.password" })}
+          type="password"
+          id="password"
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          name="passwordConfirmation"
+          label={intl.formatMessage({ id: "fields.password-confirmation" })}
+          type="password"
+          id="passwordConfirmation"
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <FormControlLabel
+          control={<Checkbox value="allowExtraEmails" color="primary" />}
+          label="I want to receive inspiration, marketing promotions and updates via email."
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 33 - 0
material-ui/src/plugins/nut/users/unlock.tsx

@@ -0,0 +1,33 @@
+import TextField from "@mui/material/TextField";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+
+import Layout from "./NonSignInLayout";
+import { useIntl } from "react-intl";
+
+const Widget = () => {
+  const handleSubmit = () => {
+    // TODO
+    // console.log(data.get("email"));
+  };
+  const intl = useIntl();
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.users.unlock.title" })}
+      handleSubmit={handleSubmit}
+    >
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="email"
+          label={intl.formatMessage({ id: "fields.email" })}
+          name="email"
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/nut/users/update-profile.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+  // TODO
+  return <div>update profile</div>;
+}
+
+export default Widget;

+ 1 - 0
material-ui/src/react-app-env.d.ts

@@ -0,0 +1 @@
+/// <reference types="react-scripts" />

+ 40 - 0
material-ui/src/reducers/current-user.ts

@@ -0,0 +1,40 @@
+import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+
+import type { RootState } from "../store";
+
+interface IState {
+  id?: string;
+  roles?: string[];
+}
+
+const initialState: IState = {};
+
+export const slice = createSlice({
+  name: "current-user",
+  initialState,
+  reducers: {
+    signIn: (state, action: PayloadAction<string>) => {
+      console.log(action.payload);
+      state.id = "todo";
+      state.roles = [];
+    },
+    signOut: (state) => {
+      state = {};
+    },
+  },
+});
+
+export const { signIn, signOut } = slice.actions;
+
+const ADMINISTRATOR = "administrator";
+
+export const isSignIn = (state: RootState): boolean =>
+  state.currentUser.id !== undefined;
+export const isAdministrtor = (state: RootState): boolean =>
+  hasRole(state, ADMINISTRATOR);
+
+export const hasRole = (state: RootState, role: string): boolean =>
+  state.currentUser.roles !== undefined &&
+  state.currentUser.roles.includes(role);
+
+export default slice.reducer;

+ 35 - 0
material-ui/src/reducers/site-info.ts

@@ -0,0 +1,35 @@
+import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+
+import type { RootState } from "../store";
+
+interface IState {
+  title: string;
+  subhead: string;
+  copyright: string;
+  languages: string[];
+}
+
+const initialState: IState = {
+  title: "",
+  subhead: "",
+  copyright: "",
+  languages: [],
+};
+
+const slice = createSlice({
+  name: "site-info",
+  initialState,
+  reducers: {
+    refresh: (state, action: PayloadAction<IState>) => {
+      Object.assign(state, action.payload);
+    },
+  },
+});
+
+export const { refresh } = slice.actions;
+
+export const selectSiteInfo = (state: RootState): IState => {
+  return { ...state.siteInfo };
+};
+
+export default slice.reducer;

+ 15 - 0
material-ui/src/reportWebVitals.ts

@@ -0,0 +1,15 @@
+import { ReportHandler } from 'web-vitals';
+
+const reportWebVitals = (onPerfEntry?: ReportHandler) => {
+  if (onPerfEntry && onPerfEntry instanceof Function) {
+    import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
+      getCLS(onPerfEntry);
+      getFID(onPerfEntry);
+      getFCP(onPerfEntry);
+      getLCP(onPerfEntry);
+      getTTFB(onPerfEntry);
+    });
+  }
+};
+
+export default reportWebVitals;

+ 1 - 0
material-ui/src/request.ts

@@ -0,0 +1 @@
+export const graphql = () => {};

+ 5 - 0
material-ui/src/setupTests.ts

@@ -0,0 +1,5 @@
+// jest-dom adds custom jest matchers for asserting on DOM nodes.
+// allows you to do things like:
+// expect(element).toHaveTextContent(/react/i)
+// learn more: https://github.com/testing-library/jest-dom
+import '@testing-library/jest-dom';

+ 17 - 0
material-ui/src/store.ts

@@ -0,0 +1,17 @@
+import { configureStore } from "@reduxjs/toolkit";
+
+import currentUser from "./reducers/current-user";
+import siteInfo from "./reducers/site-info";
+
+const store = configureStore({
+  reducer: {
+    currentUser,
+    siteInfo,
+  },
+});
+
+export type RootState = ReturnType<typeof store.getState>;
+
+export type AppDispatch = typeof store.dispatch;
+
+export default store;

+ 26 - 0
material-ui/tsconfig.json

@@ -0,0 +1,26 @@
+{
+  "compilerOptions": {
+    "target": "es5",
+    "lib": [
+      "dom",
+      "dom.iterable",
+      "esnext"
+    ],
+    "allowJs": true,
+    "skipLibCheck": true,
+    "esModuleInterop": true,
+    "allowSyntheticDefaultImports": true,
+    "strict": true,
+    "forceConsistentCasingInFileNames": true,
+    "noFallthroughCasesInSwitch": true,
+    "module": "esnext",
+    "moduleResolution": "node",
+    "resolveJsonModule": true,
+    "isolatedModules": true,
+    "noEmit": true,
+    "jsx": "react-jsx"
+  },
+  "include": [
+    "src"
+  ]
+}

+ 161 - 1
public/app/term/note.js

@@ -217,6 +217,9 @@ function note_refresh_new(callback = null) {
 						//初始化mermaid
 						mermaid.initialize({startOnLoad:true});
 
+                        //初始化气泡
+                        guide_init();
+
 					} catch (e) {
 						console.error(e);
 					}
@@ -1255,6 +1258,7 @@ function render_one_sent_tran_a(iterator, diff = false) {
 	html += "</div>";
 	return html;
 }
+//渲染nissaya单词
 function renderNissayaPreview(str){
     let html ='';
     //html +="<div class='nissaya'>";
@@ -1273,7 +1277,15 @@ function renderNissayaPreview(str){
                     break;
             }
             html += "</span>";
-            html += "<span class='meaning'>"+ word[1]+"</span>";
+            html += "<span class='meaning'>";
+            if (getCookie('language') !="my") {
+                let noPeriod = word[1].split('။');
+                noPeriod[0] = myEndingTooltip(noPeriod[0]);
+                html += noPeriod.join('။');
+            }else{
+                html += word[1];
+            }
+            html += "</span>";
             html += "</span>";
         }else{
             html += iterator;
@@ -1282,6 +1294,154 @@ function renderNissayaPreview(str){
     //html += "</div>";
     return html;
 }
+//缅文语尾高亮和提示气泡
+function myEndingTooltip(inStr){
+    let myEnding=[
+        {
+            id:"my_nom1",
+            name:"သည်",
+            tooltip:'主语',
+        },
+        {
+            id:"my_nom2",
+            name:"ကား",
+            tooltip:'主格/主语',
+        },        
+        {
+            id:"my_nom3",
+            name:"က",
+            tooltip:'主格/主语',
+        },        
+        {
+            id:"my_acc1",
+            name:"ကို",
+            tooltip:'宾格/宾语',
+        },
+        {
+            id:"my_acc2",
+            name:"သို့",
+            tooltip:'宾格/趋向',
+        },
+        {
+            id:"my_inst1",
+            name:"ဖြင့်",
+            tooltip:'具格/用',
+        },
+        {
+            id:"my_inst2",
+            name:"နှင့်",
+            tooltip:'具格/与',
+        },
+        {
+            id:"my_inst3",
+            name:"ကြောင့်",
+            tooltip:'具格/凭借;从格/原因',
+        },
+        {
+            id:"my_dat1",
+            name:"အား",
+            tooltip:'为格/对象(间接宾语)',
+        },
+        {
+            id:"my_dat2",
+            name:"ငှာ",
+            tooltip:'为格/目的(为了)',
+        },
+        {
+            id:"my_abl1",
+            name:"မှ",
+            tooltip:'从格/从',
+        },
+        {
+            id:"my_abl2",
+            name:"အောက်",
+            tooltip:'从格/比……多',
+        },
+        {
+            id:"my_abl3",
+            name:"ထက်",
+            tooltip:'从格/比……少',
+        },
+        {
+            id:"my_gen1",
+            name:"၏",
+            tooltip:'属格/的',
+        },
+        {
+            id:"my_gen2",
+            name:"တွင်",
+            tooltip:'属格/处(范围)',
+        },
+        {
+            id:"my_loc1",
+            name:"၌",
+            tooltip:'处格/处(范围)',
+        },
+        {
+            id:"my_loc2",
+            name:"ကြောင့်",
+            tooltip:'处格/因',
+        },
+        {
+            id:"my_abs",
+            name:"၍",
+            tooltip:'连续体',
+        },
+        {
+            id:"my_pl",
+            name:"တို့",
+            tooltip:'复数',
+        },
+        {
+            id:"my_pl",
+            name:"များ",
+            tooltip:'复数',
+        },
+        {
+            id:"my_pl",
+            name:"ကုန်",
+            tooltip:'复数',
+        },
+        {
+            id:"my_pl",
+            name:"ကြ",
+            tooltip:'复数',
+        },
+        {
+            id:"my_time",
+            name:"ပတ်လုံး",
+            tooltip:'时间的整数',
+        },
+        {
+            id:"my_time",
+            name:"လုံလုံး",
+            tooltip:'时间的整数',
+        },
+        {
+            id:"my_length",
+            name:"တိုင်တိုင်",
+            tooltip:'距离,长度的整数',
+        },
+        {
+            id:"my_length",
+            name:"တိုင်အောင်",
+            tooltip:'距离,长度的整数',
+        },
+        {
+            id:"my_def",
+            name:"နေစဉ်",
+            tooltip:'同时发生的时间状语(当……的时候)',
+        },
+    ];
+
+    for (const iterator of myEnding) {
+        if(inStr.indexOf(iterator.name)>=0){
+			eval("inStr=inStr.replace(/" + iterator.name + " /g,\"<guide gid='grammar_"+iterator.id+"' class='grammar_tag' style='display:unset;'>\"+iterator.name+\"</guide> \");");
+			eval("inStr=inStr.replace(/" + iterator.name + "$/g,\"<guide gid='grammar_"+iterator.id+"' class='grammar_tag' style='display:unset;'>\"+iterator.name+\"</guide>\");");
+        }
+    }
+    return inStr;
+}
 function tran_sent_textarea_event_init() {
 	let textarea = document.querySelectorAll(".tran_sent_textarea");
 	for (let iterator of textarea) {

+ 19 - 2
public/app/term/term.css

@@ -1129,17 +1129,34 @@ pali>p {
 .preview .nissaya{
     display:inline;
 }
+.preview .nsy_word{
+    display:inline;
+}
 .preview .nissaya .nsy_word{
     padding-right:10px;
 }
-.preview .nissaya .nsy_word .org{
+.nsy_word .org{
     display:inline;
     font-weight: 700;
+    padding-right: 0.5em;
 }
-.preview .nissaya .nsy_word .meaning{
+.nsy_word .meaning{
     display:inline;
     font-weight: 500;
 }
 span.sent_tran::first-letter {
     text-transform: capitalize;
+}
+
+guide.grammar_tag {
+    display: unset;
+    background: unset;
+    background-color: var(--btn-color);
+    padding: 0;
+    border-radius: 3px;
+	margin: 0;
+
+}
+guide.grammar_tag:hover {
+	text-decoration: underline;
 }

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_abl1.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 从格/从

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_abl2.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 从格/比……多

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_abl3.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 从格/比……少

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_abs.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+连续体

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_acc1.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 宾格/宾语

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_acc2.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 宾格/趋向

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_dat1.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 为格/对象(间接宾语)

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_dat2.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 为格/目的(为了)

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_gen1.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 属格/的

+ 4 - 0
public/app/users_guide/zh-cn/grammar_my_gen2.md

@@ -0,0 +1,4 @@
+# 缅文语尾
+
+- 处格/处(范围)
+- 属格/处(范围)

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_inst1.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 具格/用

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_inst2.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 具格/与

+ 4 - 0
public/app/users_guide/zh-cn/grammar_my_inst3.md

@@ -0,0 +1,4 @@
+# 缅文语尾
+
+- 具格/凭借
+- 从格/原因

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_loc1.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 处格/处(范围)

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_loc2.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 处格/因

+ 5 - 0
public/app/users_guide/zh-cn/grammar_my_nom1.md

@@ -0,0 +1,5 @@
+# 缅文语尾
+
+- 主格/主语
+- 具格/主语
+- 属格/主语

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_nom2.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 主格/主语

+ 3 - 0
public/app/users_guide/zh-cn/grammar_my_nom3.md

@@ -0,0 +1,3 @@
+# 缅文语尾
+
+- 主格/主语

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است