Commit c5abe3b1 authored by 张烨's avatar 张烨

feat: add website

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