Commit b4c4615a authored by 郝聪敏's avatar 郝聪敏

feature: 项目拆分

parent f9e8c662
# egg-vue-typescript-boilerplate
# quantum-blocks-h5
基于 Egg + Vue + Webpack SSR 服务端渲染和 CSR 前端渲染工程骨架项目。
基于 Egg + Vue + Webpack SSR 服务端渲染和 CSR 前端渲染工程项目。
Single Page Application Isomorphic Example for Egg + Vue, Front-End and Node of The Application are Written in TypeScript.
......
export function ok(data) {
if (typeof data === 'string') {
return {
code: '0001',
businessCode: '0000',
message: data,
};
}
return {
code: '0000',
businessCode: '0000',
data,
};
}
export function fail({ message = '服务异常', code = '0001', businessCode = '0001' }) {
return {
code,
businessCode,
message,
};
}
......@@ -3,33 +3,7 @@ import config from '../config';
import axios from 'axios';
export default {
getPageList(params) {
return http.get('editor/get/list', { params });
},
getPageById(params) {
return http.get(`editor/get/${params.pageId}`);
},
delPageById(pageId) {
return http.delete(`editor/${pageId}`);
},
updatePage(params) {
return http.post(`editor/update`, params);
},
savePage(params) {
return http.post(`editor/save`, params);
},
getTemplateList() {
return http.get('editor/get/template');
},
getUpToken() {
return axios.get(`${config.opapiHost}/upload/getToken`);
},
uploadBase64(base64Str, name, token) {
return axios.post(`${config.qiniuUpHost}/putb64/-1/key/${name}`, base64Str, {
headers: {
'content-type': 'application/octet-stream',
'Authorization': token,
}
});
}
};
\ No newline at end of file
......@@ -2,24 +2,6 @@ import http from '../service/http.service';
import config from '../config';
export default {
getPageList(params) {
return http.get('editor/get/list', { params });
},
getPageById(params) {
return http.get(`editor/get/${params.pageId}`);
},
delPageById(pageId) {
return http.delete(`editor/${pageId}`);
},
updatePage(params) {
return http.post(`editor/update`, params);
},
savePage(params) {
return http.post(`editor/save`, params);
},
getTemplateList() {
return http.get('editor/get/template');
},
// 商品列表-查询
skuInfo(params) {
return http.post(`${config.opapiHost}/kdspOp/api/kdsp/activity/activity-goods/sku-info/list`, params, {
......
import qs from 'qs';
import http from '../service/http.service';
import config from '../config';
const { opapiHost } = config;
export function getCaptcha() {
return `${opapiHost}/user/captcha`;
}
export function login(params) {
return http.post(`${opapiHost}/backStms/prologue/login`, qs.stringify(params), {
accessToken: true
});
}
export function getUserInfo() {
return http.get(`${opapiHost}/backStms/oauth/currentuserinfo`, {
accessToken: true
});
}
\ No newline at end of file
app/web/asset/images/favicon.ico

4.19 KB | W: | H:

app/web/asset/images/favicon.ico

2.3 KB | W: | H:

app/web/asset/images/favicon.ico
app/web/asset/images/favicon.ico
app/web/asset/images/favicon.ico
app/web/asset/images/favicon.ico
  • 2-up
  • Swipe
  • Onion skin
const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'http';
export default {
apiHost: `http://localhost:7001/`,
apiHost: `http://localhost:7002/`,
// apiHost: `http://192.168.28.199:7001/`,
// apiHost: 'https://quantum-vcc2.liangkebang.net/',
qiniuHost: `https://appsync.lkbang.net/`,
......
......@@ -39,7 +39,7 @@
let lastEvenProgress = 0;
let lastProgress = 0;
return {
showSwiper: true,
showSwiper: false,
// style: {},
swiperOptions: {
loop: this.loop,
......@@ -133,6 +133,9 @@
this.refreshSwiper('loop', newVal);
},
},
mounted() {
this.showSwiper = true;
},
methods: {
go(url) {
window.location.href = url;
......
......@@ -34,7 +34,7 @@
},
data() {
return {
showSwiper: true,
showSwiper: false,
swiperOptions: {
loop: true,
observer:true,
......@@ -63,6 +63,9 @@
}
}
},
mounted() {
this.showSwiper = true;
},
methods: {
go(link) {
window.location.href = link;
......
......@@ -7,7 +7,7 @@ import { resizeDiv } from '@/service/utils.service';
@Component({ components: { CustomMarquee }, name: 'FreedomContainer' })
export default class FreedomContainer extends Mixins(TransformStyleMixin) {
@Getter('pageData') pageData;
@State(state => state.editor.curChildIndex) curChildIndex;
@State(state => state.activity.curChildIndex) curChildIndex;
@Mutation('UPDATE_PAGE_INFO') updatePageInfo;
@Prop({type: Object, default: () => ({ child: [] })}) childItem;
......
......@@ -15,8 +15,8 @@ import { getStyle } from '@/service/utils.service';
@Component({ components: { FreedomContainer, GridLayout, GridItem, DownloadGuide, GoodsTabs, GuideCube, Advertisement, Coupon }, name: 'Activity'})
export default class Activity extends Mixins(TransformStyleMixin) {
@Getter('pageData') pageData;
@State(state => state.editor.pageInfo.pageName) pageName;
@State(state => state.editor.gridLayout.rowHeight) rowHeight;
@State(state => state.activity.pageInfo.pageName) pageName;
@State(state => state.activity.gridLayout.rowHeight) rowHeight;
@Provide('editor');
......@@ -50,7 +50,7 @@ export default class Activity extends Mixins(TransformStyleMixin) {
this.showBackTop = true;
const timer = setTimeout(() => {
this.modfiTabsStyle();
}, 500);
}, 700);
this.$once('hook:beforeDestroy', () => {
clearTimeout(timer);
});
......
......@@ -2,18 +2,18 @@
import Vue from 'vue';
import Vuex from 'vuex';
import RootState from './state';
import Editor from './modules/editor';
import Activity from './modules/activity';
Vue.use(Vuex);
export default function createStore(initState: any = {}) {
const { title, url, origin, locale, csrf, editor } = initState;
console.log('store', title, url, origin, locale, csrf, editor);
const { title, url, origin, locale, csrf, activity } = initState;
console.log('store', title, url, origin, locale, csrf, activity);
const state = { title, url, origin, locale, csrf };
return new Vuex.Store<RootState>({
state,
modules: {
editor: new Editor(editor)
activity: new Activity(activity)
}
});
}
\ No newline at end of file
import api from '@/api/editor.api';
import { Module, GetterTree, ActionTree, MutationTree } from 'vuex';
import Vue from 'vue';
import { UPDATE_PAGE_INFO, SET_PAGE_INFO } from './type';
import RootState from '../../state';
import EditorState, { PageInfo, defaultState, Page, PageElement } from './state';
export default class EditorModule implements Module<EditorState, RootState> {
state: EditorState;
getters: GetterTree<EditorState, RootState> = {
pageData(state) {
return state.pageInfo.page;
}
};
actions: ActionTree<EditorState, RootState> = {
async getPageDate({ commit }, condition) {
const res = await api.getPageById(condition);
const { page, ...rest } = res as PageInfo;
commit(SET_PAGE_INFO, { ...rest, page: JSON.parse(page as string) });
}
};
mutations: MutationTree<EditorState> = {
[SET_PAGE_INFO](state, data) {
state.pageInfo = data;
},
[UPDATE_PAGE_INFO](state, { containerIndex, childIndex, data }) {
const page = (state.pageInfo.page as Page).elements;
if (childIndex || childIndex === 0) {
page[containerIndex].child.splice(childIndex, 1, data);
} else {
page.splice(containerIndex, 1, data);
}
}
};
constructor(initState: EditorState = JSON.parse(JSON.stringify(defaultState))) {
this.state = initState;
}
}
\ No newline at end of file
import api from '@/api/editor.api';
import { Module, GetterTree, ActionTree, MutationTree } from 'vuex';
import Vue from 'vue';
import {
SET_PAGE_INFO,
SET_DRAGABLE,
COPY_OR_DELETE_PAGE_INFO,
UPDATE_PAGE_INFO,
ADD_ELEMENTS,
SET_CUR_ELE_INDEX,
SET_CUR_CHILD_INDEX,
RESET_PAGE_DATA,
SET_TEMPLATE_LIST,
SET_PAGE_DATA,
UPDATE_COMMON_STYLE,
UPDATE_PAGE_STYLE,
UPDATE_PAGE_PROPS
} from './type';
import RootState from '../../state';
import EditorState, { PageInfo, defaultState, Page, PageElement } from './state';
export default class EditorModule implements Module<EditorState, RootState> {
state: EditorState;
getters: GetterTree<EditorState, RootState> = {
pageData(state) {
return state.pageInfo.page;
},
pageId(state) {
return state.pageInfo.id;
},
pageInfo(state) {
return state.pageInfo;
}
};
actions: ActionTree<EditorState, RootState> = {
// pageInfo: 处理过的页面数据 - activity, pageData: 未处理的数据 - editor
async savePageData({ commit }, { pageInfo, pageData}) {
if (pageInfo.id) {
await api.updatePage(pageInfo);
commit(SET_PAGE_INFO, { ...pageInfo, page: pageData });
} else {
const res = await api.savePage(pageInfo);
const { page, ...rest } = res as PageInfo;
commit(SET_PAGE_INFO, { ...rest, page: pageData });
}
},
async getPageDate({ commit }, condition) {
const res = await api.getPageById(condition);
const { page, ...rest } = res as PageInfo;
commit(SET_PAGE_INFO, { ...rest, page: JSON.parse(page as string) });
},
async getTemplateList({ commit }) {
const res = await api.getTemplateList({ type: 'template' });
const handledData = res.map((v, idx) => ({ eleName: `template${idx}`, title: v.pageName, coverImage: v.coverImage, page: v.page }));
// todo 解析数据
commit(SET_TEMPLATE_LIST, handledData);
},
async setTemplateInfo({commit}, condition) {
const res = await api.getPageById(condition);
const { page } = res as PageInfo;
const { pageInfo } = JSON.parse(JSON.stringify(defaultState));
commit(SET_PAGE_INFO, { ...pageInfo, page: JSON.parse(page as string) });
},
setDragable({ commit }, condition) {
commit(SET_DRAGABLE, condition);
},
resetPageData({ commit }, condition) {
const { pageInfo, curEleIndex, curChildIndex } = JSON.parse(JSON.stringify(defaultState));
commit(SET_PAGE_INFO, pageInfo);
commit(SET_CUR_ELE_INDEX, curEleIndex);
commit(SET_CUR_CHILD_INDEX, curChildIndex);
}
};
mutations: MutationTree<EditorState> = {
[SET_PAGE_INFO](state, data) {
state.pageInfo = data;
},
[SET_DRAGABLE](state, data) {
state.gridLayout.draggable = data;
},
[SET_CUR_ELE_INDEX](state, curEleIndex) {
state.curEleIndex = curEleIndex;
},
[SET_CUR_CHILD_INDEX](state, curChildIndex) {
state.curChildIndex = curChildIndex;
},
[SET_TEMPLATE_LIST](state, data) {
state.templateList = data;
},
[SET_PAGE_DATA](state, data) {
state.pageInfo.page = data;
},
[COPY_OR_DELETE_PAGE_INFO](state, { type, containerIndex, childIndex }) {
const page = (state.pageInfo.page as Page).elements;
if (type === 'delete') {
if (childIndex || childIndex === 0) {
page[containerIndex].child.splice(childIndex, 1);
} else {
page.splice(containerIndex, 1);
}
state.curEleIndex = null;
state.curChildIndex = null;
} else if (type === 'copy') {
let eleCopyed = {} as PageElement;
if (childIndex || childIndex === 0) {
eleCopyed = page[containerIndex].child[childIndex];
const { left, top } = eleCopyed.commonStyle;
page[containerIndex].child.push({ ...eleCopyed, commonStyle: { ...eleCopyed.commonStyle, left: left + 10, top: top + 10 } });
} else {
eleCopyed = page[containerIndex];
page.push({ ...eleCopyed, point: { ...eleCopyed.point, i: page.length }});
}
}
},
[UPDATE_PAGE_INFO](state, { containerIndex, childIndex, data }) {
const page = (state.pageInfo.page as Page).elements;
if (childIndex || childIndex === 0) {
page[containerIndex].child.splice(childIndex, 1, data);
} else {
page.splice(containerIndex, 1, data);
}
},
[UPDATE_COMMON_STYLE](state, {containerIndex, childIndex, data}) {
const page = (state.pageInfo.page as Page).elements;
if (childIndex || childIndex === 0) {
Vue.set(page[containerIndex].child[childIndex], 'commonStyle', data);
} else {
Vue.set(page[containerIndex], 'commonStyle', data);
}
},
[UPDATE_PAGE_STYLE](state, { data }) {
(state.pageInfo.page as Page).commonStyle = data;
},
[UPDATE_PAGE_PROPS](state, { data }) {
(state.pageInfo.page as Page).props = data;
},
[ADD_ELEMENTS](state, { containerIndex, data }) {
const page = (state.pageInfo.page as Page).elements;
if (containerIndex || containerIndex === 0) {
page[containerIndex].child.push(data);
} else {
page.push(data);
}
},
};
constructor(initState: EditorState = JSON.parse(JSON.stringify(defaultState))) {
this.state = initState;
}
}
\ No newline at end of file
export default {
cors: {
package: 'egg-cors'
},
webpack: {
package: 'egg-webpack'
},
......
export default {
vuessr: {
package: 'egg-view-vue-ssr'
}
},
cors: {
package: 'egg-cors'
},
};
\ No newline at end of file
// This file is created by egg-ts-helper@1.25.8
// Do not modify this file!!!!!!!!!
import 'egg';
import ExtendIHelper from '../../../app/extend/helper';
type ExtendIHelperType = typeof ExtendIHelper;
declare module 'egg' {
interface IHelper extends ExtendIHelperType { }
}
\ No newline at end of file
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