Commit c5abe3b1 authored by 张烨's avatar 张烨

feat: add website

parent 19dd0baf
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
"update:deps": "yarn upgrade-interactive --latest", "update:deps": "yarn upgrade-interactive --latest",
"presetup": "npm i chalk shelljs", "presetup": "npm i chalk shelljs",
"setup": "node ./internals/scripts/setup.js", "setup": "node ./internals/scripts/setup.js",
"clean": "shjs ./internals/scripts/clean.js",
"clean:all": "npm run analyze:clean && npm run test:clean && npm run build:clean",
"generate": "plop --plopfile internals/generators/index.js", "generate": "plop --plopfile internals/generators/index.js",
"lint": "npm run lint:js && npm run lint:css", "lint": "npm run lint:js && npm run lint:css",
"lint:css": "stylelint src/**/*.less", "lint:css": "stylelint src/**/*.less",
...@@ -46,6 +44,7 @@ ...@@ -46,6 +44,7 @@
"lint:staged": "lint-staged", "lint:staged": "lint-staged",
"pretest": "npm run test:clean && npm run lint", "pretest": "npm run test:clean && npm run lint",
"test:clean": "rimraf ./coverage", "test:clean": "rimraf ./coverage",
"clean:node_modules": "rimraf ./node_modules",
"test": "cross-env NODE_ENV=test jest --coverage", "test": "cross-env NODE_ENV=test jest --coverage",
"test:watch": "cross-env NODE_ENV=test jest --watchAll", "test:watch": "cross-env NODE_ENV=test jest --watchAll",
"coveralls": "cat ./coverage/lcov.info | coveralls", "coveralls": "cat ./coverage/lcov.info | coveralls",
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
require('./env'); require('./env');
const express = require('express'); const express = require('express');
const logger = require('./logger'); const logger = require('./logger');
const argv = require('./argv'); const argv = require('./argv');
const port = require('./port'); const port = require('./port');
const setup = require('./middlewares/frontendMiddleware'); const setup = require('./middlewares/frontendMiddleware');
......
...@@ -5,8 +5,9 @@ import { ...@@ -5,8 +5,9 @@ import {
getWebModuleTree, getWebModuleTree,
getWebconfig, getWebconfig,
postEditWebConfig, postEditWebConfig,
postAddWebSite,
} from '@/services/webConfig/api'; } from '@/services/webConfig/api';
import { cancelled } from 'redux-saga/effects'; import { config } from 'shelljs';
import styles from './index.less'; import styles from './index.less';
import SiteConfig from './components/siteConfigDrawer'; import SiteConfig from './components/siteConfigDrawer';
import { appConnector } from '@/containers/App/store'; import { appConnector } from '@/containers/App/store';
...@@ -122,34 +123,38 @@ const WebConfigPage = props => { ...@@ -122,34 +123,38 @@ const WebConfigPage = props => {
const handleSubmit = values => { const handleSubmit = values => {
setSubmitting(true); setSubmitting(true);
if (isEdit) { const requestMap = {
postEditWebConfig(values) postEditWebConfig,
.then(res => { postAddWebSite,
setSubmitting(false); };
if (res.success) { const successMsg = isEdit ? '保存成功!' : '新增网站成功!';
setCurWeb({ ...curWeb, text: values.title }); const failMsg = isEdit ? '编辑失败!' : '新增网站失败!';
notification.success({ requestMap[isEdit ? 'postEditWebConfig' : 'postAddWebSite'](values)
message: '保存成功!', .then(res => {
duration: 3, setSubmitting(false);
}); if (res.success) {
updateModuleTree(userMode || 'super'); setCurWeb({ ...curWeb, text: values.title });
} else {
notification.warning({
message: res.message || '编辑失败!',
duration: 5,
});
}
})
.catch(err => {
notification.success({ notification.success({
message: '编辑失败!', message: successMsg,
duration: 3,
});
updateModuleTree(userMode || 'super');
} else {
notification.warning({
message: res.message || failMsg,
duration: 5, duration: 5,
}); });
// eslint-disable-next-line no-console }
console.error(err); })
setSubmitting(false); .catch(err => {
notification.error({
message: failMsg,
duration: 5,
}); });
} // eslint-disable-next-line no-console
console.error(err);
setSubmitting(false);
});
}; };
return ( return (
......
import qs from 'qs'; import qs from 'qs';
import { CITY_SERVICE, get, PUBLISH_SERVICE, post, postForm } from '../index'; import { CITY_SERVICE, get, PUBLISH_SERVICE, post, postForm } from '../index';
/**
* 获取所有网站配置
* @param {*} userMode
*/
export const getWebModuleTree = userMode => export const getWebModuleTree = userMode =>
get( get(
`${PUBLISH_SERVICE}/PlatformCenter/WebModuleTree?${qs.stringify({ `${PUBLISH_SERVICE}/PlatformCenter/WebModuleTree?${qs.stringify({
...@@ -8,27 +12,44 @@ export const getWebModuleTree = userMode => ...@@ -8,27 +12,44 @@ export const getWebModuleTree = userMode =>
})}`, })}`,
); );
export const getWebConfigByName = webName => /**
get(`${CITY_SERVICE}/OMS.svc/W4_GetWebsite`, { title: webName }); * 获取主题下拉选项
*/
export const getWebThemes = () => export const getWebThemes = () =>
get(`${CITY_SERVICE}/OMS.svc/W4_GetThemes`, { query: '' }); get(`${CITY_SERVICE}/OMS.svc/W4_GetThemes`, { query: '' });
/**
* 获取登录模板下拉选项
*/
export const getLoginPage = () => export const getLoginPage = () =>
get(`${CITY_SERVICE}/OMS.svc/W4_GetLoginPage`, { query: '' }); get(`${CITY_SERVICE}/OMS.svc/W4_GetLoginPage`, { query: '' });
/**
* 获取地图配置下拉选项
*/
export const getMapCofigs = () => export const getMapCofigs = () =>
get( get(
`${CITY_SERVICE}/OMS.svc/GetAllConfigText?terminalType=scheme&isBaseMap=false`, `${CITY_SERVICE}/OMS.svc/GetAllConfigText?terminalType=scheme&isBaseMap=false`,
{ query: '' }, { query: '' },
); );
/**
* 获取网站配置
* @param {*} title 网站标题
*/
export const getWebconfig = title => export const getWebconfig = title =>
get(`${CITY_SERVICE}/OMS.svc/W4_GetWebsite`, { title }); get(`${CITY_SERVICE}/OMS.svc/W4_GetWebsite`, { title });
export const postEditWebConfig = config => /**
* 编辑或添加网站。默认编辑模式
* @param {*} config 网站配置
* @param {*} isAdd true:添加 false:编辑
*/
export const postEditWebConfig = (config, isAdd = false) =>
post( post(
`${CITY_SERVICE}/OMS.svc/W4_EditWebsite?_version=9999`, `${CITY_SERVICE}/OMS.svc/${
isAdd ? 'W4_AddWebsite' : 'W4_EditWebsite'
}?_version=9999`,
qs.stringify({ config: JSON.stringify(config) }), qs.stringify({ config: JSON.stringify(config) }),
{ {
headers: { headers: {
...@@ -36,3 +57,5 @@ export const postEditWebConfig = config => ...@@ -36,3 +57,5 @@ export const postEditWebConfig = config =>
}, },
}, },
); );
export const postAddWebSite = config => postEditWebConfig(config, true);
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