Skip to content

Commit

Permalink
Merge pull request #18 from unilei/feat-add-admin-panel
Browse files Browse the repository at this point in the history
Feat add admin panel
  • Loading branch information
Lei authored Aug 21, 2024
2 parents 7c3ec94 + 21c35a6 commit c6315c8
Show file tree
Hide file tree
Showing 45 changed files with 1,464 additions and 11 deletions.
13 changes: 13 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ADMIN_USER=
ADMIN_PASSWORD=
ADMIN_EMAIL=
JWT_SECRET=

# This was inserted by `prisma init`:
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL=
29 changes: 28 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,36 @@ LABEL authors="Lei"

WORKDIR /app

# 安装pnmp
RUN npm install -g pnpm

# 复制 package.json 和 package-lock.json
COPY package*.json ./

# 使用 pnpm 安装依赖
RUN pnpm install

COPY . .

RUN npm install
# 定义构建时的变量
ARG ADMIN_USER
ARG ADMIN_PASSWORD
ARG ADMIN_EMAIL
ARG JWT_SECRET
ARG DATABASE_URL
ARG DATABASE_SCHEMA

# 将构建时的变量设置为环境变量
ENV ADMIN_USER=${ADMIN_USER}
ENV ADMIN_PASSWORD=${ADMIN_PASSWORD}
ENV ADMIN_EMAIL=${ADMIN_EMAIL}
ENV JWT_SECRET=${JWT_SECRET}
ENV DATABASE_URL=${DATABASE_URL}
ENV DATABASE_URL=${DATABASE_SCHEMA}

# RUN npm install
RUN npx prisma generate
RUN npx prisma migrate deploy
RUN npm run build

# Set NuxtJS system variables so the application can be reached on your network
Expand Down
58 changes: 54 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,35 @@
爱盼-网盘资源搜索:是一个免费开源项目!
👉 [爱盼-网盘资源搜索](https://so.aicompasspro.com)

### 更新
- 增加后台管理, 访问路径:/login | /admin/dashboard | /admin/clouddrive
- 后台可以增加自己的网盘资源

### 视频介绍
[观看视频](/assets/readme/intro/aipan-intro.mp4)

### 建议
项目使用的是第三方的API,对ip有访问限制,建议自己部署使用。

## 快速开始

### 在 Vercel 上部署

`手动安装一样的,只需要配置对应的env就行了`

[之前部署过的,一定查看此文档](/README_VERCEL.md)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/unilei/aipan-netdisk-search.git&project-name=aipan-netdisk-search&repository-name=aipan-netdisk-search)

### 在 Vercel 上手动部署 操作方法

```
```bash

1. fork 本项目
2. 在 [Vercel] 官网点击 [New Project]
3. 点击 [Import Git Repository] 并选择你 fork 的此项目并点击 [import]
4. 然后直接点 [Deploy] 接着等部署完成即可

```

### Docker执行
Expand All @@ -26,8 +40,31 @@
##### 编译

```bash
docker build -t unilei/aipan-netdisk-search:latest .

docker build \
--build-arg ADMIN_USER=your_admin_user \
--build-arg ADMIN_PASSWORD=your_admin_password \
--build-arg ADMIN_EMAIL=your_admin_email \
--build-arg JWT_SECRET=your_jwt_secret \
--build-arg DATABASE_URL=your_database_url \
-t unilei/aipan-netdisk-search:latest .
```

### 这是个例子

``` bash

docker build \
--build-arg ADMIN_USER=aipan \
--build-arg ADMIN_PASSWORD=aipan123 \
--build-arg ADMIN_EMAIL=<aipan@email.com> \
--build-arg JWT_SECRET='aipannetdisk' \
--build-arg DATABASE_SCHEMA="你创建的schema" \
--build-arg "DATABASE_URL=postgresql://数据库用户名:数据库密码@你的服务器ip:5432/数据库名字?schema=你创建的schema&pgbouncer=true&connect_timeout=15" \
-t unilei/aipan-netdisk-search:latest .

```

##### 运行

```bash
Expand Down Expand Up @@ -74,6 +111,15 @@ pnpm install

# yarn
yarn install
```

### 3. 设置prisma

```bash

npx prisma generate
npx prisma migrate deploy

```
### 3. 运行到浏览器

Expand All @@ -91,12 +137,16 @@ yarn dev
### 4. 在浏览器打开 [http://localhost:3001](http://localhost:3001)
![success_deploy.jpg](/assets/readme/screen-1.png)
![success_deploy.jpg](/assets/readme/screen-2.png)
![success_deploy.jpg](/assets/readme/screen-3.png)
![success_deploy.jpg](/assets/readme/screen-4.png)

#### 如何部署到自己服务器? NUXT.JS 打包部署文档
[部署文档](https://nuxt.com/docs/getting-started/deployment)

### 打赏
<img src="/assets/donation/wechat_pay.jpg" width=200 />

![打赏](/assets/donation/wechat_pay.jpg)

### 交流
<img src="/assets/readme/wechat.jpg" width=200 />

![交流](/assets/readme/wechat.jpg)
60 changes: 60 additions & 0 deletions README_VERCEL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 爱盼-网盘资源搜索Web
爱盼-网盘资源搜索:是一个免费开源项目!
👉 [爱盼-网盘资源搜索](https://so.aicompasspro.com)

### 更新
- 增加后台管理, 访问路径:/login | /admin/dashboard | /admin/clouddrive
- 后台可以增加自己的网盘资源

### 建议
项目使用的是第三方的API,对ip有访问限制,建议自己部署使用。

## 快速开始

### 在 Vercel 上部署

#### 之前已经部署过本项目
- 第1步,点击 storge
![第1步](/assets/readme/vercel/exist/1.png)

- 第2步,选择postgres数据库
![第2步](/assets/readme/vercel/exist/2.png)

- 第3步,创建数据库名字 aipannetdisk, 选择数据库地理位置
![第3步](/assets/readme/vercel/exist/3.png)

- 第4步,复制POSTGRES_PRISMA_URL, :后面的字符串,就是链接地址
![第4步](/assets/readme/vercel/exist/4.png)

- 第5步,切换部署的 git 分支 feat-add-admin-panel
![第5步](/assets/readme/vercel/exist/5.png)

- 第6步,创建部署时的.env
![第6步](/assets/readme/vercel/exist/6.png)

- 第7步,创建项目安装时的命令, `npm install && npx prisma generate && npx prisma migrate deploy`
![第7步](/assets/readme/vercel/exist/7.png)

- 第8步,创建新的部署
![第8步](/assets/readme/vercel/exist/8.png)

- 第9步,选择要部署的git分支
![第9步](/assets/readme/vercel/exist/9.png)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/unilei/aipan-netdisk-search.git&project-name=aipan-netdisk-search&repository-name=aipan-netdisk-search)

### 在 Vercel 上手动部署 操作方法

```
1. fork 本项目
2. 在 [Vercel] 官网点击 [New Project]
3. 点击 [Import Git Repository] 并选择你 fork 的此项目并点击 [import]
4. 然后直接点 [Deploy] 接着等部署完成即可
```


### 打赏
![打赏](/assets/donation/wechat_pay.jpg)

### 交流
![交流](/assets/readme/wechat.jpg)
Binary file added assets/readme/intro/aipan-intro.mp4
Binary file not shown.
Binary file modified assets/readme/screen-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/readme/screen-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/screen-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/screen-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/vercel/exist/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/vercel/exist/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/vercel/exist/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/vercel/exist/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/vercel/exist/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/vercel/exist/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/vercel/exist/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/vercel/exist/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme/vercel/exist/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/vod/clouddrive.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[
{
"api": "/api/sources/aipan-search"
},
{
"api": "/api/sources"
},
Expand Down
18 changes: 18 additions & 0 deletions lib/prisma.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pg from "pg";
import { PrismaPg } from "@prisma/adapter-pg";
import { PrismaClient } from "@prisma/client";

const connectionString = `${process.env.DATABASE_URL}`;
const connectionSchema = `${process.env.DATABASE_SCHEMA}`;

const pool = new pg.Pool({
connectionString,
});

const adapter = new PrismaPg(pool, {
schema: connectionSchema,
});

const prisma = new PrismaClient({ adapter });

export default prisma;
5 changes: 5 additions & 0 deletions lib/prisma.mysql.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

export default prisma;
8 changes: 8 additions & 0 deletions middleware/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default defineNuxtRouteMiddleware((to, from) => {
const token = useCookie("token", {
maxAge: 60 * 60 * 24,
});
if (!token.value) {
return navigateTo("/login");
}
});
13 changes: 9 additions & 4 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,16 @@ export default defineNuxtConfig({
],
nitro: {
devProxy: {

}

},
experimental: {
wasm: true,
},
},
runtimeConfig: {
openaiApiKey: '',
proxyUrl: ''
adminUser: process.env.ADMIN_USER,
adminPassword: process.env.ADMIN_PASSWORD,
adminEmail: process.env.ADMIN_EMAIL,
jwtSecret: process.env.JWT_SECRET
}
})
Loading

0 comments on commit c6315c8

Please sign in to comment.