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
config/plugin.local.js
config/plugin.js
config/config.*.js
config/apollo.json
config/apollo.ssr.json
index.js
config/manifest.json
app/view/*
......
import { Controller, Context } from 'egg';
import { trim, omitBy } from 'lodash';
import { v1 as uuidv1 } from 'uuid';
import * as path from 'path';
export default class EditorController extends Controller {
public async login(ctx: Context) {
......@@ -9,7 +9,12 @@ export default class EditorController extends Controller {
}
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) {
......
......@@ -4,8 +4,8 @@ export default {
apiHost: `http://localhost:7001/`,
// apiHost: `http://192.168.28.199:7001/`,
// apiHost: 'https://quantum-blocks-vcc2.liangkebang.net/',
h5Host: 'https://quantum-h5-vcc2.liangkebang.net/',
qiniuHost: `https://appsync.lkbang.net/`,
h5Host: 'https://quantum-h5-vcc2.liangkebang.net',
qiniuHost: `https://appsync.lkbang.net`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`,
opapiHost: `https://opapi-vcc2.liangkebang.net`,
qiniuUpHost: `${protocol}//up-z0.qiniup.com`,
......
const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https';
export default {
apiHost: `https://quantum-blocks.q-gp.com/`,
h5Host: 'https://quantum-h5.q-gp.com/',
qiniuHost: `https://appsync.lkbang.net/`,
const hostMap = {
apiHost: `${protocol}//quantum-blocks.q-gp.com`,
h5Host: '${protocol}//quantum-h5.q-gp.com',
qiniuHost: `${protocol}//appsync.lkbang.net`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=production`,
opapiHost: `${protocol}//opapi.q-gp.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';
export default {
apiHost: `https://quantum-blocks-test1.liangkebang.net/`,
h5Host: 'https://quantum-h5-test1.liangkebang.net/',
opapiHost: 'https://opapi-test1.liangkebang.net',
qiniuHost: `https://appsync.lkbang.net/`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=production`,
const hostMap = {
apiHost: `${protocol}//quantum-blocks-test1.liangkebang.net`,
h5Host: '${protocol}//quantum-h5-test1.liangkebang.net',
opapiHost: '${protocol}//opapi-test1.liangkebang.net',
qiniuHost: `${protocol}//appsync.lkbang.net`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`,
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;
declare var __webpack_public_path__: string;
type PlainObject<T = any> = { [key: string]: T };
interface Window {
__INITIAL_STATE__: string;
__INITIAL_STATE__: string | any;
__POWERED_BY_QIANKUN__: string;
__INJECTED_PUBLIC_PATH_BY_QIANKUN__: string;
}
declare var apollo: any;
\ No newline at end of file
......@@ -94,7 +94,7 @@ export default class DynamicForm extends Vue {
const base64 = canvas.toDataURL();
const { data: { uptoken } } = await editorApi.getUpToken();
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) {
console.log(e);
}
......
......@@ -70,7 +70,7 @@
title: '上传成功',
desc: '',
});
this.img = config.qiniuHost + res.hash;
this.img = config.qiniuHost + '/' + res.hash;
this.$emit('input', this.img);
this.$emit('change', this.img);
// this.url = config.qiniuHost + res.hash;
......@@ -118,6 +118,7 @@
margin-bottom: 10px;
width: 100%;
overflow: hidden;
&-img {
display: inline-block;
width: 60px;
......@@ -129,12 +130,14 @@
overflow: hidden;
background: #fff;
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;
img {
width: 100%;
height: 100%;
}
&-cover {
display: none;
position: absolute;
......@@ -142,7 +145,8 @@
bottom: 0;
left: 0;
right: 0;
background: rgba(0,0,0,.6);
background: rgba(0, 0, 0, 0.6);
i {
margin: 0 2px;
color: #fff;
......@@ -150,6 +154,7 @@
cursor: pointer;
}
}
&:hover {
.upload-img-cover {
display: block;
......@@ -163,9 +168,11 @@
width: 56px;
height: 56px;
line-height: 56px;
#upload_pic {
}
/deep/ .ivu-progress {
box-sizing: content-box;
height: 50px;
......
......@@ -89,7 +89,7 @@ export default class DashBoard extends Mixins(ContextMenuMixin, GoodsTabsMixin,
// 清除新增数据时的缓存
if (!isCreate) { this.removeDefaultCache(); }
if (type === 'preview') {
window.open(`${config.h5Host}activity/${this.uuid}`);
window.open(`${config.h5Host}/activity/${this.uuid}`);
} else {
this.$Notice.success({ title: '保存成功!' });
}
......
......@@ -75,7 +75,7 @@ export default {
title: '链接',
hideSearch: true,
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 {
title: '链接',
hideSearch: true,
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';
declare var window: Window;
declare var EASY_ENV_IS_NODE: boolean;
declare global {
interface Window {
apollo: any;
}
}
interface Window {
__INITIAL_STATE__: any;
......
......@@ -11,10 +11,11 @@
<link rel="stylesheet" type="text/css" href="https://activitystatic.lkbang.net/swiper/4.5.1/css/swiper.min.css">
<style>
html {
font-size: 37.5Px !important;
font-size: 37.5px !important;
}
html, body {
html,
body {
line-height: 1.15 !important;
}
</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
"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 }));
if (process.env.NODE_ENV === 'production') {
npm.run("start");
} else {
npm.run("test");
}
});
});
\ No newline at end of file
import { EggAppConfig } from 'egg';
import * as fs from 'fs';
import * as path from 'path';
export default (appInfo: EggAppConfig) => {
const config: any = {};
......
......@@ -22,16 +22,14 @@ export default (appInfo: EggAppConfig) => {
injectCss: false
};
const localMysqlConfig = {
exports.sequelize = {
dialect: 'mysql',
username: 'qa',
password: 'qatest',
host: '172.17.5.9',
port: 31024,
database: 'low_code',
};
exports.sequelize = localMysqlConfig;
};;
exports.redis = {
default: {
......
......@@ -13,7 +13,8 @@ export default (appInfo: EggAppConfig) => {
dir: '/home/quant_group/logs',
};
const prodMysqlConfig = {
exports.sequelize = {
dialect: 'mysql',
username: 'low_code_w',
password: 'B2pRHuGMLBNybuKp',
......@@ -22,20 +23,7 @@ export default (appInfo: EggAppConfig) => {
database: 'low_code',
};
const localMysqlConfig = {
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 = {
exports.redis = {
default: {
keyPrefix: appInfo.name + ':',
},
......@@ -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;
};
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 @@
"version": "0.0.1",
"description": "低代码平台",
"scripts": {
"start": "egg-scripts start --port 9050 --workers 1",
"test": "egg-scripts start --port 80 --workers 1",
"start": "cross-env NODE_ENV=production APOLLO_CLUSTER=RC egg-scripts start --port 9050 --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",
"backend": "nohup egg-scripts start --port 7001 --workers 4",
"dev": "egg-bin dev -r egg-ts-helper/register",
"debug": "egg-bin debug -r egg-ts-helper/register",
"apollo": "node bin/apollo.js",
"build": "easy build --devtool",
"tsc": "ets && tsc -p tsconfig.json",
"clean": "ets clean",
......@@ -24,14 +25,16 @@
"@easy-team/easywebpack-cli": "^4.0.0",
"@easy-team/easywebpack-vue": "^4.0.0",
"@hubcarl/json-typescript-mapper": "^2.0.0",
"@qg/apollo-nodejs": "^2.1.2",
"@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",
"@types/lodash": "^4.14.117",
"@types/node": "^10.12.0",
"@types/validator": "^4.5.26",
"axios": "^0.21.1",
"babel-plugin-transform-vue-jsx": "^4.0.1",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^2.1.0",
"egg": "^2.3.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!!!!!!!!!
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!!!!!!!!!
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!!!!!!!!!
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!!!!!!!!!
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!!!!!!!!!
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!!!!!!!!!
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!!!!!!!!!
import 'egg';
......
......@@ -6,6 +6,7 @@ const SentryConfig = require("./app/web/.sentryclirc.ts");
let { name } = require('./package');
name = name.replace(/-/g, '');
module.exports = {
entry: {
'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