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