Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
quantum-blocks-h5
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
quantum-blocks-h5
Commits
2dab0b1d
Commit
2dab0b1d
authored
May 26, 2021
by
郭志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: 添加apollo
parent
a3a30c48
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
78 additions
and
29 deletions
+78
-29
.gitignore
.gitignore
+1
-0
activity.ts
app/controller/activity.ts
+6
-1
index.ts
app/web/config/index.ts
+1
-1
prod.config.ts
app/web/config/prod.config.ts
+15
-3
test.config.ts
app/web/config/test.config.ts
+15
-3
index.d.ts
app/web/index.d.ts
+5
-1
server.js
bin/server.js
+15
-5
config.prod.ts
config/config.prod.ts
+2
-13
config.sit.ts
config/config.sit.ts
+16
-0
package.json
package.json
+2
-2
No files found.
.gitignore
View file @
2dab0b1d
...
...
@@ -17,6 +17,7 @@ app/**/*.js
config/plugin.local.js
config/plugin.js
config/config.*.js
config/apollo.json
index.js
config/manifest.json
app/view/*
...
...
app/controller/activity.ts
View file @
2dab0b1d
import
{
Controller
,
Context
}
from
'
egg
'
;
import
*
as
path
from
'
path
'
;
export
default
class
ActivityController
extends
Controller
{
public
async
home
(
ctx
:
Context
)
{
const
{
api
,
qiniu
}
=
await
import
(
path
.
resolve
(
'
./config/apollo.json
'
));
const
redisKey
=
`quantum-blocks:page:
${
ctx
.
params
.
id
}
`
;
let
body
=
await
ctx
.
service
.
redis
.
get
(
redisKey
);
if
(
body
)
{
...
...
@@ -12,6 +13,10 @@ export default class ActivityController extends Controller {
body
=
await
ctx
.
renderView
(
'
activity.js
'
,
{
url
:
ctx
.
url
});
await
ctx
.
service
.
redis
.
set
(
redisKey
,
body
);
}
if
(
process
.
env
.
NODE_ENV
===
'
production
'
)
{
const
firstScriptTagIndex
=
body
.
indexOf
(
'
<script
'
);
body
=
`
${
body
.
slice
(
0
,
firstScriptTagIndex
)}
<script>var apollo =
${
JSON
.
stringify
({...
api
,
...
qiniu
}
)}
;</script>
${
body
.
slice
(
firstScriptTagIndex
,
body
.
length
-
1
)}
`
;
}
ctx
.
body
=
body
;
}
}
\ No newline at end of file
app/web/config/index.ts
View file @
2dab0b1d
app/web/config/prod.config.ts
View file @
2dab0b1d
const
protocol
=
EASY_ENV_IS_BROWSER
?
window
.
location
.
protocol
:
'
https
'
;
export
default
{
apiHost
:
`
https:
//quantum-blocks.q-gp.com/`
,
const
hostMap
=
{
apiHost
:
`
${
protocol
}
//quantum-blocks.q-gp.com/`
,
shenceUrl
:
`
${
protocol
}
//bn.xyqb.com/sa?project=production`
,
// opapiHost: `${protocol}//opapi.q-gp.com`,
test
:
false
};
if
(
EASY_ENV_IS_BROWSER
)
{
const
apolloCfg
=
window
.
apollo
||
window
.
__INITIAL_STATE__
.
apollo
;
if
(
apolloCfg
)
{
for
(
const
key
in
apolloCfg
)
{
if
(
apolloCfg
[
key
])
{
hostMap
[
key
]
=
apolloCfg
[
key
];
}
}
}
}
export
default
hostMap
;
app/web/config/test.config.ts
View file @
2dab0b1d
const
protocol
=
EASY_ENV_IS_BROWSER
?
window
.
location
.
protocol
:
'
https
'
;
export
default
{
apiHost
:
`https://quantum-blocks-test1.liangkebang.net/`
,
// opApiHost: 'https://opapi-test1.liangkebang.net',
const
hostMap
=
{
apiHost
:
`
${
protocol
}
//quantum-blocks-test1.liangkebang.net/`
,
shenceUrl
:
`
${
protocol
}
//bn.xyqb.com/sa?project=default`
,
test
:
true
};
if
(
EASY_ENV_IS_BROWSER
)
{
const
apolloCfg
=
window
.
apollo
||
window
.
__INITIAL_STATE__
.
apollo
;
if
(
apolloCfg
)
{
for
(
const
key
in
apolloCfg
)
{
if
(
apolloCfg
[
key
])
{
hostMap
[
key
]
=
apolloCfg
[
key
];
}
}
}
}
export
default
hostMap
;
app/web/index.d.ts
View file @
2dab0b1d
declare
var
EASY_ENV_IS_NODE
:
boolean
;
declare
var
EASY_ENV_IS_BROWSER
:
boolean
;
type
PlainObject
<
T
=
any
>
=
{
[
key
:
string
]:
T
};
interface
Window
{
__INITIAL_STATE__
:
string
|
any
;
}
declare
var
apollo
:
any
;
bin/server.js
View file @
2dab0b1d
#!/usr/bin/env node
"
use strict
"
;
const
path
=
require
(
'
path
'
);
const
apollo
=
require
(
'
@qg/apollo-nodejs
'
);
const
npm
=
require
(
"
npm
"
);
npm
.
load
(()
=>
{
apollo
.
load
({
appId
:
'
quantum-block-h5
'
,
configPath
:
path
.
resolve
(
__dirname
,
'
../config
'
),
}).
then
(()
=>
{
console
.
log
(
"
>>> apollo file
"
,
require
(
path
.
resolve
(
'
./config/apollo.json
'
)));
if
(
process
.
env
.
NODE_ENV
===
'
production
'
)
{
npm
.
run
(
"
start
"
);
}
else
{
npm
.
run
(
"
test
"
);
}
});
});
\ No newline at end of file
config/config.prod.ts
View file @
2dab0b1d
...
...
@@ -13,25 +13,14 @@ export default (appInfo: EggAppConfig) => {
dir
:
'
/home/quant_group/logs
'
,
};
const
prodRedisConfig
=
{
exports
.
redis
=
{
client
:
{
port
:
6379
,
// Redis port
host
:
'
front-redis.quantgroups.com
'
,
// Redis host
password
:
'
ln4^ESq80j4nrTMZ
'
,
db
:
0
}
};
const
localRedisConfig
=
{
client
:
{
port
:
31565
,
// Redis port
host
:
'
172.17.5.13
'
,
// Redis host
password
:
''
,
db
:
0
}
};
exports
.
redis
=
process
.
env
.
NAMESPACE
?
localRedisConfig
:
prodRedisConfig
;
};;
return
exports
;
};
config/config.
tes
t.ts
→
config/config.
si
t.ts
View file @
2dab0b1d
import
{
Application
,
EggAppConfig
}
from
'
egg
'
;
const
path
=
require
(
'
path
'
);
export
default
(
appInfo
:
EggAppConfig
)
=>
{
const
exports
:
any
=
{};
const
{
redis
}
=
require
(
path
.
resolve
(
'
./config/apollo.json
'
));
exports
.
redis
=
{
default
:
{
keyPrefix
:
appInfo
.
name
+
'
:
'
,
},
client
:
redis
};
return
exports
;
};
package.json
View file @
2dab0b1d
...
...
@@ -3,8 +3,8 @@
"version"
:
"0.0.1"
,
"description"
:
"低代码平台"
,
"scripts"
:
{
"start"
:
"egg-scripts start --port 9050"
,
"test"
:
"egg-scripts start --port 80 --workers 1"
,
"start"
:
"
cross-env NODE_ENV=production APOLLO_CLUSTER=3C
egg-scripts start --port 9050"
,
"test"
:
"
cross-env NODE_ENV=production EGG_SERVER_ENV=sit DEBUG=apollo APOLLO_CLUSTER=k8s NAMESPACE=qa2
egg-scripts start --port 80 --workers 1"
,
"stop"
:
"egg-scripts stop"
,
"backend"
:
"nohup egg-scripts start --port 7001 --workers 4"
,
"dev"
:
"egg-bin dev -r egg-ts-helper/register"
,
...
...
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