@vrojs/element-plus 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +56 -0
- package/src/index.ts +13 -0
- package/src/locale/index.ts +3 -0
- package/src/locale/lang/zh-cn.ts +22 -0
- package/src/locale/types.ts +8 -0
- package/src/locale/useLocale.ts +42 -0
- package/src/style/base.scss +2 -0
- package/src/style/css.ts +2 -0
- package/src/style/deps.ts +9 -0
- package/src/style/index.scss +12 -0
- package/src/style/index.ts +2 -0
- package/src/utils/datePickerValueFormat.ts +6 -0
- package/src/utils/index.ts +2 -0
- package/src/vro-el-checkbox-group/README.md +83 -0
- package/src/vro-el-checkbox-group/index.ts +16 -0
- package/src/vro-el-checkbox-group/style/css.ts +2 -0
- package/src/vro-el-checkbox-group/style/deps.ts +2 -0
- package/src/vro-el-checkbox-group/style/index.scss +1 -0
- package/src/vro-el-checkbox-group/style/index.ts +2 -0
- package/src/vro-el-checkbox-group/types.ts +18 -0
- package/src/vro-el-checkbox-group/vro-el-checkbox-group.vue +33 -0
- package/src/vro-el-config-provider/README.md +65 -0
- package/src/vro-el-config-provider/index.ts +16 -0
- package/src/vro-el-config-provider/style/css.ts +2 -0
- package/src/vro-el-config-provider/style/deps.ts +0 -0
- package/src/vro-el-config-provider/style/index.scss +0 -0
- package/src/vro-el-config-provider/style/index.ts +2 -0
- package/src/vro-el-config-provider/types.ts +18 -0
- package/src/vro-el-config-provider/vro-el-config-provider.vue +19 -0
- package/src/vro-el-file-upload/README.md +89 -0
- package/src/vro-el-file-upload/index.ts +17 -0
- package/src/vro-el-file-upload/style/css.ts +2 -0
- package/src/vro-el-file-upload/style/deps.ts +2 -0
- package/src/vro-el-file-upload/style/index.scss +30 -0
- package/src/vro-el-file-upload/style/index.ts +2 -0
- package/src/vro-el-file-upload/types.ts +50 -0
- package/src/vro-el-file-upload/utils.ts +7 -0
- package/src/vro-el-file-upload/vro-el-file-upload.vue +95 -0
- package/src/vro-el-icon/README.md +68 -0
- package/src/vro-el-icon/index.ts +16 -0
- package/src/vro-el-icon/style/css.ts +2 -0
- package/src/vro-el-icon/style/deps.ts +1 -0
- package/src/vro-el-icon/style/index.scss +1 -0
- package/src/vro-el-icon/style/index.ts +2 -0
- package/src/vro-el-icon/types.ts +12 -0
- package/src/vro-el-icon/vro-el-icon.vue +28 -0
- package/src/vro-el-image-upload/README.md +99 -0
- package/src/vro-el-image-upload/index.ts +17 -0
- package/src/vro-el-image-upload/style/css.ts +2 -0
- package/src/vro-el-image-upload/style/deps.ts +4 -0
- package/src/vro-el-image-upload/style/index.scss +55 -0
- package/src/vro-el-image-upload/style/index.ts +2 -0
- package/src/vro-el-image-upload/types.ts +42 -0
- package/src/vro-el-image-upload/utils.ts +7 -0
- package/src/vro-el-image-upload/vro-el-image-upload.vue +134 -0
- package/src/vro-el-schema-form-dialog/README.md +64 -0
- package/src/vro-el-schema-form-dialog/function-call.ts +12 -0
- package/src/vro-el-schema-form-dialog/index.ts +17 -0
- package/src/vro-el-schema-form-dialog/style/css.ts +2 -0
- package/src/vro-el-schema-form-dialog/style/deps.ts +0 -0
- package/src/vro-el-schema-form-dialog/style/index.scss +1 -0
- package/src/vro-el-schema-form-dialog/style/index.ts +2 -0
- package/src/vro-el-schema-form-dialog/types.ts +5 -0
- package/src/vro-el-schema-form-dialog/vro-el-schema-form-dialog.vue +32 -0
- package/src/vro-el-select/README.md +83 -0
- package/src/vro-el-select/index.ts +16 -0
- package/src/vro-el-select/style/css.ts +2 -0
- package/src/vro-el-select/style/deps.ts +2 -0
- package/src/vro-el-select/style/index.scss +1 -0
- package/src/vro-el-select/style/index.ts +2 -0
- package/src/vro-el-select/types.ts +18 -0
- package/src/vro-el-select/vro-el-select.vue +33 -0
- package/src/vro-el-skeleton/README.md +128 -0
- package/src/vro-el-skeleton/index.ts +16 -0
- package/src/vro-el-skeleton/style/css.ts +3 -0
- package/src/vro-el-skeleton/style/deps.ts +3 -0
- package/src/vro-el-skeleton/style/index.scss +24 -0
- package/src/vro-el-skeleton/style/index.ts +2 -0
- package/src/vro-el-skeleton/types.ts +86 -0
- package/src/vro-el-skeleton/vro-el-skeleton.vue +73 -0
- package/src/vro-el-with-config/README.md +75 -0
- package/src/vro-el-with-config/index.ts +16 -0
- package/src/vro-el-with-config/style/css.ts +3 -0
- package/src/vro-el-with-config/style/deps.ts +2 -0
- package/src/vro-el-with-config/style/index.scss +0 -0
- package/src/vro-el-with-config/style/index.ts +2 -0
- package/src/vro-el-with-config/types.ts +18 -0
- package/src/vro-el-with-config/vro-el-with-config.vue +48 -0
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vrojs/element-plus",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "vrojs ui",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"types": "src/index.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"!src/**/demo",
|
|
10
|
+
"!src/**/README.md"
|
|
11
|
+
],
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"src/**/style/*"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"vro",
|
|
17
|
+
"vrojs",
|
|
18
|
+
"ui",
|
|
19
|
+
"element-plus",
|
|
20
|
+
"vue"
|
|
21
|
+
],
|
|
22
|
+
"author": "woshiajuana",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"copy-to-clipboard": "^3.3.3",
|
|
30
|
+
"vue-draggable-plus": "^0.6.1"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@daysnap/banana": ">=0.0.15",
|
|
34
|
+
"@daysnap/utils": ">=0.1.34",
|
|
35
|
+
"@element-plus/icons-vue": ">=2.3.2",
|
|
36
|
+
"element-plus": ">=2.11.9",
|
|
37
|
+
"vue": ">=3.0.0",
|
|
38
|
+
"@vrojs/base": "0.0.1",
|
|
39
|
+
"@vrojs/use": "0.0.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@daysnap/banana": "^0.0.15",
|
|
43
|
+
"@daysnap/utils": "^0.1.34",
|
|
44
|
+
"@element-plus/icons-vue": "^2.3.2",
|
|
45
|
+
"element-plus": "^2.11.9",
|
|
46
|
+
"rimraf": "^6.0.1",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"vue": "^3.5.22",
|
|
49
|
+
"@vrojs/use": "0.0.1",
|
|
50
|
+
"@vrojs/base": "0.0.1"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"release": "dsc publish --pnpm",
|
|
54
|
+
"sync": "dsc sync"
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* 本文件自动生成 './scripts/index.ts' */
|
|
2
|
+
|
|
3
|
+
export * from './locale'
|
|
4
|
+
export * from './utils'
|
|
5
|
+
export * from './vro-el-checkbox-group'
|
|
6
|
+
export * from './vro-el-config-provider'
|
|
7
|
+
export * from './vro-el-file-upload'
|
|
8
|
+
export * from './vro-el-icon'
|
|
9
|
+
export * from './vro-el-image-upload'
|
|
10
|
+
export * from './vro-el-schema-form-dialog'
|
|
11
|
+
export * from './vro-el-select'
|
|
12
|
+
export * from './vro-el-skeleton'
|
|
13
|
+
export * from './vro-el-with-config'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
name: 'zh-cn',
|
|
3
|
+
el: {
|
|
4
|
+
table: {
|
|
5
|
+
refresh: '刷新',
|
|
6
|
+
description: '当前颜色 {color},按 Enter 键选择新颜色',
|
|
7
|
+
},
|
|
8
|
+
skeleton: {
|
|
9
|
+
loadingDescription: '正在加载数据...',
|
|
10
|
+
emptyDescription: '暂无数据',
|
|
11
|
+
emptyBtnText: '刷新',
|
|
12
|
+
errorTitle: '哦嗬!出错了哦~',
|
|
13
|
+
errorBtnText: '刷新',
|
|
14
|
+
},
|
|
15
|
+
fileUpload: {
|
|
16
|
+
btnText: '上传',
|
|
17
|
+
},
|
|
18
|
+
imageUpload: {
|
|
19
|
+
compressText: '是否压缩',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { computed, inject, type InjectionKey, type Ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
import zhCN from './lang/zh-cn'
|
|
4
|
+
import type { Locale, TranslatePair } from './types'
|
|
5
|
+
|
|
6
|
+
export const localeContextKey: InjectionKey<Ref<Locale | undefined>> = Symbol('localeContextKey')
|
|
7
|
+
|
|
8
|
+
export function useLocale() {
|
|
9
|
+
const injectedLocale = inject(localeContextKey, undefined)
|
|
10
|
+
|
|
11
|
+
const locale = computed(() => injectedLocale?.value ?? zhCN)
|
|
12
|
+
|
|
13
|
+
const t = (path: string, option?: Record<string, string | number>) => {
|
|
14
|
+
const value = get(locale.value.el, path)
|
|
15
|
+
|
|
16
|
+
if (typeof value !== 'string') {
|
|
17
|
+
return path
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!option) {
|
|
21
|
+
return value
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return value.replace(/\{(\w+)\}/g, (_, key) => `${option[key] ?? `{${key}}`}`)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
locale,
|
|
29
|
+
lang: computed(() => locale.value.name),
|
|
30
|
+
t,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function get(source: TranslatePair, path: string) {
|
|
35
|
+
return path.split('.').reduce<TranslatePair[string] | undefined>((res, key) => {
|
|
36
|
+
if (res && typeof res === 'object' && !Array.isArray(res)) {
|
|
37
|
+
return res[key]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return undefined
|
|
41
|
+
}, source)
|
|
42
|
+
}
|
package/src/style/css.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import '../vro-el-checkbox-group/style/deps'
|
|
2
|
+
import '../vro-el-config-provider/style/deps'
|
|
3
|
+
import '../vro-el-file-upload/style/deps'
|
|
4
|
+
import '../vro-el-icon/style/deps'
|
|
5
|
+
import '../vro-el-image-upload/style/deps'
|
|
6
|
+
import '../vro-el-schema-form-dialog/style/deps'
|
|
7
|
+
import '../vro-el-select/style/deps'
|
|
8
|
+
import '../vro-el-skeleton/style/deps'
|
|
9
|
+
import '../vro-el-with-config/style/deps'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* 本文件自动生成 './scripts/index.ts' */
|
|
2
|
+
|
|
3
|
+
@use './base.scss' as *;
|
|
4
|
+
@use '../vro-el-checkbox-group/style/index.scss' as *;
|
|
5
|
+
@use '../vro-el-config-provider/style/index.scss' as *;
|
|
6
|
+
@use '../vro-el-file-upload/style/index.scss' as *;
|
|
7
|
+
@use '../vro-el-icon/style/index.scss' as *;
|
|
8
|
+
@use '../vro-el-image-upload/style/index.scss' as *;
|
|
9
|
+
@use '../vro-el-schema-form-dialog/style/index.scss' as *;
|
|
10
|
+
@use '../vro-el-select/style/index.scss' as *;
|
|
11
|
+
@use '../vro-el-skeleton/style/index.scss' as *;
|
|
12
|
+
@use '../vro-el-with-config/style/index.scss' as *;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# VroElCheckboxGroup
|
|
2
|
+
|
|
3
|
+
### 介绍
|
|
4
|
+
|
|
5
|
+
基于 `ElCheckboxGroup` 和 `ElCheckbox` 的选项化封装。适合通过 `options` 快速渲染一组选项,同时保留 Element Plus CheckboxGroup 的原有属性和事件。
|
|
6
|
+
|
|
7
|
+
## 代码演示
|
|
8
|
+
|
|
9
|
+
### 基础用法
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<template>
|
|
13
|
+
<vro-el-checkbox-group v-model="value" :options="options" />
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { ref } from 'vue'
|
|
18
|
+
|
|
19
|
+
const value = ref(['apple'])
|
|
20
|
+
const options = [
|
|
21
|
+
{ label: '苹果', value: 'apple' },
|
|
22
|
+
{ label: '香蕉', value: 'banana' },
|
|
23
|
+
{ label: '橙子', value: 'orange', props: { disabled: true } },
|
|
24
|
+
]
|
|
25
|
+
</script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 自定义字段名
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<vro-el-checkbox-group v-model="value" :options="options" label-key="name" value-key="id" />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## API
|
|
35
|
+
|
|
36
|
+
### 属性 Props
|
|
37
|
+
|
|
38
|
+
<table>
|
|
39
|
+
<tbody>
|
|
40
|
+
<tr>
|
|
41
|
+
<td>名称</td>
|
|
42
|
+
<td>类型</td>
|
|
43
|
+
<td>默认值</td>
|
|
44
|
+
</tr>
|
|
45
|
+
<tr v-for="(item, key) in vroElCheckboxGroupProps" :key="key">
|
|
46
|
+
<td>{{ key }}</td>
|
|
47
|
+
<td>{{ parseType(item.type || item) }}</td>
|
|
48
|
+
<td>{{ reserve(item.default, '-') }}</td>
|
|
49
|
+
</tr>
|
|
50
|
+
</tbody>
|
|
51
|
+
</table>
|
|
52
|
+
|
|
53
|
+
### 插槽 Slots
|
|
54
|
+
|
|
55
|
+
支持默认插槽,传入后会作为 `ElCheckboxGroup` 的内容,覆盖 `options` 自动渲染的选项。
|
|
56
|
+
|
|
57
|
+
### 事件 Events
|
|
58
|
+
|
|
59
|
+
<table>
|
|
60
|
+
<tbody>
|
|
61
|
+
<tr>
|
|
62
|
+
<td>名称</td>
|
|
63
|
+
<td>参数</td>
|
|
64
|
+
<td>说明</td>
|
|
65
|
+
</tr>
|
|
66
|
+
<tr>
|
|
67
|
+
<td>update:modelValue</td>
|
|
68
|
+
<td>value</td>
|
|
69
|
+
<td>选中值变化时触发</td>
|
|
70
|
+
</tr>
|
|
71
|
+
<tr>
|
|
72
|
+
<td>change</td>
|
|
73
|
+
<td>value</td>
|
|
74
|
+
<td>同 Element Plus CheckboxGroup change 事件</td>
|
|
75
|
+
</tr>
|
|
76
|
+
</tbody>
|
|
77
|
+
</table>
|
|
78
|
+
|
|
79
|
+
<script setup lang="ts">
|
|
80
|
+
import { reserve } from '@daysnap/utils'
|
|
81
|
+
import { VroElCheckboxGroup, vroElCheckboxGroupProps } from '.'
|
|
82
|
+
import { parseType } from '../utils'
|
|
83
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { withInstall } from '@vrojs/base'
|
|
2
|
+
|
|
3
|
+
import Component from './vro-el-checkbox-group.vue'
|
|
4
|
+
|
|
5
|
+
export * from './types'
|
|
6
|
+
|
|
7
|
+
export const VroElCheckboxGroup = withInstall<typeof Component>(Component)
|
|
8
|
+
export default VroElCheckboxGroup
|
|
9
|
+
|
|
10
|
+
export type VroElCheckboxGroupInstance = InstanceType<typeof VroElCheckboxGroup>
|
|
11
|
+
|
|
12
|
+
declare module 'vue' {
|
|
13
|
+
export interface GlobalComponents {
|
|
14
|
+
VroElCheckboxGroup: typeof VroElCheckboxGroup
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.vro-el-checkbox-group { }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { checkboxGroupProps } from 'element-plus'
|
|
2
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
3
|
+
|
|
4
|
+
export const vroElCheckboxGroupProps = {
|
|
5
|
+
...checkboxGroupProps,
|
|
6
|
+
|
|
7
|
+
options: Array as PropType<any[]>,
|
|
8
|
+
labelKey: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: 'label',
|
|
11
|
+
},
|
|
12
|
+
valueKey: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: 'value',
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type VroElCheckboxGroupProps = ExtractPropTypes<typeof vroElCheckboxGroupProps>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-checkbox-group
|
|
3
|
+
v-bind="restProps"
|
|
4
|
+
class="vro-el-checkbox-group"
|
|
5
|
+
@update:model-value="$emit('update:modelValue', $event)"
|
|
6
|
+
@change="$emit('change', $event)"
|
|
7
|
+
>
|
|
8
|
+
<el-checkbox
|
|
9
|
+
v-for="(option, index) in options"
|
|
10
|
+
v-bind="option.props"
|
|
11
|
+
:key="index"
|
|
12
|
+
:value="option[valueKey || 'value'] ?? option"
|
|
13
|
+
>
|
|
14
|
+
{{ option[labelKey || 'label'] ?? option }}
|
|
15
|
+
</el-checkbox>
|
|
16
|
+
</el-checkbox-group>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import { pick } from '@daysnap/utils'
|
|
21
|
+
import { checkboxGroupProps, ElCheckbox, ElCheckboxGroup } from 'element-plus'
|
|
22
|
+
import { computed } from 'vue'
|
|
23
|
+
|
|
24
|
+
import { vroElCheckboxGroupProps } from './types'
|
|
25
|
+
|
|
26
|
+
defineOptions({ name: 'VroElCheckboxGroup' })
|
|
27
|
+
defineEmits(['update:modelValue', 'change'])
|
|
28
|
+
const props = defineProps(vroElCheckboxGroupProps)
|
|
29
|
+
|
|
30
|
+
const restProps = computed(() => {
|
|
31
|
+
return pick(props, Object.keys(checkboxGroupProps) as any[])
|
|
32
|
+
})
|
|
33
|
+
</script>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# VroElConfigProvider
|
|
2
|
+
|
|
3
|
+
### 介绍
|
|
4
|
+
|
|
5
|
+
为 Vro Element Plus 组件提供全局配置,目前用于统一内部文案。`locale` 支持局部覆盖,未传入的字段会使用默认中文文案。
|
|
6
|
+
|
|
7
|
+
## 代码演示
|
|
8
|
+
|
|
9
|
+
### 基础用法
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<vro-el-config-provider :locale="locale">
|
|
13
|
+
<app />
|
|
14
|
+
</vro-el-config-provider>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
const locale = {
|
|
19
|
+
el: {
|
|
20
|
+
table: {
|
|
21
|
+
refresh: '重新加载',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
### 属性 Props
|
|
30
|
+
|
|
31
|
+
<table>
|
|
32
|
+
<tbody>
|
|
33
|
+
<tr>
|
|
34
|
+
<td>名称</td>
|
|
35
|
+
<td>类型</td>
|
|
36
|
+
<td>默认值</td>
|
|
37
|
+
</tr>
|
|
38
|
+
<tr v-for="(item, key) in vroElConfigProviderProps" :key="key">
|
|
39
|
+
<td>{{ key }}</td>
|
|
40
|
+
<td>{{ parseType(item.type || item) }}</td>
|
|
41
|
+
<td>{{ reserve(item.default, '-') }}</td>
|
|
42
|
+
</tr>
|
|
43
|
+
</tbody>
|
|
44
|
+
</table>
|
|
45
|
+
|
|
46
|
+
### 插槽 Slots
|
|
47
|
+
|
|
48
|
+
<table>
|
|
49
|
+
<tbody>
|
|
50
|
+
<tr>
|
|
51
|
+
<td>名称</td>
|
|
52
|
+
<td>说明</td>
|
|
53
|
+
</tr>
|
|
54
|
+
<tr>
|
|
55
|
+
<td>default</td>
|
|
56
|
+
<td>默认内容</td>
|
|
57
|
+
</tr>
|
|
58
|
+
</tbody>
|
|
59
|
+
</table>
|
|
60
|
+
|
|
61
|
+
<script setup lang="ts">
|
|
62
|
+
import { reserve } from '@daysnap/utils'
|
|
63
|
+
import { VroElConfigProvider, vroElConfigProviderProps } from '.'
|
|
64
|
+
import { parseType } from '../utils'
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { withInstall } from '@vrojs/base'
|
|
2
|
+
|
|
3
|
+
import Component from './vro-el-config-provider.vue'
|
|
4
|
+
|
|
5
|
+
export * from './types'
|
|
6
|
+
|
|
7
|
+
export const VroElConfigProvider = withInstall<typeof Component>(Component)
|
|
8
|
+
export default VroElConfigProvider
|
|
9
|
+
|
|
10
|
+
export type VroElConfigProviderInstance = InstanceType<typeof VroElConfigProvider>
|
|
11
|
+
|
|
12
|
+
declare module 'vue' {
|
|
13
|
+
export interface GlobalComponents {
|
|
14
|
+
VroElConfigProvider: typeof VroElConfigProvider
|
|
15
|
+
}
|
|
16
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DeepPartial } from '@vrojs/base'
|
|
2
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
3
|
+
|
|
4
|
+
import type { Locale } from '../locale'
|
|
5
|
+
|
|
6
|
+
export type VroElLocale = DeepPartial<Locale>
|
|
7
|
+
|
|
8
|
+
export const vroElConfigProviderProps = {
|
|
9
|
+
/**
|
|
10
|
+
* 组件内部文案配置,支持局部覆盖。
|
|
11
|
+
*/
|
|
12
|
+
locale: {
|
|
13
|
+
type: Object as PropType<VroElLocale>,
|
|
14
|
+
default: () => ({}),
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type VroElConfigProviderProps = ExtractPropTypes<typeof vroElConfigProviderProps>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<slot> </slot>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { merge } from '@daysnap/utils'
|
|
7
|
+
import { computed, provide } from 'vue'
|
|
8
|
+
|
|
9
|
+
import { localeContextKey, zhCN } from '../locale'
|
|
10
|
+
import { vroElConfigProviderProps } from './types'
|
|
11
|
+
|
|
12
|
+
defineOptions({ name: 'VroElConfigProvider' })
|
|
13
|
+
|
|
14
|
+
const props = defineProps(vroElConfigProviderProps)
|
|
15
|
+
|
|
16
|
+
const locale = computed(() => merge({}, zhCN, props.locale))
|
|
17
|
+
|
|
18
|
+
provide(localeContextKey, locale)
|
|
19
|
+
</script>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# VroElFileUpload
|
|
2
|
+
|
|
3
|
+
### 介绍
|
|
4
|
+
|
|
5
|
+
基于 Element Plus Button 的轻量文件上传组件。组件只负责选择文件、展示已上传地址和删除交互,实际上传逻辑由 `upload` 回调提供。
|
|
6
|
+
|
|
7
|
+
## 代码演示
|
|
8
|
+
|
|
9
|
+
### 基础用法
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<template>
|
|
13
|
+
<vro-el-file-upload v-model="value" :upload="upload" />
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { ref } from 'vue'
|
|
18
|
+
|
|
19
|
+
const value = ref('')
|
|
20
|
+
|
|
21
|
+
const upload = async (files: File[]) => {
|
|
22
|
+
return files.map((file) => URL.createObjectURL(file))
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 多文件上传
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<vro-el-file-upload v-model="value" :max="3" :upload="upload" />
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 全局上传配置
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { setVroElFileUploadOptions } from '@vrojs/element-plus'
|
|
37
|
+
|
|
38
|
+
setVroElFileUploadOptions({
|
|
39
|
+
upload: async (files, { params }) => {
|
|
40
|
+
return files.map((file) => `${params.domain}/${file.name}`)
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## API
|
|
46
|
+
|
|
47
|
+
### 属性 Props
|
|
48
|
+
|
|
49
|
+
<table>
|
|
50
|
+
<tbody>
|
|
51
|
+
<tr>
|
|
52
|
+
<td>名称</td>
|
|
53
|
+
<td>类型</td>
|
|
54
|
+
<td>默认值</td>
|
|
55
|
+
</tr>
|
|
56
|
+
<tr v-for="(item, key) in vroElFileUploadProps" :key="key">
|
|
57
|
+
<td>{{ key }}</td>
|
|
58
|
+
<td>{{ parseType(item.type || item) }}</td>
|
|
59
|
+
<td>{{ reserve(item.default, '-') }}</td>
|
|
60
|
+
</tr>
|
|
61
|
+
</tbody>
|
|
62
|
+
</table>
|
|
63
|
+
|
|
64
|
+
### 插槽 Slots
|
|
65
|
+
|
|
66
|
+
暂无。
|
|
67
|
+
|
|
68
|
+
### 事件 Events
|
|
69
|
+
|
|
70
|
+
<table>
|
|
71
|
+
<tbody>
|
|
72
|
+
<tr>
|
|
73
|
+
<td>名称</td>
|
|
74
|
+
<td>参数</td>
|
|
75
|
+
<td>说明</td>
|
|
76
|
+
</tr>
|
|
77
|
+
<tr>
|
|
78
|
+
<td>update:modelValue</td>
|
|
79
|
+
<td>value: string | string[]</td>
|
|
80
|
+
<td>上传或删除后触发</td>
|
|
81
|
+
</tr>
|
|
82
|
+
</tbody>
|
|
83
|
+
</table>
|
|
84
|
+
|
|
85
|
+
<script setup lang="ts">
|
|
86
|
+
import { reserve } from '@daysnap/utils'
|
|
87
|
+
import { VroElFileUpload, vroElFileUploadProps } from '.'
|
|
88
|
+
import { parseType } from '../utils'
|
|
89
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { withInstall } from '@vrojs/base'
|
|
2
|
+
|
|
3
|
+
import Component from './vro-el-file-upload.vue'
|
|
4
|
+
|
|
5
|
+
export * from './types'
|
|
6
|
+
export * from './utils'
|
|
7
|
+
|
|
8
|
+
export const VroElFileUpload = withInstall<typeof Component>(Component)
|
|
9
|
+
export default VroElFileUpload
|
|
10
|
+
|
|
11
|
+
export type VroElFileUploadInstance = InstanceType<typeof VroElFileUpload>
|
|
12
|
+
|
|
13
|
+
declare module 'vue' {
|
|
14
|
+
export interface GlobalComponents {
|
|
15
|
+
VroElFileUpload: typeof VroElFileUpload
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.vro-el-file-upload-btn {
|
|
2
|
+
position: relative;
|
|
3
|
+
input {
|
|
4
|
+
position: absolute;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
top: 0;
|
|
8
|
+
left: 0;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
opacity: 0;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
.vro-el-file-upload-item {
|
|
14
|
+
position: relative;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
margin-top: 4px;
|
|
19
|
+
a {
|
|
20
|
+
text-decoration: underline;
|
|
21
|
+
color: #007bee;
|
|
22
|
+
margin-right: 10px;
|
|
23
|
+
}
|
|
24
|
+
i {
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
margin-right: 10px;
|
|
27
|
+
color: #ee0000;
|
|
28
|
+
background-color: #f2f2f2;
|
|
29
|
+
}
|
|
30
|
+
}
|