feat: improve admin workflows and open-source docs
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
# The browser calls Vite on the same origin; Vite forwards /api to this target.
|
||||||
|
VITE_API_BASE_URL=/api
|
||||||
|
VITE_DEV_API_TARGET=http://localhost:8080
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# The production OpenResty site forwards /api to the Java service.
|
||||||
|
VITE_API_BASE_URL=/api
|
||||||
@@ -1,5 +1,181 @@
|
|||||||
# Vue 3 + TypeScript + Vite
|
# My House · 生活档案馆管理后台(Admin)
|
||||||
|
|
||||||
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
My House 三端项目的内容管理后台,用于集中维护文章、影像、生活记录、访客反馈、文件和站点配置。
|
||||||
|
|
||||||
Learn more about the recommended Project Setup and IDE Support in the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
## 项目预览
|
||||||
|
|
||||||
|
<!--
|
||||||
|
将后台首页截图保存为 docs/images/dashboard.png 后,用下面这行替换截图占位:
|
||||||
|
<img src="./docs/images/dashboard.png" alt="生活档案馆管理后台首页" width="100%" />
|
||||||
|
-->
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<br />
|
||||||
|
<strong>📷 截图占位 · 后台仪表盘</strong>
|
||||||
|
<br />
|
||||||
|
<sub>建议尺寸:1600 × 900</sub>
|
||||||
|
<br /><br /><br />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
将内容编辑截图保存为 docs/images/content-editor.png 后,用下面这行替换截图占位:
|
||||||
|
<img src="./docs/images/content-editor.png" alt="文章与内容编辑界面" width="100%" />
|
||||||
|
-->
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<br />
|
||||||
|
<strong>📷 截图占位 · 内容编辑界面</strong>
|
||||||
|
<br />
|
||||||
|
<sub>建议展示文章编辑或站点配置页面</sub>
|
||||||
|
<br /><br /><br />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## 三端组成
|
||||||
|
|
||||||
|
| 项目 | 职责 | 仓库 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Blog | 面向访客的博客与生活档案前台 | [spring_blogs](https://github.com/RRTiamo/spring_blogs) |
|
||||||
|
| Admin | 内容与站点配置管理后台 | **当前仓库** |
|
||||||
|
| Server | API、鉴权、数据库与文件存储 | [spring_server](https://github.com/RRTiamo/spring_server) |
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
manager["管理员"] --> admin["Admin · Vue"]
|
||||||
|
admin --> api["Server · /api"]
|
||||||
|
api --> mysql[("MySQL")]
|
||||||
|
api --> storage["本地 / MinIO / 七牛云"]
|
||||||
|
api --> blog["Blog · Next.js"]
|
||||||
|
```
|
||||||
|
|
||||||
|
## 主要功能
|
||||||
|
|
||||||
|
- 登录状态与 Sa-Token 会话管理
|
||||||
|
- 仪表盘与内容概览
|
||||||
|
- 文章、分类、照片墙、随笔便签和成就管理
|
||||||
|
- 恋爱记录、愿望清单、时间胶囊和岁月信箱管理
|
||||||
|
- “此时此刻”、关于作者、友情链接和页面可见性配置
|
||||||
|
- 鱼塘反馈审核、回复、标签与状态管理
|
||||||
|
- 本地、MinIO、七牛云文件的统一管理入口
|
||||||
|
- 品牌、主题、备案、地图、AI、数据库和存储配置
|
||||||
|
|
||||||
|
## 技术栈
|
||||||
|
|
||||||
|
- Vue 3 + TypeScript
|
||||||
|
- Vite 6
|
||||||
|
- Vue Router + Pinia
|
||||||
|
- Naive UI + UnoCSS
|
||||||
|
- Axios
|
||||||
|
- ECharts、Leaflet、GSAP
|
||||||
|
|
||||||
|
## 本地运行
|
||||||
|
|
||||||
|
### 环境要求
|
||||||
|
|
||||||
|
- Node.js 20 LTS 或 Node.js 22+
|
||||||
|
- npm
|
||||||
|
- 已启动的 [spring_server](https://github.com/RRTiamo/spring_server),默认地址为 `http://localhost:8080`
|
||||||
|
|
||||||
|
### 1. 获取项目
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/RRTiamo/spring_admin.git
|
||||||
|
cd spring_admin
|
||||||
|
npm ci
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 配置开发环境
|
||||||
|
|
||||||
|
项目根目录创建或修改 `.env.development`:
|
||||||
|
|
||||||
|
```dotenv
|
||||||
|
# 浏览器端使用的 API 基础路径。
|
||||||
|
VITE_API_BASE_URL=/api
|
||||||
|
|
||||||
|
# Vite 开发代理的 Server 地址,不包含 /api。
|
||||||
|
VITE_DEV_API_TARGET=http://localhost:8080
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 启动
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
访问终端输出的本地地址,通常为 [http://localhost:5173](http://localhost:5173)。
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> 后台账号由 Server 的 `APP_ADMIN_USERNAME` 与 `APP_ADMIN_PASSWORD` 提供。服务端没有默认密码,启动 Server 前必须显式设置。
|
||||||
|
|
||||||
|
## 环境变量
|
||||||
|
|
||||||
|
| 变量 | 用途 | 开发环境建议值 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `VITE_API_BASE_URL` | 浏览器端 API 基础路径,会写入构建产物 | `/api` |
|
||||||
|
| `VITE_DEV_API_TARGET` | Vite 开发服务器的代理目标 | `http://localhost:8080` |
|
||||||
|
|
||||||
|
如果生产环境使用同域反向代理,保留 `VITE_API_BASE_URL=/api` 即可;如果 API 位于独立域名,应填写完整 HTTPS 地址并重新构建。
|
||||||
|
|
||||||
|
## 可用命令
|
||||||
|
|
||||||
|
| 命令 | 说明 |
|
||||||
|
| --- | --- |
|
||||||
|
| `npm run dev` | 启动 Vite 开发服务器 |
|
||||||
|
| `npm run lint` | 运行 `vue-tsc` 类型检查 |
|
||||||
|
| `npm run build` | 类型检查并构建至 `dist/` |
|
||||||
|
| `npm run preview` | 本地预览生产构建 |
|
||||||
|
|
||||||
|
提交前至少运行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run lint
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
## 目录结构
|
||||||
|
|
||||||
|
```text
|
||||||
|
src/
|
||||||
|
├─ api/ # 统一 API 请求与接口封装
|
||||||
|
├─ assets/ # 后台静态资源
|
||||||
|
├─ components/ # 可复用组件
|
||||||
|
├─ icon/ # 菜单及业务图标配置
|
||||||
|
├─ interface/ # 核心 TypeScript 类型
|
||||||
|
├─ mock/ # 静态兜底数据
|
||||||
|
├─ router/ # 页面路由与登录守卫
|
||||||
|
├─ store/ # Pinia 状态
|
||||||
|
└─ views/ # 各业务管理页面
|
||||||
|
```
|
||||||
|
|
||||||
|
## 生产部署
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm ci
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
将 `dist/` 作为静态站点发布,并为 SPA 路由配置回退到 `index.html`。同时确认:
|
||||||
|
|
||||||
|
1. `/api` 已反向代理到 Server,或 `VITE_API_BASE_URL` 已指向完整 API 地址。
|
||||||
|
2. Admin 与 Server 使用 HTTPS。
|
||||||
|
3. Server 的 CORS 白名单只包含真实的 Blog/Admin 域名。
|
||||||
|
4. 默认管理员凭据已更换,敏感配置未进入 Git。
|
||||||
|
|
||||||
|
## 开源与安全检查
|
||||||
|
|
||||||
|
- 不要提交数据库密码、AI Key、对象存储密钥或生产 Token。
|
||||||
|
- Vite 的 `VITE_*` 变量会进入浏览器构建产物,只能存放公开配置。
|
||||||
|
- 检查 `public/`、Mock 数据及表单默认值,移除个人信息和无授权素材。
|
||||||
|
- 生产环境应限制后台访问入口,并在反向代理层启用 HTTPS、安全响应头和访问日志。
|
||||||
|
|
||||||
|
## 参与贡献
|
||||||
|
|
||||||
|
欢迎通过 Issue 或 Pull Request 参与改进。新增网络请求、核心类型、Mock 数据和图标时,请继续放在对应的 `api/`、`interface/`、`mock/` 与 `icon/` 目录中。
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
当前仓库尚未附带开源许可证。在仓库根目录补充明确的 `LICENSE` 前,代码默认保留全部权利。
|
||||||
|
|||||||
+3
-1
@@ -63,8 +63,10 @@ function processDates(obj: any): any {
|
|||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const apiBaseUrl = (import.meta.env.VITE_API_BASE_URL || '/api').replace(/\/+$/, '')
|
||||||
|
|
||||||
const request = axios.create({
|
const request = axios.create({
|
||||||
baseURL: 'http://localhost:8080/api',
|
baseURL: apiBaseUrl,
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=about"
|
action="/api/blogs/upload?type=about"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="handleAvatarUploadFinish"
|
@finish="handleAvatarUploadFinish"
|
||||||
@@ -161,7 +161,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=about"
|
action="/api/blogs/upload?type=about"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="(event) => handleCoordinateUploadFinish(Number(idx), event)"
|
@finish="(event) => handleCoordinateUploadFinish(Number(idx), event)"
|
||||||
@@ -255,7 +255,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=about"
|
action="/api/blogs/upload?type=about"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="(event) => handleFragmentUploadFinish(Number(idx), event)"
|
@finish="(event) => handleFragmentUploadFinish(Number(idx), event)"
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
class="flex-1"
|
class="flex-1"
|
||||||
/>
|
/>
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=achieve"
|
action="/api/blogs/upload?type=achieve"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="handleUploadFinish"
|
@finish="handleUploadFinish"
|
||||||
|
|||||||
@@ -15,25 +15,25 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<n-button size="small" secondary type="warning" @click="triggerFileInput">
|
<n-button size="small" secondary type="primary" @click="triggerFileInput">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<span class="i-mdi-file-import-outline"></span>
|
<span class="i-mdi-file-import-outline"></span>
|
||||||
</template>
|
</template>
|
||||||
导入 Markdown (.md)
|
导入 Markdown (.md)
|
||||||
</n-button>
|
</n-button>
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
ref="fileInputRef"
|
ref="fileInputRef"
|
||||||
accept=".md"
|
accept=".md,text/markdown"
|
||||||
style="display: none"
|
class="hidden"
|
||||||
@change="handleImportMarkdown"
|
@change="handleImportMarkdown"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 导言提醒 -->
|
<!-- 导言提醒 -->
|
||||||
<p class="m-0 text-xs tone-muted">
|
<p class="m-0 text-xs tone-muted">
|
||||||
在这里可以享受宽广的随笔写作空间。支持直接使用 Markdown 格式输入正文,或者通过右上角按钮直接导入本地 Markdown 随笔文件。
|
支持直接使用 Markdown 格式输入正文,也可以通过右上角按钮导入由 Typora、PicGo 等工具处理好的 Markdown 文件。
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<n-form ref="formRef" :model="formModel" :rules="formRules" label-placement="top">
|
<n-form ref="formRef" :model="formModel" :rules="formRules" label-placement="top">
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
<div class="flex-1 space-y-2.5 w-full">
|
<div class="flex-1 space-y-2.5 w-full">
|
||||||
<!-- 上传与输入组合 -->
|
<!-- 上传与输入组合 -->
|
||||||
<div class="flex items-center gap-2 w-full">
|
<div class="flex items-center gap-2 w-full">
|
||||||
<n-input v-model:value="formModel.cover" placeholder="输入路径(如 /assets/writing-tokyo.png)或上传图片" class="flex-1" />
|
<n-input v-model:value="formModel.cover" placeholder="请输入封面地址,或使用右侧按钮选择图片" class="flex-1" />
|
||||||
|
|
||||||
<n-button type="info" secondary round @click="emit('open-gallery')" class="shrink-0">
|
<n-button type="info" secondary round @click="emit('open-gallery')" class="shrink-0">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
</n-button>
|
</n-button>
|
||||||
|
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=blog"
|
action="/api/blogs/upload?type=blog"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="handleUploadFinish"
|
@finish="handleUploadFinish"
|
||||||
@@ -190,13 +190,19 @@ const triggerFileInput = () => {
|
|||||||
|
|
||||||
const handleImportMarkdown = (event: Event) => {
|
const handleImportMarkdown = (event: Event) => {
|
||||||
const input = event.target as HTMLInputElement
|
const input = event.target as HTMLInputElement
|
||||||
if (!input.files || input.files.length === 0) return
|
const file = input.files?.[0]
|
||||||
const file = input.files[0]
|
if (!file) return
|
||||||
|
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
reader.onload = (e) => {
|
reader.onload = (loadEvent) => {
|
||||||
const text = e.target?.result as string
|
const content = String(loadEvent.target?.result || '').replace(/^\uFEFF/, '')
|
||||||
emit('import-md', text)
|
emit('import-md', content)
|
||||||
message.success(`本地 Markdown 文件「${file.name}」导入成功!`)
|
message.success(`Markdown 文件「${file.name}」导入成功`)
|
||||||
|
input.value = ''
|
||||||
|
}
|
||||||
|
reader.onerror = () => {
|
||||||
|
message.error(`无法读取 Markdown 文件「${file.name}」`)
|
||||||
|
input.value = ''
|
||||||
}
|
}
|
||||||
reader.readAsText(file)
|
reader.readAsText(file)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ const formModel = ref({
|
|||||||
const formRules = {
|
const formRules = {
|
||||||
title: { required: true, message: '请输入文章标题', trigger: 'blur' },
|
title: { required: true, message: '请输入文章标题', trigger: 'blur' },
|
||||||
content: { required: true, message: '请输入文章正文内容', trigger: 'blur' },
|
content: { required: true, message: '请输入文章正文内容', trigger: 'blur' },
|
||||||
|
cover: { required: true, message: '请上传、选择或填写文章封面', trigger: ['blur', 'change'] },
|
||||||
categoryId: { required: true, type: 'number', message: '请选择文章归档分类', trigger: 'change' }
|
categoryId: { required: true, type: 'number', message: '请选择文章归档分类', trigger: 'change' }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,7 +295,7 @@ const openCreate = () => {
|
|||||||
categoryId: categories.value[0]?.id || null,
|
categoryId: categories.value[0]?.id || null,
|
||||||
mood: 'quiet',
|
mood: 'quiet',
|
||||||
visibility: 'public',
|
visibility: 'public',
|
||||||
cover: '/assets/writing-tokyo.png'
|
cover: ''
|
||||||
}
|
}
|
||||||
showEditor.value = true
|
showEditor.value = true
|
||||||
}
|
}
|
||||||
@@ -312,7 +313,7 @@ const openEdit = (blog: Blog) => {
|
|||||||
categoryId: blog.categoryId ? Number(blog.categoryId) : null,
|
categoryId: blog.categoryId ? Number(blog.categoryId) : null,
|
||||||
mood: blog.mood || 'quiet',
|
mood: blog.mood || 'quiet',
|
||||||
visibility: blog.visibility || 'public',
|
visibility: blog.visibility || 'public',
|
||||||
cover: blog.cover
|
cover: blog.cover || ''
|
||||||
}
|
}
|
||||||
showEditor.value = true
|
showEditor.value = true
|
||||||
}
|
}
|
||||||
@@ -402,10 +403,32 @@ const generateAISummary = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导入 Markdown 文件
|
// 从 Markdown 正文中提取第一个一级标题
|
||||||
const handleImportMarkdownContent = (text: string) => {
|
const extractH1Title = (markdownText: string): string => {
|
||||||
|
if (!markdownText) return ''
|
||||||
|
|
||||||
|
// 1. 匹配 Atx 风格一级标题: ^# 标题 或 \n# 标题
|
||||||
|
const atxMatch = markdownText.match(/(?:^|\n)#\s+([^\n]+)/)
|
||||||
|
if (atxMatch && atxMatch[1].trim()) {
|
||||||
|
return atxMatch[1].trim().replace(/^[*_~`]+|[*_~`]+$/g, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 匹配 Setext 风格一级标题 (标题文本\n===)
|
||||||
|
const setextMatch = markdownText.match(/(?:^|\n)([^\n]+)\r?\n=+\s*(?:\n|$)/)
|
||||||
|
if (setextMatch && setextMatch[1].trim()) {
|
||||||
|
return setextMatch[1].trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导入 Markdown 文件;正文中的远程图片链接由渲染器直接解析
|
||||||
|
const handleImportMarkdownContent = (content: string) => {
|
||||||
const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/
|
const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/
|
||||||
const match = frontmatterRegex.exec(text)
|
const match = frontmatterRegex.exec(content)
|
||||||
|
|
||||||
|
let extractedTitle = ''
|
||||||
|
let body = content.trim()
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
const yamlContent = match[1]
|
const yamlContent = match[1]
|
||||||
@@ -421,25 +444,36 @@ const handleImportMarkdownContent = (text: string) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
formModel.value.title = meta['title'] || '导入文章'
|
body = bodyContent.trim()
|
||||||
|
extractedTitle = meta['title'] || extractH1Title(body)
|
||||||
|
|
||||||
|
formModel.value.title = extractedTitle || '导入文章'
|
||||||
formModel.value.slug = meta['slug'] || ''
|
formModel.value.slug = meta['slug'] || ''
|
||||||
formModel.value.tags = meta['tags'] ? meta['tags'].split(',').map((t) => t.trim()).filter(Boolean) : []
|
formModel.value.tags = meta['tags'] ? meta['tags'].split(',').map((tag) => tag.trim()).filter(Boolean) : []
|
||||||
formModel.value.summary = meta['description'] || meta['summary'] || ''
|
formModel.value.summary = meta['description'] || meta['summary'] || ''
|
||||||
formModel.value.category = meta['category'] || 'Thoughts'
|
formModel.value.category = meta['category'] || 'Thoughts'
|
||||||
|
formModel.value.categoryId = meta['categoryid']
|
||||||
|
? Number(meta['categoryid'])
|
||||||
|
: (categories.value[0]?.id || null)
|
||||||
formModel.value.mood = meta['mood'] || 'quiet'
|
formModel.value.mood = meta['mood'] || 'quiet'
|
||||||
formModel.value.visibility = meta['visibility'] || 'public'
|
formModel.value.visibility = meta['visibility'] || 'public'
|
||||||
formModel.value.cover = meta['cover'] || '/assets/writing-camera.png'
|
formModel.value.cover = meta['cover'] || ''
|
||||||
formModel.value.content = bodyContent.trim()
|
formModel.value.content = body
|
||||||
} else {
|
return
|
||||||
formModel.value.title = '导入文章'
|
|
||||||
formModel.value.content = text.trim()
|
|
||||||
formModel.value.tags = []
|
|
||||||
formModel.value.summary = ''
|
|
||||||
formModel.value.category = 'Thoughts'
|
|
||||||
formModel.value.mood = 'quiet'
|
|
||||||
formModel.value.visibility = 'public'
|
|
||||||
formModel.value.cover = '/assets/writing-camera.png'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extractedTitle = extractH1Title(body)
|
||||||
|
|
||||||
|
formModel.value.title = extractedTitle || '导入文章'
|
||||||
|
formModel.value.slug = ''
|
||||||
|
formModel.value.content = body
|
||||||
|
formModel.value.tags = []
|
||||||
|
formModel.value.summary = ''
|
||||||
|
formModel.value.category = 'Thoughts'
|
||||||
|
formModel.value.categoryId = categories.value[0]?.id || null
|
||||||
|
formModel.value.mood = 'quiet'
|
||||||
|
formModel.value.visibility = 'public'
|
||||||
|
formModel.value.cover = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// 图册封面选择器
|
// 图册封面选择器
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useMessage, NForm, NFormItem, NInput, NButton } from 'naive-ui'
|
import { useMessage, NForm, NFormItem, NInput, NButton } from 'naive-ui'
|
||||||
import axios from 'axios'
|
import request from '@/api/request'
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
@@ -65,7 +65,7 @@ const aiConfig = ref({
|
|||||||
const fetchConfigs = async () => {
|
const fetchConfigs = async () => {
|
||||||
try {
|
try {
|
||||||
const token = localStorage.getItem('satoken')
|
const token = localStorage.getItem('satoken')
|
||||||
const response = await axios.get('http://localhost:8080/api/config/list', {
|
const response = await request.get('/config/list', {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ const handleSave = async () => {
|
|||||||
]
|
]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('http://localhost:8080/api/config/update-batch', payload, {
|
const response = await request.post('/config/update-batch', payload, {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useMessage, NForm, NFormItem, NInput, NButton } from 'naive-ui'
|
import { useMessage, NForm, NFormItem, NInput, NButton } from 'naive-ui'
|
||||||
import axios from 'axios'
|
import request from '@/api/request'
|
||||||
|
|
||||||
const getBlogUrl = (path: string) => {
|
const getBlogUrl = (path: string) => {
|
||||||
const protocol = window.location.protocol
|
const protocol = window.location.protocol
|
||||||
@@ -108,7 +108,7 @@ const encryptKey = (str: string): string => {
|
|||||||
const fetchConfigs = async () => {
|
const fetchConfigs = async () => {
|
||||||
try {
|
try {
|
||||||
const token = localStorage.getItem('satoken')
|
const token = localStorage.getItem('satoken')
|
||||||
const response = await axios.get('http://localhost:8080/api/config/list', {
|
const response = await request.get('/config/list', {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ const handleSave = async () => {
|
|||||||
]
|
]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('http://localhost:8080/api/config/update-batch', payload, {
|
const response = await request.post('/config/update-batch', payload, {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useMessage, NForm, NFormItem, NInput, NButton } from 'naive-ui'
|
import { useMessage, NForm, NFormItem, NInput, NButton } from 'naive-ui'
|
||||||
import axios from 'axios'
|
import request from '@/api/request'
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
@@ -53,7 +53,7 @@ const beian = ref({
|
|||||||
const fetchConfigs = async () => {
|
const fetchConfigs = async () => {
|
||||||
try {
|
try {
|
||||||
const token = localStorage.getItem('satoken')
|
const token = localStorage.getItem('satoken')
|
||||||
const response = await axios.get('http://localhost:8080/api/config/list', {
|
const response = await request.get('/config/list', {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ const handleSave = async () => {
|
|||||||
]
|
]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('http://localhost:8080/api/config/update-batch', payload, {
|
const response = await request.post('/config/update-batch', payload, {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
<div class="flex items-center gap-2 shrink-0 justify-end sm:justify-start">
|
<div class="flex items-center gap-2 shrink-0 justify-end sm:justify-start">
|
||||||
<n-button secondary size="small" class="shrink-0" @click="openGallerySelect('logoUrl')">相册选择</n-button>
|
<n-button secondary size="small" class="shrink-0" @click="openGallerySelect('logoUrl')">相册选择</n-button>
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=brand"
|
action="/api/blogs/upload?type=brand"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
class="flex shrink-0"
|
class="flex shrink-0"
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
<div class="flex items-center gap-2 shrink-0 justify-end sm:justify-start">
|
<div class="flex items-center gap-2 shrink-0 justify-end sm:justify-start">
|
||||||
<n-button secondary size="small" class="shrink-0" @click="openGallerySelect('faviconUrl')">相册选择</n-button>
|
<n-button secondary size="small" class="shrink-0" @click="openGallerySelect('faviconUrl')">相册选择</n-button>
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=brand"
|
action="/api/blogs/upload?type=brand"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
class="flex shrink-0"
|
class="flex shrink-0"
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
<div class="flex items-center gap-2 shrink-0 justify-end sm:justify-start">
|
<div class="flex items-center gap-2 shrink-0 justify-end sm:justify-start">
|
||||||
<n-button secondary size="small" class="shrink-0" @click="openGallerySelect('heroBgUrl')">相册选择</n-button>
|
<n-button secondary size="small" class="shrink-0" @click="openGallerySelect('heroBgUrl')">相册选择</n-button>
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=brand"
|
action="/api/blogs/upload?type=brand"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
class="flex shrink-0"
|
class="flex shrink-0"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<div class="archive-card p-5 sm:p-6 bg-(--archive-bg-card) border border-(--archive-border) rounded-2xl">
|
<div class="archive-card p-5 sm:p-6 bg-(--archive-bg-card) border border-(--archive-border) rounded-2xl">
|
||||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-4 border-b border-(--archive-border)/40">
|
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-4 border-b border-(--archive-border)/40">
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useMessage, NForm, NFormItem, NInput, NButton } from 'naive-ui'
|
import { useMessage, NForm, NFormItem, NInput, NButton } from 'naive-ui'
|
||||||
import axios from 'axios'
|
import request from '@/api/request'
|
||||||
|
|
||||||
const getBlogUrl = (path: string) => {
|
const getBlogUrl = (path: string) => {
|
||||||
const protocol = window.location.protocol
|
const protocol = window.location.protocol
|
||||||
@@ -98,7 +98,7 @@ const dbConfig = ref({
|
|||||||
const fetchDbConfig = async () => {
|
const fetchDbConfig = async () => {
|
||||||
try {
|
try {
|
||||||
const token = localStorage.getItem('satoken')
|
const token = localStorage.getItem('satoken')
|
||||||
const response = await axios.get('http://localhost:8080/api/config/database', {
|
const response = await request.get('/config/database', {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
if (response.data && response.data.code === 200) {
|
if (response.data && response.data.code === 200) {
|
||||||
@@ -113,7 +113,7 @@ const handleSave = async () => {
|
|||||||
saving.value = true
|
saving.value = true
|
||||||
const token = localStorage.getItem('satoken')
|
const token = localStorage.getItem('satoken')
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('http://localhost:8080/api/config/database', dbConfig.value, {
|
const response = await request.post('/config/database', dbConfig.value, {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
if (response.data && response.data.code === 200) {
|
if (response.data && response.data.code === 200) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<div class="archive-card p-5 sm:p-6 bg-(--archive-bg-card) border border-(--archive-border) rounded-2xl">
|
<div class="archive-card p-5 sm:p-6 bg-(--archive-bg-card) border border-(--archive-border) rounded-2xl">
|
||||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-4 border-b border-(--archive-border)/40">
|
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-4 border-b border-(--archive-border)/40">
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { useMessage, NForm, NFormItem, NSelect, NInput, NButton } from 'naive-ui'
|
import { useMessage, NForm, NFormItem, NSelect, NInput, NButton } from 'naive-ui'
|
||||||
import axios from 'axios'
|
import request from '@/api/request'
|
||||||
|
|
||||||
const getBlogUrl = (path: string) => {
|
const getBlogUrl = (path: string) => {
|
||||||
const protocol = window.location.protocol
|
const protocol = window.location.protocol
|
||||||
@@ -159,7 +159,7 @@ const activeStorageLabel = computed(() => {
|
|||||||
const fetchConfigs = async () => {
|
const fetchConfigs = async () => {
|
||||||
try {
|
try {
|
||||||
const token = localStorage.getItem('satoken')
|
const token = localStorage.getItem('satoken')
|
||||||
const response = await axios.get('http://localhost:8080/api/config/list', {
|
const response = await request.get('/config/list', {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ const handleSave = async () => {
|
|||||||
]
|
]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('http://localhost:8080/api/config/update-batch', payload, {
|
const response = await request.post('/config/update-batch', payload, {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,7 @@
|
|||||||
|
|
||||||
<div class="flex flex-wrap items-center gap-2 mb-2">
|
<div class="flex flex-wrap items-center gap-2 mb-2">
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=theme"
|
action="/api/blogs/upload?type=theme"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="handleBgUploadFinish"
|
@finish="handleBgUploadFinish"
|
||||||
@@ -260,7 +260,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { useMessage, NForm, NFormItem, NInput, NInputNumber, NSwitch, NUpload, NButton, NModal, NSpin } from 'naive-ui'
|
import { useMessage, NForm, NFormItem, NInput, NInputNumber, NSwitch, NUpload, NButton, NModal, NSpin } from 'naive-ui'
|
||||||
import axios from 'axios'
|
import request from '@/api/request'
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
@@ -303,7 +303,7 @@ const uploadHeaders = computed(() => ({
|
|||||||
const fetchConfigs = async () => {
|
const fetchConfigs = async () => {
|
||||||
try {
|
try {
|
||||||
const token = localStorage.getItem('satoken')
|
const token = localStorage.getItem('satoken')
|
||||||
const response = await axios.get('http://localhost:8080/api/config/list', {
|
const response = await request.get('/config/list', {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ const handleSave = async () => {
|
|||||||
]
|
]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('http://localhost:8080/api/config/update-batch', payload, {
|
const response = await request.post('/config/update-batch', payload, {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -412,7 +412,7 @@ const openGallerySelect = async () => {
|
|||||||
selectedPhotoUrl.value = theme.value.bgImageUrl || ''
|
selectedPhotoUrl.value = theme.value.bgImageUrl || ''
|
||||||
const token = localStorage.getItem('satoken')
|
const token = localStorage.getItem('satoken')
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('http://localhost:8080/api/gallery/list', {
|
const response = await request.get('/gallery/list', {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
if (response.data && response.data.code === 200) {
|
if (response.data && response.data.code === 200) {
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useMessage, NForm, NSwitch, NButton, NInput, NFormItem } from 'naive-ui'
|
import { useMessage, NForm, NSwitch, NButton, NInput, NFormItem } from 'naive-ui'
|
||||||
import axios from 'axios'
|
import request from '@/api/request'
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
@@ -127,7 +127,7 @@ const passcode = ref('2026')
|
|||||||
const fetchConfigs = async () => {
|
const fetchConfigs = async () => {
|
||||||
try {
|
try {
|
||||||
const token = localStorage.getItem('satoken')
|
const token = localStorage.getItem('satoken')
|
||||||
const response = await axios.get('http://localhost:8080/api/config/list', {
|
const response = await request.get('/config/list', {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ const handleSave = async () => {
|
|||||||
]
|
]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('http://localhost:8080/api/config/update-batch', payload, {
|
const response = await request.post('/config/update-batch', payload, {
|
||||||
headers: { satoken: token }
|
headers: { satoken: token }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+284
-74
@@ -33,7 +33,15 @@
|
|||||||
class="min-w-36 lg:max-w-40"
|
class="min-w-36 lg:max-w-40"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
class="px-4 py-2 text-xs font-semibold rounded-xl bg-(--archive-bg) border border-(--archive-border) text-(--archive-text) hover:bg-(--archive-border)/40 active:scale-[0.98] transition-all flex items-center justify-center gap-1.5 cursor-pointer whitespace-nowrap"
|
||||||
|
@click="viewMode = viewMode === 'folder' ? 'flat' : 'folder'; page = 1;"
|
||||||
|
>
|
||||||
|
<span :class="viewMode === 'folder' ? 'i-mdi-format-list-bulleted' : 'i-mdi-folder-outline'"></span>
|
||||||
|
<span>{{ viewMode === 'folder' ? '平铺视图' : '文件夹视图' }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
class="px-4 py-2 text-xs font-semibold rounded-xl bg-(--archive-bg) border border-(--archive-border) text-(--archive-text) hover:bg-(--archive-border)/40 active:scale-[0.98] transition-all flex items-center justify-center gap-1.5 cursor-pointer whitespace-nowrap"
|
class="px-4 py-2 text-xs font-semibold rounded-xl bg-(--archive-bg) border border-(--archive-border) text-(--archive-text) hover:bg-(--archive-border)/40 active:scale-[0.98] transition-all flex items-center justify-center gap-1.5 cursor-pointer whitespace-nowrap"
|
||||||
@click="loadData"
|
@click="loadData"
|
||||||
>
|
>
|
||||||
@@ -41,7 +49,7 @@
|
|||||||
<span>刷新</span>
|
<span>刷新</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="px-4 py-2 text-xs font-semibold rounded-xl bg-(--archive-accent) text-white hover:opacity-90 active:scale-[0.98] transition-all flex items-center justify-center gap-1.5 shadow-sm cursor-pointer whitespace-nowrap"
|
class="px-4 py-2 text-xs font-semibold rounded-xl bg-(--archive-accent) text-white hover:opacity-90 active:scale-[0.98] transition-all flex items-center justify-center gap-1.5 shadow-sm cursor-pointer whitespace-nowrap"
|
||||||
@click="goToConfig"
|
@click="goToConfig"
|
||||||
>
|
>
|
||||||
@@ -51,6 +59,49 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 路径面包屑导航 -->
|
||||||
|
<div v-if="viewMode === 'folder'" class="border border-(--archive-border) rounded-2xl bg-(--archive-bg-card) px-5 py-3 shadow-sm flex items-center justify-between gap-4 transition-all hover:shadow-md">
|
||||||
|
<div class="flex items-center gap-1.5 text-xs font-medium text-left">
|
||||||
|
<span class="tone-muted flex items-center gap-1">
|
||||||
|
<span class="i-mdi-home-outline text-sm"></span>
|
||||||
|
当前位置:
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
class="px-2 py-0.5 rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors cursor-pointer border-none bg-transparent font-semibold"
|
||||||
|
:class="currentDir === '' ? 'text-(--archive-accent)' : 'text-(--archive-text)'"
|
||||||
|
@click="currentDir = ''; page = 1;"
|
||||||
|
>
|
||||||
|
根目录
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<template v-for="(part, idx) in breadcrumbs" :key="idx">
|
||||||
|
<span class="text-(--archive-text)/40">/</span>
|
||||||
|
<button
|
||||||
|
class="px-2 py-0.5 rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors cursor-pointer border-none bg-transparent font-semibold"
|
||||||
|
:class="idx === breadcrumbs.length - 1 ? 'text-(--archive-accent)' : 'text-(--archive-text)'"
|
||||||
|
@click="navigateToBreadcrumb(idx)"
|
||||||
|
>
|
||||||
|
{{ part }}
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<n-button
|
||||||
|
v-if="currentDir !== ''"
|
||||||
|
size="tiny"
|
||||||
|
secondary
|
||||||
|
round
|
||||||
|
@click="goBackDir"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<span class="i-mdi-arrow-up"></span>
|
||||||
|
</template>
|
||||||
|
返回上级
|
||||||
|
</n-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 统计指示面板 -->
|
<!-- 统计指示面板 -->
|
||||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-5">
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-5">
|
||||||
<!-- 存储介质卡片 -->
|
<!-- 存储介质卡片 -->
|
||||||
@@ -118,76 +169,104 @@
|
|||||||
<!-- 文件卡片网格列表 -->
|
<!-- 文件卡片网格列表 -->
|
||||||
<div v-else class="space-y-6">
|
<div v-else class="space-y-6">
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-5">
|
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-5">
|
||||||
<div
|
<div
|
||||||
v-for="item in paginatedFiles"
|
v-for="item in paginatedItems"
|
||||||
:key="item.fileName"
|
:key="item.isDir ? 'dir_' + item.path : 'file_' + item.fileName"
|
||||||
class="border border-(--archive-border) rounded-2xl bg-(--archive-bg-card) p-3 flex flex-col group transition-all duration-300 hover:shadow-md hover:-translate-y-0.5"
|
class="border border-(--archive-border) rounded-2xl bg-(--archive-bg-card) p-3 flex flex-col group transition-all duration-300 hover:shadow-md hover:-translate-y-0.5 cursor-pointer"
|
||||||
|
@click="handleItemClick(item)"
|
||||||
>
|
>
|
||||||
<!-- 预览图/占位图 -->
|
<!-- 文件夹卡片 -->
|
||||||
<div class="relative w-full h-38 rounded-xl overflow-hidden bg-white/2 dark:bg-white/5 shrink-0">
|
<template v-if="item.isDir">
|
||||||
<template v-if="isImage(item.fileName)">
|
<div class="relative w-full h-38 rounded-xl overflow-hidden bg-(--archive-accent)/5 flex flex-col items-center justify-center gap-2.5 shrink-0 transition-colors group-hover:bg-(--archive-accent)/10">
|
||||||
<n-image
|
<span class="i-mdi-folder text-5xl text-(--archive-accent) drop-shadow-sm transition-transform duration-300 group-hover:scale-105"></span>
|
||||||
:src="item.url"
|
<span class="text-[10px] uppercase font-bold tracking-wider text-(--archive-accent)/80">
|
||||||
class="w-full h-full"
|
文件夹
|
||||||
:img-props="{ class: 'w-full h-full object-cover transition-transform duration-500 group-hover:scale-103' }"
|
</span>
|
||||||
show-toolbar-tooltip
|
</div>
|
||||||
fallback-src="/life-assets/placeholder.jpg"
|
|
||||||
/>
|
<div class="mt-3 flex flex-col text-left grow">
|
||||||
</template>
|
<span class="text-xs font-bold text-(--archive-text) truncate" :title="item.name">
|
||||||
<template v-else>
|
{{ item.name }}
|
||||||
<div class="w-full h-full flex flex-col items-center justify-center gap-2 text-(--archive-text)/40 bg-black/5 dark:bg-white/5">
|
</span>
|
||||||
<span :class="getFileIcon(item.fileName)" class="text-4xl"></span>
|
<div class="flex items-center justify-between mt-2.5">
|
||||||
<span class="text-[10px] uppercase font-bold tracking-wider opacity-60">
|
<span class="text-[10px] px-1.5 py-0.5 rounded font-medium bg-(--archive-accent)/10 text-(--archive-accent)">
|
||||||
{{ getFileExt(item.fileName) }} 文件
|
{{ item.childCount }} 个文件
|
||||||
|
</span>
|
||||||
|
<span class="text-[10px] tone-muted">
|
||||||
|
目录
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
|
||||||
|
|
||||||
<!-- 悬浮操作层 -->
|
|
||||||
<div class="absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center gap-3">
|
|
||||||
<n-tooltip trigger="hover">
|
|
||||||
<template #trigger>
|
|
||||||
<button
|
|
||||||
class="h-9 w-9 rounded-full bg-white text-gray-800 flex items-center justify-center hover:bg-(--archive-accent) hover:text-white active:scale-95 transition-all shadow cursor-pointer border-none"
|
|
||||||
@click="copyUrl(item.url)"
|
|
||||||
>
|
|
||||||
<span class="i-mdi-content-copy text-base"></span>
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
复制链接
|
|
||||||
</n-tooltip>
|
|
||||||
|
|
||||||
<n-tooltip trigger="hover">
|
|
||||||
<template #trigger>
|
|
||||||
<button
|
|
||||||
class="h-9 w-9 rounded-full bg-white text-red-600 flex items-center justify-center hover:bg-red-600 hover:text-white active:scale-95 transition-all shadow cursor-pointer border-none"
|
|
||||||
@click="handleDelete(item)"
|
|
||||||
>
|
|
||||||
<span class="i-mdi-trash-can-outline text-base"></span>
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
删除文件
|
|
||||||
</n-tooltip>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
|
|
||||||
<!-- 详细信息区 -->
|
<!-- 文件卡片 -->
|
||||||
<div class="mt-3 flex flex-col text-left grow">
|
<template v-else>
|
||||||
<span
|
<!-- 预览图/占位图 -->
|
||||||
class="text-xs font-bold text-(--archive-text) truncate"
|
<div class="relative w-full h-38 rounded-xl overflow-hidden bg-white/2 dark:bg-white/5 shrink-0">
|
||||||
:title="item.fileName"
|
<template v-if="isImage(item.fileName)">
|
||||||
>
|
<n-image
|
||||||
{{ getFileNameOnly(item.fileName) }}
|
:src="item.url"
|
||||||
</span>
|
class="w-full h-full"
|
||||||
<div class="flex items-center justify-between mt-2.5">
|
:img-props="{ class: 'w-full h-full object-cover transition-transform duration-500 group-hover:scale-103' }"
|
||||||
<span class="text-[10px] px-1.5 py-0.5 rounded font-medium bg-black/5 dark:bg-white/10 tone-muted">
|
show-toolbar-tooltip
|
||||||
{{ formatBytes(item.size) }}
|
fallback-src="/life-assets/placeholder.jpg"
|
||||||
</span>
|
/>
|
||||||
<span class="text-[10px] tone-muted">
|
</template>
|
||||||
{{ formatTime(item.updateTime) }}
|
<template v-else>
|
||||||
</span>
|
<div class="w-full h-full flex flex-col items-center justify-center gap-2 text-(--archive-text)/40 bg-black/5 dark:bg-white/5">
|
||||||
|
<span :class="getFileIcon(item.fileName)" class="text-4xl"></span>
|
||||||
|
<span class="text-[10px] uppercase font-bold tracking-wider opacity-60">
|
||||||
|
{{ getFileExt(item.fileName) }} 文件
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 悬浮操作层 (阻止冒泡防误触) -->
|
||||||
|
<div class="absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center gap-3" @click.stop>
|
||||||
|
<n-tooltip trigger="hover">
|
||||||
|
<template #trigger>
|
||||||
|
<button
|
||||||
|
class="h-9 w-9 rounded-full bg-white text-gray-800 flex items-center justify-center hover:bg-(--archive-accent) hover:text-white active:scale-95 transition-all shadow cursor-pointer border-none"
|
||||||
|
@click="copyUrl(item.url)"
|
||||||
|
>
|
||||||
|
<span class="i-mdi-content-copy text-base"></span>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
复制链接
|
||||||
|
</n-tooltip>
|
||||||
|
|
||||||
|
<n-tooltip trigger="hover">
|
||||||
|
<template #trigger>
|
||||||
|
<button
|
||||||
|
class="h-9 w-9 rounded-full bg-white text-red-600 flex items-center justify-center hover:bg-red-600 hover:text-white active:scale-95 transition-all shadow cursor-pointer border-none"
|
||||||
|
@click="handleDelete(item)"
|
||||||
|
>
|
||||||
|
<span class="i-mdi-trash-can-outline text-base"></span>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
删除文件
|
||||||
|
</n-tooltip>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
<!-- 详细信息区 -->
|
||||||
|
<div class="mt-3 flex flex-col text-left grow">
|
||||||
|
<span
|
||||||
|
class="text-xs font-bold text-(--archive-text) truncate"
|
||||||
|
:title="item.fileName"
|
||||||
|
>
|
||||||
|
{{ item.name }}
|
||||||
|
</span>
|
||||||
|
<div class="flex items-center justify-between mt-2.5">
|
||||||
|
<span class="text-[10px] px-1.5 py-0.5 rounded font-medium bg-black/5 dark:bg-white/10 tone-muted">
|
||||||
|
{{ formatBytes(item.size) }}
|
||||||
|
</span>
|
||||||
|
<span class="text-[10px] tone-muted">
|
||||||
|
{{ formatTime(item.updateTime) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -196,7 +275,7 @@
|
|||||||
<n-pagination
|
<n-pagination
|
||||||
v-model:page="page"
|
v-model:page="page"
|
||||||
v-model:page-size="pageSize"
|
v-model:page-size="pageSize"
|
||||||
:item-count="filteredFiles.length"
|
:item-count="totalItemsCount"
|
||||||
:page-sizes="[10, 20, 30, 40, 50]"
|
:page-sizes="[10, 20, 30, 40, 50]"
|
||||||
show-size-picker
|
show-size-picker
|
||||||
class="archive-pagination"
|
class="archive-pagination"
|
||||||
@@ -224,6 +303,10 @@ const files = ref<FileItem[]>([])
|
|||||||
const searchQuery = ref('')
|
const searchQuery = ref('')
|
||||||
const typeFilter = ref('all')
|
const typeFilter = ref('all')
|
||||||
|
|
||||||
|
// 视图与路径参数
|
||||||
|
const viewMode = ref<'folder' | 'flat'>('folder')
|
||||||
|
const currentDir = ref('')
|
||||||
|
|
||||||
// 分页状态
|
// 分页状态
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
const pageSize = ref(10)
|
const pageSize = ref(10)
|
||||||
@@ -239,7 +322,14 @@ watch([searchQuery, typeFilter, pageSize], () => {
|
|||||||
page.value = 1
|
page.value = 1
|
||||||
})
|
})
|
||||||
|
|
||||||
// 计算属性:当前存储介质的工作空间/桶名标题
|
// 当用户输入搜索内容时,自动切换为“平铺视图”,以方便全局快速检索文件
|
||||||
|
watch(searchQuery, (newVal) => {
|
||||||
|
if (newVal.trim()) {
|
||||||
|
viewMode.value = 'flat'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 计算属性:当前工作空间/桶名标题
|
||||||
const getBucketTitle = computed(() => {
|
const getBucketTitle = computed(() => {
|
||||||
if (!storageInfo.value) return 'uploads'
|
if (!storageInfo.value) return 'uploads'
|
||||||
const info = storageInfo.value
|
const info = storageInfo.value
|
||||||
@@ -248,7 +338,13 @@ const getBucketTitle = computed(() => {
|
|||||||
return 'uploads/ (本地文件夹)'
|
return 'uploads/ (本地文件夹)'
|
||||||
})
|
})
|
||||||
|
|
||||||
// 文件过滤列表
|
// 计算属性:路径面包屑片段
|
||||||
|
const breadcrumbs = computed(() => {
|
||||||
|
if (!currentDir.value) return []
|
||||||
|
return currentDir.value.split('/')
|
||||||
|
})
|
||||||
|
|
||||||
|
// 文件过滤列表 (搜索与类型)
|
||||||
const filteredFiles = computed(() => {
|
const filteredFiles = computed(() => {
|
||||||
let list = files.value
|
let list = files.value
|
||||||
|
|
||||||
@@ -268,11 +364,100 @@ const filteredFiles = computed(() => {
|
|||||||
return list
|
return list
|
||||||
})
|
})
|
||||||
|
|
||||||
// 分页计算后的展示文件列表
|
interface FolderItem {
|
||||||
const paginatedFiles = computed(() => {
|
isDir: true
|
||||||
|
name: string
|
||||||
|
path: string
|
||||||
|
childCount: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FileItemWrap {
|
||||||
|
isDir: false
|
||||||
|
fileName: string
|
||||||
|
name: string
|
||||||
|
url: string
|
||||||
|
size: number
|
||||||
|
updateTime: number
|
||||||
|
storageType: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type DisplayItem = FolderItem | FileItemWrap
|
||||||
|
|
||||||
|
// 计算属性:当前文件夹下的所有子文件夹与文件集合 (虚拟文件树解析)
|
||||||
|
const currentItems = computed<DisplayItem[]>(() => {
|
||||||
|
const list = filteredFiles.value
|
||||||
|
const foldersMap = new Map<string, { path: string; files: any[] }>()
|
||||||
|
const filesList: FileItemWrap[] = []
|
||||||
|
|
||||||
|
const currentPrefix = currentDir.value ? (currentDir.value.endsWith('/') ? currentDir.value : currentDir.value + '/') : ''
|
||||||
|
|
||||||
|
list.forEach(item => {
|
||||||
|
const name = item.fileName
|
||||||
|
if (currentPrefix && !name.startsWith(currentPrefix)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const relative = currentPrefix ? name.substring(currentPrefix.length) : name
|
||||||
|
|
||||||
|
if (relative.includes('/')) {
|
||||||
|
const dirName = relative.split('/')[0]
|
||||||
|
const fullSubDirPath = currentPrefix + dirName
|
||||||
|
|
||||||
|
if (!foldersMap.has(dirName)) {
|
||||||
|
foldersMap.set(dirName, { path: fullSubDirPath, files: [] })
|
||||||
|
}
|
||||||
|
foldersMap.get(dirName)!.files.push(item)
|
||||||
|
} else {
|
||||||
|
filesList.push({
|
||||||
|
isDir: false,
|
||||||
|
fileName: item.fileName,
|
||||||
|
name: relative,
|
||||||
|
url: item.url,
|
||||||
|
size: item.size,
|
||||||
|
updateTime: item.updateTime,
|
||||||
|
storageType: item.storageType
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 转换为展示用文件夹对象列表
|
||||||
|
const displayFolders: FolderItem[] = Array.from(foldersMap.entries()).map(([name, val]) => ({
|
||||||
|
isDir: true,
|
||||||
|
name,
|
||||||
|
path: val.path,
|
||||||
|
childCount: val.files.length
|
||||||
|
}))
|
||||||
|
|
||||||
|
// 文件夹按拼音/字母排序在前,文件保持更新时间倒序在后
|
||||||
|
return [
|
||||||
|
...displayFolders.sort((a, b) => a.name.localeCompare(b.name)),
|
||||||
|
...filesList
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
// 分页切片数据源
|
||||||
|
const paginatedItems = computed(() => {
|
||||||
const start = (page.value - 1) * pageSize.value
|
const start = (page.value - 1) * pageSize.value
|
||||||
const end = start + pageSize.value
|
const end = start + pageSize.value
|
||||||
return filteredFiles.value.slice(start, end)
|
|
||||||
|
if (viewMode.value === 'flat') {
|
||||||
|
return filteredFiles.value.map(item => ({
|
||||||
|
isDir: false as const,
|
||||||
|
fileName: item.fileName,
|
||||||
|
name: getFileNameOnly(item.fileName),
|
||||||
|
url: item.url,
|
||||||
|
size: item.size,
|
||||||
|
updateTime: item.updateTime,
|
||||||
|
storageType: item.storageType
|
||||||
|
})).slice(start, end)
|
||||||
|
} else {
|
||||||
|
return currentItems.value.slice(start, end)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 分页所用总项数
|
||||||
|
const totalItemsCount = computed(() => {
|
||||||
|
return viewMode.value === 'flat' ? filteredFiles.value.length : currentItems.value.length
|
||||||
})
|
})
|
||||||
|
|
||||||
// 总文件占用容量格式化
|
// 总文件占用容量格式化
|
||||||
@@ -281,6 +466,32 @@ const totalSizeFormatted = computed(() => {
|
|||||||
return formatBytes(sumBytes)
|
return formatBytes(sumBytes)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 点击网格卡片的回调
|
||||||
|
const handleItemClick = (item: DisplayItem) => {
|
||||||
|
if (item.isDir) {
|
||||||
|
currentDir.value = item.path
|
||||||
|
page.value = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导航到指定面包屑层级
|
||||||
|
const navigateToBreadcrumb = (index: number) => {
|
||||||
|
const parts = currentDir.value.split('/')
|
||||||
|
currentDir.value = parts.slice(0, index + 1).join('/')
|
||||||
|
page.value = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回上一级文件夹
|
||||||
|
const goBackDir = () => {
|
||||||
|
const parts = currentDir.value.split('/')
|
||||||
|
if (parts.length <= 1) {
|
||||||
|
currentDir.value = ''
|
||||||
|
} else {
|
||||||
|
currentDir.value = parts.slice(0, -1).join('/')
|
||||||
|
}
|
||||||
|
page.value = 1
|
||||||
|
}
|
||||||
|
|
||||||
// 加载后台数据
|
// 加载后台数据
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@@ -318,7 +529,7 @@ const copyUrl = async (url: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除文件操作
|
// 删除文件操作
|
||||||
const handleDelete = (item: FileItem) => {
|
const handleDelete = (item: any) => {
|
||||||
dialog.warning({
|
dialog.warning({
|
||||||
title: '强物理删除确认',
|
title: '强物理删除确认',
|
||||||
content: `您确定要彻底删除文件「${getFileNameOnly(item.fileName)}」吗?该删除行为将在存储中进行物理擦除,不可撤销。已在博客内容中引用该文件的链接将会失效。`,
|
content: `您确定要彻底删除文件「${getFileNameOnly(item.fileName)}」吗?该删除行为将在存储中进行物理擦除,不可撤销。已在博客内容中引用该文件的链接将会失效。`,
|
||||||
@@ -329,7 +540,6 @@ const handleDelete = (item: FileItem) => {
|
|||||||
const response = await deleteFile(item.fileName)
|
const response = await deleteFile(item.fileName)
|
||||||
if (response.data?.code === 200) {
|
if (response.data?.code === 200) {
|
||||||
message.success('文件物理删除成功 🗑️')
|
message.success('文件物理删除成功 🗑️')
|
||||||
// 重新加载数据刷新列表
|
|
||||||
await loadData()
|
await loadData()
|
||||||
} else {
|
} else {
|
||||||
throw new Error(response.data?.msg || '删除失败')
|
throw new Error(response.data?.msg || '删除失败')
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=gallery"
|
action="/api/blogs/upload?type=gallery"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="handleUploadFinish"
|
@finish="handleUploadFinish"
|
||||||
|
|||||||
@@ -101,7 +101,7 @@
|
|||||||
|
|
||||||
<n-upload
|
<n-upload
|
||||||
v-if="letterImagesList.length < 2"
|
v-if="letterImagesList.length < 2"
|
||||||
action="http://localhost:8080/api/blogs/upload?type=letter"
|
action="/api/blogs/upload?type=letter"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="handleUploadFinish"
|
@finish="handleUploadFinish"
|
||||||
|
|||||||
@@ -95,7 +95,7 @@
|
|||||||
|
|
||||||
<div class="grid grid-cols-2 gap-2 mb-6">
|
<div class="grid grid-cols-2 gap-2 mb-6">
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=love"
|
action="/api/blogs/upload?type=love"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="handleAtmosphereUploadFinish"
|
@finish="handleAtmosphereUploadFinish"
|
||||||
|
|||||||
@@ -252,7 +252,7 @@
|
|||||||
<div class="flex gap-2 items-center">
|
<div class="flex gap-2 items-center">
|
||||||
<n-input v-model:value="formModel.reading.coverUrl" placeholder="输入外部路径,或点击上传" class="archive-input flex-1" />
|
<n-input v-model:value="formModel.reading.coverUrl" placeholder="输入外部路径,或点击上传" class="archive-input flex-1" />
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=now"
|
action="/api/blogs/upload?type=now"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="handleUploadFinish"
|
@finish="handleUploadFinish"
|
||||||
@@ -475,7 +475,7 @@
|
|||||||
<div class="flex gap-2 w-full">
|
<div class="flex gap-2 w-full">
|
||||||
<n-input v-model:value="bgm.src" placeholder="例如: /assets/music/mr-lawrence.mp3" class="archive-input font-mono flex-1" />
|
<n-input v-model:value="bgm.src" placeholder="例如: /assets/music/mr-lawrence.mp3" class="archive-input font-mono flex-1" />
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=now"
|
action="/api/blogs/upload?type=now"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="(options: any) => handleAudioUploadFinish(options, bgm)"
|
@finish="(options: any) => handleAudioUploadFinish(options, bgm)"
|
||||||
@@ -529,7 +529,7 @@
|
|||||||
<div class="flex gap-2 w-full">
|
<div class="flex gap-2 w-full">
|
||||||
<n-input v-model:value="noise.src" placeholder="例如: /assets/music/rain.mp3" class="archive-input font-mono flex-1" />
|
<n-input v-model:value="noise.src" placeholder="例如: /assets/music/rain.mp3" class="archive-input font-mono flex-1" />
|
||||||
<n-upload
|
<n-upload
|
||||||
action="http://localhost:8080/api/blogs/upload?type=now"
|
action="/api/blogs/upload?type=now"
|
||||||
:headers="uploadHeaders"
|
:headers="uploadHeaders"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@finish="(options: any) => handleAudioUploadFinish(options, noise)"
|
@finish="(options: any) => handleAudioUploadFinish(options, noise)"
|
||||||
|
|||||||
+15
-2
@@ -1,4 +1,4 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig, loadEnv } from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import UnoCSS from 'unocss/vite'
|
import UnoCSS from 'unocss/vite'
|
||||||
import { fileURLToPath, URL } from 'node:url'
|
import { fileURLToPath, URL } from 'node:url'
|
||||||
@@ -12,7 +12,19 @@ import {
|
|||||||
} from 'unocss'
|
} from 'unocss'
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig(({ mode }) => {
|
||||||
|
const env = loadEnv(mode, process.cwd(), '')
|
||||||
|
const devApiTarget = env.VITE_DEV_API_TARGET || 'http://localhost:8080'
|
||||||
|
|
||||||
|
return {
|
||||||
|
server: {
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: devApiTarget,
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
UnoCSS({
|
UnoCSS({
|
||||||
@@ -127,5 +139,6 @@ export default defineConfig({
|
|||||||
alias: {
|
alias: {
|
||||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user