forked from opentiny/tiny-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportNoticeDialog.vue
More file actions
158 lines (143 loc) · 4.75 KB
/
Copy pathImportNoticeDialog.vue
File metadata and controls
158 lines (143 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<template>
<tiny-dialog-box
class="import-notice-dialog"
:visible="visible"
:append-to-body="true"
:modal="true"
:lock-scroll="true"
width="560px"
:title="dialogTitle"
@update:visible="onUpdateVisible"
>
<div class="summary">{{ summaryText }}</div>
<div class="section">
<div class="section-title">重点说明</div>
<ul class="notice-list">
<li class="notice-item" v-for="item in noticeItems" :key="item">
{{ item }}
</li>
</ul>
</div>
<template #footer>
<tiny-button type="primary" @click="emitConfirm">继续导入</tiny-button>
<tiny-button @click="emitCancel">取消</tiny-button>
</template>
</tiny-dialog-box>
</template>
<script lang="ts">
import { computed, defineComponent } from 'vue'
import { DialogBox, Button } from '@opentiny/vue'
export default defineComponent({
name: 'ImportNoticeDialog',
components: {
TinyDialogBox: DialogBox as any,
TinyButton: Button as any
},
props: {
visible: { type: Boolean, default: false },
uploadType: { type: String, default: 'directory' }
},
emits: ['confirm', 'cancel', 'update:visible'],
setup(props, { emit }) {
const importModeLabel = computed(() => (props.uploadType === 'zip' ? '项目压缩包' : '项目目录'))
const dialogTitle = computed(() => `导入${importModeLabel.value}提醒`)
const summaryText = computed(() =>
props.uploadType === 'zip'
? '导入项目压缩包前,请确认压缩包内直接包含项目根结构,而不是只压缩 src 目录。若目录结构不符合约定,部分页面或配置会被跳过。'
: '导入项目目录前,请确认你选择的是项目根目录,而不是 src 或其他子目录。若目录结构不符合约定,部分页面或配置会被跳过。'
)
const noticeItems = computed(() => {
const modeSpecificItems =
props.uploadType === 'zip'
? [
'压缩包内应直接包含 src、public、package.json 等项目根文件,不建议只打包 src 目录。',
'若压缩包里额外套了多层无关目录,固定路径可能匹配失败,导致页面、路由或资源识别不完整。'
]
: [
'请选择项目根目录,不要只选 src、views 或其他子目录。',
'目录上传会按所选目录作为根路径解析;如果根目录选错,固定路径文件可能全部识别不到。'
]
return [
...modeSpecificItems,
'页面只会读取 src/views/**/*.vue,其他目录下的页面文件不会直接导入。',
'页面里实际使用到的本地 .vue 子组件会转成区块,未使用的组件不会导入。',
'路由、国际化、数据源、全局状态仅识别固定路径,如 src/router/index.js、src/i18n、src/lowcodeConfig/dataSource.json、src/stores/*.js。',
'本地图片仅支持静态本地路径引用,远程地址和运行时拼接路径不会自动导入。',
'若未识别到 src/views 页面,将不会创建页面,只会尽量导入全局配置、资源或区块。'
]
})
const emitConfirm = () => {
emit('update:visible', false)
emit('confirm')
}
const emitCancel = () => {
emit('update:visible', false)
emit('cancel')
}
const onUpdateVisible = (value: boolean) => emit('update:visible', value)
return {
importModeLabel,
dialogTitle,
summaryText,
noticeItems,
emitConfirm,
emitCancel,
onUpdateVisible
}
}
})
</script>
<style lang="less" scoped>
.import-notice-dialog {
.summary {
font-size: 12px;
line-height: 20px;
color: var(--te-toolbars-upload-text-color-primary);
margin-bottom: 12px;
}
.section {
padding: 12px;
border-radius: 8px;
background: var(--te-toolbars-upload-bg-color);
}
.section-title {
margin-bottom: 8px;
font-size: 12px;
font-weight: 600;
color: var(--te-toolbars-upload-text-color-primary);
}
.notice-list {
margin: 0;
padding: 0;
list-style: none;
color: var(--te-toolbars-upload-text-color-secondary);
font-size: 12px;
line-height: 20px;
}
.notice-item {
position: relative;
padding-left: 16px;
display: flex;
align-items: center;
}
.notice-item + .notice-item {
margin-top: 8px;
padding-top: 8px;
}
.notice-item::before {
content: '';
position: absolute;
left: 0;
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--te-toolbars-upload-icon-color-primary);
}
code {
padding: 0 4px;
border-radius: 4px;
color: var(--te-toolbars-upload-text-color-primary);
background: var(--te-toolbars-upload-bg-color-primary);
}
}
</style>