Skip to content

Commit ac1bb46

Browse files
committed
feat(template-center)
1 parent 0df158a commit ac1bb46

6 files changed

Lines changed: 38 additions & 17 deletions

File tree

packages/design-core/re-export.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export { default as Styles } from '@opentiny/tiny-engine-setting-styles'
3535
export { default as Layout, LayoutService } from '@opentiny/tiny-engine-layout'
3636
export { default as Canvas } from '@opentiny/tiny-engine-canvas'
3737
export { initPreview } from './src/preview/src/main'
38+
export { initTemplate } from './src/template/src/main'
3839
export {
3940
GenerateCodeService,
4041
PluginPanel,

packages/design-core/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default {
2525
const layoutRegistry = getMergeMeta('engine.layout')
2626
const materialsApi = getMetaApi('engine.plugins.materials')
2727
const blockApi = getMetaApi('engine.plugins.blockmanage')
28-
28+
console.log(layoutRegistry)
2929
// 此处接收画布内部的错误和警告提示
3030
const { data } = useBroadcastChannel({ name: BROADCAST_CHANNEL.Notify })
3131

packages/design-core/src/init.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ export const init = async ({
131131
createAppSignal = [],
132132
initTimeout = 30000
133133
} = {}) => {
134+
// 如果输入的URL没有任何参数则跳转到应用中心
135+
const [baseUrl, query] = window.location.href.split('?')
136+
if (!query) {
137+
window.location.href = `${baseUrl}template.html?type=app`
138+
return
139+
}
134140
const { beforeAppCreate, appCreated, appMounted } = lifeCycles
135141

136142
registerConfigurators(configurators)

packages/design-core/src/preview/src/Toolbar.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<component :is="ToolbarMedia" :isCanvas="false" @setViewPort="setViewPort"></component>
88
</div>
99
<div class="toolbar-right">
10-
<span><tiny-switch v-model="debugSwitch"></tiny-switch><span class="toolbar-button-text">调试模式</span></span>
10+
<span v-if="debugMode === null || debugMode === 'show'"><tiny-switch v-model="debugSwitch"></tiny-switch><span class="toolbar-button-text">调试模式</span></span>
1111
<component :is="ChangeLang" :langChannel="previewLangChannel" :options="langOptions"></component>
1212
</div>
1313
</div>
@@ -33,6 +33,7 @@ export default {
3333
const langOptions = getMergeMeta('engine.toolbars.lang').options
3434
const ToolbarMedia = null // TODO: Media plugin rely on layout/canvas. Further processing is required.
3535
const { setBreadcrumbPage, setBreadcrumbBlock } = useBreadcrumb()
36+
const debugMode = new URLSearchParams(location.search).get('debugmode')
3637
3738
watch(
3839
() => previewState.currentPage,
@@ -63,7 +64,8 @@ export default {
6364
langOptions,
6465
ToolbarMedia,
6566
setViewPort,
66-
debugSwitch
67+
debugSwitch,
68+
debugMode
6769
}
6870
}
6971
}

packages/design-core/src/template/src/template/AppCenter.vue

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
</div>
7171
</template>
7272
</div>
73-
<tiny-grid ref="gridRef" class="table" v-if="state.type === 'table'" :data="appList">
73+
<tiny-grid ref="gridRef" class="table" v-if="state.type === 'table' && appList.length" :data="appList">
7474
<tiny-grid-column field="name" title="应用名称" show-overflow>
7575
<template #default="data">
7676
<div class="app-name">
@@ -90,6 +90,7 @@
9090
</template>
9191
</tiny-grid-column>
9292
</tiny-grid>
93+
<search-empty :isShow="!appList.length" />
9394
</div>
9495
<tiny-pager
9596
v-if="state.total > state.pageSize"
@@ -114,6 +115,7 @@
114115
import { reactive, ref, onMounted } from 'vue'
115116
import { Button, Select, Pager, Grid, GridColumn, Popover, Search, Modal, Notify } from '@opentiny/vue'
116117
import { iconSearch } from '@opentiny/vue-icon'
118+
import { SearchEmpty } from '@opentiny/tiny-engine-common'
117119
import AppDialog from './AppDialog.vue'
118120
import { fetchApplicationList, createApplication, updateApplication, deleteApplication } from '../js/http'
119121
@@ -126,8 +128,9 @@ export default {
126128
TinyGridColumn: GridColumn,
127129
TinyPopover: Popover,
128130
TinySearch: Search,
129-
Modal,
130-
Notify,
131+
TinyModal: Modal,
132+
TinyNotify: Notify,
133+
SearchEmpty,
131134
TinyIconSearch: iconSearch(),
132135
AppDialog
133136
},
@@ -177,7 +180,7 @@ export default {
177180
orderBy: 'created_time',
178181
appSearchKey: '',
179182
type: 'default',
180-
total: 50,
183+
total: 0,
181184
pageSize: 10,
182185
currentPage: 1,
183186
pageSizes: [10, 20, 30, 40],
@@ -210,7 +213,7 @@ export default {
210213
}
211214
212215
const handleDelete = (template) => {
213-
Modal.confirm({
216+
TinyModal.confirm({
214217
message: '即将删除应用,删除后不可恢复,请谨慎操作。',
215218
title: '删除应用'
216219
}).then((res) => {
@@ -220,7 +223,7 @@ export default {
220223
getTemplateList()
221224
})
222225
.catch((error) => {
223-
Notify({
226+
TinyNotify({
224227
type: 'error',
225228
message: error,
226229
position: 'top-right',
@@ -257,7 +260,7 @@ export default {
257260
delete formData.id
258261
updateApplication(updateId, formData)
259262
.then(() => {
260-
Notify({
263+
TinyNotify({
261264
type: 'success',
262265
message: '应用更新成功',
263266
position: 'top-right',
@@ -266,7 +269,7 @@ export default {
266269
getApplicationList()
267270
})
268271
.catch((error) => {
269-
Notify({
272+
TinyNotify({
270273
type: 'error',
271274
message: error,
272275
position: 'top-right',
@@ -276,7 +279,7 @@ export default {
276279
} else {
277280
createApplication(formData)
278281
.then(() => {
279-
Notify({
282+
TinyNotify({
280283
type: 'success',
281284
message: '应用创建成功',
282285
position: 'top-right',
@@ -285,7 +288,7 @@ export default {
285288
getApplicationList()
286289
})
287290
.catch((error) => {
288-
Notify({
291+
TinyNotify({
289292
type: 'error',
290293
message: error,
291294
position: 'top-right',
@@ -455,6 +458,9 @@ export default {
455458
margin-bottom: 12px;
456459
max-height: calc(100% - 80px);
457460
overflow: auto;
461+
.empty-wrap {
462+
width: 100%;
463+
}
458464
}
459465
.options {
460466
.option {

packages/design-core/src/template/src/template/TemplateCenter.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
</div>
8383
</div>
8484
</template>
85+
<search-empty :isShow="!templateList.length" />
8586
</div>
8687
<tiny-pager
8788
v-if="state.total > state.pageSize"
@@ -109,6 +110,7 @@
109110
import { ref, reactive, onMounted } from 'vue'
110111
import { Pager, Search, Notify } from '@opentiny/vue'
111112
import { iconSearch } from '@opentiny/vue-icon'
113+
import { SearchEmpty } from '@opentiny/tiny-engine-common'
112114
import TemplateDetail from './TemplateDetail.vue'
113115
import { fetchBusinessCategoryByGroup, fetchTemplateList } from '../js/http'
114116
@@ -117,7 +119,8 @@ export default {
117119
TemplateDetail,
118120
TinyPager: Pager,
119121
TinySearch: Search,
120-
Notify,
122+
TinyNotify: Notify,
123+
SearchEmpty,
121124
TinyIconSearch: iconSearch()
122125
},
123126
@@ -136,7 +139,7 @@ export default {
136139
searchValue: '',
137140
scene: null,
138141
industry: null,
139-
framework: 'Vue',
142+
framework: '',
140143
total: 0,
141144
currentPage: 1,
142145
pageSize: 10,
@@ -150,7 +153,7 @@ export default {
150153
tagList.industry = res[1] || []
151154
})
152155
.catch((error) => {
153-
Notify({
156+
TinyNotify({
154157
type: 'error',
155158
message: error,
156159
position: 'top-right',
@@ -174,7 +177,7 @@ export default {
174177
state.total = res.total
175178
})
176179
.catch((error) => {
177-
Notify({
180+
TinyNotify({
178181
type: 'error',
179182
message: error,
180183
position: 'top-right',
@@ -274,6 +277,9 @@ export default {
274277
margin-bottom: 12px;
275278
overflow: auto;
276279
max-height: calc(100% - 80px);
280+
.empty-wrap {
281+
width: 100%;
282+
}
277283
.item {
278284
width: 300px;
279285
border-radius: 8px;

0 commit comments

Comments
 (0)