Skip to content

Commit

Permalink
feat: Add support for Upyun cloud service and token generation functi…
Browse files Browse the repository at this point in the history
…onality
  • Loading branch information
ATQQ committed Mar 31, 2024
1 parent daa5869 commit f2116e0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"main": "token.js",
"scripts": {
"generate": "node ./token.js",
"generate:upyun": "node ./upyun-token.js",
"generare:copy": "copy=true node ./token.js"
},
"dependencies": {
Expand Down
28 changes: 24 additions & 4 deletions packages/client/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<h1 align="center"> 七牛云OSS图床 </h1>
<h1 align="center"> 基于 OSS(对象存储库) 图床 </h1>

<p align="center"><img width="160px" src="./public/favicon.ico"/></p>

<p align="center">基于<a target="_blank" href="https://www.qiniu.com/products/kodo">七牛云对象存储服务</a>搭建的图床应用,<strong>前端纯静态,无需后端</strong></p>
<p align="center">基于对象存储服务搭建的图床应用,<strong>前端纯静态,无需后端</strong></p>

<p align="center">支持 <a target="_blank" href="https://www.qiniu.com/products/kodo">七牛云</a> | <a target="_blank" href="https://www.upyun.com/products/file-storage">又拍云</a></p>

<p align="center">
<a href="https://atqq.github.io/image-bed-qiniu/" target="_blank">GitHub Pages Demo</a> |
Expand All @@ -27,6 +29,7 @@ pnpm preview
```

### 🚧 Docker启动
TODO:待构建镜像

## 配置token
### 生成token
Expand All @@ -47,24 +50,41 @@ QINIU_SCOPE=default

# token有效期,默认一个月,单位秒,你可以自行设置
# QINIU_EXPIRES=2592000

# 又拍云相关配置
UPYUN_OPERATOR=operator
UPYUN_PASSWORD=password
UPYUN_BUCKET=service-name
UPYUN_DOMAIN=http://service-name.test.upcdn.net
UPYUN_PREFIX=image
UPYUN_SCOPE=default
# token有效期,默认一个月,单位秒,你可以自行设置(60*60*24*30)
# UPYUN_EXPIRES=2592000
```
最后资源地址为 **`domain/prefix/scope/md5`**

执行生成 token 脚本
① 七牛云:执行生成 token 脚本
```sh
npm run generate
# 或者
node token.js
```

② 又拍云:执行生成 token 脚本
```sh
npm run generate:upyun
# 或者
node upyun-token.js
```

![token-snippet](./token.png)

### 配置项目默认
*执行 `node token.js` 默认会生成这个文件*

[packages/client](./../client/) 下创建`.env.local`
```sh
VITE_APP_QINIU_TOKEN=你的token
VITE_APP_UPLOAD_TOKEN=你的token
```

启动构建项目即可
Expand Down
2 changes: 1 addition & 1 deletion packages/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>七牛云OSS图床 | 粥里有勺糖</title>
<title>纯静态 OSS 图床 | 粥里有勺糖</title>
<script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
<script>LA.init({ id: "KK6tcRYp7qnv7PCY", ck: "KK6tcRYp7qnv7PCY", hashMode: true })</script>
</head>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/components/HomeHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ElAlert, ElLink } from 'element-plus';
<header>
<div class="left">
<img src="../assets/logo.gif">
<span>七牛云 OSS 图床</span>
<span>纯静态 OSS 图床</span>
</div>
<span class="right">
<ConfigPanel />
Expand Down

0 comments on commit f2116e0

Please sign in to comment.