Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Nov 11, 2020
2 parents 0772a2c + c92d7ac commit ed71003
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 11 deletions.
7 changes: 4 additions & 3 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/FEMessage/upload-to-ali/pulls)
[![Automated Release Notes by gren](https://img.shields.io/badge/%F0%9F%A4%96-release%20notes-00B2EE.svg)](https://github-tools.github.io/github-release-notes/)

对接阿里云 OSS,可通过环境变量配置上传信息,可自定义域名,支持多选、限制文件大小、删除、粘贴上传功能,拖拽上传功能,让上传功能更加简单
可通过环境变量配置上传信息,可自定义域名,支持多选、限制文件大小、删除、粘贴上传功能,拖拽上传功能,让上传功能更加简单。
> 虽然最初的设计是上传至阿里云,但现在已可通过设置环境变量 `UPLOAD_ACTION` 把数据传送至自定义的后端接口,因此,理论上可以上传至任何云!考虑到有许多项目在用,就暂时不改包名了。
![](https://i.loli.net/2019/11/15/UZ2P7wR83GiDXky.gif)

Expand All @@ -31,7 +32,7 @@
- 可截图粘贴上传
- 可拖拽上传
- 可预览图片
- 支持 v-model
- 支持 v-model

可以只设置 `action` props, 指向上传地址,组件内部默认实现了一套 post 方法,向上传地址传递数据

Expand All @@ -42,7 +43,7 @@
## Links

- [docs](https://FEMessage.github.io/upload-to-ali/)
- [ali oss guide](docs/ali-oss-guide.md)
- [ali oss guide](docs/guide-ali-oss.md)

[⬆ Back to Top](#table-of-contents)

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/FEMessage/upload-to-ali/pulls)
[![Automated Release Notes by gren](https://img.shields.io/badge/%F0%9F%A4%96-release%20notes-00B2EE.svg)](https://github-tools.github.io/github-release-notes/)

This component can upload file to Aliyun-OSS easily.
In the beginning, this component is designed to upload file to Aliyun-OSS easily,but now it can upload to any oss as you wish.

You can configure OSS information through environmental variables, customize domain, support multi-selection, limit file size, delete, paste to upload, drag and drop to upload, make files upload simpler.

Expand Down Expand Up @@ -46,7 +46,7 @@ You can set `request` props to customize own upload function.
## Links

- [docs](https://FEMessage.github.io/upload-to-ali/)
- [ali oss guide](docs/ali-oss-guide.md)
- [ali oss guide](docs/guide-ali-oss.md)

[⬆ Back to Top](#table-of-contents)

Expand Down Expand Up @@ -130,6 +130,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
Expand Down
21 changes: 21 additions & 0 deletions docs/faq.md
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>
```
17 changes: 17 additions & 0 deletions netlify.sh
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
25 changes: 22 additions & 3 deletions notify.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
#!/bin/sh
# https://stackoverflow.com/questions/13872048/bash-script-what-does-bin-bash-mean
echo "1/5: checking TRAVIS_TEST_RESULT"
if [ "$TRAVIS_TEST_RESULT" != "0" ]
then
echo "build not success, bye"
exit 1
fi

git remote add github https://$GITHUB_TOKEN@github.com/FEMessage/upload-to-ali.git > /dev/null 2>&1
ORG_NAME=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f 1)
REPO_NAME=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f 2)

echo "2/5: pushing commit and tag to github"
# 该命令很可能报错,但不影响实际进行,因而不能简单地在脚本开头 set -e
git remote add github https://$GITHUB_TOKEN@github.com/$TRAVIS_REPO_SLUG.git > /dev/null 2>&1
git push github HEAD:master --follow-tags

echo "3/5: generating github release notes"
GREN_GITHUB_TOKEN=$GITHUB_TOKEN yarn release

url=https://api.github.com/repos/FEMessage/upload-to-ali/releases/latest
# 避免发送错误信息
if [ $? -ne 0 ]
then
echo "gren fails, bye"
exit 1
fi

echo "4/5: downloading github release info"
url=https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/latest
resp_tmp_file=resp.tmp

curl -H "Authorization: token $GITHUB_TOKEN" $url > $resp_tmp_file
Expand All @@ -19,8 +35,11 @@ html_url=$(sed -n 5p $resp_tmp_file | sed 's/\"html_url\"://g' | awk -F '"' '{pr
body=$(grep body < $resp_tmp_file | sed 's/\"body\"://g;s/\"//g')
version=$(echo $html_url | awk -F '/' '{print $NF}')

msg='{"msgtype": "markdown", "markdown": {"title": "upload-to-ali更新", "text": "@所有人\n# [upload-to-ali('$version')]('$html_url')\n'$body'"}}'
echo "5/5: notifying with dingtalk bot"
msg='{"msgtype": "markdown", "markdown": {"title": "'$REPO_NAME'更新", "text": "@所有人\n# ['$REPO_NAME'('$version')]('$html_url')\n'$body'"}}'

curl -X POST https://oapi.dingtalk.com/robot/send\?access_token\=$DINGTALK_ROBOT_TOKEN -H 'Content-Type: application/json' -d "$msg"

rm $resp_tmp_file

echo "executing notify.sh successfully"
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"browser": {
"./sfc": "src/upload-to-ali.vue"
},
"types": "src/upload-to-ali.d.ts",
"scripts": {
"dev": "vue-styleguidist server",
"test": "jest",
Expand All @@ -43,7 +44,7 @@
"@babel/core": "^7.4.3",
"@babel/plugin-transform-runtime": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@femessage/github-release-notes": "^0.19.0",
"@femessage/github-release-notes": "latest",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.5",
"dotenv": "^7.0.0",
Expand Down Expand Up @@ -78,7 +79,7 @@
"publishConfig": {
"access": "public"
},
"vue-sfc-cli": "1.10.6",
"vue-sfc-cli": "1.12.0",
"engines": {
"node": ">= 4.0.0",
"npm": ">= 3.0.0"
Expand Down
90 changes: 90 additions & 0 deletions src/upload-to-ali.d.ts
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
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@
exec-sh "^0.3.2"
minimist "^1.2.0"

"@femessage/github-release-notes@^0.19.0":
"@femessage/github-release-notes@latest":
version "0.19.0"
resolved "https://registry.npmjs.org/@femessage/github-release-notes/-/github-release-notes-0.19.0.tgz#483767c6a52d3a1086000442580503fed72a0898"
integrity sha512-p97YOnBoLfgiWknF5bzqlUOTHIBcBpI8L7bpekPls3annTV65TGfdkl2ICZZAvhjIcl9usDqGFj6pJWj+R+Rzw==
Expand Down

0 comments on commit ed71003

Please sign in to comment.