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

fix: 问题修复

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