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

feat(refresh): 刷新功能

parent 8f38572b
...@@ -71,6 +71,10 @@ export default class EditorController extends Controller { ...@@ -71,6 +71,10 @@ export default class EditorController extends Controller {
ctx.body = ctx.helper.ok(list); ctx.body = ctx.helper.ok(list);
} }
public async clearCache(ctx: Context) {
ctx.body = ctx.helper.ok({});
}
public async delete(ctx: Context) { public async delete(ctx: Context) {
const pageInfo = await ctx.model.PageInfo.update({ enable: 0 }, {where: { id: +ctx.params.pageId }}); const pageInfo = await ctx.model.PageInfo.update({ enable: 0 }, {where: { id: +ctx.params.pageId }});
ctx.body = ctx.helper.ok(pageInfo); ctx.body = ctx.helper.ok(pageInfo);
......
...@@ -11,6 +11,7 @@ export default (application: Application) => { ...@@ -11,6 +11,7 @@ export default (application: Application) => {
router.post('/editor/save', controller.editor.save); router.post('/editor/save', controller.editor.save);
router.post('/editor/update', controller.editor.update); router.post('/editor/update', controller.editor.update);
router.post('/editor/clearcache', controller.editor.clearCache);
router.get('/editor/get/list', controller.editor.getList); router.get('/editor/get/list', controller.editor.getList);
router.get('/editor/get/template', controller.editor.getTemplateList); router.get('/editor/get/template', controller.editor.getTemplateList);
router.get('/editor/get/:uuid', controller.editor.get); router.get('/editor/get/:uuid', controller.editor.get);
......
...@@ -6,6 +6,9 @@ export default { ...@@ -6,6 +6,9 @@ export default {
getPageList(params) { getPageList(params) {
return http.get('editor/get/list', { params }); return http.get('editor/get/list', { params });
}, },
refreshCache() {
return http.post('editor/clearcache');
},
getPageById(params) { getPageById(params) {
return http.get(`editor/get/${params.pageId}`); return http.get(`editor/get/${params.pageId}`);
}, },
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<script> <script>
import FormList from '../mixins/formList.mixin.ts'; import FormList from '../mixins/formList.mixin.ts';
import { SHOP_CART_CONFIG, SHARE_CONFIG, DEFAULT_CONFIG } from '@service/staticData.service'; import { SHOP_CART_CONFIG, SHARE_CONFIG, DEFAULT_CONFIG } from '@service/staticData.service';
import { v4 as uuid } from 'uuid';
const CONFIG_MAP = { const CONFIG_MAP = {
['购物车']: SHOP_CART_CONFIG, ['购物车']: SHOP_CART_CONFIG,
...@@ -42,6 +43,16 @@ const CONFIG_MAP = { ...@@ -42,6 +43,16 @@ const CONFIG_MAP = {
this.$set(this.list, index, JSON.parse(JSON.stringify(CONFIG_MAP[e]))); this.$set(this.list, index, JSON.parse(JSON.stringify(CONFIG_MAP[e])));
this.oldPersets[index] = e; this.oldPersets[index] = e;
} }
},
add() {
const object = this.formControl.reduce((pre, cur) => {
pre[cur.key] = this.formDefault[cur.key] || '';
return pre;
}, {});
if (object.persets === '自定义') {
object.name = '自定义-' + uuid().slice(19);
}
this.list.push(object);
} }
} }
} }
......
...@@ -77,6 +77,15 @@ export default class DynamicPageForm extends Mixins(ContextMenuMixin) { ...@@ -77,6 +77,15 @@ export default class DynamicPageForm extends Mixins(ContextMenuMixin) {
type: 'select', type: 'select',
options: ['购物车', '分享', '自定义'] options: ['购物车', '分享', '自定义']
}, },
{
key: 'name',
name: '名称',
type: 'text',
props: {
require: true,
placeholder: '(必填) 区分埋点'
}
},
{ {
key: 'txt', key: 'txt',
name: '文字', name: '文字',
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:request="query" :request="query"
@newBtnClick="addPage" @newBtnClick="addPage"
> >
<Button type="default" class="btnStyle" @click="refreshData()">更新缓存</Button>
</QGTable> </QGTable>
</template> </template>
<script> <script>
...@@ -187,7 +188,16 @@ export default { ...@@ -187,7 +188,16 @@ export default {
}, },
addPage() { addPage() {
this.$router.push('/detail'); this.$router.push('/detail');
} },
async refreshData() {
try {
await editorApi.refreshCache();
this.$Notice.success({ title: '刷新成功!' });
} catch (error) {
console.log(error);
this.$Notice.warning({ title: '刷新失败!' });
}
},
}, },
mounted(){} mounted(){}
} }
......
...@@ -90,6 +90,7 @@ export const defaultState = { ...@@ -90,6 +90,7 @@ export const defaultState = {
btAttachVal: [ btAttachVal: [
{ {
persets: '购物车', persets: '购物车',
name: '购物车',
icon: 'shopping-cart-o', icon: 'shopping-cart-o',
url: 'xyqb://shoppingCart?needLogin=1', url: 'xyqb://shoppingCart?needLogin=1',
color: '#333', color: '#333',
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
export const SHOP_CART_CONFIG = { export const SHOP_CART_CONFIG = {
persets: '购物车', persets: '购物车',
txt: '', txt: '',
name: '购物车',
icon: 'shopping-cart-o', icon: 'shopping-cart-o',
url: 'xyqb://shoppingCart?needLogin=1', url: 'xyqb://shoppingCart?needLogin=1',
color: '#333', color: '#333',
...@@ -15,6 +16,7 @@ export const SHOP_CART_CONFIG = { ...@@ -15,6 +16,7 @@ export const SHOP_CART_CONFIG = {
export const BACK_TOP_CONFIG = { export const BACK_TOP_CONFIG = {
persets: '自定义', persets: '自定义',
name: '',
icon: 'back-top-o', icon: 'back-top-o',
background: '#fff', background: '#fff',
color: '#333', color: '#333',
...@@ -25,6 +27,7 @@ export const BACK_TOP_CONFIG = { ...@@ -25,6 +27,7 @@ export const BACK_TOP_CONFIG = {
export const SHARE_CONFIG = { export const SHARE_CONFIG = {
persets: '分享', persets: '分享',
name: '分享',
txt: '', txt: '',
icon: 'share', icon: 'share',
url: '', url: '',
...@@ -39,6 +42,7 @@ export const SHARE_CONFIG = { ...@@ -39,6 +42,7 @@ export const SHARE_CONFIG = {
export const DEFAULT_CONFIG = { export const DEFAULT_CONFIG = {
persets: '自定义', persets: '自定义',
name: '',
txt: '', txt: '',
icon: '', icon: '',
url: '', url: '',
......
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