-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add package @suika/suika-multiplayer
- Loading branch information
Showing
120 changed files
with
4,781 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.git | ||
.gitignore | ||
*.md | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
FROM node:18-alpine AS build | ||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN npm config set registry https://registry.npmmirror.com/ | ||
RUN npm install -g [email protected] | ||
RUN pnpm install --frozen-lockfile | ||
RUN pnpm build | ||
|
||
FROM nginx | ||
|
||
COPY --from=build /app/packages/suika-multiplayer/build /usr/share/nginx/html | ||
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
server { | ||
listen 8002; | ||
server_name localhost; | ||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html; | ||
try_files $uri $uri/ /index.html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@suika/suika-multiplayer | ||
|
||
the Web UI of suika editor for multiple user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>suika-multiplayer</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/index.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "@suika/suika-multiplayer", | ||
"version": "0.0.1", | ||
"description": "a graphics editor.", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@floating-ui/react": "^0.22.3", | ||
"@hocuspocus/provider": "^2.13.5", | ||
"@suika/common": "workspace:^", | ||
"@suika/components": "workspace:^", | ||
"@suika/core": "workspace:^", | ||
"@suika/geo": "workspace:^", | ||
"@suika/icons": "workspace:^", | ||
"ahooks": "^3.7.4", | ||
"axios": "^1.7.3", | ||
"classnames": "^2.3.2", | ||
"react": "^18.2.0", | ||
"react-color": "^2.19.3", | ||
"react-dom": "^18.2.0", | ||
"react-intl": "^6.3.2", | ||
"react-scripts": "5.0.1", | ||
"sass": "^1.57.1", | ||
"stats.js": "^0.17.0", | ||
"y-websocket": "^2.0.3", | ||
"yjs": "^13.6.17" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.2.25", | ||
"@types/react-color": "^3.0.6", | ||
"@types/react-dom": "^18.2.0", | ||
"@types/stats.js": "^0.17.3", | ||
"@typescript-eslint/eslint-plugin": "^6.14.0", | ||
"@typescript-eslint/parser": "^6.14.0", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"eslint": "^8.55.0", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-refresh": "^0.4.5", | ||
"sass": "^1.70.0", | ||
"vite": "^5.0.8", | ||
"vite-plugin-checker": "^0.6.4" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
overscroll-behavior-x: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import './App.css'; | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { IntlProvider } from 'react-intl'; | ||
|
||
import Editor from './components/Editor'; | ||
import { appEventEmitter } from './events'; | ||
import { en, type SupportedLocale, zh } from './locale'; | ||
|
||
const messageMap = { | ||
zh, | ||
en, | ||
}; | ||
|
||
const getLocale = (): SupportedLocale => { | ||
const locale = localStorage.getItem('suika-locale') || navigator.language; | ||
return locale.startsWith('zh') ? 'zh' : 'en'; | ||
}; | ||
|
||
function App() { | ||
const [locale, setLocale] = useState(getLocale()); | ||
|
||
useEffect(() => { | ||
const localeChangeHandler = (locale: SupportedLocale) => { | ||
setLocale(locale); | ||
}; | ||
appEventEmitter.on('localeChange', localeChangeHandler); | ||
return () => { | ||
appEventEmitter.off('localeChange', localeChangeHandler); | ||
}; | ||
}); | ||
|
||
return ( | ||
<IntlProvider locale={locale} messages={messageMap[locale]}> | ||
<div className="suika"> | ||
<Editor /> | ||
</div> | ||
</IntlProvider> | ||
); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import axios from 'axios'; | ||
|
||
const configAxios = () => { | ||
axios.defaults.baseURL = '/api'; | ||
axios.interceptors.response.use( | ||
(config) => { | ||
return config; | ||
}, | ||
(err) => { | ||
const statusCode = err?.response?.status; | ||
if (statusCode === 401) { | ||
if (location.pathname !== '/login') { | ||
location.href = '/login'; | ||
} | ||
} | ||
throw err; | ||
}, | ||
); | ||
}; | ||
|
||
configAxios(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import './api-config'; | ||
|
||
import axios from 'axios'; | ||
|
||
interface FileItem { | ||
id: number; | ||
title: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
} | ||
|
||
type ResStruct<T> = { | ||
code: number; | ||
status: number; | ||
message: string; | ||
error: boolean; | ||
data: T; | ||
}; | ||
|
||
interface LoginRes { | ||
accessToken: string; | ||
} | ||
|
||
interface UserProfileRes { | ||
username: string; | ||
id: number; | ||
} | ||
|
||
export const ApiService = { | ||
login: async (username: string, password: string) => { | ||
const res = await axios.post<ResStruct<LoginRes>>('auth/login', { | ||
username, | ||
password, | ||
}); | ||
return res.data; | ||
}, | ||
register: async (username: string, password: string) => { | ||
const res = await axios.post<ResStruct<LoginRes>>('auth/register', { | ||
username, | ||
password, | ||
}); | ||
return res.data; | ||
}, | ||
getFileList: async () => { | ||
const res = await axios.get<ResStruct<FileItem[]>>('files'); | ||
return res.data; | ||
}, | ||
createFile: async (title: string) => { | ||
const res = await axios.post<ResStruct<FileItem[]>>('files/create', { | ||
title, | ||
}); | ||
return res.data; | ||
}, | ||
getFile: async (id: number) => { | ||
const res = await axios.get<ResStruct<FileItem>>(`files/${id}`); | ||
return res.data; | ||
}, | ||
deleteFiles: async (ids: number[]) => { | ||
const res = await axios.delete<ResStruct<FileItem[]>>('files', { | ||
params: { | ||
ids, | ||
}, | ||
}); | ||
return res.data; | ||
}, | ||
updateFile: async (id: number, data: Partial<FileItem>) => { | ||
const res = await axios.patch<ResStruct<FileItem[]>>(`files/${id}`, { | ||
data, | ||
}); | ||
return res.data; | ||
}, | ||
getUserInfo: async () => { | ||
const res = await axios.get<ResStruct<UserProfileRes>>( | ||
'/users/self/profile', | ||
); | ||
return res.data; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './api-service'; |
25 changes: 25 additions & 0 deletions
25
packages/suika-multiplayer/src/components/Cards/AlignCard/AlignCard.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.suika { | ||
.align-list { | ||
display: flex; | ||
padding: 0 8px; | ||
.align-item { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
margin: 0 1px; | ||
border-radius: 3px; | ||
width: 32px; | ||
height: 32px; | ||
color: #333; | ||
&:hover { | ||
background-color: #f2f2f2; | ||
} | ||
} | ||
|
||
&.disabled { | ||
pointer-events: none; | ||
opacity: 0.3; | ||
} | ||
} | ||
} |
Oops, something went wrong.