Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
op-web-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
op-web-service
Commits
9661ddf4
Commit
9661ddf4
authored
Jun 09, 2021
by
lvweichao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: koa route static index
parent
60f06237
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
4 deletions
+25
-4
app.js
app.js
+2
-1
static-router.js
server/controllers/static-router.js
+17
-0
router.js
server/router.js
+3
-0
index.js
src/router/index.js
+2
-2
vue.config.js
vue.config.js
+1
-1
No files found.
app.js
View file @
9661ddf4
...
@@ -11,10 +11,11 @@ const env = process.env.NODE_ENV;
...
@@ -11,10 +11,11 @@ const env = process.env.NODE_ENV;
const
app
=
new
Koa
();
const
app
=
new
Koa
();
app
.
use
(
router
.
routes
(),
router
.
allowedMethods
());
app
.
use
(
serve
(
path
.
join
(
__dirname
,
'./public'
)));
app
.
use
(
serve
(
path
.
join
(
__dirname
,
'./public'
)));
app
.
use
(
koaBody
({
multipart
:
true
}));
app
.
use
(
koaBody
({
multipart
:
true
}));
app
.
use
(
bodyParser
());
app
.
use
(
bodyParser
());
app
.
use
(
router
.
routes
(),
router
.
allowedMethods
());
app
.
listen
(
config
.
port
,
()
=>
{
app
.
listen
(
config
.
port
,
()
=>
{
console
.
info
(
console
.
info
(
...
...
server/controllers/static-router.js
0 → 100644
View file @
9661ddf4
const
fs
=
require
(
'fs'
)
const
path
=
require
(
'path'
)
const
cachePage
=
null
;
exports
.
index
=
(
ctx
,
next
)
=>
{
console
.
log
(
'----- home'
)
if
(
!
cachePage
)
{
cachePage
=
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'../../public/dist/index.html'
),
{
encoding
:
'utf-8'
})
}
const
content
=
cachePage
;
ctx
.
body
=
content
}
\ No newline at end of file
server/router.js
View file @
9661ddf4
const
Router
=
require
(
"koa-router"
);
const
Router
=
require
(
"koa-router"
);
const
static
=
require
(
"./controllers/static-router"
);
const
system
=
require
(
"./controllers/system"
);
const
system
=
require
(
"./controllers/system"
);
const
user
=
require
(
"./controllers/user"
);
const
user
=
require
(
"./controllers/user"
);
const
enterprise
=
require
(
"./controllers/enterprise"
);
const
enterprise
=
require
(
"./controllers/enterprise"
);
...
@@ -9,6 +10,8 @@ const image = require('./controllers/image')
...
@@ -9,6 +10,8 @@ const image = require('./controllers/image')
const
router
=
Router
();
const
router
=
Router
();
const
API_VERSION
=
"/api/v1"
;
const
API_VERSION
=
"/api/v1"
;
router
.
get
(
'/'
,
static
.
index
)
// router.post(`${API_VERSION}/login`, system.login);
// router.post(`${API_VERSION}/login`, system.login);
router
.
get
(
`
${
API_VERSION
}
/fetch_user`
,
system
.
fetch_user
);
router
.
get
(
`
${
API_VERSION
}
/fetch_user`
,
system
.
fetch_user
);
router
.
get
(
`
${
API_VERSION
}
/user/:type`
,
user
.
query
)
router
.
get
(
`
${
API_VERSION
}
/user/:type`
,
user
.
query
)
...
...
src/router/index.js
View file @
9661ddf4
import
{
createRouter
,
createWebHistory
}
from
"vue-router"
;
import
{
createRouter
,
createWebH
ashH
istory
}
from
"vue-router"
;
import
Certification
from
'@/pages/Enterprise/Certification'
import
Certification
from
'@/pages/Enterprise/Certification'
import
Audit
from
'@/pages/Enterprise/Audit'
import
Audit
from
'@/pages/Enterprise/Audit'
...
@@ -113,7 +113,7 @@ const routes = [
...
@@ -113,7 +113,7 @@ const routes = [
];
];
const
router
=
createRouter
({
const
router
=
createRouter
({
history
:
createWebHistory
(),
history
:
createWebH
ashH
istory
(),
routes
routes
});
});
...
...
vue.config.js
View file @
9661ddf4
...
@@ -5,7 +5,7 @@ const isDev = process.env.NODE_ENV === 'development';
...
@@ -5,7 +5,7 @@ const isDev = process.env.NODE_ENV === 'development';
module
.
exports
=
{
module
.
exports
=
{
outputDir
:
isDev
outputDir
:
isDev
?
'./dist'
?
'./dist'
:
path
.
resolve
(
'./dist/'
),
:
path
.
resolve
(
'./
public/
dist/'
),
publicPath
:
isDev
?
'/'
:
'/dist'
,
publicPath
:
isDev
?
'/'
:
'/dist'
,
configureWebpack
:
{
configureWebpack
:
{
devServer
:
{
devServer
:
{
...
...
Write
Preview
Markdown
is supported
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