Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deployment of source code #102

Merged
merged 7 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions apps/cli/src/commands/start_server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import cors from '@koa/cors';
import mount from 'koa-mount';
import { PathPrefix } from '#/constants';
import { updateConfig, getConfig, Config, Mode } from '@/config';
import definition from '@/definition';
import initialize from './initialize';
import startSchedule from './schedule';
import { getAssetApp } from './asset_app';
Expand Down Expand Up @@ -61,14 +60,7 @@ export default async ({
server.use(mount(`/${PathPrefix.FORM}`, getFormApp()));
server.use(mount(`/${PathPrefix.API}`, getApiApp()));
server.use(mount(`/${PathPrefix.BASE}`, getBaseApp()));

/**
* 非构建模式下不用托管 pwa
* @author mebtte<hi@mebtte.com>
*/
if (definition.BUILT) {
server.use(mount('/', getPwaApp()));
}
server.use(mount('/', getPwaApp()));

http.createServer(server.callback()).listen(getConfig().port);
};
8 changes: 7 additions & 1 deletion apps/cli/src/commands/start_server/pwa_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ import path from 'path';
import Koa from 'koa';
import serve from 'koa-static';
import etag from 'koa-etag';
import definition from '@/definition';

export function getPwaApp() {
const app = new Koa();
app.use(etag());
app.use(serve(path.join(__dirname, 'pwa')));

if (definition.BUILT) {
app.use(serve(path.join(__dirname, 'pwa')));
} else {
app.use(serve(path.join(__dirname, '../../../../../dist/pwa')));
}
return app;
}
4 changes: 3 additions & 1 deletion apps/pwa/src/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ErrorBoundary from '@/components/error_boundary';
import { GlobalStyle } from '@/global_style';
import { GlobalStyle as SelectGlobalStyle } from '@/components/select';
import { ThemeProvider } from 'styled-components';
import App from './app';
import UncaughtError from './uncaught_error';
Expand All @@ -13,8 +14,9 @@ function Wrapper() {
<ErrorBoundary fallback={fallback}>
<ThemeProvider theme={theme.useState()}>
<Head />
<GlobalStyle />
<App />
<GlobalStyle />
<SelectGlobalStyle />
</ThemeProvider>
</ErrorBoundary>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/pwa/src/components/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const Style = styled.button<{
padding: 0 15px;

border-radius: ${CSSVariable.BORDER_RADIUS_NORMAL};
font-size: 14px;
font-size: ${CSSVariable.TEXT_SIZE_NORMAL};
cursor: pointer;
transition: all 300ms;
user-select: none;
Expand Down
16 changes: 10 additions & 6 deletions apps/pwa/src/components/cover/cover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ function Cover({
useLayoutEffect(() => {
setCurrentSrc(DefaultCover);

const unobserve = intersectionObserver.observe(ref.current!, () =>
loadImage(src)
.then(() => setCurrentSrc(src))
.catch((error) => logger.error(error, `Failed to load cover "${src}"`)),
);
return unobserve;
if (src) {
const unobserve = intersectionObserver.observe(ref.current!, () =>
loadImage(src)
.then(() => setCurrentSrc(src))
.catch((error) =>
logger.error(error, `Failed to load cover "${src}"`),
),
);
return unobserve;
}
}, [src]);

const transitions = useTransition(currentSrc, {
Expand Down
2 changes: 1 addition & 1 deletion apps/pwa/src/components/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const Content = styled.div`
flex: 1;
min-height: 0;

font-size: 14px;
font-size: ${CSSVariable.TEXT_SIZE_NORMAL};
color: ${CSSVariable.TEXT_COLOR_SECONDARY};
line-height: 1.5;
overflow: auto;
Expand Down
2 changes: 1 addition & 1 deletion apps/pwa/src/components/empty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Style = styled.div`
}

> .description {
font-size: 12px;
font-size: ${CSSVariable.TEXT_SIZE_SMALL};
color: ${CSSVariable.TEXT_COLOR_SECONDARY};

${capitalize}
Expand Down
2 changes: 1 addition & 1 deletion apps/pwa/src/components/error_card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Style = styled.div`
max-width: 400px;

white-space: pre-wrap;
font-size: 12px;
font-size: ${CSSVariable.TEXT_SIZE_SMALL};
line-height: 1.5;
text-align: center;

Expand Down
3 changes: 2 additions & 1 deletion apps/pwa/src/components/file_select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import selectFile from '../utils/select_file';
const Style = styled.div<{ disabled: boolean }>`
padding: 10px 20px;

border-radius: ${CSSVariable.BORDER_RADIUS_NORMAL};
border: 1px solid ${CSSVariable.COLOR_BORDER};
cursor: pointer;
text-align: center;
font-size: 12px;
font-size: ${CSSVariable.TEXT_SIZE_SMALL};
transition: inherit;
user-select: none;
word-break: break-all;
Expand Down
2 changes: 1 addition & 1 deletion apps/pwa/src/components/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Input = styled.input`
border-radius: ${CSSVariable.BORDER_RADIUS_NORMAL};
border: 1px solid ${CSSVariable.COLOR_BORDER};
color: ${CSSVariable.TEXT_COLOR_PRIMARY};
font-size: 14px;
font-size: ${CSSVariable.TEXT_SIZE_NORMAL};
outline: none;
transition: inherit;
-webkit-tap-highlight-color: transparent;
Expand Down
2 changes: 1 addition & 1 deletion apps/pwa/src/components/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Style = styled.label`
min-width: 0;

color: ${CSSVariable.TEXT_COLOR_PRIMARY};
font-size: 12px;
font-size: ${CSSVariable.TEXT_SIZE_SMALL};
transition: inherit;
${upperCaseFirstLetter}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/pwa/src/components/menu_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Style = styled.div<{ active: boolean }>`
border-radius: ${CSSVariable.BORDER_RADIUS_NORMAL};

> .label {
font-size: 14px;
font-size: ${CSSVariable.TEXT_SIZE_NORMAL};
${capitalize}
}

Expand Down
5 changes: 0 additions & 5 deletions apps/pwa/src/components/multiple_select/constants.ts

This file was deleted.

5 changes: 0 additions & 5 deletions apps/pwa/src/components/multiple_select/index.tsx

This file was deleted.

121 changes: 0 additions & 121 deletions apps/pwa/src/components/multiple_select/multiple_select.tsx

This file was deleted.

Loading