99 <template #content >
1010 <div class =" resource-list-content" >
1111 <tiny-button round @click =" openAddSourceForm" ><svg-icon name =" add" ></svg-icon >添加资源</tiny-button >
12+ <tiny-alert
13+ :closable =" false"
14+ description =" 资源名称只能包含中文、英文、数字、下划线、中划线、=、+、()、{}、[]等字符,且以文件后缀名为结尾"
15+ ></tiny-alert >
1216 <span class =" resource-description" >支持上传png、jpg、svg文件,支持批量上传</span >
1317 <div class =" action-wrap" >
1418 <div >
9599 :valid-config =" { message: 'inline' }"
96100 :edit-rules =" validRules"
97101 >
98- <tiny-grid-column field =" name" title =" 资源名称" :show-icon =" false" :editor =" {}" >
102+ <tiny-grid-column field =" name" title =" 资源名称" :show-icon =" false" width = " 170 " :editor =" {}" >
99103 <template #edit =" data " >
100104 <span v-if =" data.row.type === 'upload'" > {{ data.row.name }} </span >
101105 <tiny-input
106110 ></tiny-input >
107111 </template >
108112 </tiny-grid-column >
109- <tiny-grid-column field =" resourceUrl" title =" 资源URL" :show-icon =" false" :editor =" {}" >
113+ <tiny-grid-column field =" resourceUrl" title =" 资源URL" :show-icon =" false" width = " 170 " :editor =" {}" >
110114 <template #edit =" data " >
111115 <span v-if =" data.row.type === 'upload'" ></span >
112116 <tiny-input
122126 <tiny-input v-model =" data.row.description" placeholder =" 请输入资源描述" ></tiny-input >
123127 </template >
124128 </tiny-grid-column >
125- <tiny-grid-column title =" 操作" >
129+ <tiny-grid-column title =" 操作" width = " 100 " >
126130 <template #default =" data " >
127131 <template v-if =" $refs .addSourceGridRef && $refs .addSourceGridRef .hasActiveRow (data .row )" >
128- <tiny-button size = " mini " @click =" saveRowEvent(data.row)" > 保存 </tiny-button >
129- <tiny-button size = " mini " @click =" cancelRowEvent(data)" > 取消 </tiny-button >
132+ <tiny-button type = " text " @click =" saveRowEvent(data.row)" > 保存 </tiny-button >
133+ <tiny-button type = " text " @click =" cancelRowEvent(data)" > 取消 </tiny-button >
130134 </template >
131- <tiny-popconfirm
132- v-else
133- title =" 确认要删除该资源吗?"
134- type =" info"
135- trigger =" click"
136- @confirm =" removeSource(data)"
137- >
138- <template #reference >
139- <svg-icon name =" delete" ></svg-icon >
140- </template >
141- </tiny-popconfirm >
135+ <tiny-button v-else type =" text" @click =" removeSource(data)" >删除</tiny-button >
142136 </template >
143137 </tiny-grid-column >
144138 </tiny-grid >
145139 <template #footer >
146- <tiny-button type =" primary" @click =" submitSourceAdd" round >确 定</tiny-button >
147- <tiny-button @click =" cancelAddSource" round >取 消</tiny-button >
140+ <tiny-button type =" primary" size = " mini " @click =" submitSourceAdd" round >确 定</tiny-button >
141+ <tiny-button size = " mini " @click =" cancelAddSource" round >取 消</tiny-button >
148142 </template >
149143 </tiny-dialog-box >
150144 </teleport >
@@ -161,8 +155,8 @@ import {
161155 Checkbox ,
162156 Popover ,
163157 DialogBox ,
164- FileUpload ,
165- Popconfirm
158+ Alert ,
159+ FileUpload
166160} from ' @opentiny/vue'
167161import { iconPopup } from ' @opentiny/vue-icon'
168162import { useLayout , useModal , useNotify } from ' @opentiny/tiny-engine-meta-register'
@@ -200,8 +194,8 @@ export default {
200194 TinyCheckbox: Checkbox,
201195 TinyPopover: Popover,
202196 TinyDialogBox: DialogBox,
197+ TinyAlert: Alert,
203198 TinyFileUpload: FileUpload,
204- TinyPopconfirm: Popconfirm,
205199 ButtonGroup,
206200 SearchEmpty,
207201 TinyIconPopup: iconPopup ()
@@ -233,8 +227,9 @@ export default {
233227 type: ' string' ,
234228 validator : ({ row }, value ) => {
235229 return new Promise ((resolve , reject ) => {
236- if (! / ^ [a-zA-Z0-9 _-] + \. (png| jpg| jpeg| svg)$ / .test (value)) {
237- reject (new Error (' 资源名成只能包含字母、数字、_和-等字符,且须以文件后缀名结尾' ))
230+ const regex = / ^ [a-zA-Z0-9 _\-= +(){}[\] ] + \. (png| jpg| jpeg| svg| PNG| JPG| JPEG| SVG)$ / i
231+ if (! regex .test (value)) {
232+ reject (new Error (' 资源名称格式错误' ))
238233 } else if (addSourceData .value .find ((item ) => item ._RID !== row ._RID && item .name === value)) {
239234 reject (new Error (' 已存在的资源名称' ))
240235 } else {
@@ -252,8 +247,8 @@ export default {
252247 if (type === ' url' ) {
253248 if (! value) {
254249 reject (new Error (' 资源URL必填' ))
255- } else if (! / ^ (http| https):\/\/ [^ \s ] + ( \. png | \. jpg | \. jpeg | \. svg) $ / .test (value)) {
256- reject (new Error (' URL须以http或https开头,以文件后缀名结尾 ' ))
250+ } else if (! / ^ (http| https):\/\/ [^ \s ] + $ / .test (value)) {
251+ reject (new Error (' URL以http或https开头 ' ))
257252 }
258253 }
259254 resolve ()
@@ -379,6 +374,7 @@ export default {
379374 })
380375 .then (() => {
381376 getSourceList ()
377+ selectedSources .value = []
382378 })
383379 .catch ((error ) => {
384380 useNotify ({
@@ -566,7 +562,7 @@ export default {
566562 left: 0 ;
567563 right: 0 ;
568564 bottom: 0 ;
569- text- align: center ;
565+ text- align: left ;
570566 line- height: 28px ;
571567 width: 185px ;
572568 color: #fff;
@@ -611,6 +607,10 @@ export default {
611607 }
612608}
613609
610+ : deep (.tiny - button .tiny - button .tiny - button -- text ) {
611+ padding: 0 ;
612+ }
613+
614614.actions {
615615 display: flex;
616616 flex- direction: column;
@@ -624,5 +624,6 @@ export default {
624624.resource - action {
625625 display: flex;
626626 gap: 8px ;
627+ margin- bottom: 16px ;
627628}
628629< / style>
0 commit comments