Commit a2b960ef authored by 郭志伟's avatar 郭志伟

fix: 问题修复

parent 09fa2065
......@@ -18,6 +18,7 @@ config/plugin.local.js
config/plugin.js
config/config.*.js
config/apollo.json
config/apollo.ssr.json
index.js
config/manifest.json
app/view/*
......
......@@ -10,10 +10,9 @@ export default class ActivityController extends Controller {
}
if (!body) {
let apollo = {};
// if (process.env.NODE_ENV === 'production') {
// const { api, qiniu } = ctx.app.config.apollo || {};
// apollo = { ...api, ...qiniu };
// }
if (process.env.NODE_ENV === 'production' && process.env.EGG_SERVER_ENV === 'sit') {
apollo = ctx.app.config.apollo || {};
}
body = await ctx.renderView('activity.js', { url: ctx.url, apollo });
await ctx.service.redis.set(redisKey, body);
}
......
......@@ -3,6 +3,6 @@ import config from '../config';
export default {
getPageById(params) {
return http.get(`${config.apiHost}editor/get/${params.pageId}`);
return http.get(`${config.apiHost}/editor/get/${params.pageId}`);
}
};
\ No newline at end of file
......@@ -6,15 +6,4 @@ const hostMap = {
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;
import apolloSsr from '../../../config/apollo.ssr.json';
const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'https';
const hostMap = {
......@@ -7,11 +8,20 @@ const hostMap = {
};
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];
const apolloWin = window.apollo || window.__INITIAL_STATE__.apollo;
if (apolloWin) {
for (const key in apolloWin) {
if (apolloWin[key]) {
hostMap[key] = apolloWin[key];
}
}
}
}
if (EASY_ENV_IS_NODE) {
if (apolloSsr) {
for (const key in apolloSsr) {
if (apolloSsr[key]) {
hostMap[key] = apolloSsr[key];
}
}
}
......
declare module "*.json" {
const value: any;
export default value;
}
\ No newline at end of file
import Vue from 'vue';
import { sync } from 'vuex-router-sync';
import initService from '@/service/init.service';
export default class App {
config: any;
constructor(config) {
......
......@@ -2,6 +2,7 @@
"use strict";
const path = require('path');
const fs = require('fs');
const apollo = require('@qg/apollo-nodejs');
const npm = require("npm");
......@@ -10,7 +11,8 @@ npm.load(() => {
appId: 'quantum-block-h5',
configPath: path.resolve(__dirname, '../config'),
}).then(() => {
console.log(">>> apollo file", require(path.resolve('./config/apollo.json')));
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 {
......
import { Application, EggAppConfig } from 'egg';
const path = require('path');
const { redis, api, qiniu } = require(path.resolve('./config/apollo.json'));
export default (appInfo: EggAppConfig) => {
const exports: any = {};
exports.logger = {
dir: '/home/quant_group/logs',
};
const { redis } = require(path.resolve('./config/apollo.json'));
exports.redis = {
client: redis
};
return exports;
return {...exports, apollo: { ...api, ...qiniu }};
};
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