Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nocobase
Commits
6a7aa227
Commit
6a7aa227
authored
3 years ago
by
chenos
Browse files
Options
Download
Email Patches
Plain Diff
feat: improve code
parent
019d182a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
packages/api/src/index.ts
+4
-1
packages/api/src/index.ts
packages/app/.umirc.ts
+1
-0
packages/app/.umirc.ts
packages/app/src/pages/index.tsx
+2
-0
packages/app/src/pages/index.tsx
packages/client/src/index.tsx
+0
-2
packages/client/src/index.tsx
packages/plugin-client/src/plugin.ts
+20
-0
packages/plugin-client/src/plugin.ts
with
27 additions
and
3 deletions
+27
-3
packages/api/src/index.ts
+
4
-
1
View file @
6a7aa227
...
...
@@ -41,7 +41,6 @@ const plugins = [
'
@nocobase/plugin-collection-manager
'
,
'
@nocobase/plugin-ui-schema-storage
'
,
'
@nocobase/plugin-ui-routes-storage
'
,
'
@nocobase/plugin-client
'
,
'
@nocobase/plugin-file-manager
'
,
'
@nocobase/plugin-system-settings
'
,
'
@nocobase/plugin-users
'
,
...
...
@@ -53,6 +52,10 @@ for (const plugin of plugins) {
api
.
plugin
(
require
(
plugin
).
default
);
}
api
.
plugin
(
require
(
'
@nocobase/plugin-client
'
).
default
,
{
dist
:
resolve
(
__dirname
,
'
../../app/dist
'
),
});
if
(
process
.
argv
.
length
<
3
)
{
// @ts-ignore
process
.
argv
.
push
(
'
start
'
,
'
--port
'
,
process
.
env
.
API_PORT
||
12302
);
...
...
This diff is collapsed.
Click to expand it.
packages/app/.umirc.ts
+
1
-
0
View file @
6a7aa227
...
...
@@ -13,6 +13,7 @@ const umiConfig = getUmiConfig();
export
default
defineConfig
({
define
:
{
'
process.env.NOCOBASE_ENV
'
:
process
.
env
.
NOCOBASE_ENV
,
...
umiConfig
.
define
,
},
// only proxy when using `umi dev`
...
...
This diff is collapsed.
Click to expand it.
packages/app/src/pages/index.tsx
+
2
-
0
View file @
6a7aa227
...
...
@@ -35,6 +35,8 @@ import { I18nextProvider } from 'react-i18next';
import
{
Link
,
NavLink
}
from
'
react-router-dom
'
;
import
apiClient
from
'
./apiClient
'
;
console
.
log
=
(...
args
)
=>
null
;
apiClient
.
axios
.
interceptors
.
response
.
use
(
(
response
)
=>
response
,
(
error
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
packages/client/src/index.tsx
+
0
-
2
View file @
6a7aa227
import
debug
from
'
debug
'
;
import
'
./global.less
'
;
debug
.
log
=
console
.
log
.
bind
(
console
);
export
*
from
'
./acl
'
;
export
*
from
'
./antd-config-provider
'
;
...
...
This diff is collapsed.
Click to expand it.
packages/plugin-client/src/plugin.ts
+
20
-
0
View file @
6a7aa227
import
{
skip
}
from
'
@nocobase/acl
'
;
import
{
Plugin
}
from
'
@nocobase/server
'
;
import
send
from
'
koa-send
'
;
import
serve
from
'
koa-static
'
;
import
{
resolve
}
from
'
path
'
;
export
class
ClientPlugin
extends
Plugin
{
async
beforeLoad
()
{
...
...
@@ -36,6 +39,23 @@ export class ClientPlugin extends Plugin {
},
},
});
let
root
=
this
.
options
.
dist
;
if
(
root
&&
!
root
.
startsWith
(
'
/
'
))
{
root
=
resolve
(
process
.
cwd
(),
root
);
}
this
.
app
.
middleware
.
unshift
(
async
(
ctx
,
next
)
=>
{
if
(
process
.
env
.
NOCOBASE_ENV
===
'
production
'
)
{
return
next
();
}
if
(
!
root
)
{
return
next
();
}
await
serve
(
root
)(
ctx
,
next
);
// console.log('koa-send', root, ctx.status);
if
(
ctx
.
status
==
404
)
{
return
send
(
ctx
,
'
index.html
'
,
{
root
});
}
});
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help