-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
161 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## 在 TypeScript 中指定组件的类型 | ||
|
||
```html | ||
<template> | ||
<upload-to-ali ref="uploadToAli" v-model="url" /> | ||
</template> | ||
<script lang="ts"> | ||
// 需要引入这个 | ||
// import { UploadToAliType } from '@femessage/upload-to-ali' | ||
export default { | ||
data() { | ||
return { | ||
url: '' | ||
} | ||
}, | ||
mounted() { | ||
(this.$refs.uploadToAli as UploadToAliType).dir = 'images/' | ||
}, | ||
} | ||
</script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
echo "is netlify: $NETLIFY" | ||
echo "in branch: $BRANCH" | ||
echo "head: $HEAD" | ||
|
||
if [ "$NETLIFY" != "true" ] | ||
then | ||
echo "this script only runs in netlify, bye" | ||
exit 1 | ||
fi | ||
|
||
if [ "$BRANCH" != "dev" ] && [ "$HEAD" != "dev" ] | ||
then | ||
yarn doc | ||
else | ||
echo "this script only runs in targeting dev's PR deploy preview, bye" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import Vue, {VueConstructor} from 'vue' | ||
|
||
declare module '@femessage/upload-to-ali' { | ||
class FemessageComponent extends Vue { | ||
static install(vue: typeof Vue): void | ||
} | ||
|
||
type CombinedVueInstance< | ||
Instance extends Vue, | ||
Data, | ||
Methods, | ||
Computed, | ||
Props | ||
> = Data & Methods & Computed & Props & Instance | ||
|
||
type ExtendedVue< | ||
Instance extends Vue, | ||
Data, | ||
Methods, | ||
Computed, | ||
Props | ||
> = VueConstructor< | ||
CombinedVueInstance<Instance, Data, Methods, Computed, Props> & Vue | ||
> | ||
|
||
type Combined<Data, Methods, Computed, Props> = Data & | ||
Methods & | ||
Computed & | ||
Props | ||
|
||
type UploadToAliData = { | ||
previewUrl: string | ||
|
||
uploading: boolean | ||
|
||
isHighlight: boolean | ||
} | ||
|
||
type UploadToAliMethods = { | ||
selectFiles: () => void | ||
} | ||
|
||
type UploadToAliComputed = { | ||
uploadList: any[] | ||
canUpload: boolean | ||
uploadRequest: (file: any) => Promise<string> | ||
} | ||
|
||
type UploadToAliProps = { | ||
action: string | ||
bucket: string | ||
region: string | ||
dir: string | ||
customDomain: string | ||
value: string | any[] | ||
multiple: boolean | ||
size: number | ||
accept: string | ||
timeout: number | ||
disabled: boolean | ||
max: number | ||
compressOptions: {[key: string]: any} | ||
uploadOptions: {[key: string]: any} | ||
preview: boolean | ||
tip: string | ||
onClick: (url: string, isFile: boolean) => void | ||
beforeUpload: (files: any[]) => Promise<any> | ||
onOversize: (fileOvesize: any) => void | ||
request: (file: any) => Promise<string> | ||
} | ||
|
||
type UploadToAli = Combined< | ||
UploadToAliData, | ||
UploadToAliMethods, | ||
UploadToAliComputed, | ||
UploadToAliProps | ||
> | ||
|
||
export interface UploadToAliType extends FemessageComponent, UploadToAli {} | ||
|
||
const UploadToAliConstruction: ExtendedVue< | ||
Vue, | ||
UploadToAliData, | ||
UploadToAliMethods, | ||
UploadToAliComputed, | ||
UploadToAliProps | ||
> | ||
|
||
export default UploadToAliConstruction | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters