Skip to content

Commit 714aa24

Browse files
Merge pull request #219 from OpenWebGAL/dev
4.4.9
2 parents 016f5ae + 8c51c97 commit 714aa24

40 files changed

+1647
-1694
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webgal-terre",
3-
"version": "4.4.8",
3+
"version": "4.4.9",
44
"private": true,
55
"scripts": {
66
"dev": "concurrently \"yarn dev:terre\" \"yarn dev:origine\" \"yarn dev:start-dev-server\"",

packages/dev-server/index.js

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
const express = require("express");
22
const { createProxyMiddleware } = require("http-proxy-middleware");
3+
const { env } = require("process")
4+
35
const app = express();
46
app.set("port", "80");
57

6-
app.all("*", function(req, res, next) {
8+
app.all("*", function (req, res, next) {
79
// 解决跨域问题
810
res.header("Access-Control-Allow-Origin", "*");
9-
res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");
11+
res.header(
12+
"Access-Control-Allow-Headers",
13+
"Content-Type,Content-Length, Authorization, Accept,X-Requested-With"
14+
);
1015
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
1116
if (req.method === "OPTIONS") {
1217
res.send(200);
@@ -15,21 +20,32 @@ app.all("*", function(req, res, next) {
1520
}
1621
});
1722

18-
app.use(createProxyMiddleware("/api", {
19-
target: "http://localhost:3001",// http代理跨域目标接口
20-
changeOrigin: true
21-
}));
23+
let WEBGAL_PORT = 3000; // default port
24+
if (env.WEBGAL_PORT) {
25+
WEBGAL_PORT = Number.parseInt(env.WEBGAL_PORT);
26+
}
27+
28+
app.use(
29+
createProxyMiddleware("/api", {
30+
target: `http://localhost:${WEBGAL_PORT + 1}`, // http代理跨域目标接口
31+
changeOrigin: true,
32+
})
33+
);
2234

23-
app.use(createProxyMiddleware("/games", {
24-
target: "http://localhost:3001",// http代理跨域目标接口
25-
changeOrigin: true,
26-
}));
35+
app.use(
36+
createProxyMiddleware("/games", {
37+
target: `http://localhost:${WEBGAL_PORT + 1}`, // http代理跨域目标接口
38+
changeOrigin: true,
39+
})
40+
);
2741

28-
app.use(createProxyMiddleware("/", {
29-
target: "http://localhost:3000",// http代理跨域目标接口
30-
ws:true,
31-
changeOrigin: true
32-
}));
42+
app.use(
43+
createProxyMiddleware("/", {
44+
target: `http://localhost:${WEBGAL_PORT}`, // http代理跨域目标接口
45+
ws: true,
46+
changeOrigin: true,
47+
})
48+
);
3349

3450
app.listen(app.get("port"), () => {
3551
console.log(`反向代理已开启,端口:${app.get("port")}`);

packages/origine2/openapi.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44

55
import axios from 'axios';
66
import {writeFileSync} from 'fs';
7-
import { exec } from 'child_process';
7+
import { exec } from 'child_process'
8+
import { env } from 'process';
89

9-
const SWAGGER_URL = 'http://localhost:3001/api-json';
10+
let WEBGAL_PORT = 3000; // default port
11+
if (env.WEBGAL_PORT) {
12+
WEBGAL_PORT = Number.parseInt(env.WEBGAL_PORT);
13+
};
14+
15+
const SWAGGER_URL = `http://localhost:${WEBGAL_PORT + 1}/api-json`;
1016
const SWAGGER_JSON_PATH = './src/config/swagger.json';
1117
const API_OUTPUT_PATH = './src/api';
1218

packages/origine2/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "webgal-origine-2",
33
"private": true,
4-
"version": "4.4.8",
4+
"version": "4.4.9",
55
"license": "MPL-2.0",
66
"scripts": {
7-
"dev": "vite --port=3000 --host",
7+
"dev": "vite --host",
88
"build": "node version-sync.js && tsc && vite build --base=./",
99
"build-lowram": "node version-sync.js && tsc && node --max_old_space_size=512000 ./node_modules/bin/vite build --base=./",
1010
"preview": "vite preview",
@@ -13,6 +13,8 @@
1313
},
1414
"dependencies": {
1515
"@fluentui/react": "^8.77.3",
16+
"@fluentui/react-components": "^9.44.1",
17+
"@fluentui/react-icons": "^2.0.224",
1618
"@fluentui/react-icons-mdl2": "^1.3.41",
1719
"@icon-park/react": "^1.4.2",
1820
"@monaco-editor/react": "^4.4.5",

packages/origine2/src/App.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.App {
22
text-align: center;
3+
background-color: #fafafa;
4+
width: 100%;
5+
height: 100%;
36
}
47

58
.App-logo {

packages/origine2/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ function App() {
5151
}, triggerCharacters: ["-", "", ":", "\n"]
5252
});
5353
});
54+
5455
return (
5556
// 将编辑器的根元素占满整个视口
56-
<div className="App" style={{width: "100vw", height: "100vh", overflow: "hidden"}}>
57+
<div className="App">
5758
<Provider store={origineStore}>
5859
<PersistGate loading={null} persistor={persistor}>
5960
<Translation/>

packages/origine2/src/config/info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ export interface Info {
44
}
55

66
export const __INFO: Info = {
7-
version: '4.4.8',
7+
version: '4.4.9',
88
buildTime: '2023-12-30T03:22:49.651Z', // 编译时会通过 version-sync.js 自动更新
99
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {useDispatch, useSelector} from "react-redux";
2+
import {RootState} from "@/store/origineStore";
3+
import {updateGraphicalEditorCurrentExpandSentence} from "@/store/statusReducer";
4+
5+
export function useExpand() {
6+
const currentExpandSentence = useSelector((state: RootState) => state.status.editor.graphicalEditorState.currentExpandSentence);
7+
const dispatch = useDispatch();
8+
const updateIndex = (index:number)=>dispatch(updateGraphicalEditorCurrentExpandSentence(index));
9+
return {expandIndex:currentExpandSentence,updateExpandIndex:updateIndex};
10+
}

packages/origine2/src/main.tsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,37 @@ import { jp } from "./translations/jp";
1010
import 'primereact/resources/themes/fluent-light/theme.css';
1111
import "primereact/resources/primereact.min.css";
1212
import "./primereact.scss";
13+
import { BrandVariants, createLightTheme, createDarkTheme, FluentProvider, makeStyles, Theme } from "@fluentui/react-components";
14+
15+
const terre: BrandVariants = {
16+
10: "#020306",
17+
20: "#111725",
18+
30: "#152642",
19+
40: "#17325A",
20+
50: "#163E73",
21+
60: "#124B8D",
22+
70: "#0558A8",
23+
80: "#2A65B4",
24+
90: "#4672BC",
25+
100: "#5D80C3",
26+
110: "#728ECA",
27+
120: "#859CD1",
28+
130: "#98ABD8",
29+
140: "#ABB9DF",
30+
150: "#BEC8E7",
31+
160: "#D0D7EE"
32+
};
33+
34+
const lightTheme: Theme = {
35+
...createLightTheme(terre),
36+
};
37+
38+
const darkTheme: Theme = {
39+
...createDarkTheme(terre),
40+
};
41+
42+
darkTheme.colorBrandForeground1 = terre[110];
43+
darkTheme.colorBrandForeground2 = terre[120];
1344

1445
function initTranslation() {
1546
i18n.use(initReactI18next) // passes i18n down to react-i18next
@@ -38,6 +69,8 @@ initializeIcons();
3869
// 不用 StrictMode,因为会和 react-butiful-dnd 冲突
3970
ReactDOM.createRoot(document.getElementById("root")!).render(
4071
// <React.StrictMode>
41-
<App />
72+
<FluentProvider theme={lightTheme} style={{width: '100%', height: '100%'}}>
73+
<App />
74+
</FluentProvider>
4275
// </React.StrictMode>
4376
);

packages/origine2/src/pages/dashboard/About.tsx

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import * as React from 'react';
2-
import { Callout, Link, Text } from '@fluentui/react';
3-
import { useBoolean, useId } from '@fluentui/react-hooks';
4-
import { CommandBarButton } from '@fluentui/react/lib/Button';
5-
import styles from './about.module.scss';
62
import { __INFO } from "@/config/info";
73
import { useRelease } from "../../hooks/useRelease";
84
import { logger } from '@/utils/logger';
95
import useTrans from '@/hooks/useTrans';
6+
import { Link, Popover, PopoverSurface, PopoverTrigger, Text, Title1, ToolbarButton } from '@fluentui/react-components';
7+
import { Info24Filled, Info24Regular, bundleIcon } from '@fluentui/react-icons';
8+
import { useState } from 'react';
109

1110
interface DateTimeFormatOptions {
1211
year: 'numeric' | '2-digit';
@@ -15,15 +14,12 @@ interface DateTimeFormatOptions {
1514
}
1615

1716
const About: React.FunctionComponent = () => {
18-
const [isCalloutVisible, { toggle: toggleIsCalloutVisible }] = useBoolean(false);
19-
const buttonId = useId('callout-button');
20-
const labelId = useId('callout-label');
21-
const descriptionId = useId('callout-description');
22-
17+
const [open, setOpen] = useState(false);
2318
const t = useTrans('editor.topBar.');
24-
2519
const latestRelease = useRelease();
2620

21+
const InfoIcon = bundleIcon(Info24Filled, Info24Regular);
22+
2723
/**
2824
* 比较版本号
2925
* @param latestVersion 最新版本
@@ -60,29 +56,23 @@ const About: React.FunctionComponent = () => {
6056
const dateTimeOptions: DateTimeFormatOptions = { year: 'numeric', month: '2-digit', day: '2-digit' };
6157

6258
return (
63-
<>
64-
<CommandBarButton
65-
className={styles.button}
66-
id={buttonId}
67-
onClick={toggleIsCalloutVisible}
68-
text={`${t('about.about')} ${isNewRelease ? `(${t('about.checkedForNewVersion')})` : ''}`}
69-
iconProps={{ iconName: 'Info' }}
70-
/>
71-
{isCalloutVisible &&
72-
<Callout
73-
className={styles.callout}
74-
ariaLabelledBy={labelId}
75-
ariaDescribedBy={descriptionId}
76-
role="dialog"
77-
gapSpace={0}
78-
target={`#${buttonId}`}
79-
onDismiss={toggleIsCalloutVisible}
80-
setInitialFocus
81-
>
82-
<Text as="h1" block variant="xLarge" className={styles.title} id={labelId}>
59+
<Popover
60+
withArrow
61+
trapFocus
62+
open={open}
63+
onOpenChange={() => setOpen(!open)}
64+
>
65+
<PopoverTrigger disableButtonEnhancement>
66+
<ToolbarButton aria-label={t('about.about')} icon={<InfoIcon />}>
67+
{t('about.about')} {isNewRelease ? `(${t('about.checkedForNewVersion')})` : ''}
68+
</ToolbarButton>
69+
</PopoverTrigger>
70+
<PopoverSurface>
71+
<div>
72+
<Text as='h1' block size={500}>
8373
WebGAL Terre
8474
</Text>
85-
<Text block variant="medium" className={styles.info} id={descriptionId}>
75+
<Text as='b' block>
8676
<p>{t('about.slogan')}</p>
8777
<small>
8878
{t('about.currentVersion')}: {`${__INFO.version} (${new Date(__INFO.buildTime).toLocaleString('zh-CN', dateTimeOptions).replaceAll('/', '-')})`}<br />
@@ -95,7 +85,7 @@ const About: React.FunctionComponent = () => {
9585
<p>
9686
{
9787
isNewRelease &&
98-
<Link href="https://openwebgal.com/download/" target="_blank" className={styles.link}>
88+
<Link href="https://openwebgal.com/download/" target="_blank">
9989
{t('about.downloadLatest')}
10090
</Link>
10191
}
@@ -109,20 +99,20 @@ const About: React.FunctionComponent = () => {
10999
</div>
110100
</small>
111101
</Text>
112-
<div className={styles.link_group}>
113-
<Link href="https://openwebgal.com/" target="_blank" className={styles.link}>
102+
<div style={{display:'flex', gap:'0.5rem', marginTop:'1rem'}}>
103+
<Link href="https://openwebgal.com/" target="_blank">
114104
{t('about.homePage')}
115105
</Link>
116-
<Link href="https://docs.openwebgal.com/" target="_blank" className={styles.link}>
106+
<Link href="https://docs.openwebgal.com/" target="_blank">
117107
{t('about.document')}
118108
</Link>
119-
<Link href="https://github.com/MakinoharaShoko/WebGAL_Terre" target="_blank" className={styles.link}>
109+
<Link href="https://github.com/MakinoharaShoko/WebGAL_Terre" target="_blank">
120110
GitHub
121111
</Link>
122112
</div>
123-
</Callout>
124-
}
125-
</>
113+
</div>
114+
</PopoverSurface>
115+
</Popover>
126116
);
127117
};
128118

0 commit comments

Comments
 (0)