Commit 9b6f9861 authored by 郭志伟's avatar 郭志伟

Merge branch 'feature/apollo' into 'master'

Feature/apollo

See merge request !19
parents 563ff17a 00ee7f0f
...@@ -17,6 +17,8 @@ app/**/*.js ...@@ -17,6 +17,8 @@ app/**/*.js
config/plugin.local.js config/plugin.local.js
config/plugin.js config/plugin.js
config/config.*.js config/config.*.js
config/apollo.json
config/apollo.ssr.json
index.js index.js
config/manifest.json config/manifest.json
app/view/* app/view/*
......
import { Controller, Context } from 'egg'; import { Controller, Context } from 'egg';
import { trim, omitBy } from 'lodash'; import { trim, omitBy } from 'lodash';
import { v1 as uuidv1 } from 'uuid'; import { v1 as uuidv1 } from 'uuid';
import * as path from 'path';
export default class EditorController extends Controller { export default class EditorController extends Controller {
public async login(ctx: Context) { public async login(ctx: Context) {
...@@ -9,7 +9,12 @@ export default class EditorController extends Controller { ...@@ -9,7 +9,12 @@ export default class EditorController extends Controller {
} }
public async home(ctx: Context) { public async home(ctx: Context) {
await ctx.renderClient('editor.js', {}); let apollo = {};
if (process.env.NODE_ENV === 'production' && process.env.EGG_SERVER_ENV === 'sit') {
apollo = ctx.app.config.apollo || {};
}
await ctx.renderClient('editor.js', { apollo });
} }
public async save(ctx: Context) { public async save(ctx: Context) {
......
...@@ -4,8 +4,8 @@ export default { ...@@ -4,8 +4,8 @@ export default {
apiHost: `http://localhost:7001/`, apiHost: `http://localhost:7001/`,
// apiHost: `http://192.168.28.199:7001/`, // apiHost: `http://192.168.28.199:7001/`,
// apiHost: 'https://quantum-blocks-vcc2.liangkebang.net/', // apiHost: 'https://quantum-blocks-vcc2.liangkebang.net/',
h5Host: 'https://quantum-h5-vcc2.liangkebang.net/', h5Host: 'https://quantum-h5-vcc2.liangkebang.net',
qiniuHost: `https://appsync.lkbang.net/`, qiniuHost: `https://appsync.lkbang.net`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`, shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`,
opapiHost: `https://opapi-vcc2.liangkebang.net`, opapiHost: `https://opapi-vcc2.liangkebang.net`,
qiniuUpHost: `${protocol}//up-z0.qiniup.com`, qiniuUpHost: `${protocol}//up-z0.qiniup.com`,
......
...@@ -3,4 +3,4 @@ import dev from './dev.config'; ...@@ -3,4 +3,4 @@ import dev from './dev.config';
import test from './test.config'; import test from './test.config';
// export default process.env.NODE_ENV === 'test' ? test : process.env.NODE_ENV === 'production' ? prod : dev; // export default process.env.NODE_ENV === 'test' ? test : process.env.NODE_ENV === 'production' ? prod : dev;
export default process.env.SENTRY_ENV ? test : process.env.NODE_ENV === 'production' ? prod : dev; export default process.env.SENTRY_ENV ? test : process.env.NODE_ENV === 'production' ? prod : dev;
const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https'; const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https';
export default { const hostMap = {
apiHost: `https://quantum-blocks.q-gp.com/`, apiHost: `${protocol}//quantum-blocks.q-gp.com`,
h5Host: 'https://quantum-h5.q-gp.com/', h5Host: '${protocol}//quantum-h5.q-gp.com',
qiniuHost: `https://appsync.lkbang.net/`, qiniuHost: `${protocol}//appsync.lkbang.net`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=production`, shenceUrl: `${protocol}//bn.xyqb.com/sa?project=production`,
opapiHost: `${protocol}//opapi.q-gp.com`, opapiHost: `${protocol}//opapi.q-gp.com`,
qiniuUpHost: `${protocol}//up-z0.qiniup.com`, qiniuUpHost: `${protocol}//up-z0.qiniup.com`,
}; };
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;
\ No newline at end of file
const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https'; const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https';
export default { const hostMap = {
apiHost: `https://quantum-blocks-test1.liangkebang.net/`, apiHost: `${protocol}//quantum-blocks-test1.liangkebang.net`,
h5Host: 'https://quantum-h5-test1.liangkebang.net/', h5Host: '${protocol}//quantum-h5-test1.liangkebang.net',
opapiHost: 'https://opapi-test1.liangkebang.net', opapiHost: '${protocol}//opapi-test1.liangkebang.net',
qiniuHost: `https://appsync.lkbang.net/`, qiniuHost: `${protocol}//appsync.lkbang.net`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=production`, shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`,
qiniuUpHost: `${protocol}//up-z0.qiniup.com`, qiniuUpHost: `${protocol}//up-z0.qiniup.com`,
}; };
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;
...@@ -3,7 +3,8 @@ declare var EASY_ENV_IS_BROWSER: boolean; ...@@ -3,7 +3,8 @@ declare var EASY_ENV_IS_BROWSER: boolean;
declare var __webpack_public_path__: string; declare var __webpack_public_path__: string;
type PlainObject<T = any> = { [key: string]: T }; type PlainObject<T = any> = { [key: string]: T };
interface Window { interface Window {
__INITIAL_STATE__: string; __INITIAL_STATE__: string | any;
__POWERED_BY_QIANKUN__: string; __POWERED_BY_QIANKUN__: string;
__INJECTED_PUBLIC_PATH_BY_QIANKUN__: string; __INJECTED_PUBLIC_PATH_BY_QIANKUN__: string;
} }
\ No newline at end of file declare var apollo: any;
\ No newline at end of file
...@@ -94,7 +94,7 @@ export default class DynamicForm extends Vue { ...@@ -94,7 +94,7 @@ export default class DynamicForm extends Vue {
const base64 = canvas.toDataURL(); const base64 = canvas.toDataURL();
const { data: { uptoken } } = await editorApi.getUpToken(); const { data: { uptoken } } = await editorApi.getUpToken();
const { data: { key } } = await editorApi.uploadBase64(base64.split(',')[1], imgName, `UpToken ${uptoken}`); const { data: { key } } = await editorApi.uploadBase64(base64.split(',')[1], imgName, `UpToken ${uptoken}`);
this.formCustom.coverImage = config.qiniuHost + key; this.formCustom.coverImage = config.qiniuHost + '/' + key;
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
title: '上传成功', title: '上传成功',
desc: '', desc: '',
}); });
this.img = config.qiniuHost + res.hash; this.img = config.qiniuHost + '/' + res.hash;
this.$emit('input', this.img); this.$emit('input', this.img);
this.$emit('change', this.img); this.$emit('change', this.img);
// this.url = config.qiniuHost + res.hash; // this.url = config.qiniuHost + res.hash;
...@@ -118,43 +118,48 @@ ...@@ -118,43 +118,48 @@
margin-bottom: 10px; margin-bottom: 10px;
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
&-img { &-img {
display: inline-block; display: inline-block;
width: 60px; width: 60px;
height: 60px; height: 60px;
text-align: center; text-align: center;
line-height: 60px; line-height: 60px;
border: 1px solid transparent; border: 1px solid transparent;
border-radius: 4px; border-radius: 4px;
overflow: hidden; overflow: hidden;
background: #fff; background: #fff;
position: relative; position: relative;
box-shadow: 0 1px 1px rgba(0,0,0,.2); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
margin-right: 4px; margin-right: 4px;
img {
width: 100%; img {
height: 100%; width: 100%;
} height: 100%;
&-cover { }
display: none;
position: absolute; &-cover {
top: 0; display: none;
bottom: 0; position: absolute;
left: 0; top: 0;
right: 0; bottom: 0;
background: rgba(0,0,0,.6); left: 0;
i { right: 0;
margin: 0 2px; background: rgba(0, 0, 0, 0.6);
color: #fff;
font-size: 20px; i {
cursor: pointer; margin: 0 2px;
} color: #fff;
font-size: 20px;
cursor: pointer;
} }
&:hover { }
.upload-img-cover {
display: block; &:hover {
} .upload-img-cover {
display: block;
} }
}
} }
&-container { &-container {
...@@ -163,9 +168,11 @@ ...@@ -163,9 +168,11 @@
width: 56px; width: 56px;
height: 56px; height: 56px;
line-height: 56px; line-height: 56px;
#upload_pic { #upload_pic {
} }
/deep/ .ivu-progress { /deep/ .ivu-progress {
box-sizing: content-box; box-sizing: content-box;
height: 50px; height: 50px;
......
...@@ -89,7 +89,7 @@ export default class DashBoard extends Mixins(ContextMenuMixin, GoodsTabsMixin, ...@@ -89,7 +89,7 @@ export default class DashBoard extends Mixins(ContextMenuMixin, GoodsTabsMixin,
// 清除新增数据时的缓存 // 清除新增数据时的缓存
if (!isCreate) { this.removeDefaultCache(); } if (!isCreate) { this.removeDefaultCache(); }
if (type === 'preview') { if (type === 'preview') {
window.open(`${config.h5Host}activity/${this.uuid}`); window.open(`${config.h5Host}/activity/${this.uuid}`);
} else { } else {
this.$Notice.success({ title: '保存成功!' }); this.$Notice.success({ title: '保存成功!' });
} }
......
...@@ -75,7 +75,7 @@ export default { ...@@ -75,7 +75,7 @@ export default {
title: '链接', title: '链接',
hideSearch: true, hideSearch: true,
render: (h, params) => { render: (h, params) => {
return h('span', `${config.h5Host}activity/${params.row.uuid}`) return h('span', `${config.h5Host}/activity/${params.row.uuid}`)
} }
}, },
{ {
......
...@@ -75,7 +75,7 @@ export default { ...@@ -75,7 +75,7 @@ export default {
title: '链接', title: '链接',
hideSearch: true, hideSearch: true,
render: (h, params) => { render: (h, params) => {
return h('span', `${config.h5Host}activity/${params.row.uuid}`) return h('span', `${config.h5Host}/activity/${params.row.uuid}`)
} }
}, },
{ {
......
...@@ -2,6 +2,11 @@ import { AxiosRequestConfig } from 'axios'; ...@@ -2,6 +2,11 @@ import { AxiosRequestConfig } from 'axios';
declare var window: Window; declare var window: Window;
declare var EASY_ENV_IS_NODE: boolean; declare var EASY_ENV_IS_NODE: boolean;
declare global {
interface Window {
apollo: any;
}
}
interface Window { interface Window {
__INITIAL_STATE__: any; __INITIAL_STATE__: any;
......
...@@ -11,10 +11,11 @@ ...@@ -11,10 +11,11 @@
<link rel="stylesheet" type="text/css" href="https://activitystatic.lkbang.net/swiper/4.5.1/css/swiper.min.css"> <link rel="stylesheet" type="text/css" href="https://activitystatic.lkbang.net/swiper/4.5.1/css/swiper.min.css">
<style> <style>
html { html {
font-size: 37.5Px !important; font-size: 37.5px !important;
} }
html, body { html,
body {
line-height: 1.15 !important; line-height: 1.15 !important;
} }
</style> </style>
......
#!/usr/bin/env node
"use strict";
const path = require('path');
const fs = require('fs');
const apollo = require('@qg/apollo-nodejs');
const npm = require("npm");
npm.load(() => {
apollo.load({
appId: 'quantum-block-h5',
configPath: path.resolve(__dirname, '../config'),
}).then(() => {
const { api, qiniu } = require(path.resolve('./config/apollo.json'));
fs.writeFileSync(path.resolve('./config/apollo.ssr.json'), JSON.stringify({ ...api, ...qiniu }));
});
});
\ No newline at end of file
#!/usr/bin/env node #!/usr/bin/env node
"use strict"; "use strict";
const path = require('path');
const fs = require('fs');
const apollo = require('@qg/apollo-nodejs');
const npm = require("npm"); const npm = require("npm");
npm.load(() => { npm.load(() => {
if (process.env.NODE_ENV === 'production') { apollo.load({
npm.run("start"); appId: 'quantum-block-h5',
} else { configPath: path.resolve(__dirname, '../config'),
npm.run("test"); }).then(() => {
} const { api, qiniu } = require(path.resolve('./config/apollo.json'));
fs.writeFileSync(path.resolve('./config/apollo.ssr.json'), JSON.stringify({ ...api, ...qiniu }));
if (process.env.NODE_ENV === 'production') {
npm.run("start");
} else {
npm.run("test");
}
});
}); });
\ No newline at end of file
import { EggAppConfig } from 'egg'; import { EggAppConfig } from 'egg';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
export default (appInfo: EggAppConfig) => { export default (appInfo: EggAppConfig) => {
const config: any = {}; const config: any = {};
......
...@@ -22,16 +22,14 @@ export default (appInfo: EggAppConfig) => { ...@@ -22,16 +22,14 @@ export default (appInfo: EggAppConfig) => {
injectCss: false injectCss: false
}; };
const localMysqlConfig = { exports.sequelize = {
dialect: 'mysql', dialect: 'mysql',
username: 'qa', username: 'qa',
password: 'qatest', password: 'qatest',
host: '172.17.5.9', host: '172.17.5.9',
port: 31024, port: 31024,
database: 'low_code', database: 'low_code',
}; };;
exports.sequelize = localMysqlConfig;
exports.redis = { exports.redis = {
default: { default: {
......
...@@ -13,7 +13,8 @@ export default (appInfo: EggAppConfig) => { ...@@ -13,7 +13,8 @@ export default (appInfo: EggAppConfig) => {
dir: '/home/quant_group/logs', dir: '/home/quant_group/logs',
}; };
const prodMysqlConfig = {
exports.sequelize = {
dialect: 'mysql', dialect: 'mysql',
username: 'low_code_w', username: 'low_code_w',
password: 'B2pRHuGMLBNybuKp', password: 'B2pRHuGMLBNybuKp',
...@@ -22,20 +23,7 @@ export default (appInfo: EggAppConfig) => { ...@@ -22,20 +23,7 @@ export default (appInfo: EggAppConfig) => {
database: 'low_code', database: 'low_code',
}; };
const localMysqlConfig = { exports.redis = {
dialect: 'mysql',
username: 'qa',
password: 'qatest',
host: '172.17.5.9',
port: 31024,
database: 'low_code',
};
console.log('process.env.NAMESPACE', process.env.NAMESPACE);
exports.sequelize = process.env.NAMESPACE ? localMysqlConfig : prodMysqlConfig;
const prodRedisConfig = {
default: { default: {
keyPrefix: appInfo.name + ':', keyPrefix: appInfo.name + ':',
}, },
...@@ -47,19 +35,5 @@ export default (appInfo: EggAppConfig) => { ...@@ -47,19 +35,5 @@ export default (appInfo: EggAppConfig) => {
} }
}; };
const localRedisConfig = {
default: {
keyPrefix: appInfo.name + ':',
},
client: {
port: 31565, // Redis port
host: '172.17.5.13', // Redis host
password: '',
db: 0
}
};
exports.redis = process.env.NAMESPACE ? localRedisConfig: prodRedisConfig;
return exports; return exports;
}; };
const path = require('path');
import { Application, EggAppConfig } from 'egg';
const { mysql, redis, api, qiniu } = require(path.resolve(__dirname, './apollo.json'));
export default (appInfo: EggAppConfig) => {
const exports: any = {};
exports.logger = {
dir: '/home/quant_group/logs',
};
exports.sequelize = {
dialect: 'mysql',
...mysql.low_code
};
exports.redis = {
default: {
keyPrefix: appInfo.name + ':',
},
client: redis
};
return {...exports, apollo: { ...api, ...qiniu }};
};
import { Application, EggAppConfig } from 'egg';
export default (appInfo: EggAppConfig) => {
const exports: any = {};
return exports;
};
declare module "*.json" {
const value: any;
export default value;
}
\ No newline at end of file
This diff is collapsed.
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
"version": "0.0.1", "version": "0.0.1",
"description": "低代码平台", "description": "低代码平台",
"scripts": { "scripts": {
"start": "egg-scripts start --port 9050 --workers 1", "start": "cross-env NODE_ENV=production APOLLO_CLUSTER=RC egg-scripts start --port 9050 --workers 1",
"test": "egg-scripts start --port 80 --workers 1", "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", "stop": "egg-scripts stop",
"backend": "nohup egg-scripts start --port 7001 --workers 4", "backend": "nohup egg-scripts start --port 7001 --workers 4",
"dev": "egg-bin dev -r egg-ts-helper/register", "dev": "egg-bin dev -r egg-ts-helper/register",
"debug": "egg-bin debug -r egg-ts-helper/register", "debug": "egg-bin debug -r egg-ts-helper/register",
"apollo": "node bin/apollo.js",
"build": "easy build --devtool", "build": "easy build --devtool",
"tsc": "ets && tsc -p tsconfig.json", "tsc": "ets && tsc -p tsconfig.json",
"clean": "ets clean", "clean": "ets clean",
...@@ -24,14 +25,16 @@ ...@@ -24,14 +25,16 @@
"@easy-team/easywebpack-cli": "^4.0.0", "@easy-team/easywebpack-cli": "^4.0.0",
"@easy-team/easywebpack-vue": "^4.0.0", "@easy-team/easywebpack-vue": "^4.0.0",
"@hubcarl/json-typescript-mapper": "^2.0.0", "@hubcarl/json-typescript-mapper": "^2.0.0",
"@qg/apollo-nodejs": "^2.1.2",
"@qg/cherry-ui": "2.20.19", "@qg/cherry-ui": "2.20.19",
"@qg/citrus-ui": "0.1.5", "@qg/citrus-ui": "0.1.4-beta4",
"@riophae/vue-treeselect": "^0.4.0", "@riophae/vue-treeselect": "^0.4.0",
"@types/lodash": "^4.14.117", "@types/lodash": "^4.14.117",
"@types/node": "^10.12.0", "@types/node": "^10.12.0",
"@types/validator": "^4.5.26", "@types/validator": "^4.5.26",
"axios": "^0.21.1", "axios": "^0.21.1",
"babel-plugin-transform-vue-jsx": "^4.0.1", "babel-plugin-transform-vue-jsx": "^4.0.1",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^2.1.0", "cz-conventional-changelog": "^2.1.0",
"egg": "^2.3.0", "egg": "^2.3.0",
"egg-bin": "^4.9.0", "egg-bin": "^4.9.0",
......
// This file is created by egg-ts-helper@1.25.8 // This file is created by egg-ts-helper@1.25.9
// Do not modify this file!!!!!!!!! // Do not modify this file!!!!!!!!!
import 'egg'; import 'egg';
......
// This file is created by egg-ts-helper@1.25.8 // This file is created by egg-ts-helper@1.25.9
// Do not modify this file!!!!!!!!! // Do not modify this file!!!!!!!!!
import 'egg'; import 'egg';
......
// This file is created by egg-ts-helper@1.25.8 // This file is created by egg-ts-helper@1.25.9
// Do not modify this file!!!!!!!!! // Do not modify this file!!!!!!!!!
import 'egg'; import 'egg';
......
// This file is created by egg-ts-helper@1.25.8 // This file is created by egg-ts-helper@1.25.9
// Do not modify this file!!!!!!!!! // Do not modify this file!!!!!!!!!
import 'egg'; import 'egg';
......
// This file is created by egg-ts-helper@1.25.8 // This file is created by egg-ts-helper@1.25.9
// Do not modify this file!!!!!!!!! // Do not modify this file!!!!!!!!!
import 'egg'; import 'egg';
......
// This file is created by egg-ts-helper@1.25.8 // This file is created by egg-ts-helper@1.25.9
// Do not modify this file!!!!!!!!! // Do not modify this file!!!!!!!!!
import 'egg'; import 'egg';
......
// This file is created by egg-ts-helper@1.25.8 // This file is created by egg-ts-helper@1.25.9
// Do not modify this file!!!!!!!!! // Do not modify this file!!!!!!!!!
import 'egg'; import 'egg';
......
...@@ -6,6 +6,7 @@ const SentryConfig = require("./app/web/.sentryclirc.ts"); ...@@ -6,6 +6,7 @@ const SentryConfig = require("./app/web/.sentryclirc.ts");
let { name } = require('./package'); let { name } = require('./package');
name = name.replace(/-/g, ''); name = name.replace(/-/g, '');
module.exports = { module.exports = {
entry: { entry: {
'login': 'app/web/page/login/index.vue', 'login': 'app/web/page/login/index.vue',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment