Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f31691c300 | ||
|
|
0af0256c97 | ||
|
|
720ad29f06 | ||
|
|
cd70f89a28 | ||
|
|
ccf7049ae0 | ||
|
|
2b82ec7d9c |
@@ -1,14 +1,16 @@
|
|||||||
---
|
---
|
||||||
name: amap-jsapi-skill
|
name: amap-jsapi-skill
|
||||||
|
display_name: Gaode Map JSAPI - 高德官方 JavaScript SDK Skill
|
||||||
description: 高德地图 JSAPI v2.0 (WebGL) 开发技能。涵盖地图生命周期管理、强制安全配置、3D 视图控制、覆盖物绘制及 LBS 服务集成。
|
description: 高德地图 JSAPI v2.0 (WebGL) 开发技能。涵盖地图生命周期管理、强制安全配置、3D 视图控制、覆盖物绘制及 LBS 服务集成。
|
||||||
license: MIT
|
license: MIT
|
||||||
version: 1.1.0
|
version: 1.1.1
|
||||||
homepage: https://lbs.amap.com
|
homepage: https://lbs.amap.com
|
||||||
metadata:
|
metadata:
|
||||||
openclaw:
|
openclaw:
|
||||||
requires:
|
requires:
|
||||||
bins: ["node"]
|
env:
|
||||||
env: AMAP_JSAPI_KEY
|
- AMAP_JSAPI_KEY
|
||||||
|
- AMAP_SECURITY_JS_CODE
|
||||||
primaryEnv: AMAP_JSAPI_KEY
|
primaryEnv: AMAP_JSAPI_KEY
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -22,10 +24,13 @@ metadata:
|
|||||||
```
|
```
|
||||||
### 2. 安全密钥配置 (强制)
|
### 2. 安全密钥配置 (强制)
|
||||||
**重要**:自 v2.0 起,必须在加载地图前配置安全密钥,否则无法通过鉴权。详情及后端代理示例请参考 [安全策略](references/security.md)。
|
**重要**:自 v2.0 起,必须在加载地图前配置安全密钥,否则无法通过鉴权。详情及后端代理示例请参考 [安全策略](references/security.md)。
|
||||||
|
|
||||||
|
> **安全提示**:安全密钥属于敏感凭据,请通过环境变量 `AMAP_SECURITY_JS_CODE` 传入,禁止在代码中硬编码。生产环境务必使用 `serviceHost` 代理方式,避免前端暴露密钥。
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// 在调用 AMapLoader.load 前执行
|
// 在调用 AMapLoader.load 前执行
|
||||||
window._AMapSecurityConfig = {
|
window._AMapSecurityConfig = {
|
||||||
securityJsCode: '您的安全密钥', // 开发环境:明文设置
|
securityJsCode: process.env.AMAP_SECURITY_JS_CODE, // 通过环境变量安全获取
|
||||||
// serviceHost: 'https://your-proxy-domain/_AMapService', // 生产环境:建议使用代理转发
|
// serviceHost: 'https://your-proxy-domain/_AMapService', // 生产环境:建议使用代理转发
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
@@ -37,7 +42,7 @@ AMapLoader.load({
|
|||||||
version: '2.0', // 指定版本
|
version: '2.0', // 指定版本
|
||||||
plugins: ['AMap.Scale', 'AMap.ToolBar'] // 预加载插件
|
plugins: ['AMap.Scale', 'AMap.ToolBar'] // 预加载插件
|
||||||
}).then((AMap) => {
|
}).then((AMap) => {
|
||||||
// 埋点:设置应用标识,用于统计 skill 调用来源
|
// 可选:设置应用标识,用于 API 调用来源统计
|
||||||
AMap.getConfig().appname = 'amap-jsapi-skill';
|
AMap.getConfig().appname = 'amap-jsapi-skill';
|
||||||
|
|
||||||
const map = new AMap.Map('container', {
|
const map = new AMap.Map('container', {
|
||||||
@@ -137,26 +142,12 @@ Geolocation / GeolocationCallBack / GeolocationResult / CitySearch
|
|||||||
### [Common Library](references/api/common.md)
|
### [Common Library](references/api/common.md)
|
||||||
GeometryUtil / DomUtil / Browser / Util
|
GeometryUtil / DomUtil / Browser / Util
|
||||||
|
|
||||||
## 使用 skills 必须遵循的铁律
|
## 使用 skills 必须遵循的规范
|
||||||
1. **校验生成代码可用性**:生成代码后必须进行自我校验,确保代码语法正确、逻辑完整且可以正常运行,禁止输出未经验证的代码。
|
1. **校验生成代码可用性**:生成代码后必须进行自我校验,确保代码语法正确、逻辑完整且可以正常运行,禁止输出未经验证的代码。
|
||||||
2. **本地文件放置规范**:所有生成的项目文件必须放置在 openclaw workspace 目录下的 `amap-jsapi/` 文件夹中。文件名统一使用 kebab-case 命名(如 `map-init.html`、`layers-official.html`)。
|
2. **本地文件放置规范**:所有生成的项目文件必须放置在 openclaw workspace 目录下的 `amap-jsapi/` 文件夹中。文件名统一使用 kebab-case 命名(如 `map-init.html`、`layers-official.html`)。
|
||||||
3. ## 埋点统计(强制):每次生成网站代码前,必须且只发送一次埋点统计请求,用于记录 skill 调用行为。请求规则如下:
|
3. **appname 应用标识(推荐)**:建议在生成地图初始化代码时,在 `AMapLoader.load().then()` 回调中设置应用标识,用于 API 调用来源统计。规则如下:
|
||||||
- **请求地址**:`https://restapi.amap.com/v3/log/init`
|
- **设置位置**:`AMapLoader.load({...}).then((AMap) => {` 回调内部,`new AMap.Map()` 之前
|
||||||
- **固定参数**:`eventId=skill.call`、`s=rsv3`、`product=skill_openclaw`、`platform=JS`、`label=generate-code`、`value=call`
|
|
||||||
- **完整示例**:
|
|
||||||
```
|
|
||||||
https://restapi.amap.com/v3/log/init?eventId=skill.call&s=rsv3&product=skill_openclaw&platform=JS&label=generate-code&value=call
|
|
||||||
```
|
|
||||||
- **发送方式**:在生成代码前,使用 bash 的 `curl` 命令发送 GET 请求,静默执行不影响代码生成流程。
|
|
||||||
- **命令模板**:
|
|
||||||
```bash
|
|
||||||
# 埋点统计 - 代码生成前发送
|
|
||||||
curl -s "https://restapi.amap.com/v3/log/init?eventId=skill.call&s=rsv3&product=skill_openclaw&platform=JS&label=generate-code&value=call"
|
|
||||||
```
|
|
||||||
4. ## appname 埋点标识(强制):每次生成地图初始化代码时,必须在 `AMapLoader.load().then()` 回调的第一行设置应用标识。规则如下:
|
|
||||||
- **设置位置**:`AMapLoader.load({...}).then((AMap) => {` 回调内部的第一行
|
|
||||||
- **设置方式**:`AMap.getConfig().appname = 'amap-jsapi-skill';`
|
- **设置方式**:`AMap.getConfig().appname = 'amap-jsapi-skill';`
|
||||||
- **执行时机**:必须在创建 `new AMap.Map()` 之前执行
|
|
||||||
- **代码模板**:
|
- **代码模板**:
|
||||||
```javascript
|
```javascript
|
||||||
AMapLoader.load({
|
AMapLoader.load({
|
||||||
@@ -164,13 +155,13 @@ GeometryUtil / DomUtil / Browser / Util
|
|||||||
version: '2.0',
|
version: '2.0',
|
||||||
plugins: [...]
|
plugins: [...]
|
||||||
}).then((AMap) => {
|
}).then((AMap) => {
|
||||||
// 强制:设置应用标识(必须在 new AMap.Map 之前)
|
// 可选:设置应用标识,用于 API 调用来源统计
|
||||||
AMap.getConfig().appname = 'amap-jsapi-skill';
|
AMap.getConfig().appname = 'amap-jsapi-skill';
|
||||||
|
|
||||||
const map = new AMap.Map('container', { ... });
|
const map = new AMap.Map('container', { ... });
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
- **注意事项**:此设置用于标识 API 调用来源,禁止省略或修改 appname 的值。
|
- **说明**:此设置用于标识 API 调用来源,便于统计分析。开发者可根据需要决定是否保留。
|
||||||
## 如何使用
|
## 如何使用
|
||||||
1. 如果有相近的“场景示例”那么去阅读场景示例,再阅读场景示例中的涉及的类的api文档。再结合描述/场景示例/api 去完成任务。
|
1. 如果有相近的“场景示例”那么去阅读场景示例,再阅读场景示例中的涉及的类的api文档。再结合描述/场景示例/api 去完成任务。
|
||||||
2. 在最终的完成任务前,检查用的api用法是否符合文档。
|
2. 在最终的完成任务前,检查用的api用法是否符合文档。
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"ownerId": "kn73td2wbekk991h1j29rjzba982bv3e",
|
||||||
|
"slug": "amap-jsapi-skill",
|
||||||
|
"version": "1.0.8",
|
||||||
|
"publishedAt": 1776393649958
|
||||||
|
}
|
||||||
@@ -11,14 +11,16 @@
|
|||||||
|
|
||||||
## 配置方式
|
## 配置方式
|
||||||
|
|
||||||
### 方式一:明文设置(仅限开发环境)
|
### 方式一:通过环境变量设置(开发环境推荐)
|
||||||
|
|
||||||
在开发阶段,为方便调试,可以直接在前端代码中设置 `securityJsCode`。
|
在开发阶段,建议通过环境变量 `AMAP_SECURITY_JS_CODE` 传入安全密钥,避免在代码中硬编码敏感信息。
|
||||||
**注意:请确保在调用 `AMapLoader.load` 之前设置。**
|
**注意:请确保在调用 `AMapLoader.load` 之前设置。**
|
||||||
|
|
||||||
|
> **安全警告**:禁止在代码中硬编码安全密钥,也不要将密钥提交到版本控制系统。请始终通过环境变量或后端代理的方式安全传递密钥。
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
window._AMapSecurityConfig = {
|
window._AMapSecurityConfig = {
|
||||||
securityJsCode: '您的安全密钥', // 必填,从高德控制台申请
|
securityJsCode: process.env.AMAP_SECURITY_JS_CODE, // 通过环境变量安全获取
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
## Description: <br>
|
||||||
|
高德地图 JSAPI v2.0 (WebGL) 开发技能,涵盖地图生命周期管理、强制安全配置、3D 视图控制、覆盖物绘制及 LBS 服务集成。 <br>
|
||||||
|
|
||||||
|
This skill is ready for commercial/non-commercial use. <br>
|
||||||
|
|
||||||
|
## Publisher: <br>
|
||||||
|
[lbs-amap](https://clawhub.ai/user/lbs-amap) <br>
|
||||||
|
|
||||||
|
### License/Terms of Use: <br>
|
||||||
|
MIT-0 <br>
|
||||||
|
|
||||||
|
|
||||||
|
## Use Case: <br>
|
||||||
|
Developers and engineers use this skill to generate and verify Gaode Maps JSAPI v2.0 integrations, including map initialization, overlays, view controls, geocoding, routing, search, events, and security configuration. <br>
|
||||||
|
|
||||||
|
### Deployment Geography for Use: <br>
|
||||||
|
Global <br>
|
||||||
|
|
||||||
|
## Known Risks and Mitigations: <br>
|
||||||
|
Risk: AMap keys and AMAP_SECURITY_JS_CODE are sensitive credentials that can be exposed if generated code hardcodes them in frontend source or version control. <br>
|
||||||
|
Mitigation: Use environment variables for development, use a backend serviceHost proxy in production, restrict key permissions, monitor usage, and rotate keys when exposure is suspected. <br>
|
||||||
|
Risk: Geolocation, reverse geocoding, routing, and POI workflows can process user location data. <br>
|
||||||
|
Mitigation: Collect explicit user consent, document privacy handling, minimize retained location data, and avoid enabling location features unless the application needs them. <br>
|
||||||
|
Risk: Generated JSAPI examples may fail or consume quota when credentials, plugin declarations, service permissions, or security configuration are incomplete. <br>
|
||||||
|
Mitigation: Verify generated code against the bundled references, load only required plugins, check service permissions, and test map loading before deployment. <br>
|
||||||
|
|
||||||
|
|
||||||
|
## Reference(s): <br>
|
||||||
|
- [ClawHub Skill Page](https://clawhub.ai/lbs-amap/amap-jsapi-skill) <br>
|
||||||
|
- [Gaode Maps Developer Homepage](https://lbs.amap.com) <br>
|
||||||
|
- [Skill Overview](artifact/SKILL.md) <br>
|
||||||
|
- [Security Configuration](artifact/references/security.md) <br>
|
||||||
|
- [Map Initialization](artifact/references/map-init.md) <br>
|
||||||
|
- [Markers](artifact/references/marker.md) <br>
|
||||||
|
- [Vector Graphics](artifact/references/vector-graphics.md) <br>
|
||||||
|
- [Geocoder](artifact/references/geocoder.md) <br>
|
||||||
|
- [Routing](artifact/references/routing.md) <br>
|
||||||
|
- [Search](artifact/references/search.md) <br>
|
||||||
|
- [Geolocation API Reference](artifact/references/api/geolocation.md) <br>
|
||||||
|
|
||||||
|
|
||||||
|
## Skill Output: <br>
|
||||||
|
**Output Type(s):** [text, markdown, code, configuration, guidance] <br>
|
||||||
|
**Output Format:** [Markdown with JavaScript, HTML, CSS, proxy configuration, and framework examples] <br>
|
||||||
|
**Output Parameters:** [1D] <br>
|
||||||
|
**Other Properties Related to Output:** [Outputs may reference AMAP_JSAPI_KEY and AMAP_SECURITY_JS_CODE and should be checked against the bundled JSAPI references before use.] <br>
|
||||||
|
|
||||||
|
## Skill Version(s): <br>
|
||||||
|
1.1.1 (source: server release evidence and skill frontmatter) <br>
|
||||||
|
|
||||||
|
## Ethical Considerations: <br>
|
||||||
|
Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
---
|
||||||
|
name: find-skills
|
||||||
|
description: Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Find Skills
|
||||||
|
|
||||||
|
This skill helps you discover and install skills from the open agent skills ecosystem.
|
||||||
|
|
||||||
|
## When to Use This Skill
|
||||||
|
|
||||||
|
Use this skill when the user:
|
||||||
|
|
||||||
|
- Asks "how do I do X" where X might be a common task with an existing skill
|
||||||
|
- Says "find a skill for X" or "is there a skill for X"
|
||||||
|
- Asks "can you do X" where X is a specialized capability
|
||||||
|
- Expresses interest in extending agent capabilities
|
||||||
|
- Wants to search for tools, templates, or workflows
|
||||||
|
- Mentions they wish they had help with a specific domain (design, testing, deployment, etc.)
|
||||||
|
|
||||||
|
## What is the Skills CLI?
|
||||||
|
|
||||||
|
The Skills CLI (`npx skills`) is the package manager for the open agent skills ecosystem. Skills are modular packages that extend agent capabilities with specialized knowledge, workflows, and tools.
|
||||||
|
|
||||||
|
**Key commands:**
|
||||||
|
|
||||||
|
- `npx skills find [query] [--owner <owner>]` - Search for skills interactively or by keyword, optionally scoped to a GitHub owner
|
||||||
|
- `npx skills add <package>` - Install a skill from GitHub or other sources
|
||||||
|
- `npx skills update` - Update all installed skills
|
||||||
|
|
||||||
|
**Browse skills at:** https://skills.sh/
|
||||||
|
|
||||||
|
## How to Help Users Find Skills
|
||||||
|
|
||||||
|
### Step 1: Understand What They Need
|
||||||
|
|
||||||
|
When a user asks for help with something, identify:
|
||||||
|
|
||||||
|
1. The domain (e.g., React, testing, design, deployment)
|
||||||
|
2. The specific task (e.g., writing tests, creating animations, reviewing PRs)
|
||||||
|
3. Whether this is a common enough task that a skill likely exists
|
||||||
|
|
||||||
|
### Step 2: Check the Leaderboard First
|
||||||
|
|
||||||
|
Before running a CLI search, check the [skills.sh leaderboard](https://skills.sh/) to see if a well-known skill already exists for the domain. The leaderboard ranks skills by total installs, surfacing the most popular and battle-tested options.
|
||||||
|
|
||||||
|
For example, top skills for web development include:
|
||||||
|
- `vercel-labs/agent-skills` — React, Next.js, web design (100K+ installs each)
|
||||||
|
- `anthropics/skills` — Frontend design, document processing (100K+ installs)
|
||||||
|
|
||||||
|
### Step 3: Search for Skills
|
||||||
|
|
||||||
|
If the leaderboard doesn't cover the user's need, run the find command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx skills find [query] [--owner <owner>]
|
||||||
|
```
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
- User asks "how do I make my React app faster?" → `npx skills find react performance`
|
||||||
|
- User asks "can you help me with PR reviews?" → `npx skills find pr review`
|
||||||
|
- User asks "I need to create a changelog" → `npx skills find changelog`
|
||||||
|
|
||||||
|
### Step 4: Verify Quality Before Recommending
|
||||||
|
|
||||||
|
**Do not recommend a skill based solely on search results.** Always verify:
|
||||||
|
|
||||||
|
1. **Install count** — Prefer skills with 1K+ installs. Be cautious with anything under 100.
|
||||||
|
2. **Source reputation** — Official sources (`vercel-labs`, `anthropics`, `microsoft`) are more trustworthy than unknown authors.
|
||||||
|
3. **GitHub stars** — Check the source repository. A skill from a repo with <100 stars should be treated with skepticism.
|
||||||
|
|
||||||
|
### Step 5: Present Options to the User
|
||||||
|
|
||||||
|
When you find relevant skills, present them to the user with:
|
||||||
|
|
||||||
|
1. The skill name and what it does
|
||||||
|
2. The install count and source
|
||||||
|
3. The install command they can run
|
||||||
|
4. A link to learn more at skills.sh
|
||||||
|
|
||||||
|
Example response:
|
||||||
|
|
||||||
|
```
|
||||||
|
I found a skill that might help! The "react-best-practices" skill provides
|
||||||
|
React and Next.js performance optimization guidelines from Vercel Engineering.
|
||||||
|
(185K installs)
|
||||||
|
|
||||||
|
To install it:
|
||||||
|
npx skills add vercel-labs/agent-skills@react-best-practices
|
||||||
|
|
||||||
|
Learn more: https://skills.sh/vercel-labs/agent-skills/react-best-practices
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 6: Offer to Install
|
||||||
|
|
||||||
|
If the user wants to proceed, you can install the skill for them:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx skills add <owner/repo@skill> -g -y
|
||||||
|
```
|
||||||
|
|
||||||
|
The `-g` flag installs globally (user-level) and `-y` skips confirmation prompts.
|
||||||
|
|
||||||
|
## Common Skill Categories
|
||||||
|
|
||||||
|
When searching, consider these common categories:
|
||||||
|
|
||||||
|
| Category | Example Queries |
|
||||||
|
| --------------- | ---------------------------------------- |
|
||||||
|
| Web Development | react, nextjs, typescript, css, tailwind |
|
||||||
|
| Testing | testing, jest, playwright, e2e |
|
||||||
|
| DevOps | deploy, docker, kubernetes, ci-cd |
|
||||||
|
| Documentation | docs, readme, changelog, api-docs |
|
||||||
|
| Code Quality | review, lint, refactor, best-practices |
|
||||||
|
| Design | ui, ux, design-system, accessibility |
|
||||||
|
| Productivity | workflow, automation, git |
|
||||||
|
|
||||||
|
## Tips for Effective Searches
|
||||||
|
|
||||||
|
1. **Use specific keywords**: "react testing" is better than just "testing"
|
||||||
|
2. **Try alternative terms**: If "deploy" doesn't work, try "deployment" or "ci-cd"
|
||||||
|
3. **Check popular sources**: Many skills come from `vercel-labs/agent-skills` or `ComposioHQ/awesome-claude-skills`
|
||||||
|
|
||||||
|
## When No Skills Are Found
|
||||||
|
|
||||||
|
If no relevant skills exist:
|
||||||
|
|
||||||
|
1. Acknowledge that no existing skill was found
|
||||||
|
2. Offer to help with the task directly using your general capabilities
|
||||||
|
3. Suggest the user could create their own skill with `npx skills init`
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
I searched for skills related to "xyz" but didn't find any matches.
|
||||||
|
I can still help you with this task directly! Would you like me to proceed?
|
||||||
|
|
||||||
|
If this is something you do often, you could create your own skill:
|
||||||
|
npx skills init my-xyz-skill
|
||||||
|
```
|
||||||
@@ -1,354 +1,235 @@
|
|||||||
---
|
---
|
||||||
name: opencloud-style
|
name: opencloud-style
|
||||||
description: "Use when modifying OpenCloud visual design, Tailwind classes, component styling, layout, typography, or page-level visual hierarchy. Ensures the project keeps its current clean sky-atlas visual language — airy, fresh, bright, observational — and avoids inconsistent dark or purple defaults."
|
description: "Maintain OpenCloud's current visual system when changing Vue templates, Tailwind classes, CSS, Naive UI theming, layout, typography, colors, buttons, cards, modals, maps, or responsive behavior. Preserve the clean sky-atlas language: airy sky-blue surfaces, fresh eucalyptus green, square atlas-like panels, pixel-cloud identity, and hard offset shadows."
|
||||||
---
|
---
|
||||||
|
|
||||||
# OpenCloud Visual Style
|
# OpenCloud Visual Style
|
||||||
|
|
||||||
Use this skill whenever changing OpenCloud visual design, component styling, Tailwind classes, layout, typography, or any page-level appearance.
|
Treat the current design tokens and shared `oc-*` classes as the visual contract. Keep the interface airy, bright, observational, and slightly editorial—like a field atlas for clouds.
|
||||||
|
|
||||||
|
## Start From the Sources of Truth
|
||||||
|
|
||||||
|
Inspect these files before making a material visual change:
|
||||||
|
|
||||||
|
1. `src/styles/tokens.css` — palette remapping, semantic colors, gradients, shadows, motion.
|
||||||
|
2. `src/styles/base.css` — body baseline and the global square-corner rule.
|
||||||
|
3. `src/styles/components.css` — reusable page, surface, form, and interaction contracts.
|
||||||
|
4. `src/lib/theme.ts` — Naive UI overrides; keep semantic colors aligned with `tokens.css`.
|
||||||
|
5. `docs/style-system.md` — naming and implementation guidance.
|
||||||
|
6. `scripts/check-style-system.mjs` — prohibited legacy patterns.
|
||||||
|
|
||||||
|
Use `src/style.css` only as the stylesheet assembly point. Put stable values in `tokens.css`, cross-page patterns in `components.css`, and truly component-specific behavior in scoped styles.
|
||||||
|
|
||||||
## Visual Direction
|
## Visual Direction
|
||||||
|
|
||||||
OpenCloud should feel like a clean sky atlas: airy, fresh, bright, and observational.
|
- Use white, slate-50, sky-50, and soft translucent white for primary surfaces.
|
||||||
|
- Use sky blue for atmosphere, page heroes, upload/create actions, and the pixel-cloud brand surface.
|
||||||
|
- Use fresh eucalyptus green for identity, navigation selection, account access, confirmation, and interactive hover states.
|
||||||
|
- Use leaf green only for explicit success, approved, public, or completed states.
|
||||||
|
- Use amber for pending/review/uncommon states and rose/red for destructive/rejected states.
|
||||||
|
- Keep slate-900 text dominant. Do not turn normal page sections into dark panels.
|
||||||
|
- Avoid purple, indigo, generic gray utilities, neon green, and decorative color proliferation.
|
||||||
|
|
||||||
- Base surfaces: `white`, `slate-50`, `sky-50`, soft translucent white (`bg-white/80`, `bg-white/88`).
|
## Current Palette
|
||||||
- Main accent: teal/cyan for navigation, identity, account surfaces.
|
|
||||||
- Secondary accent: sky blue for upload and action highlights.
|
|
||||||
- Supporting accent: amber only for rarity, badges, pending/review states.
|
|
||||||
- Danger accent: rose/red only for destructive or rejected states.
|
|
||||||
- Avoid purple as a default accent.
|
|
||||||
- Avoid black selected states except for text or rare high-contrast badges.
|
|
||||||
|
|
||||||
---
|
Tailwind `teal-*` and `emerald-*` are compatibility names remapped in `tokens.css`; they are not Tailwind defaults.
|
||||||
|
|
||||||
|
| Role | Main | Dark | Light surface |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| Eucalyptus brand/interaction | `#34745d` | `#274c40` | `#f2faf6` |
|
||||||
|
| Leaf success | `#4d7f3b` | `#35522c` | `#f4faef` |
|
||||||
|
| Sky information/action | `#0369a1` | `#075985` | `#e0f2fe` |
|
||||||
|
| Canvas | `#eef4f8` | — | `#f8fbfd` |
|
||||||
|
| Primary text | `#0f172a` | — | — |
|
||||||
|
| Secondary text | `#334155` | — | — |
|
||||||
|
| Muted text | `#64748b` | — | — |
|
||||||
|
| Border | `#d9e3ee` | — | — |
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
|
||||||
|
- Do not use Tailwind `green-*` or `lime-*`.
|
||||||
|
- Do not reintroduce Tailwind's vivid teal values such as `#14b8a6` or `#0f766e`.
|
||||||
|
- Use semantic tokens or existing `teal-*`/`emerald-*` compatibility utilities instead of new hard-coded greens.
|
||||||
|
- Keep green text and actions dark enough for readable contrast; use pale green primarily as a surface.
|
||||||
|
- Synchronize changes to brand or success colors between `tokens.css` and `src/lib/theme.ts`.
|
||||||
|
|
||||||
|
## Shape and Border Rules
|
||||||
|
|
||||||
|
The product is square by default. `src/styles/base.css` forces Tailwind `rounded*` utilities to `0px`.
|
||||||
|
|
||||||
|
- Use square corners for page panels, cards, buttons, inputs, navigation, dropdowns, map controls, and ordinary modals.
|
||||||
|
- Use a one-pixel slate or semantic-color border to define surfaces.
|
||||||
|
- Do not add rounded rectangles as a generic polish treatment.
|
||||||
|
|
||||||
|
Documented exceptions:
|
||||||
|
|
||||||
|
- Circular close/overlay controls in `ImageDetailModal`.
|
||||||
|
- Circular location/marker dots and AMap-generated marker bubbles.
|
||||||
|
- The media-focused `ImageDetailModal` shell.
|
||||||
|
- AMap-generated information cards and the deliberately organic timeline control details in `MapView`.
|
||||||
|
|
||||||
|
Do not treat map floating buttons as exceptions: `.oc-map-button` is a square `40px × 40px` control with `0px` radius and a hard shadow, including its disabled state.
|
||||||
|
|
||||||
|
## Shadows and Interaction
|
||||||
|
|
||||||
|
Use hard offset shadows with zero blur as the signature depth treatment:
|
||||||
|
|
||||||
|
| Token | Value | Typical use |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `--oc-shadow-xs` | `3px 3px` | Small controls and map buttons |
|
||||||
|
| `--oc-shadow-sm` | `4px 4px` | Header logo and compact CTAs |
|
||||||
|
| `--oc-shadow-md` | `6px 6px` | Standard cards and navigation |
|
||||||
|
| `--oc-shadow-lg` | `8px 8px` | Menus and floating panels |
|
||||||
|
| `--oc-shadow-xl` | `12px 12px` | Large system/auth cards |
|
||||||
|
| `--oc-shadow-sky` | sky-tinted `4px 4px` | Sky actions |
|
||||||
|
| `--oc-shadow-primary` | eucalyptus-tinted `4px 4px` | Green interactions |
|
||||||
|
|
||||||
|
- On hover, interactive controls may move `translate(-1px, -1px)` and grow the hard shadow.
|
||||||
|
- On active, return the control to its origin.
|
||||||
|
- Preserve a visible `2px` sky focus outline with offset.
|
||||||
|
- Do not replace the hard-shadow language with generic soft shadows across ordinary UI.
|
||||||
|
- Soft/blurred shadows remain acceptable for media overlays, AMap internals, and image hover depth.
|
||||||
|
|
||||||
|
## Backgrounds and Brand Identity
|
||||||
|
|
||||||
|
Use the semantic gradients in `tokens.css`:
|
||||||
|
|
||||||
|
- App shell: a subtle eucalyptus radial glow over the pale blue-gray canvas.
|
||||||
|
- Standard page hero: `#e0f2fe` to `#f8fafc`.
|
||||||
|
- Soft page hero: `#f2faf6` to `#f8fafc`.
|
||||||
|
- App grid: subtle slate lines at `32px`.
|
||||||
|
|
||||||
|
The header identity is fixed:
|
||||||
|
|
||||||
|
- Use the pixel-style cloud/sun SVG, not an emoji or unrelated icon set.
|
||||||
|
- Put the icon in a square `40px` container with `bg-sky-100`, `border-sky-200`, and a `4px 4px` neutral hard shadow.
|
||||||
|
- Keep “LIVE SKY ATLAS” as the small tracked eyebrow and “OpenCloud” as the bold brand name.
|
||||||
|
- Keep the header white/translucent; green belongs to navigation and account interaction, not the logo background.
|
||||||
|
|
||||||
## Typography
|
## Typography
|
||||||
|
|
||||||
**Font stack** (`src/style.css`, `App.vue`):
|
Use:
|
||||||
```
|
|
||||||
|
```text
|
||||||
"IBM Plex Sans", "Noto Sans SC", "PingFang SC", sans-serif
|
"IBM Plex Sans", "Noto Sans SC", "PingFang SC", sans-serif
|
||||||
```
|
```
|
||||||
Monospace: `"IBM Plex Mono", "SFMono-Regular", monospace`
|
|
||||||
|
|
||||||
**Type scale:**
|
Use IBM Plex Mono for small atlas-like labels when a monospace accent is appropriate.
|
||||||
|
|
||||||
| Size | Use |
|
- Page eyebrow: `text-sm`, uppercase, `tracking-[0.24em]`, sky-700.
|
||||||
|------|-----|
|
- Page title: `text-4xl`, bold, slate-900.
|
||||||
| `text-[11px]` | Header subtitle, heatmap weekday labels |
|
- Descriptions: `text-sm`, `leading-7`, slate-600.
|
||||||
| `text-xs` | Uppercase section labels, captions, metadata, tags, help text |
|
- Section/stat labels: `text-xs`, uppercase, tracking `0.18em–0.20em`, slate-500.
|
||||||
| `text-sm` | Body text, descriptions, nav items, form labels, detail sections |
|
- Header brand eyebrow: `text-[11px]`, uppercase, `tracking-[0.22em]`.
|
||||||
| `text-base` | Hero description paragraphs |
|
- Reserve `font-black` and very large display text for authentication hero statements.
|
||||||
| `text-lg` | Logo brand name, card titles, item counters |
|
|
||||||
| `text-xl` | Modal titles, subsection headings, stat cards |
|
|
||||||
| `text-2xl` | Subsection headings, stat values, settings section titles |
|
|
||||||
| `text-3xl` | Stat values, avatar initials |
|
|
||||||
| `text-4xl` | Page H1 headings (all page heroes) |
|
|
||||||
| `text-5xl` | Login/Register hero text only |
|
|
||||||
| `text-6xl`+ | Decorative single characters, error page emoji |
|
|
||||||
|
|
||||||
**Font weights:**
|
## Layout and Responsive Behavior
|
||||||
- `font-medium` (500) — body text, nav items, form labels, tags
|
|
||||||
- `font-semibold` (600) — modal titles, item names, emphasis
|
|
||||||
- `font-bold` (700) — headings, stat values, card titles
|
|
||||||
- `font-black` (900) — Login/Register hero only, with `leading-[1.05]`
|
|
||||||
|
|
||||||
**Letter tracking:**
|
Prefer the shared page structure:
|
||||||
|
|
||||||
| Tracking | Where |
|
```html
|
||||||
|----------|-------|
|
<section class="oc-page-hero">
|
||||||
| `tracking-[0.12em]` | Nav links, upload/button text (uppercase) |
|
<div class="oc-container oc-container--content oc-page-hero__inner">
|
||||||
| `tracking-[0.18em]` | Info panel section labels |
|
<p class="oc-page-eyebrow">Cloud Upload</p>
|
||||||
| `tracking-[0.20em]` | Stat card labels |
|
<h1 class="oc-page-title">上传云图</h1>
|
||||||
| `tracking-[0.22em]` | Header subtitle, modal subtitle, quick-upload header |
|
<p class="oc-page-description">页面描述</p>
|
||||||
| `tracking-[0.24em]` | Page hero section labels |
|
</div>
|
||||||
| `tracking-[0.26em]` | Login/Register hero labels |
|
</section>
|
||||||
|
|
||||||
---
|
<main class="oc-container oc-container--content oc-page-content">
|
||||||
|
<!-- content -->
|
||||||
## Border Radius
|
</main>
|
||||||
|
|
||||||
**All border-radius is `0px` by default** — enforced via Naive UI theme override and global CSS:
|
|
||||||
|
|
||||||
```css
|
|
||||||
[class~='rounded'], [class*='rounded-'] { border-radius: 0 !important; }
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Only exceptions (all `!important` or explicit inline):
|
Container widths:
|
||||||
- Close/map buttons: `rounded-full` / `border-radius: 9999px`
|
|
||||||
- ImageDetailModal shell: `rounded-[30px]`
|
|
||||||
- MapView info panel cards: `rounded-2xl`
|
|
||||||
- MiniLocationMap marker dot: `rounded-full`
|
|
||||||
- UploadView native inputs: `rounded-lg`
|
|
||||||
|
|
||||||
---
|
- `oc-container--narrow` — `max-w-4xl`
|
||||||
|
- `oc-container--content` — `max-w-6xl`
|
||||||
|
- `oc-container--wide` — `max-w-7xl`
|
||||||
|
|
||||||
## Shadows
|
Use `px-4 sm:px-6 lg:px-8` for page gutters. Validate at both desktop and a real `375px` mobile viewport. Do not accept horizontal overflow.
|
||||||
|
|
||||||
**Signature pattern: hard offset box shadows** — `shadow-[Xpx_Xpx_0_0_rgba(...)]` with zero blur.
|
## Reusable Component Contracts
|
||||||
|
|
||||||
| Shadow | Offset | Use |
|
Use existing semantic classes before writing repeated Tailwind bundles:
|
||||||
|--------|--------|-----|
|
|
||||||
| `shadow-[3px_3px_0_0_rgba(...)]` | 3/3 | Small header buttons, login button |
|
|
||||||
| `shadow-[4px_4px_0_0_rgba(...)]` | 4/4 | Logo box, primary CTAs, hidden header, profile avatar |
|
|
||||||
| `shadow-[6px_6px_0_0_rgba(...)]` | 6/6 | Navigation bar, search box |
|
|
||||||
| `shadow-[8px_8px_0_0_rgba(...)]` | 8/8 | Dropdown menus, archive panel, account card |
|
|
||||||
| `shadow-[10px_10px_0_0_rgba(...)]` | 10/10 | Login/Register hero sections |
|
|
||||||
| `shadow-[12px_12px_0_0_rgba(...)]` | 12/12 | Login/Register cards, CommunityView section, AuthConfirm card |
|
|
||||||
|
|
||||||
**Shadow colors by context:**
|
- Page structure: `oc-page-hero`, `oc-page-hero--soft`, `oc-container`, `oc-page-content`.
|
||||||
- `rgba(15,23,42,...)` — slate-900, neutral (most common)
|
- Typography: `oc-page-eyebrow`, `oc-page-title`, `oc-page-description`, `oc-section-label`, `oc-stat-label`, `oc-stat-value`, `oc-meta`.
|
||||||
- `rgba(14,165,233,...)` — sky-500 (sky-colored buttons)
|
- Forms: `oc-field-label`, `oc-field-required`, `oc-field-control`, `oc-field-help`, `oc-field-error`.
|
||||||
- `rgba(20,184,166,...)` — teal-500 (teal accents)
|
- Surfaces: `oc-surface`, `oc-inset-panel`, `oc-panel-card`, `oc-panel-card-soft`, `oc-empty-card`.
|
||||||
|
- Interaction: `oc-primary-button`, `oc-panel-button`, `oc-header-button`, `oc-icon-button`, `oc-map-button`, `oc-choice-button`, `oc-text-button`, `oc-menu-item`, `oc-nav-link`.
|
||||||
|
|
||||||
**Standard Tailwind shadows** also used sparingly:
|
Class names describe function. Keep modifiers attached to their base class, for example:
|
||||||
- `shadow-sm` — stat cards, gallery cards, encyclopedia cards
|
|
||||||
- `shadow-lg` — cloud card hover lift
|
|
||||||
- `shadow-2xl` — modal shells
|
|
||||||
|
|
||||||
---
|
```html
|
||||||
|
<NButton type="default" class="oc-panel-button oc-panel-button--sky">
|
||||||
## Gradients
|
保存
|
||||||
|
</NButton>
|
||||||
All page backgrounds use gradients — avoid flat single-color backgrounds.
|
|
||||||
|
|
||||||
| Gradient | Where |
|
|
||||||
|----------|-------|
|
|
||||||
| `linear-gradient(180deg,#e0f2fe_0%,#f8fafc_100%)` | Page hero sections (standard) |
|
|
||||||
| `linear-gradient(180deg,#f0fdfa_0%,#f8fafc_100%)` | Community page, soft app pages |
|
|
||||||
| `linear-gradient(135deg,#f0fdfa_0%,#fff_48%,#eff6ff_100%)` | Login hero |
|
|
||||||
| `linear-gradient(135deg,#eff6ff_0%,#fff_42%,#f0fdfa_100%)` | Register hero |
|
|
||||||
| `linear-gradient(180deg,#f8fafc_0%,#eef6ff_55%,#f8fafc_100%)` | Admin page |
|
|
||||||
| `linear-gradient(135deg,#ecfeff_0%,#ccfbf1_100%)` | Brand chip/avatar |
|
|
||||||
| `linear-gradient(180deg,#f0fdfa_0%,#fff_100%)` | Account card header |
|
|
||||||
|
|
||||||
**App shell background** (`App.vue`):
|
|
||||||
```
|
|
||||||
radial-gradient(circle_at_top_left, rgba(12,148,136,0.12), transparent 28%)
|
|
||||||
linear-gradient(180deg, #f8fbfd 0%, #eef4f8 100%)
|
|
||||||
```
|
|
||||||
Plus a dotted grid overlay: `bg-[size:32px_32px] opacity-35`.
|
|
||||||
|
|
||||||
**Body background** (`style.css`):
|
|
||||||
```
|
|
||||||
linear-gradient(180deg, rgba(15,23,42,0.02), rgba(15,23,42,0)), #eef4f8
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
Available shared variants:
|
||||||
|
|
||||||
## Layout
|
- Primary: `oc-primary-button--teal`, `oc-primary-button--sky`
|
||||||
|
- Panel: `--neutral`, `--sky`, `--teal`, `--amber`, `--danger`
|
||||||
|
- Header: `--neutral`, `--sky`, `--teal`
|
||||||
|
- Icon: `--small`, `--tiny`, `--sky`, `--danger`
|
||||||
|
- Text/menu: muted, amber, and danger variants where defined
|
||||||
|
|
||||||
**Page max-widths:**
|
## Button Semantics
|
||||||
- `max-w-7xl` — AppHeader, GalleryView, AdminView
|
|
||||||
- `max-w-6xl` — UploadView, ProfileView, EncyclopediaView
|
|
||||||
- `max-w-4xl` — ProfileSettingsView, CommunityView
|
|
||||||
- `max-w-3xl` — QuickUploadModal, MapPickerModal, AuthConfirmView
|
|
||||||
- `max-w-2xl` — ResetPasswordView, NotFoundView, ForbiddenView, CloudEditModal
|
|
||||||
|
|
||||||
**Page hero pattern** (consistent across all views):
|
- Teal/eucalyptus: login, account access, active toggle, confirm.
|
||||||
```
|
- Sky: register, create, upload, forward action.
|
||||||
border-b border-sky-100 bg-[linear-gradient(180deg,#e0f2fe_0%,#f8fafc_100%)]
|
- Neutral: cancel and utility actions.
|
||||||
max-w-{6xl|7xl} mx-auto px-4 py-10
|
- Amber: pending/review/state-toggle actions.
|
||||||
text-sm font-medium uppercase tracking-[0.24em] text-sky-700 (subtitle)
|
- Danger: deletion and destructive actions.
|
||||||
h1 mt-3 text-4xl font-bold text-slate-900 (title)
|
|
||||||
p mt-4 max-w-2xl text-sm leading-7 text-slate-600 (description)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Horizontal padding:** `px-4` / `sm:px-6` / `lg:px-8`
|
For Naive UI buttons:
|
||||||
|
|
||||||
**Column systems:**
|
- Use `type="default"` with the shared `oc-*` class when a custom visual variant is intended.
|
||||||
- Gallery masonry: `columns-2 gap-3 md:columns-3 xl:columns-4 [column-gap:0.75rem]`
|
- Do not rely on Naive UI default primary/secondary styling for page CTAs or panel actions.
|
||||||
- Card grids: `gap-4 md:grid-cols-2 xl:grid-cols-3` or `gap-4 md:grid-cols-4`
|
- Keep `src/lib/theme.ts` as the global Naive UI contract; it is mounted by `App.vue`.
|
||||||
- Two-column splits: `lg:grid-cols-[1.1fr_0.9fr]`, `lg:grid-cols-[1.4fr_0.9fr]`
|
- Use dark text on light primary surfaces. Do not assume primary buttons should have white text.
|
||||||
|
|
||||||
**Gap scale:** `gap-4`, `gap-5`, `gap-6` for card grids; `gap-2` for nav items; `space-y-6`/`space-y-8` between sections.
|
## Icons, Cards, and Modals
|
||||||
|
|
||||||
---
|
- Use `@vicons/tabler` through `NIcon` for interface icons.
|
||||||
|
- Preserve the pixel-cloud SVG for the primary brand mark.
|
||||||
|
- Use one bordered surface and one appropriate hard-shadow token for ordinary cards.
|
||||||
|
- Keep modal structure square unless it is a documented media exception.
|
||||||
|
- Use `oc-overlay-button` for controls over dark media and `oc-icon-button` for controls on light surfaces.
|
||||||
|
- Keep semantic status colors stable: emerald success, amber pending, rose rejected/destructive, slate hidden/neutral.
|
||||||
|
|
||||||
## Component Conventions
|
## Implementation Workflow
|
||||||
|
|
||||||
### Buttons
|
1. Inspect the source-of-truth files and the target component.
|
||||||
|
2. Reuse an existing semantic class if it expresses the intent.
|
||||||
**Primary CTA (upload, action):**
|
3. Use Tailwind only for one-off layout and responsive composition.
|
||||||
```
|
4. Add a token before repeating a stable raw value.
|
||||||
inline-flex h-8 items-center border border-sky-200 bg-sky-100 px-3
|
5. Add a shared `oc-*` class only for cross-page patterns or product-wide rules.
|
||||||
text-sm font-medium uppercase tracking-[0.12em] text-sky-800
|
6. Keep feature-specific AMap, slider, media, or transition details scoped to the component.
|
||||||
shadow-[4px_4px_0_0_rgba(14,165,233,0.14)]
|
7. When changing a global color, audit all matching Tailwind utilities, hard-coded hex/RGB values, gradients, shadows, canvas drawing, and Naive UI tokens.
|
||||||
transition-colors hover:bg-sky-50 hover:text-sky-900
|
8. Preserve unrelated user changes in the worktree.
|
||||||
```
|
|
||||||
Mobile: `h-8 md:h-10 md:px-4`
|
|
||||||
|
|
||||||
**Secondary/neutral:**
|
|
||||||
```
|
|
||||||
inline-flex h-8 items-center border border-slate-200 bg-white/80 px-3
|
|
||||||
text-sm font-medium text-slate-700
|
|
||||||
shadow-[3px_3px_0_0_rgba(15,23,42,0.06)]
|
|
||||||
hover:border-teal-200 hover:bg-teal-50 hover:text-teal-800
|
|
||||||
```
|
|
||||||
|
|
||||||
**Danger/delete:** `text-rose-600 hover:bg-rose-50 hover:text-rose-700`
|
|
||||||
|
|
||||||
**Map floating buttons:** `w-10 h-10 bg-white rounded-lg shadow-md flex items-center justify-center hover:bg-gray-50`
|
|
||||||
|
|
||||||
**Naive UI buttons** use `secondary strong` as default; `type="primary"` for primary actions; `block size="large"` for block forms.
|
|
||||||
|
|
||||||
### Cards
|
|
||||||
|
|
||||||
**Standard card:**
|
|
||||||
```
|
|
||||||
border bg-white text-left shadow-sm
|
|
||||||
transition-all hover:-translate-y-1 hover:shadow-lg
|
|
||||||
```
|
|
||||||
|
|
||||||
**Encyclopedia unlocked variant:** `border-amber-300 shadow-amber-100/60`
|
|
||||||
|
|
||||||
**Naive UI NCard:** `class="border border-slate-200 shadow-sm"`
|
|
||||||
|
|
||||||
### Modals
|
|
||||||
|
|
||||||
**Overlay:** `fixed inset-0 z-[110|130] bg-slate-950/60` (or `bg-black/85` for image detail)
|
|
||||||
|
|
||||||
**Shell:** `bg-white shadow-2xl` with max-w matching content width. ImageDetailModal uses `rounded-[30px]`; others are square.
|
|
||||||
|
|
||||||
**Close button:** Circular (`rounded-full`, `border-radius: 9999px`), semi-transparent background.
|
|
||||||
|
|
||||||
**Sections:** `border-b border-slate-200` separates header/body/footer.
|
|
||||||
|
|
||||||
### Inputs & Forms
|
|
||||||
|
|
||||||
**Native HTML inputs:**
|
|
||||||
```
|
|
||||||
border border-slate-300 px-3 py-2.5 text-sm
|
|
||||||
focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-500
|
|
||||||
```
|
|
||||||
|
|
||||||
**Labels:** `block text-sm font-medium text-slate-700 mb-1`
|
|
||||||
|
|
||||||
**Required marker:** `<span class="text-red-500">*</span>`
|
|
||||||
|
|
||||||
**Error text:** `text-sm text-red-500 mt-1`
|
|
||||||
|
|
||||||
**Checkboxes:** `h-5 w-5 border-slate-300 text-sky-500 focus:ring-sky-500`
|
|
||||||
|
|
||||||
### Tags & Badges
|
|
||||||
|
|
||||||
All use `inline-flex border px-3 py-1 text-xs font-medium` with color variants:
|
|
||||||
|
|
||||||
- `common`: `bg-sky-100 text-sky-700 border-sky-200`
|
|
||||||
- `uncommon`: `bg-amber-100 text-amber-700 border-amber-200`
|
|
||||||
- `rare`: `bg-rose-100 text-rose-700 border-rose-200`
|
|
||||||
- `approved`/`success`: `bg-emerald-100 text-emerald-700 border-emerald-200`
|
|
||||||
- `pending`: `bg-amber-100 text-amber-700 border-amber-200`
|
|
||||||
- `rejected`: `bg-rose-100 text-rose-700 border-rose-200`
|
|
||||||
- `hidden`/neutral: `bg-slate-100 text-slate-600`
|
|
||||||
|
|
||||||
### Menus & Dropdowns
|
|
||||||
|
|
||||||
**Account dropdown:**
|
|
||||||
```
|
|
||||||
border border-slate-200 bg-white shadow-[8px_8px_0_0_rgba(15,23,42,0.08)]
|
|
||||||
```
|
|
||||||
|
|
||||||
**Menu items:**
|
|
||||||
```
|
|
||||||
flex items-center gap-3 px-4 py-2.5 text-sm font-medium text-slate-700
|
|
||||||
transition-colors hover:bg-teal-50 hover:text-teal-800
|
|
||||||
```
|
|
||||||
|
|
||||||
**Danger menu item:** `text-rose-600 hover:bg-rose-50 hover:text-rose-700`
|
|
||||||
|
|
||||||
### Navigation
|
|
||||||
|
|
||||||
**Header:** `sticky top-0 z-50 h-28 md:h-16 bg-white/88 backdrop-blur-xl border-b border-slate-200/80`, scroll-hides with `transition-transform duration-300`.
|
|
||||||
|
|
||||||
**Selected nav item:** `bg-teal-100 text-teal-800 ring-1 ring-teal-200`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Core Palette
|
|
||||||
|
|
||||||
Use these Tailwind families first:
|
|
||||||
|
|
||||||
- `slate` — text, borders, neutral panels
|
|
||||||
- `sky` — page gradients, upload/action emphasis, map/cloud atmosphere
|
|
||||||
- `teal` — navigation selected states, account identity, calm success-adjacent UI
|
|
||||||
- `cyan` — subtle sky gradients and avatar/logo surfaces
|
|
||||||
- `emerald` — explicit success/approved state only
|
|
||||||
- `amber` — pending/review/uncommon rarity
|
|
||||||
- `rose` — rejected/destructive/rare rarity
|
|
||||||
|
|
||||||
**Key hex values:**
|
|
||||||
|
|
||||||
| Role | Value |
|
|
||||||
|------|-------|
|
|
||||||
| Page background | `#eef4f8` / `#f3f7fb` |
|
|
||||||
| Body text | `#0f172a` (slate-900) |
|
|
||||||
| Secondary text | `#334155` (slate-700) |
|
|
||||||
| Muted text | `#64748b` (slate-500) |
|
|
||||||
| Borders | `#d9e3ee`, `#e2e8f0`, `#cbd5e1` |
|
|
||||||
| Selection | `rgba(15,118,110,0.18)` (teal-700) |
|
|
||||||
| Text on primary | `#0f172a` (dark, not white — Naive UI override) |
|
|
||||||
|
|
||||||
**Naive UI theme tokens** (`App.vue`):
|
|
||||||
```
|
|
||||||
primaryColor: '#0f766e' (teal-700)
|
|
||||||
infoColor: '#0369a1' (sky-700)
|
|
||||||
successColor: '#0f766e' (teal-700)
|
|
||||||
warningColor: '#d97706' (amber-600)
|
|
||||||
errorColor: '#dc2626' (red-600)
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Animation & Transitions
|
|
||||||
|
|
||||||
**Hover effects:**
|
|
||||||
- Cards: `transition-all hover:-translate-y-1 hover:shadow-lg` (lift)
|
|
||||||
- Images: `transition duration-500 group-hover:scale-[1.04]` (subtle zoom)
|
|
||||||
- Gallery items: `transition-transform duration-300 hover:-translate-y-1`
|
|
||||||
- Badges on cards: `transition-opacity md:opacity-0 md:group-hover:opacity-100`
|
|
||||||
|
|
||||||
**Modal transitions:**
|
|
||||||
- ImageDetailModal: opacity 180ms, shell scale+translateY 220ms, `cubic-bezier(0.22, 1, 0.36, 1)`
|
|
||||||
- Other modals: default Vue transitions
|
|
||||||
|
|
||||||
**Header scroll:** `transition-transform duration-300`
|
|
||||||
|
|
||||||
**Image loading:** `transition-opacity duration-300` for thumbnail-to-hires crossfade, low-res preview gets `blur-[1px]` until full-res loads.
|
|
||||||
|
|
||||||
**Skeleton shimmer:**
|
|
||||||
```
|
|
||||||
animate-pulse bg-[linear-gradient(110deg,#0f172a_0%,#1e293b_45%,#334155_55%,#0f172a_100%)]
|
|
||||||
bg-[length:220%_100%]
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Icons
|
|
||||||
|
|
||||||
**Library:** `@vicons/tabler` (Tabler Icons), rendered via `<NIcon size="16|18|20|22|30|42">` from Naive UI.
|
|
||||||
|
|
||||||
Common icons: `User`, `Settings`, `Logout`, `Shield`, `Search`, `X`, `Clock`, `Location`/`MapIcon`, `CloudUpload`, `Map`/`Satellite`, `Adjustments`, `Calendar`, `Refresh`, `InfoCircle`, `Lock`, `Check`, `Eye`/`EyeOff`, `Trash`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Anti-Patterns
|
## Anti-Patterns
|
||||||
|
|
||||||
- Do not use purple as a fallback visual direction.
|
- Default Tailwind `green-*`, `lime-*`, vivid teal, purple, indigo, or generic `gray-*`.
|
||||||
- Do not use `bg-slate-900 text-white` for ordinary selected navigation.
|
- Ad hoc rounded cards, pills, or map buttons.
|
||||||
- Do not introduce dark-mode-heavy sections unless the surrounding page already uses that language.
|
- Soft drop shadows replacing hard atlas shadows across normal UI.
|
||||||
- Do not overuse rounded rectangles; the project uses sharp, atlas-like panels.
|
- New button styling copied into templates instead of shared `oc-*` variants.
|
||||||
- Do not mix random accent colors within the same feature. Pick one accent family and keep it consistent.
|
- `NButton type="primary"` used as a shortcut around the shared button contract.
|
||||||
- Do not use flat single-color backgrounds where a gradient belongs.
|
- White text on pale green or sky action surfaces.
|
||||||
- Do not add border-radius without an explicit reason — `0px` is the project default.
|
- Emoji used as the site identity.
|
||||||
- Do not use white text on primary buttons — Naive UI primary buttons use dark text (`#0f172a`).
|
- Flat page backgrounds where the shared hero/canvas gradient applies.
|
||||||
|
- Green used indiscriminately for both brand interaction and success state.
|
||||||
---
|
|
||||||
|
|
||||||
## Validation
|
## Validation
|
||||||
|
|
||||||
After style changes, run:
|
After style changes, run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx vue-tsc -b
|
npm run check:styles
|
||||||
|
git diff --check
|
||||||
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
Run `npm run build` if the change touches routes, imported components, or package dependencies.
|
For material visual changes, render representative pages and inspect desktop and `375px` mobile screenshots. Check computed styles when shape, shadow, color token, or responsive overflow is part of the request.
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
VITE_API_URL=http://localhost:8000/api/v1
|
VITE_API_URL=http://localhost:3000
|
||||||
VITE_AMAP_KEY=
|
VITE_AMAP_KEY=
|
||||||
VITE_SITE_URL=http://localhost:5173
|
VITE_SITE_URL=http://localhost:5173
|
||||||
|
|||||||
@@ -10,12 +10,16 @@ lerna-debug.log*
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
dist-ssr
|
dist-ssr
|
||||||
|
coverage
|
||||||
|
.eslintcache
|
||||||
|
.prettiercache
|
||||||
*.local
|
*.local
|
||||||
.env
|
.env
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
!.vscode/settings.json
|
||||||
.idea
|
.idea
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.claude
|
.claude
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
dist-ssr/
|
||||||
|
coverage/
|
||||||
|
.agents/
|
||||||
|
.codex/
|
||||||
|
.claude/
|
||||||
|
.env*
|
||||||
|
package-lock.json
|
||||||
|
skills-lock.json
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"tabWidth": 4,
|
||||||
|
"useTabs": false,
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 100,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"endOfLine": "lf"
|
||||||
|
}
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"recommendations": ["Vue.volar", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
|
||||||
|
}
|
||||||
Vendored
+11
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"editor.tabSize": 4,
|
||||||
|
"editor.insertSpaces": true,
|
||||||
|
"editor.detectIndentation": false,
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.eslint": "explicit"
|
||||||
|
},
|
||||||
|
"eslint.validate": ["javascript", "typescript", "vue"]
|
||||||
|
}
|
||||||
@@ -3,96 +3,103 @@
|
|||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
- `npm run dev` — Vite dev server with HMR
|
- `npm run dev` — Vite dev server with HMR
|
||||||
|
- `npm run lint` / `npm run lint:fix` — ESLint checks / automatic fixes for JS, TS, and Vue; warnings fail the check
|
||||||
|
- `npm run format:check` / `npm run format` — Prettier check / formatting for source, config, and docs
|
||||||
|
- `npm run check` — lint, formatting, style contracts, typecheck, and communication tests
|
||||||
|
- `npm run check:styles` — validates shared style contracts and blocks deprecated palettes/classes
|
||||||
- `npm run build` — `vue-tsc -b && vite build` (typecheck must pass or build aborts)
|
- `npm run build` — `vue-tsc -b && vite build` (typecheck must pass or build aborts)
|
||||||
- `npx vue-tsc -b` — standalone typecheck (no script in package.json)
|
- `npm run typecheck` — standalone Vue / TypeScript typecheck
|
||||||
- No linter, formatter, or test runner exists
|
- `npm run preview` — previews the production build on strict port `5173`
|
||||||
|
- ESLint uses `eslint.config.js`; Prettier uses `.prettierrc.json`. Keep formatting rules in Prettier. Communication tests use Node’s built-in runner (`npm test`, Node 22.18+); `check:styles` checks the visual system.
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
- **Vue 3 + Vite + Tailwind CSS + Vue Router + Pinia + FastAPI + AMap (高德地图) + Naive UI**
|
- **Vue 3 + Vite + Tailwind CSS + Vue Router + Pinia + Hono + Better Auth + AMap (高德地图) + Naive UI**
|
||||||
- Path alias `@/` → `src/` (configured in both `vite.config.ts` and `tsconfig.app.json`)
|
- Path alias `@/` → `src/` (configured in both `vite.config.ts` and `tsconfig.app.json`)
|
||||||
- FastAPI client at `src/lib/api.ts`; API base URL comes from `VITE_API_URL`
|
- HTTP transport at `src/lib/api.ts`; business calls in `features/{clouds,profile,admin}/api.ts`; API base URL comes from `VITE_API_URL`
|
||||||
- AMap loaded lazily via `src/lib/amap.ts` with type declarations in `src/types/amap.d.ts`
|
- AMap loaded lazily via `src/shared/map/amap.ts` with type declarations in `src/shared/map/types/amap.d.ts`
|
||||||
- UI language is Chinese (zh-CN)
|
- UI language is Chinese (zh-CN)
|
||||||
- All persistence, storage, authorization, and admin operations go through the FastAPI backend
|
- All persistence, storage, authorization, and admin operations go through the Hono backend
|
||||||
|
|
||||||
## Directory Map
|
## Directory Map
|
||||||
|
|
||||||
| Path | Purpose |
|
| Path | Purpose |
|
||||||
| --- | --- |
|
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `src/lib/` | Singletons and utilities: FastAPI client, amap, canvas patch, cloudTypes constants, cloudBadges canvas renderer, SEO meta builder |
|
| `src/features/` | Business modules; each owns its route views, components, stores, and composables as needed |
|
||||||
| `src/stores/` | Pinia stores: auth, clouds (cloud_types cache), encyclopedia (collection + unlock tracking), profile (user pages + cloud CRUD) |
|
| `src/features/auth/` | Auth views, auth store, and Better Auth client |
|
||||||
| `src/composables/` | Vue composables: `useUpload` (batch multipart upload, EXIF extraction, badge result handling) |
|
| `src/features/clouds/` | Shared cloud detail/edit/like components, cloud-type and likes stores, cloud-type constants |
|
||||||
| `src/components/cloud/` | Cloud-related modals and widgets: ImageDetailModal, CloudEditModal, MapPickerModal, QuickUploadModal, MiniLocationMap |
|
| `src/features/upload/` | UploadView, QuickUploadModal, and useUpload |
|
||||||
| `src/components/layout/` | AppHeader (top nav bar with auth state) |
|
| `src/features/profile/` | Profile views, profile store, and ContributionHeatmap |
|
||||||
| `src/components/profile/` | ContributionHeatmap |
|
| `src/features/encyclopedia/` | Encyclopedia views and encyclopedia store |
|
||||||
| `src/style.css` | Global visual system hooks: shared button/card utility classes, base typography, body background |
|
| `src/features/{map,gallery,community,admin,system}/views/` | Remaining route views grouped by feature |
|
||||||
| `src/views/` | Route-level page components (see Routes below) |
|
| `src/shared/map/` | Reusable location picker and mini map, AMap loader, and AMap declarations |
|
||||||
| `src/types/` | TypeScript types: domain models (`database.ts`), API DTOs (`api.ts`), AMap declarations (`amap.d.ts`), router meta (`router.d.ts`) |
|
| `src/lib/` | Shared infrastructure: API client and adapters, SEO meta builder, Naive UI theme |
|
||||||
|
| `src/components/layout/` | AppHeader (top nav bar with auth state) |
|
||||||
|
| `src/style.css` | Global stylesheet assembly point; imports Tailwind, tokens, base rules, and shared components |
|
||||||
|
| `src/styles/` | Visual system source: semantic tokens, global square-corner baseline, shared `oc-*` component contracts |
|
||||||
|
| `src/lib/theme.ts` | Naive UI theme overrides aligned with the semantic tokens |
|
||||||
|
| `src/router/` | Route registration, lazy view imports, guards, and per-route SEO |
|
||||||
|
| `src/types/` | Frontend models (`models.ts`, `view-models.ts`), generated HTTP DTOs (`api-contract.ts`), and router meta (`router.d.ts`) |
|
||||||
|
| `docs/project-structure.md` | File ownership, dependency conventions, and examples for placing new code |
|
||||||
|
| `docs/style-system.md` | Concise implementation and naming guide for the visual system |
|
||||||
|
| `scripts/check-style-system.mjs` | Automated guard against deprecated palettes and malformed shared classes |
|
||||||
|
|
||||||
|
- When adding or moving source files, follow `docs/project-structure.md`: colocate business code under its owning feature; keep reusable location primitives in `shared/map` and application layout in `components/layout`.
|
||||||
|
- Import concrete files directly; route views remain lazy imports in `src/router/index.ts`.
|
||||||
|
|
||||||
## Routes
|
## Routes
|
||||||
|
|
||||||
| Path | View | Auth Required |
|
| Path | View | Auth Required |
|
||||||
| --- | --- | :---: |
|
| ---------------------------------------------------------------------------------- | -------------------- | :-----------: |
|
||||||
| `/` | MapView | No |
|
| `/` | MapView | No |
|
||||||
| `/login`, `/register`, `/forgot-password`, `/auth/confirm`, `/auth/reset-password` | Auth views | No |
|
| `/login`, `/register`, `/forgot-password`, `/auth/confirm`, `/auth/reset-password` | Auth views | No |
|
||||||
| `/upload` | UploadView | Yes |
|
| `/upload` | UploadView | Yes |
|
||||||
| `/encyclopedia` | EncyclopediaView | Yes |
|
| `/encyclopedia` | EncyclopediaView | Yes |
|
||||||
| `/encyclopedia/:id` | CloudTypeView | Yes |
|
| `/encyclopedia/:id` | CloudTypeView | Yes |
|
||||||
| `/gallery` | GalleryView | No |
|
| `/gallery` | GalleryView | No |
|
||||||
| `/community` | CommunityView | No |
|
| `/community` | CommunityView | No |
|
||||||
| `/profile` | ProfileView (own) | Yes |
|
| `/profile` | ProfileView (own) | Yes |
|
||||||
| `/profile/settings` | ProfileSettingsView | Yes |
|
| `/profile/settings` | ProfileSettingsView | Yes |
|
||||||
| `/profile/:id` | ProfileView (public) | No |
|
| `/profile/:id` | ProfileView (public) | No |
|
||||||
| `/admin` | AdminView | Yes (admin) |
|
| `/admin` | AdminView | Yes (admin) |
|
||||||
| `/403` | ForbiddenView | No |
|
| `/403` | ForbiddenView | No |
|
||||||
| `/401` | AuthRequiredView | No |
|
| `/401` | AuthRequiredView | No |
|
||||||
| `/:pathMatch(.*)*` | NotFoundView | No |
|
| `/:pathMatch(.*)*` | NotFoundView | No |
|
||||||
|
|
||||||
- Route guards in `router/index.ts`: `requiresAuth` redirects to `/401` with the intended URL in the `redirect` query; `requiresAdmin` redirects to `/403`
|
- Route guards in `router/index.ts`: `requiresAuth` redirects to `/401` with the intended URL in the `redirect` query; `requiresAdmin` redirects to `/403`
|
||||||
- SEO meta tags applied per-route via `lib/seo.ts` in `router.afterEach`
|
- SEO meta tags applied per-route via `lib/seo.ts` in `router.afterEach`
|
||||||
|
|
||||||
## Auth Flow
|
## Auth Flow
|
||||||
|
|
||||||
- **`main.ts` initializes auth before mounting**: `authStore.initialize()` exchanges the HttpOnly refresh cookie for an access token. The app only mounts after this initial check.
|
- `main.ts` calls `authStore.initialize()` before mounting: Better Auth checks the session cookie and then loads `/profiles/me`.
|
||||||
- Access tokens live in memory only. Refresh cookies are managed by the backend and sent with `credentials: 'include'`.
|
- The backend manages HttpOnly session cookies; browser requests use `credentials: 'include'`.
|
||||||
- `src/lib/api.ts` performs one automatic refresh-and-retry after an authenticated request receives `401`.
|
- `features/auth/authClient.ts` owns Better Auth SDK configuration and error adaptation. No custom access-token refresh or automatic mutation retry.
|
||||||
- API auth state changes are synchronized back to the Pinia store through `opencloud:auth-updated` and `opencloud:auth-expired` window events.
|
- Required business requests receiving 401 dispatch `opencloud:auth-expired`, which clears Pinia auth state. Public requests use `{ auth: false }` to suppress that event.
|
||||||
- Email confirmation and password reset pages consume the opaque `token` query parameter generated by the backend.
|
- Email confirmation and password reset consume the backend’s opaque `token` query parameter. Passwords require at least 8 characters.
|
||||||
- Passwords must contain at least 8 characters in registration, settings, and reset flows.
|
|
||||||
- Registration, email confirmation, login, password reset, profile creation, and uniqueness checks are backend responsibilities.
|
|
||||||
|
|
||||||
## Stores
|
## Stores
|
||||||
|
|
||||||
- **auth** — User session, profile, login/register/logout, username/password update, password reset. `initialize()` must be called before app mounts.
|
- **auth** — User session, profile, login/register/logout, username/password update, password reset. `initialize()` must be called before app mounts.
|
||||||
- **clouds** — Simple cache of cloud types returned by `GET /cloud-types`. Fetched once and shared across views.
|
- **clouds** — Simple cache of cloud types returned by `GET /cloud-types`. Fetched once and shared across views.
|
||||||
- **encyclopedia** — Cloud types + user's collection (unlock state). Tracks `unlockPercent` for progress display. Depends on `authStore`.
|
- **encyclopedia** — Cloud-type catalog cache for encyclopedia pages; numeric rarity comes from the backend.
|
||||||
- **profile** — User profile pages. Fetches profile + cloud list per-user. Supports update/delete/visibility-toggle with optimistic cache patching; backend deletion also removes stored files.
|
- **profile** — User profile pages. Fetches profile + cloud list per-user. Supports update/delete/visibility-toggle with optimistic cache patching; backend deletion also removes stored files.
|
||||||
|
|
||||||
## FastAPI Backend
|
## Backend and API Conventions
|
||||||
|
|
||||||
- Backend project lives in the sibling directory `../opencloud-backend`.
|
- Current backend: sibling `../hono-api` (Hono + Better Auth + PostgreSQL + object storage), default `http://localhost:3000`.
|
||||||
- Default development API URL is `http://localhost:8000/api/v1`; set `VITE_API_URL` for deployed environments.
|
- When changing requests, DTOs, pagination, or authentication, read `docs/api-architecture.md`; the backend `API.md` lists endpoints and migration details.
|
||||||
- Frontend route guards are for navigation UX only. The backend enforces ownership, authentication, admin roles, and disabled-account rules.
|
- Views/stores call their feature API module; only feature API modules call `lib/api.ts`. Better Auth SDK calls stay in the auth module.
|
||||||
- Images are uploaded as multipart form data. The backend stores originals, creates thumbnails, blurs coordinates, writes database records, and atomically unlocks badges.
|
- Backend `src/schemas/` generates `contracts/api.ts`; run frontend `npm run api:sync` to update `src/types/api-contract.ts`. For coordinated changes, run backend `contract:check` and frontend `api:check`; do not hand-edit generated DTOs.
|
||||||
|
- Use `query` objects, plain JSON bodies, and typed upload input. The API module handles URL encoding and FormData construction.
|
||||||
## API Conventions
|
- Business JSON uses snake_case and ISO UTC date strings. Pagination returns `items/page/page_size/has_more`; use the explicit flag for navigation.
|
||||||
|
- Business errors use `{message, issues?}`; Better Auth keeps its SDK protocol. `ApiError` preserves HTTP status and error details.
|
||||||
- All requests must go through `src/lib/api.ts`; do not call `fetch` directly from views, stores, or composables.
|
- Batch mutations accept at most 100 UUID strings; feature API modules split larger selections. Completed batches remain applied after later failures.
|
||||||
- API paths passed to `apiRequest()` are relative to `VITE_API_URL`, for example `/clouds` rather than `/api/v1/clouds`.
|
- Backend permissions enforce ownership, verified sessions, roles, and disabled accounts; route guards provide navigation UX only.
|
||||||
- Public requests explicitly use `{ auth: false }`. Authenticated requests use the default and receive a Bearer access token.
|
|
||||||
- JSON request bodies are plain objects. Image uploads use `FormData`; do not set the multipart `Content-Type` header manually.
|
|
||||||
- FastAPI errors use `detail`; `ApiError` converts string and validation-array details into a user-facing message.
|
|
||||||
- Backend DTO fields use `snake_case`. Page/store adapters may expose display-only camelCase fields such as `cloudTypeName`.
|
|
||||||
- Paginated endpoints return `items`, `page`, `page_size`, `total`, and `total_pages`.
|
|
||||||
- Cloud batch mutation endpoints accept at most 100 IDs. Profile and admin code split larger selections into chunks of 100.
|
|
||||||
|
|
||||||
## Gallery Pagination
|
## Gallery Pagination
|
||||||
|
|
||||||
- Page-based navigation (50 items/page), not infinite scroll.
|
- Page-based navigation, 50 items/page, with a 250ms search debounce.
|
||||||
- The backend resolves cloud-type/custom-type searches and `@username` searches.
|
- Backend resolves cloud-type names and `@username` searches. Next-page availability comes from `has_more`.
|
||||||
- Each response includes `items`, `total`, `page`, `page_size`, and `total_pages`.
|
|
||||||
- Search debounced at 250ms.
|
|
||||||
|
|
||||||
## Map Timeline
|
## Map Timeline
|
||||||
|
|
||||||
@@ -102,16 +109,15 @@
|
|||||||
|
|
||||||
## Upload Flow
|
## Upload Flow
|
||||||
|
|
||||||
- `useUpload` handles file selection, previews, EXIF date extraction, validation, sequential multipart uploads, progress, and badge results. Thumbnail generation, coordinate blurring, storage, database insertion, and badge unlocking run on the backend.
|
- `useUpload` handles selection, previews, EXIF dates, validation, sequential uploads and progress. The cloud API module encodes multipart data; the backend creates previews, stores variants and inserts records. Coordinates are blurred by the current frontend forms.
|
||||||
- Batch items upload sequentially. If a later item fails, earlier successful uploads remain saved; there is no transactional rollback or resumable upload in the frontend.
|
- Batch items upload sequentially. If a later item fails, earlier successful uploads remain saved; there is no transactional rollback or resumable upload in the frontend.
|
||||||
- `UploadView` is the full-page batch uploader. `QuickUploadModal` is a single-image shortcut from the map page.
|
- `UploadView` is the full-page batch uploader. `QuickUploadModal` is a single-image shortcut from the map page.
|
||||||
|
|
||||||
## Build & Deploy
|
## Build & Deploy
|
||||||
|
|
||||||
- **Vercel** with `vercel.json`: SPA rewrites, security headers (X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy). No CSP or HSTS configured.
|
- **Vercel** with `vercel.json`: SPA rewrites, security headers (X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy). No CSP or HSTS configured.
|
||||||
- Vite dev and preview servers both use strict port `5173`, matching the backend's default `CORS_ORIGINS` and `FRONTEND_URL`.
|
- Vite dev and preview servers both use strict port `5173`, matching the backend’s `CORS_ORIGIN` development setting.
|
||||||
- **SEO plugin** in `vite.config.ts`: generates `robots.txt` and `sitemap.xml` at build time. Auth-only routes, including `/encyclopedia`, are excluded from the sitemap and disallowed in `robots.txt`.
|
- **SEO plugin** in `vite.config.ts`: generates `robots.txt` and `sitemap.xml` at build time. Auth-only routes, including `/encyclopedia`, are excluded from the sitemap and disallowed in `robots.txt`.
|
||||||
- **`lib/canvas.ts`**: patches `HTMLCanvasElement.getContext('2d')` to always pass `willReadFrequently: true` — needed for the badge card renderer in `lib/cloudBadges.ts`.
|
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|
||||||
@@ -121,37 +127,61 @@ Required for map features:
|
|||||||
|
|
||||||
Optional:
|
Optional:
|
||||||
|
|
||||||
- `VITE_API_URL` — FastAPI base URL including `/api/v1` (defaults to `http://localhost:8000/api/v1`)
|
- `VITE_API_URL` — Hono root URL (defaults to `http://localhost:3000`, without `/api/v1`)
|
||||||
- `VITE_SITE_URL` — canonical frontend URL used by route SEO and generated sitemap; set it explicitly in deployed environments
|
- `VITE_SITE_URL` — canonical frontend URL used by route SEO and generated sitemap; set it explicitly in deployed environments
|
||||||
|
|
||||||
Backend-only variables such as database credentials, JWT secrets, SMTP settings, cookie policy, CORS origins, and upload paths belong in `../opencloud-backend/.env`, never in the Vite environment.
|
Backend-only variables such as database credentials, Better Auth secrets, email-provider settings, cookie policy, CORS origins, and object-storage settings belong in `../hono-api/.env`, never in the Vite environment.
|
||||||
|
|
||||||
|
## Visual System
|
||||||
|
|
||||||
|
- The design language is a clean sky atlas: airy sky-blue surfaces, fresh eucalyptus green, square editorial panels, pixel-cloud identity, and hard offset shadows.
|
||||||
|
- Read `.agents/skills/opencloud-style/SKILL.md` before material visual changes. Treat `src/styles/tokens.css`, `src/styles/base.css`, `src/styles/components.css`, and `src/lib/theme.ts` as the implementation sources of truth.
|
||||||
|
- Shared/stable decisions belong in layers:
|
||||||
|
- tokens and palette remapping → `src/styles/tokens.css`
|
||||||
|
- global baseline and square-corner policy → `src/styles/base.css`
|
||||||
|
- cross-page semantic classes → `src/styles/components.css`
|
||||||
|
- feature-specific map/slider/media details → the component's scoped style
|
||||||
|
- one-off layout and responsive composition → Tailwind in the template
|
||||||
|
- The global interface is square by default. Ordinary cards, inputs, dropdowns, buttons, modals, and map controls use `0px` radius. Circular marker dots, media overlay controls, AMap-generated bubbles/cards, and the media-focused image-detail shell are explicit exceptions.
|
||||||
|
- Use hard zero-blur offset shadows (`--oc-shadow-xs` through `--oc-shadow-xl`) for ordinary UI depth. Interactive controls may lift by `translate(-1px, -1px)` on hover.
|
||||||
|
- Brand/interaction green is fresh eucalyptus: main `#34745d`, dark `#274c40`, light surface `#f2faf6`.
|
||||||
|
- Success green is a distinct leaf green: main `#4d7f3b`, dark `#35522c`, light surface `#f4faef`.
|
||||||
|
- Existing `teal-*` and `emerald-*` Tailwind class names are compatibility aliases remapped in `tokens.css`; do not assume Tailwind's default values.
|
||||||
|
- Do not introduce Tailwind `green-*`/`lime-*`, vivid default teal, purple, indigo, or generic gray palettes. Use slate, sky, remapped teal/emerald, amber, and rose according to semantic purpose.
|
||||||
|
- The header brand mark is the pixel cloud/sun SVG inside a square `40px` `sky-100` surface with a `sky-200` border and neutral `4px` hard shadow. Do not replace it with emoji or give it a green background.
|
||||||
|
- Map floating buttons use `oc-map-button`: square `40px × 40px`, white background, slate border, `0px` radius, and a hard shadow even when disabled.
|
||||||
|
- For material visual changes, inspect representative desktop and real `375px` mobile screenshots and verify there is no horizontal overflow.
|
||||||
|
|
||||||
## Naive UI
|
## Naive UI
|
||||||
|
|
||||||
- Used for modals, buttons, inputs, tags, progress bars, alerts, dropdowns, empty states, skeletons, and message toasts.
|
- Used for modals, buttons, inputs, tags, progress bars, alerts, dropdowns, empty states, skeletons, and message toasts.
|
||||||
- No SSR — pure client-side rendering.
|
- No SSR — pure client-side rendering.
|
||||||
- Custom CSS overrides via scoped `<style>` blocks for slider styling, transitions, and component tweaks.
|
- Custom CSS overrides via scoped `<style>` blocks for slider styling, transitions, and component tweaks.
|
||||||
- **Do not rely on default Naive UI primary/secondary colors for page CTAs or panel actions.** The project now uses shared global classes in `src/style.css` to keep buttons visually consistent with the sky-atlas theme.
|
- Global overrides are defined in `src/lib/theme.ts` and mounted by `App.vue`; keep brand/success colors aligned with `src/styles/tokens.css`.
|
||||||
|
- **Do not rely on default Naive UI primary/secondary colors for page CTAs or panel actions.** Use the shared classes in `src/styles/components.css`.
|
||||||
- Auth buttons use `oc-primary-button` with semantic variants:
|
- Auth buttons use `oc-primary-button` with semantic variants:
|
||||||
- `oc-primary-button--teal` — login / account-access actions
|
- `oc-primary-button--teal` — login / account-access actions
|
||||||
- `oc-primary-button--sky` — register / create / forward actions
|
- `oc-primary-button--sky` — register / create / forward actions
|
||||||
- Panel and utility buttons use `oc-panel-button` with semantic variants:
|
- Panel and utility buttons use `oc-panel-button` with semantic variants:
|
||||||
- `oc-panel-button--neutral` — white card-style utility actions
|
- `oc-panel-button--neutral` — white card-style utility actions
|
||||||
- `oc-panel-button--sky` — primary panel actions
|
- `oc-panel-button--sky` — primary panel actions
|
||||||
- `oc-panel-button--teal` — active toggles / confirm actions
|
- `oc-panel-button--teal` — active toggles / confirm actions
|
||||||
- `oc-panel-button--danger` — destructive actions
|
- `oc-panel-button--danger` — destructive actions
|
||||||
- `oc-panel-button--amber` — admin/state-toggle actions where warning emphasis fits better than danger
|
- `oc-panel-button--amber` — admin/state-toggle actions where warning emphasis fits better than danger
|
||||||
- Card-like containers should prefer shared shadow classes instead of ad-hoc shadows:
|
- Card-like containers should prefer shared shadow classes instead of ad-hoc shadows:
|
||||||
- `oc-panel-card`
|
- `oc-panel-card`
|
||||||
- `oc-panel-card-soft`
|
- `oc-panel-card-soft`
|
||||||
- `oc-empty-card`
|
- `oc-empty-card`
|
||||||
- When styling `NButton`, prefer `type="default"` plus the shared class when a custom panel button variant is intended. Otherwise Naive UI theme variables may override white backgrounds or semantic colors.
|
- When styling `NButton`, prefer `type="default"` plus the shared class when a custom panel button variant is intended. Otherwise Naive UI theme variables may override white backgrounds or semantic colors.
|
||||||
|
- Primary and panel actions use dark text on light semantic surfaces; do not assume primary buttons should use white text.
|
||||||
|
|
||||||
## Visual Notes
|
## Visual Notes
|
||||||
|
|
||||||
- The site icon and header brand mark are a matching pixel-style cloud motif; avoid reintroducing emoji or unrelated icon styles for primary brand surfaces.
|
- The site icon and header brand mark are a matching pixel-style cloud motif on a light sky-blue square; avoid emoji or unrelated icon styles for primary brand surfaces.
|
||||||
- Header action buttons use slight hover lift (`translate(-1px, -1px)`) with hard-offset shadow growth; new header-like actions should follow that interaction pattern.
|
- Header action buttons use slight hover lift (`translate(-1px, -1px)`) with hard-offset shadow growth; new header-like actions should follow that interaction pattern.
|
||||||
- Heatmap view toggles in `ContributionHeatmap` intentionally use separate buttons with gap spacing instead of `NButtonGroup`, because grouped buttons visually collide once hard shadows and hover transforms are applied.
|
- Heatmap view toggles in `ContributionHeatmap` intentionally use separate buttons with gap spacing instead of `NButtonGroup`, because grouped buttons visually collide once hard shadows and hover transforms are applied.
|
||||||
|
- Reuse existing `oc-*` classes before duplicating Tailwind bundles. New shared modifiers must always appear with their base class.
|
||||||
|
- Validate style work with `npm run check:styles`, `git diff --check`, and `npm run build`.
|
||||||
|
|
||||||
## MVP Constraints
|
## MVP Constraints
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# OpenCloud API 文档入口
|
||||||
|
|
||||||
|
当前前端接入 Hono 后端 `hono-api`,默认 API 根地址为 `http://localhost:3000`。
|
||||||
|
|
||||||
|
- 前端分层、Cookie 认证、分页和契约同步:[通信架构](docs/api-architecture.md)。
|
||||||
|
- 完整端点、请求字段、权限与迁移表:相邻后端仓库的 [API.md](../hono-api/API.md)。
|
||||||
|
- 前端使用的生成契约:[api-contract.ts](src/types/api-contract.ts)。
|
||||||
|
|
||||||
|
前端不再维护后端手册的副本。修改后端 schema 后先生成契约,再执行 `npm run api:sync` 和 `npm run api:check`;前后端配套检查通过后一起发布。本次资源路径、字段名与分页格式有破坏性变化,迁移明细以当前后端文档为准。
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
# OpenCloud 前端
|
# OpenCloud 前端
|
||||||
|
|
||||||
Vue 3 + TypeScript + Vite 前端,通过 FastAPI 提供认证、云图、图鉴、个人主页和管理后台数据。
|
Vue 3 + TypeScript + Vite 前端,通过 Hono 后端和 Better Auth 提供认证、云图、图鉴、个人主页和管理后台数据。
|
||||||
|
|
||||||
## 本地开发
|
## 本地开发
|
||||||
|
|
||||||
1. 在相邻的 `opencloud-backend` 项目中启动 FastAPI 服务。
|
1. 在相邻的 `hono-api` 项目中启动后端服务(该仓库的本地启动方式见其 README)。
|
||||||
2. 复制 `.env.example` 为 `.env`,配置高德地图 Key;如果后端不在默认地址,修改 `VITE_API_URL`。
|
2. 复制 `.env.example` 为 `.env`,配置高德地图 Key;如果后端不在默认地址,修改 `VITE_API_URL`。
|
||||||
3. 安装依赖并启动前端:
|
3. 安装依赖并启动前端:
|
||||||
|
|
||||||
@@ -13,12 +13,37 @@ npm install
|
|||||||
npm run dev
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
默认后端地址为 `http://localhost:8000/api/v1`。
|
默认后端地址为 `http://localhost:3000`。
|
||||||
开发服务器和本地 Preview 都固定使用 `http://localhost:5173`,与后端默认 CORS 配置保持一致。运行 Preview 前请先停止开发服务器。
|
开发服务器和本地 Preview 都固定使用 `http://localhost:5173`,与后端默认 CORS 配置保持一致。运行 Preview 前请先停止开发服务器。
|
||||||
|
|
||||||
## 检查与构建
|
## 检查与构建
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx vue-tsc -b
|
npm run check
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`check` 依次执行 ESLint、Prettier 格式检查、项目样式检查、TypeScript 类型检查和通信层测试。也可以单独运行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run lint # 检查 JS、TS 和 Vue 代码,警告也会导致失败
|
||||||
|
npm run lint:fix # 自动修复可修复的代码问题
|
||||||
|
npm run format:check # 检查格式,不修改文件
|
||||||
|
npm run format # 格式化源码、配置和文档
|
||||||
|
npm run check:styles # 检查项目视觉规范
|
||||||
|
npm run typecheck # Vue / TypeScript 类型检查
|
||||||
|
```
|
||||||
|
|
||||||
|
ESLint 使用 flat config,启用 JavaScript、TypeScript 和 Vue 推荐规则;Prettier 负责格式,使用 4 个空格缩进、单引号和无分号风格。通过 `eslint-config-prettier` 关闭冲突的格式规则,构建产物、依赖、环境文件和工具管理的目录不参与格式化。
|
||||||
|
|
||||||
|
VS Code 用户可安装工作区推荐的 Vue、ESLint、Prettier 扩展,保存时自动格式化并执行 ESLint 修复。
|
||||||
|
|
||||||
|
配置参考:[Vue ESLint 官方指南](https://eslint.vuejs.org/user-guide/)、[typescript-eslint 入门](https://typescript-eslint.io/getting-started/)、[Prettier 安装指南](https://prettier.io/docs/install)。
|
||||||
|
|
||||||
|
## 项目结构
|
||||||
|
|
||||||
|
业务代码按功能集中在 `src/features/`:页面、组件、store 和 composable 放入各自所属模块。跨业务的地图控件集中在 `src/shared/map/`,应用导航位于 `src/components/layout/`,API 客户端、全局样式和公共类型保留独立目录。
|
||||||
|
|
||||||
|
新增或移动文件时,参见[目录结构与依赖约定](docs/project-structure.md)。
|
||||||
|
|
||||||
|
前后端配套修改时,参见[通信架构与契约同步](docs/api-architecture.md),先生成并同步契约,再运行 `npm run api:check`。该检查需要相邻的后端仓库;前端独立构建使用已提交的类型快照。
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# 前后端通信约定
|
||||||
|
|
||||||
|
当前后端是相邻的 `hono-api` 仓库,默认根地址 `http://localhost:3000`。业务接口由 Hono 提供,认证由 Better Auth 提供;旧 `opencloud-backend` FastAPI 项目不参与当前调用。
|
||||||
|
|
||||||
|
## 职责
|
||||||
|
|
||||||
|
| 层 | 文件 | 负责内容 |
|
||||||
|
| ------------ | ------------------------------------------------- | ----------------------------------------------------------- |
|
||||||
|
| HTTP 传输 | `src/lib/api.ts` | Cookie、查询编码、JSON/FormData、HTTP 错误和 401 事件 |
|
||||||
|
| 业务调用 | `src/features/{clouds,profile,admin}/api.ts` | 资源路径、输入/输出类型、批量分块、分页收集、响应适配 |
|
||||||
|
| 响应适配 | `src/lib/api-adapters.ts` | 生成 DTO 到前端视图模型的明确映射,图片 URL |
|
||||||
|
| 后端契约 | `src/types/api-contract.ts` | 从后端 schema 生成并同步,禁止手改 |
|
||||||
|
| 前端模型 | `src/types/models.ts`、`src/types/view-models.ts` | 页面需要的 Cloud、CloudType、Profile、CloudDetail、AuthUser |
|
||||||
|
| 认证客户端 | `src/features/auth/authClient.ts` | Better Auth SDK 与其独立错误协议 |
|
||||||
|
| 页面与 store | `src/features/` | 交互、缓存、业务展示;调用业务 API 模块 |
|
||||||
|
|
||||||
|
页面不再直接调用 `apiRequest`;ESLint 会检查该规则。传输层不引用云图/用户模型,也不承担认证 SDK 的职责。后端数据库命名、HTTP 字段命名和页面显示字段各自有明确适配位置。稀有度统一使用后端数值,不再伪造 `common` 分类。
|
||||||
|
|
||||||
|
## 请求与响应
|
||||||
|
|
||||||
|
`apiRequest` 的路径相对于后端根地址,如 `/clouds`,不要加入 `/api/v1`。查询条件通过 `query` 对象传入,由传输层编码一次。JSON body 是普通对象,上传模块接受类型化参数并构建 FormData,浏览器生成 multipart Content-Type。
|
||||||
|
|
||||||
|
所有请求携带 Cookie。`auth: false` 表示该公开请求的 401 不触发清空登录状态,并不禁止携带 Cookie。需要登录的请求默认派发 `opencloud:auth-expired`。传输层不会重试写操作;网络错误、非法成功响应及结构化 HTTP 错误会抛给调用者。
|
||||||
|
|
||||||
|
业务错误为 `{message, issues?}`,保存在 `ApiError.message/status/detail`。成功 JSON 响应必须能解析;204 返回 undefined。图片 URL 直接用于媒体元素,不通过 JSON 请求函数。
|
||||||
|
|
||||||
|
云图分页使用 `{items, page, page_size, has_more}`。页面通过 `has_more` 控制下一页;热力图、点赞集合与当前管理统计需要完整集合时,由业务 API 使用 `collectPages` 收集。地图为上限 1000 条的时间范围数组,用户管理与云类型目录目前为非分页数组。没有实时订阅或跨页快照。
|
||||||
|
|
||||||
|
批量变更每次最多 100 个 UUID。已完成的删除批次立即修补缓存,后续批次失败不会回滚。上传仍逐张进行,失败前已上传的云图保留;没有恢复上传或自动整批重试。
|
||||||
|
|
||||||
|
## 契约同步与验证
|
||||||
|
|
||||||
|
后端 `src/schemas/` 是单一事实来源。后端生成的 `contracts/api.ts` 只含 HTTP 类型,不引入数据库、SDK、服务端配置或运行时包。前端保存类型快照,独立构建不依赖旁边存在后端仓库。
|
||||||
|
|
||||||
|
两仓库配套修改时:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 在 hono-api 中
|
||||||
|
npm run contract:generate
|
||||||
|
npm run check
|
||||||
|
|
||||||
|
# 在 opencloud 中
|
||||||
|
npm run api:sync
|
||||||
|
npm run api:check
|
||||||
|
npm run check
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
后端不在默认位置时,设置 `OPENCLOUD_API_DIR` 为实际路径。`api:check` 比较已生成的后端类型与前端快照,不会替代后端的 `contract:check`;两者都通过才能确认契约一致。前端 `npm test` 使用 Node 内置测试与 TypeScript 类型剥离,需要 Node 22.18+,不新增测试框架依赖。
|
||||||
|
|
||||||
|
## 部署与迁移
|
||||||
|
|
||||||
|
此次改动需要两端一起发布或回滚。旧路径 `/cloud`、`/profile`、`/image`、`/info/cloudtype` 改为 `/clouds`、`/profiles`、`/images`、`/cloud-types`;旧请求字段 `type_id/user_name/user_role` 改为 `cloud_type_id/username/role`。云图响应使用 `cloud_type/review_status`,日期统一 ISO UTC,批量 ID 为字符串数组。
|
||||||
|
|
||||||
|
认证仍在 `/auth/*`,VITE_API_URL 仍为后端根地址。完整端点与迁移表在后端 `API.md`。本次不需要数据库迁移,TypeScript 字段改名显式映射原数据库列。
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="1800" height="1420" viewBox="0 0 1800 1420" role="img" aria-labelledby="title desc">
|
||||||
|
<title id="title">OpenCloud 当前架构</title>
|
||||||
|
<desc id="desc">前端 Vue 页面和 Pinia store 经业务 API 模块、HTTP 传输层访问 Hono 后端;后端路由使用校验、鉴权、Drizzle 和复用服务,集中序列化响应。Better Auth 独立处理认证,认证与业务共用 PostgreSQL,图片存于对象存储,邮件由 Resend 发送。下方展示从后端 Zod schema 生成并同步前端 TypeScript 契约的开发流程。</desc>
|
||||||
|
<defs>
|
||||||
|
<marker id="arrow" markerWidth="9" markerHeight="9" refX="8" refY="4.5" orient="auto-start-reverse"><path d="M0 0 9 4.5 0 9" fill="#34745d"/></marker>
|
||||||
|
<marker id="return" markerWidth="9" markerHeight="9" refX="8" refY="4.5" orient="auto"><path d="M0 0 9 4.5 0 9" fill="#0284c7"/></marker>
|
||||||
|
<marker id="build" markerWidth="9" markerHeight="9" refX="8" refY="4.5" orient="auto"><path d="M0 0 9 4.5 0 9" fill="#a16207"/></marker>
|
||||||
|
<style>
|
||||||
|
text { font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif; fill: #243746; }
|
||||||
|
.title { font-size: 42px; font-weight: 750; letter-spacing: -1px; }
|
||||||
|
.section { font-size: 26px; font-weight: 700; }
|
||||||
|
.node { font-size: 23px; font-weight: 700; }
|
||||||
|
.body { font-size: 19px; }
|
||||||
|
.small { font-size: 16px; }
|
||||||
|
.muted { fill: #64748b; }
|
||||||
|
.code { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: 16px; fill: #475569; }
|
||||||
|
.flow { fill: none; stroke: #34745d; stroke-width: 2.5; marker-end: url(#arrow); stroke-linejoin: round; }
|
||||||
|
.response { fill: none; stroke: #0284c7; stroke-width: 2.5; stroke-dasharray: 8 6; marker-end: url(#return); }
|
||||||
|
.build { fill: none; stroke: #a16207; stroke-width: 2.5; stroke-dasharray: 5 5; marker-end: url(#build); }
|
||||||
|
</style>
|
||||||
|
</defs>
|
||||||
|
<rect width="1800" height="1420" fill="#f6fafd"/>
|
||||||
|
|
||||||
|
<rect x="48" y="44" width="68" height="68" fill="#cbd5e1"/>
|
||||||
|
<rect x="44" y="40" width="68" height="68" fill="#e0f2fe" stroke="#bae6fd"/>
|
||||||
|
<path d="M59 71h8V59h21v7h11v21H59z" fill="#7dd3fc"/><path d="M82 50h13v13H82z" fill="#f5c66b"/>
|
||||||
|
<text x="138" y="79" class="title">OpenCloud · 当前系统架构</text>
|
||||||
|
<text x="140" y="111" class="body" style="fill:#64748b">运行时请求、认证与开发期契约同步 / 2026-09-30</text>
|
||||||
|
<path d="M 1255 63 H 1310" class="flow"/>
|
||||||
|
<text x="1325" y="70" class="small">调用 / 请求</text>
|
||||||
|
<path d="M 1255 100 H 1310" class="response"/>
|
||||||
|
<text x="1325" y="107" class="small">JSON 响应</text>
|
||||||
|
<path d="M 1515 100 H 1570" class="build"/>
|
||||||
|
<text x="1585" y="107" class="small">契约生成 / 同步</text>
|
||||||
|
<rect x="40" y="172" width="510" height="832" fill="#edf7fc" stroke="#cbd5e1"/>
|
||||||
|
<text x="64" y="213" class="section">01 浏览器 · opencloud</text>
|
||||||
|
<text x="64" y="244" class="small" style="fill:#64748b">Vue 3 · Pinia · Vue Router · Vite</text>
|
||||||
|
<rect x="680" y="172" width="650" height="832" fill="#f2faf6" stroke="#cbd5e1"/>
|
||||||
|
<text x="704" y="213" class="section">02 API 服务 · hono-api</text>
|
||||||
|
<text x="704" y="244" class="small" style="fill:#64748b">Hono · Better Auth · Zod · Drizzle</text>
|
||||||
|
<rect x="1450" y="172" width="310" height="832" fill="#f8fafc" stroke="#cbd5e1"/>
|
||||||
|
<text x="1474" y="213" class="section">03 数据与外部服务</text>
|
||||||
|
<text x="1474" y="244" class="small" style="fill:#64748b">持久化、图片与邮件</text>
|
||||||
|
<rect x="69" y="282" width="460" height="104" fill="#cbd5e1"/>
|
||||||
|
<rect x="65" y="278" width="460" height="104" fill="#fff" stroke="#b6c8d2"/>
|
||||||
|
<text x="87" y="314" class="node">页面 / 组件 / Pinia stores</text>
|
||||||
|
<text x="87" y="346" class="body">交互、加载状态、业务缓存</text>
|
||||||
|
<text x="87" y="373" class="code">src/features/</text>
|
||||||
|
<rect x="69" y="435" width="460" height="123" fill="#cbd5e1"/>
|
||||||
|
<rect x="65" y="431" width="460" height="123" fill="#fff" stroke="#b6c8d2"/>
|
||||||
|
<text x="87" y="467" class="node">业务 API 模块</text>
|
||||||
|
<text x="87" y="499" class="code">clouds/api.ts · profile/api.ts · admin/api.ts</text>
|
||||||
|
<text x="87" y="526" class="body">路径、分页、批量分块、响应适配</text>
|
||||||
|
<text x="87" y="553" class="code">api-adapters.ts → 前端视图模型</text>
|
||||||
|
<rect x="69" y="614" width="460" height="122" fill="#cbd5e1"/>
|
||||||
|
<rect x="65" y="610" width="460" height="122" fill="#fff" stroke="#b6c8d2"/>
|
||||||
|
<text x="87" y="646" class="node">HTTP 传输层</text>
|
||||||
|
<text x="87" y="678" class="code">src/lib/api.ts</text>
|
||||||
|
<text x="87" y="705" class="body">Cookie · 查询编码 · JSON / FormData</text>
|
||||||
|
<text x="87" y="732" class="body">ApiError · 401 认证失效事件</text>
|
||||||
|
<path d="M 295 382 V 431" class="flow"/>
|
||||||
|
<path d="M 295 554 V 610" class="flow"/>
|
||||||
|
<text x="66" y="775" class="small" style="fill:#64748b">浏览器媒体元素直接请求 /images/:id/:variant</text>
|
||||||
|
<rect x="69" y="828" width="460" height="111" fill="#cbd5e1"/>
|
||||||
|
<rect x="65" y="824" width="460" height="111" fill="#fff" stroke="#94b8aa"/>
|
||||||
|
<text x="87" y="860" class="node">独立认证客户端</text>
|
||||||
|
<text x="87" y="892" class="code">authClient.ts → Better Auth SDK</text>
|
||||||
|
<text x="87" y="919" class="body">登录 / 注册 / 会话 / 邮箱验证 / 密码</text>
|
||||||
|
<text x="66" y="976" class="small" style="fill:#64748b">AMap:浏览器按需加载地图 SDK</text>
|
||||||
|
<rect x="709" y="282" width="600" height="104" fill="#cbd5e1"/>
|
||||||
|
<rect x="705" y="278" width="600" height="104" fill="#fff" stroke="#b6c8d2"/>
|
||||||
|
<text x="727" y="314" class="node">统一响应序列化</text>
|
||||||
|
<text x="727" y="346" class="code">src/serializers.ts</text>
|
||||||
|
<text x="727" y="373" class="body">Cloud / CloudType / User → JSON · ISO UTC</text>
|
||||||
|
<rect x="709" y="435" width="600" height="123" fill="#cbd5e1"/>
|
||||||
|
<rect x="705" y="431" width="600" height="123" fill="#fff" stroke="#b6c8d2"/>
|
||||||
|
<text x="727" y="467" class="node">业务路由 + 按需复用服务</text>
|
||||||
|
<text x="727" y="499" class="code">/clouds · /cloud-types · /profiles · /admin</text>
|
||||||
|
<text x="727" y="526" class="body">Zod 请求校验 · 会话、角色与所有权校验</text>
|
||||||
|
<text x="727" y="553" class="body">Drizzle 查询 · 分页 / 点赞 / 压缩 / 存储</text>
|
||||||
|
<rect x="709" y="614" width="600" height="122" fill="#cbd5e1"/>
|
||||||
|
<rect x="705" y="610" width="600" height="122" fill="#fff" stroke="#b6c8d2"/>
|
||||||
|
<text x="727" y="646" class="node">Hono HTTP 入口</text>
|
||||||
|
<text x="727" y="678" class="code">src/index.ts</text>
|
||||||
|
<text x="727" y="705" class="body">CORS · request ID · 计时 · 错误处理</text>
|
||||||
|
<text x="727" y="732" class="body">资源路由分发;/images 代理图片流</text>
|
||||||
|
<path d="M 1005 610 V 554" class="flow"/>
|
||||||
|
<text x="1025" y="590" class="small" style="fill:#34745d">分发 / 校验</text>
|
||||||
|
<path d="M 1005 431 V 382" class="flow"/>
|
||||||
|
<text x="1025" y="412" class="small" style="fill:#34745d">查询结果</text>
|
||||||
|
<path d="M 525 669 H 705" class="flow"/>
|
||||||
|
<text x="554" y="626" class="small" style="fill:#34745d">HTTPS</text>
|
||||||
|
<text x="553" y="649" class="small" style="fill:#34745d">携带 Cookie</text>
|
||||||
|
<path d="M 705 323 H 612 V 704 H 525" class="response"/>
|
||||||
|
<text x="568" y="300" class="small" style="fill:#0284c7">响应</text>
|
||||||
|
<text x="706" y="775" class="small" style="fill:#64748b">JSON 业务协议与 Better Auth 原生协议分别处理</text>
|
||||||
|
<rect x="709" y="828" width="600" height="111" fill="#cbd5e1"/>
|
||||||
|
<rect x="705" y="824" width="600" height="111" fill="#fff" stroke="#b6c8d2"/>
|
||||||
|
<text x="727" y="860" class="node">Better Auth · /auth/*</text>
|
||||||
|
<text x="727" y="892" class="code">HttpOnly session cookie · Drizzle adapter</text>
|
||||||
|
<text x="727" y="919" class="body">认证表与业务表共用同一个 PostgreSQL</text>
|
||||||
|
<path d="M 525 880 H 705" class="flow"/>
|
||||||
|
<text x="554" y="861" class="code">/auth/*</text>
|
||||||
|
<text x="706" y="976" class="small" style="fill:#64748b">事务外图片存储:串行写入,上传失败执行补偿清理</text>
|
||||||
|
<rect x="1474" y="282" width="270" height="142" fill="#cbd5e1"/>
|
||||||
|
<rect x="1470" y="278" width="270" height="142" fill="#fff" stroke="#b6c8d2"/>
|
||||||
|
<text x="1492" y="314" class="node">PostgreSQL</text>
|
||||||
|
<text x="1492" y="346" class="body">用户 / 会话 / 凭据</text>
|
||||||
|
<text x="1492" y="373" class="body">云类型 / 云图 / 点赞</text>
|
||||||
|
<text x="1492" y="400" class="small">业务与认证共同使用</text>
|
||||||
|
<path d="M 1305 469 H 1394 V 350 H 1470" class="flow"/>
|
||||||
|
<text x="1360" y="326" class="small" style="fill:#34745d">Drizzle</text>
|
||||||
|
<rect x="1474" y="492" width="270" height="142" fill="#cbd5e1"/>
|
||||||
|
<rect x="1470" y="488" width="270" height="142" fill="#fff" stroke="#b6c8d2"/>
|
||||||
|
<text x="1492" y="524" class="node">对象存储</text>
|
||||||
|
<text x="1492" y="556" class="body">MinIO / S3 兼容接口</text>
|
||||||
|
<text x="1492" y="583" class="code">original + preview</text>
|
||||||
|
<text x="1492" y="610" class="small">上传、删除、图片读取</text>
|
||||||
|
<path d="M 1305 520 H 1415 V 556 H 1470" class="flow"/>
|
||||||
|
<text x="1353" y="500" class="small" style="fill:#34745d">storage</text>
|
||||||
|
<rect x="1474" y="828" width="270" height="111" fill="#cbd5e1"/>
|
||||||
|
<rect x="1470" y="824" width="270" height="111" fill="#fff" stroke="#b6c8d2"/>
|
||||||
|
<text x="1492" y="860" class="node">Resend</text>
|
||||||
|
<text x="1492" y="892" class="body">验证邮箱 / 密码重置</text>
|
||||||
|
<text x="1492" y="919" class="code">services/email.ts</text>
|
||||||
|
<path d="M 1305 880 H 1470" class="flow"/>
|
||||||
|
<text x="1341" y="861" class="small" style="fill:#34745d">发送邮件</text>
|
||||||
|
<text x="1471" y="687" class="small" style="fill:#64748b">公开可见规则</text>
|
||||||
|
<text x="1471" y="718" class="body">审核通过且未隐藏</text>
|
||||||
|
<text x="1471" y="747" class="small" style="fill:#64748b">上传者 / 管理员另行授权</text>
|
||||||
|
<rect x="40" y="1040" width="1720" height="266" fill="#fffbef" stroke="#e6d7b0"/>
|
||||||
|
<text x="65" y="1082" class="section">04 开发期 · 生成契约,阻止前后端类型漂移</text>
|
||||||
|
<text x="65" y="1113" class="body" style="fill:#64748b">只同步 TypeScript 类型;前端独立构建使用已提交快照,不加载后端运行时依赖。</text>
|
||||||
|
<rect x="69" y="1154" width="340" height="113" fill="#cbd5e1"/>
|
||||||
|
<rect x="65" y="1150" width="340" height="113" fill="#fff" stroke="#d6bf82"/>
|
||||||
|
<text x="87" y="1186" class="node">后端 Zod 定义</text>
|
||||||
|
<text x="87" y="1218" class="code">hono-api/src/schemas/</text>
|
||||||
|
<text x="87" y="1245" class="body">请求校验 + JSON 响应</text>
|
||||||
|
<rect x="584" y="1154" width="330" height="113" fill="#cbd5e1"/>
|
||||||
|
<rect x="580" y="1150" width="330" height="113" fill="#fff" stroke="#d6bf82"/>
|
||||||
|
<text x="602" y="1186" class="node">后端生成物</text>
|
||||||
|
<text x="602" y="1218" class="code">hono-api/contracts/api.ts</text>
|
||||||
|
<text x="602" y="1245" class="small">contract:check 检查过期</text>
|
||||||
|
<rect x="1074" y="1154" width="405" height="113" fill="#cbd5e1"/>
|
||||||
|
<rect x="1070" y="1150" width="405" height="113" fill="#fff" stroke="#d6bf82"/>
|
||||||
|
<text x="1092" y="1186" class="node">前端契约快照</text>
|
||||||
|
<text x="1092" y="1218" class="code">src/types/api-contract.ts</text>
|
||||||
|
<text x="1092" y="1245" class="body">业务 API 模块引用这些类型</text>
|
||||||
|
<path d="M 405 1207 H 580" class="build"/>
|
||||||
|
<text x="421" y="1185" class="code">contract:generate</text>
|
||||||
|
<path d="M 910 1207 H 1070" class="build"/>
|
||||||
|
<text x="944" y="1185" class="code">api:sync</text>
|
||||||
|
<text x="1510" y="1187" class="body">跨仓库核对</text>
|
||||||
|
<text x="1510" y="1220" class="code">api:check</text>
|
||||||
|
<text x="1510" y="1248" class="small" style="fill:#64748b">比对两端契约</text>
|
||||||
|
<text x="44" y="1357" class="small" style="fill:#34745d">通信约定</text>
|
||||||
|
<text x="155" y="1357" class="body">snake_case · ISO UTC · 分页 { items, page, page_size, has_more } · 错误 { message, issues? }</text>
|
||||||
|
<text x="44" y="1391" class="small" style="fill:#64748b">当前实现:刷新式加载;批量每次最多 100 个 ID;写请求不自动重试。图中省略页面内部组件与单个数据库索引。</text>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,80 @@
|
|||||||
|
# 目录结构与依赖约定
|
||||||
|
|
||||||
|
按业务功能组织文件,使一次功能修改涉及的页面、组件和状态尽量集中。通信层按下文分工;接口变更与后端配套验证,见[通信架构](api-architecture.md)。
|
||||||
|
|
||||||
|
## 目录职责
|
||||||
|
|
||||||
|
```text
|
||||||
|
src/
|
||||||
|
├── main.ts # 初始化 Pinia、认证和路由
|
||||||
|
├── App.vue # 全局 provider 与应用布局
|
||||||
|
├── router/index.ts # 路由、懒加载、权限守卫与 SEO
|
||||||
|
├── features/
|
||||||
|
│ ├── auth/
|
||||||
|
│ │ ├── authClient.ts # 认证客户端与错误适配
|
||||||
|
│ │ ├── stores/auth.ts
|
||||||
|
│ │ └── views/ # 登录、注册、邮箱验证、密码重置
|
||||||
|
│ ├── clouds/
|
||||||
|
│ │ ├── cloudTypes.ts # 云型常量与名称查询
|
||||||
|
│ │ ├── components/ # 云图详情、编辑、点赞
|
||||||
|
│ │ └── stores/ # clouds.ts、likes.ts
|
||||||
|
│ ├── upload/
|
||||||
|
│ │ ├── components/QuickUploadModal.vue
|
||||||
|
│ │ ├── composables/useUpload.ts
|
||||||
|
│ │ └── views/UploadView.vue
|
||||||
|
│ ├── profile/
|
||||||
|
│ │ ├── components/ContributionHeatmap.vue
|
||||||
|
│ │ ├── stores/profile.ts
|
||||||
|
│ │ └── views/ # 个人主页与账号设置
|
||||||
|
│ ├── encyclopedia/
|
||||||
|
│ │ ├── stores/encyclopedia.ts
|
||||||
|
│ │ └── views/ # 图鉴列表与云型详情
|
||||||
|
│ └── {map,gallery,community,admin,system}/views/
|
||||||
|
├── shared/map/
|
||||||
|
│ ├── amap.ts # 高德加载器
|
||||||
|
│ ├── types/amap.d.ts # 高德类型声明,与同名加载器分开放置
|
||||||
|
│ └── components/ # MapPickerModal、MiniLocationMap
|
||||||
|
├── components/layout/ # 应用外壳:AppHeader
|
||||||
|
├── lib/ # api.ts、api-adapters.ts、pagination.ts、seo.ts、theme.ts
|
||||||
|
├── types/ # 生成的 API 契约、前端模型、路由元数据
|
||||||
|
├── styles/ # 全局设计令牌、基线、共享样式
|
||||||
|
└── style.css # 全局样式入口
|
||||||
|
```
|
||||||
|
|
||||||
|
## 文件归属
|
||||||
|
|
||||||
|
| 修改内容 | 归属位置 |
|
||||||
|
| -------------------------------------- | ------------------------------------------------------------ |
|
||||||
|
| 登录、会话、验证邮件 | `features/auth/` |
|
||||||
|
| 多个页面复用的云图详情、编辑、点赞 | `features/clouds/` |
|
||||||
|
| 上传表单、上传弹窗、文件处理与上传状态 | `features/upload/` |
|
||||||
|
| 用户主页、设置、贡献热力图 | `features/profile/` |
|
||||||
|
| 图鉴列表、云型详情及其状态 | `features/encyclopedia/` |
|
||||||
|
| 首页地图时间轴、标记交互 | `features/map/` |
|
||||||
|
| 通用选点、位置预览、高德加载 | `shared/map/` |
|
||||||
|
| 应用导航和整体布局 | `components/layout/` |
|
||||||
|
| HTTP 请求与响应适配、公共 API 类型 | `lib/api.ts`、`lib/api-adapters.ts`、`types/api-contract.ts` |
|
||||||
|
|
||||||
|
按职责归属文件:快捷上传虽然从地图打开,仍属于上传模块;云图点赞虽然在多个页面使用,仍属于云图业务;选点和小地图仅提供位置能力,放在公共地图模块。
|
||||||
|
|
||||||
|
## 依赖与新增文件
|
||||||
|
|
||||||
|
- 功能模块按需创建 `views/`、`components/`、`stores/`、`composables/`;只有页面的模块保留 `views/` 即可。
|
||||||
|
- 业务组件放在所属功能模块。`components/layout/` 仅存放应用布局,`lib/` 存放公共基础设施。
|
||||||
|
- 功能模块可以依赖公共地图能力、基础设施、公共类型和其他模块的具体组件、store 或 composable。`shared/map/`、`lib/` 和 `types/` 保持独立于业务模块;新增跨模块依赖时避免循环引用。
|
||||||
|
- 使用 `@/features/...`、`@/shared/...` 等具体文件路径,不增加统一导出所有页面和 store 的入口。路由继续在 `router/index.ts` 中动态导入各模块页面,保持按页面懒加载。
|
||||||
|
- 页面与 store 调用所属功能的 `api.ts`,由该模块通过 `lib/api.ts` 发送请求。认证 SDK 调用集中在 `features/auth/authClient.ts` 和认证 store。生成 DTO 在 `types/api-contract.ts`,前端模型在 `types/models.ts` 与 `types/view-models.ts`。
|
||||||
|
- 现有 `clouds` 与 `encyclopedia` store 保留各自的缓存行为;后续如需合并缓存,应作为独立行为变更验证。
|
||||||
|
- 共享视觉规则遵循[样式体系](style-system.md),组件专属样式随组件迁移。
|
||||||
|
|
||||||
|
例如,新增上传进度组件放到 `features/upload/components/`;新增通用地图控件放到 `shared/map/components/`;新增个人主页统计 composable 放到 `features/profile/composables/`。
|
||||||
|
|
||||||
|
## 迁移验证
|
||||||
|
|
||||||
|
移动文件后更新静态 import、路由动态 import 和文档引用,并运行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run check
|
||||||
|
npm run build
|
||||||
|
git diff --check
|
||||||
|
```
|
||||||
+37
-25
@@ -4,17 +4,32 @@
|
|||||||
|
|
||||||
## 分层
|
## 分层
|
||||||
|
|
||||||
| 层级 | 文件 | 职责 |
|
| 层级 | 文件 | 职责 |
|
||||||
| --- | --- | --- |
|
| ---------- | --------------------------- | ----------------------------------------------------- |
|
||||||
| 设计令牌 | `src/styles/tokens.css` | 颜色、字体、渐变、阴影、动效时长等稳定决策 |
|
| 设计令牌 | `src/styles/tokens.css` | 颜色、字体、渐变、阴影、动效时长等稳定决策 |
|
||||||
| 基础规则 | `src/styles/base.css` | 页面基线、选中文本、全局圆角策略 |
|
| 基础规则 | `src/styles/base.css` | 页面基线、选中文本、全局圆角策略 |
|
||||||
| 组件规则 | `src/styles/components.css` | 页面 Hero、容器、表单、面板、按钮等共享语义类 |
|
| 组件规则 | `src/styles/components.css` | 页面 Hero、容器、表单、面板、按钮等共享语义类 |
|
||||||
| 第三方主题 | `src/lib/theme.ts` | Naive UI 的全局主题契约;值应与设计令牌保持一致 |
|
| 第三方主题 | `src/lib/theme.ts` | Naive UI 的全局主题契约;值应与设计令牌保持一致 |
|
||||||
| 单组件样式 | Vue 文件的 `<style scoped>` | 只属于一个功能的滑杆、动画、地图或媒体细节 |
|
| 单组件样式 | Vue 文件的 `<style scoped>` | 只属于一个功能的滑杆、动画、地图或媒体细节 |
|
||||||
| 一次性布局 | Vue 模板中的 Tailwind 类 | flex/grid、间距、响应式排列及确实只出现一次的视觉调整 |
|
| 一次性布局 | Vue 模板中的 Tailwind 类 | flex/grid、间距、响应式排列及确实只出现一次的视觉调整 |
|
||||||
|
|
||||||
`src/style.css` 只负责按以上顺序装配全局样式,不再直接堆放组件规则。
|
`src/style.css` 只负责按以上顺序装配全局样式,不再直接堆放组件规则。
|
||||||
|
|
||||||
|
## 清新绿色策略
|
||||||
|
|
||||||
|
OpenCloud 的绿色应接近清晨的桉叶与嫩叶,而不是灰暗的苔藓色或高饱和的荧光青绿。
|
||||||
|
|
||||||
|
- 品牌、导航与账户交互使用清透但稳重的桉叶绿。
|
||||||
|
- 成功、通过和公开状态使用更偏嫩叶的成功绿色,与品牌色保持区分。
|
||||||
|
- `teal-*` 和 `emerald-*` 是现有模板的兼容类名,实际色值由 `tokens.css` 重映射;不要假定它们仍是 Tailwind 默认色。
|
||||||
|
- 不直接使用 Tailwind 默认 `green-*`、`lime-*`,也不要在组件里写亮绿色十六进制值或 RGB。
|
||||||
|
- 新增绿色前先判断它属于品牌交互还是成功状态,并优先使用已有语义类或设计令牌。
|
||||||
|
|
||||||
|
| 语义 | 主色 | 深色 | 浅色表面 |
|
||||||
|
| --------- | --------- | --------- | --------- |
|
||||||
|
| 品牌/交互 | `#34745d` | `#274c40` | `#f2faf6` |
|
||||||
|
| 成功/通过 | `#4d7f3b` | `#35522c` | `#f4faef` |
|
||||||
|
|
||||||
## 命名规则
|
## 命名规则
|
||||||
|
|
||||||
- 所有共享类使用 `oc-` 前缀,避免与 Naive UI、AMap 和 Tailwind 冲突。
|
- 所有共享类使用 `oc-` 前缀,避免与 Naive UI、AMap 和 Tailwind 冲突。
|
||||||
@@ -29,26 +44,26 @@
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<section class="oc-page-hero">
|
<section class="oc-page-hero">
|
||||||
<div class="oc-container oc-container--content oc-page-hero__inner">
|
<div class="oc-container oc-container--content oc-page-hero__inner">
|
||||||
<p class="oc-page-eyebrow">Cloud Upload</p>
|
<p class="oc-page-eyebrow">Cloud Upload</p>
|
||||||
<h1 class="oc-page-title">上传云图</h1>
|
<h1 class="oc-page-title">上传云图</h1>
|
||||||
<p class="oc-page-description">页面描述</p>
|
<p class="oc-page-description">页面描述</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<main class="oc-container oc-container--content oc-page-content">
|
<main class="oc-container oc-container--content oc-page-content">
|
||||||
<!-- 页面内容 -->
|
<!-- 页面内容 -->
|
||||||
</main>
|
</main>
|
||||||
```
|
```
|
||||||
|
|
||||||
容器宽度只有三个语义档位:`oc-container--narrow`、`oc-container--content`、`oc-container--wide`。不要在同类页面重复手写 `max-w-* mx-auto px-*`。
|
容器宽度只有三个语义档位:`oc-container--narrow`、`oc-container--content`、`oc-container--wide`。不要在同类页面重复手写 `max-w-* mx-auto px-*`。
|
||||||
|
|
||||||
|
Hero 同时包含左侧介绍和右侧状态卡时,使用 `oc-page-hero__split`。它会在有效视口达到 `900px` 时启用接近均衡的双栏,避免浏览器缩放到 125% 后过早堆叠;需要两栏等高时同时添加 `oc-page-hero__split--stretch`。
|
||||||
|
|
||||||
### 表单
|
### 表单
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<label class="oc-field-label">
|
<label class="oc-field-label"> 拍摄时间 <span class="oc-field-required">*</span> </label>
|
||||||
拍摄时间 <span class="oc-field-required">*</span>
|
|
||||||
</label>
|
|
||||||
<input class="oc-field-control" />
|
<input class="oc-field-control" />
|
||||||
<p class="oc-field-help">补充说明</p>
|
<p class="oc-field-help">补充说明</p>
|
||||||
<p class="oc-field-error">错误信息</p>
|
<p class="oc-field-error">错误信息</p>
|
||||||
@@ -61,7 +76,8 @@
|
|||||||
- `oc-section-label`:详情面板中的字段标题。
|
- `oc-section-label`:详情面板中的字段标题。
|
||||||
- `oc-stat-label` / `oc-stat-value`:统计数据的标签和值。
|
- `oc-stat-label` / `oc-stat-value`:统计数据的标签和值。
|
||||||
- `oc-inset-panel`:详情中的浅色信息块。
|
- `oc-inset-panel`:详情中的浅色信息块。
|
||||||
- `oc-panel-card` / `oc-panel-card-soft`:Naive UI 卡片的硬阴影。
|
- `oc-panel-card` / `oc-panel-card-soft` / `oc-panel-card-xl`:普通、柔和和大型卡片的硬阴影。
|
||||||
|
- `oc-floating-panel` / `oc-modal-shell`:浮动菜单与普通方形弹窗的共享表面。
|
||||||
- `oc-surface`:普通 HTML 容器的标准白色表面。
|
- `oc-surface`:普通 HTML 容器的标准白色表面。
|
||||||
- `oc-empty-card`:空状态表面。
|
- `oc-empty-card`:空状态表面。
|
||||||
|
|
||||||
@@ -70,15 +86,11 @@
|
|||||||
Naive UI 按钮继续使用 `type="default"`,视觉语义由共享类控制:
|
Naive UI 按钮继续使用 `type="default"`,视觉语义由共享类控制:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<NButton class="oc-panel-button oc-panel-button--neutral" type="default">
|
<NButton class="oc-panel-button oc-panel-button--neutral" type="default"> 取消 </NButton>
|
||||||
取消
|
<NButton class="oc-panel-button oc-panel-button--sky" type="default"> 保存 </NButton>
|
||||||
</NButton>
|
|
||||||
<NButton class="oc-panel-button oc-panel-button--sky" type="default">
|
|
||||||
保存
|
|
||||||
</NButton>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
页面级主操作使用 `oc-primary-button`;面板内操作使用 `oc-panel-button`。可用变体为 `neutral`、`sky`、`teal`、`amber`、`danger`,不要临时创建新的强调色。
|
页面级主操作使用 `oc-primary-button`;面板内操作使用 `oc-panel-button`。可用变体为 `neutral`、`sky`、`teal`、`amber`、`danger`,不要临时创建新的强调色。其中 `teal` 是兼容命名,视觉上使用的是清新桉叶绿。
|
||||||
|
|
||||||
## 新增或修改样式的决策顺序
|
## 新增或修改样式的决策顺序
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import js from '@eslint/js'
|
||||||
|
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||||
|
import prettier from 'eslint-config-prettier/flat'
|
||||||
|
import vue from 'eslint-plugin-vue'
|
||||||
|
import globals from 'globals'
|
||||||
|
import ts from 'typescript-eslint'
|
||||||
|
|
||||||
|
export default defineConfig([
|
||||||
|
globalIgnores([
|
||||||
|
'dist/**',
|
||||||
|
'dist-ssr/**',
|
||||||
|
'coverage/**',
|
||||||
|
'.agents/**',
|
||||||
|
'.codex/**',
|
||||||
|
'.claude/**',
|
||||||
|
]),
|
||||||
|
{
|
||||||
|
files: ['**/*.{js,mjs,cjs,ts,mts,cts,vue}'],
|
||||||
|
extends: [js.configs.recommended],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*.{ts,mts,cts,vue}'],
|
||||||
|
extends: [ts.configs.recommended],
|
||||||
|
rules: {
|
||||||
|
// vue-tsc checks undefined names, including ambient types in Vue scripts.
|
||||||
|
'no-undef': 'off',
|
||||||
|
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*.vue'],
|
||||||
|
extends: [vue.configs['flat/recommended']],
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
parser: ts.parser,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['src/**/*.{js,ts,vue}'],
|
||||||
|
languageOptions: {
|
||||||
|
globals: globals.browser,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: [
|
||||||
|
'*.{js,mjs,cjs,ts,mts,cts}',
|
||||||
|
'scripts/**/*.{js,mjs,cjs,ts,mts,cts}',
|
||||||
|
'tests/**/*.mjs',
|
||||||
|
],
|
||||||
|
languageOptions: {
|
||||||
|
globals: globals.node,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['src/features/**/*.{ts,vue}'],
|
||||||
|
ignores: ['src/features/*/api.ts', 'src/features/auth/authClient.ts'],
|
||||||
|
rules: {
|
||||||
|
'no-restricted-imports': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
paths: [
|
||||||
|
{
|
||||||
|
name: '@/lib/api',
|
||||||
|
importNames: ['apiRequest'],
|
||||||
|
message: '请通过所属业务的 api.ts 调用接口。',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Keep formatting in Prettier; this must follow the rule presets.
|
||||||
|
prettier,
|
||||||
|
])
|
||||||
+11
-11
@@ -1,14 +1,14 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" sizes="any" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" sizes="any" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta name="description" content="OpenCloud - 活的天空地图,拍云、识别、收藏" />
|
<meta name="description" content="OpenCloud - 活的天空地图,拍云、识别、收藏" />
|
||||||
<title>OpenCloud</title>
|
<title>OpenCloud</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Generated
+1789
File diff suppressed because it is too large
Load Diff
+49
-31
@@ -1,33 +1,51 @@
|
|||||||
{
|
{
|
||||||
"name": "opencloud",
|
"name": "opencloud",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"check:styles": "node scripts/check-style-system.mjs",
|
"lint": "eslint . --max-warnings=0",
|
||||||
"build": "vue-tsc -b && vite build",
|
"lint:fix": "eslint . --fix --max-warnings=0",
|
||||||
"preview": "vite preview"
|
"format": "prettier --write .",
|
||||||
},
|
"format:check": "prettier --check .",
|
||||||
"dependencies": {
|
"typecheck": "vue-tsc -b",
|
||||||
"@amap/amap-jsapi-loader": "^1.0.1",
|
"check": "npm run lint && npm run format:check && npm run check:styles && npm run typecheck && npm test",
|
||||||
"@vercel/speed-insights": "^2.0.0",
|
"check:styles": "node scripts/check-style-system.mjs",
|
||||||
"naive-ui": "^2.44.1",
|
"build": "vue-tsc -b && vite build",
|
||||||
"pinia": "^3.0.4",
|
"preview": "vite preview",
|
||||||
"vue": "^3.5.34",
|
"api:sync": "node scripts/sync-api-contract.mjs",
|
||||||
"vue-router": "^4.5.0"
|
"api:check": "node scripts/sync-api-contract.mjs --check",
|
||||||
},
|
"test": "node --import ./scripts/test-resolver.mjs --test tests/*.test.mjs"
|
||||||
"devDependencies": {
|
},
|
||||||
"@tailwindcss/vite": "^4.3.3",
|
"dependencies": {
|
||||||
"@types/node": "^24.12.3",
|
"@amap/amap-jsapi-loader": "^1.0.1",
|
||||||
"@vercel/analytics": "^2.0.1",
|
"@vercel/speed-insights": "^2.0.0",
|
||||||
"@vicons/tabler": "^0.13.0",
|
"better-auth": "^1.7.6",
|
||||||
"@vicons/utils": "^0.1.4",
|
"naive-ui": "^2.44.1",
|
||||||
"@vitejs/plugin-vue": "^6.0.6",
|
"pinia": "^3.0.4",
|
||||||
"@vue/tsconfig": "^0.9.1",
|
"vue": "^3.5.34",
|
||||||
"tailwindcss": "^4.3.3",
|
"vue-router": "^4.5.0"
|
||||||
"typescript": "~6.0.2",
|
},
|
||||||
"vite": "^8.0.16",
|
"devDependencies": {
|
||||||
"vue-tsc": "^3.2.8"
|
"@eslint/js": "10.0.1",
|
||||||
}
|
"@tailwindcss/vite": "^4.3.3",
|
||||||
|
"@types/node": "^24.12.3",
|
||||||
|
"@vercel/analytics": "^2.0.1",
|
||||||
|
"@vicons/tabler": "^0.13.0",
|
||||||
|
"@vicons/utils": "^0.1.4",
|
||||||
|
"@vitejs/plugin-vue": "^6.0.6",
|
||||||
|
"@vue/tsconfig": "^0.9.1",
|
||||||
|
"eslint": "10.11.0",
|
||||||
|
"eslint-config-prettier": "10.1.8",
|
||||||
|
"eslint-plugin-vue": "10.11.1",
|
||||||
|
"globals": "17.12.0",
|
||||||
|
"prettier": "3.9.9",
|
||||||
|
"tailwindcss": "^4.3.3",
|
||||||
|
"typescript": "~6.0.2",
|
||||||
|
"typescript-eslint": "8.71.0",
|
||||||
|
"vite": "^8.0.16",
|
||||||
|
"vue-eslint-parser": "10.4.1",
|
||||||
|
"vue-tsc": "^3.2.8"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,85 +5,118 @@ const projectRoot = new URL('..', import.meta.url)
|
|||||||
const sourceRoot = new URL('../src', import.meta.url)
|
const sourceRoot = new URL('../src', import.meta.url)
|
||||||
|
|
||||||
const deprecatedPatterns = [
|
const deprecatedPatterns = [
|
||||||
{
|
{
|
||||||
pattern: /\b(?:bg|border|ring|text)-(?:gray|indigo|purple|violet)-\d+\b/g,
|
pattern: /\b(?:bg|border|ring|text)-(?:gray|indigo|purple|violet)-\d+\b/g,
|
||||||
message: '使用项目约定的 slate/sky/teal 语义色,不要重新引入灰色或紫色系。',
|
message: '使用项目约定的 slate/sky/自然绿色语义色,不要重新引入灰色或紫色系。',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: /text-xs uppercase tracking-\[0\.18em\] text-slate-500/g,
|
pattern: /\b(?:bg|border|ring|text)-(?:green|lime)-\d+\b/g,
|
||||||
message: '重复的小节标签应使用 oc-section-label。',
|
message:
|
||||||
},
|
'绿色必须使用项目重映射后的 teal 品牌色或 emerald 成功色,不要引入默认 green/lime 荧光色。',
|
||||||
{
|
},
|
||||||
pattern: /border border-slate-200 bg-slate-50 p-4/g,
|
{
|
||||||
message: '标准内嵌信息面板应使用 oc-inset-panel。',
|
pattern: /#(?:f0fdfa|ccfbf1|99f6e4|5eead4|2dd4bf|14b8a6|0d9488|0f766e|115e59|134e4a)\b/gi,
|
||||||
},
|
message: '检测到旧版高饱和 teal 色值,请改用自然绿色设计令牌。',
|
||||||
{
|
},
|
||||||
pattern: /border-b border-sky-100 bg-\[linear-gradient\(180deg,#e0f2fe_0%,#f8fafc_100%\)\]/g,
|
{
|
||||||
message: '标准页面头部应使用 oc-page-hero。',
|
pattern: /#(?:c084fc|a855f7|9333ea|7e22ce)\b/gi,
|
||||||
},
|
message: '检测到禁用的紫色硬编码,请改用 rose 或项目语义令牌。',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern: /#(?:1f2937|9ca3af)\b/gi,
|
||||||
|
message: '检测到默认 gray 调色板硬编码,请改用对应的 slate 色值或语义令牌。',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern: /#60a5fa\b/gi,
|
||||||
|
message: '检测到默认 blue-400 硬编码,请按用途改用 sky 或 amber 等项目语义色。',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern: /text-xs uppercase tracking-\[0\.18em\] text-slate-500/g,
|
||||||
|
message: '重复的小节标签应使用 oc-section-label。',
|
||||||
|
vueOnly: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern: /border border-slate-200 bg-slate-50 p-4/g,
|
||||||
|
message: '标准内嵌信息面板应使用 oc-inset-panel。',
|
||||||
|
vueOnly: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern:
|
||||||
|
/border-b border-sky-100 bg-\[linear-gradient\(180deg,#e0f2fe_0%,#f8fafc_100%\)\]/g,
|
||||||
|
message: '标准页面头部应使用 oc-page-hero。',
|
||||||
|
vueOnly: true,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
async function collectVueFiles(directory) {
|
const styleSourceExtensions = new Set(['.vue', '.css', '.ts'])
|
||||||
const entries = await readdir(directory, { withFileTypes: true })
|
|
||||||
const files = await Promise.all(entries.map(async (entry) => {
|
|
||||||
const path = join(directory, entry.name)
|
|
||||||
return entry.isDirectory() ? collectVueFiles(path) : [path]
|
|
||||||
}))
|
|
||||||
|
|
||||||
return files.flat().filter((path) => extname(path) === '.vue')
|
async function collectStyleSourceFiles(directory) {
|
||||||
|
const entries = await readdir(directory, { withFileTypes: true })
|
||||||
|
const files = await Promise.all(
|
||||||
|
entries.map(async entry => {
|
||||||
|
const path = join(directory, entry.name)
|
||||||
|
return entry.isDirectory() ? collectStyleSourceFiles(path) : [path]
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
return files.flat().filter(path => styleSourceExtensions.has(extname(path)))
|
||||||
}
|
}
|
||||||
|
|
||||||
function lineNumberAt(source, index) {
|
function lineNumberAt(source, index) {
|
||||||
return source.slice(0, index).split('\n').length
|
return source.slice(0, index).split('\n').length
|
||||||
}
|
}
|
||||||
|
|
||||||
const violations = []
|
const violations = []
|
||||||
|
|
||||||
for (const file of await collectVueFiles(sourceRoot.pathname)) {
|
for (const file of await collectStyleSourceFiles(sourceRoot.pathname)) {
|
||||||
const source = await readFile(file, 'utf8')
|
const source = await readFile(file, 'utf8')
|
||||||
|
|
||||||
for (const rule of deprecatedPatterns) {
|
for (const rule of deprecatedPatterns) {
|
||||||
for (const match of source.matchAll(rule.pattern)) {
|
if (rule.vueOnly && extname(file) !== '.vue') continue
|
||||||
violations.push({
|
|
||||||
file: relative(projectRoot.pathname, file),
|
|
||||||
line: lineNumberAt(source, match.index),
|
|
||||||
message: rule.message,
|
|
||||||
value: match[0],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const match of source.matchAll(/(?:^|\s)class="([^"]+)"/gm)) {
|
for (const match of source.matchAll(rule.pattern)) {
|
||||||
const classes = match[1].split(/\s+/)
|
violations.push({
|
||||||
const panelModifier = classes.some((name) => name.startsWith('oc-panel-button--'))
|
file: relative(projectRoot.pathname, file),
|
||||||
const primaryModifier = classes.some((name) => name.startsWith('oc-primary-button--'))
|
line: lineNumberAt(source, match.index),
|
||||||
|
message: rule.message,
|
||||||
if (panelModifier && !classes.includes('oc-panel-button')) {
|
value: match[0],
|
||||||
violations.push({
|
})
|
||||||
file: relative(projectRoot.pathname, file),
|
}
|
||||||
line: lineNumberAt(source, match.index),
|
|
||||||
message: 'oc-panel-button 修饰类必须与基础类一起使用。',
|
|
||||||
value: match[0],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (primaryModifier && !classes.includes('oc-primary-button')) {
|
for (const match of source.matchAll(/(?:^|\s)class="([^"]+)"/gm)) {
|
||||||
violations.push({
|
const classes = match[1].split(/\s+/)
|
||||||
file: relative(projectRoot.pathname, file),
|
const panelModifier = classes.some(name => name.startsWith('oc-panel-button--'))
|
||||||
line: lineNumberAt(source, match.index),
|
const primaryModifier = classes.some(name => name.startsWith('oc-primary-button--'))
|
||||||
message: 'oc-primary-button 修饰类必须与基础类一起使用。',
|
|
||||||
value: match[0],
|
if (panelModifier && !classes.includes('oc-panel-button')) {
|
||||||
})
|
violations.push({
|
||||||
|
file: relative(projectRoot.pathname, file),
|
||||||
|
line: lineNumberAt(source, match.index),
|
||||||
|
message: 'oc-panel-button 修饰类必须与基础类一起使用。',
|
||||||
|
value: match[0],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (primaryModifier && !classes.includes('oc-primary-button')) {
|
||||||
|
violations.push({
|
||||||
|
file: relative(projectRoot.pathname, file),
|
||||||
|
line: lineNumberAt(source, match.index),
|
||||||
|
message: 'oc-primary-button 修饰类必须与基础类一起使用。',
|
||||||
|
value: match[0],
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (violations.length > 0) {
|
if (violations.length > 0) {
|
||||||
console.error('样式体系检查失败:')
|
console.error('样式体系检查失败:')
|
||||||
for (const violation of violations) {
|
for (const violation of violations) {
|
||||||
console.error(`- ${violation.file}:${violation.line} ${violation.message} (${violation.value})`)
|
console.error(
|
||||||
}
|
`- ${violation.file}:${violation.line} ${violation.message} (${violation.value})`,
|
||||||
process.exitCode = 1
|
)
|
||||||
|
}
|
||||||
|
process.exitCode = 1
|
||||||
} else {
|
} else {
|
||||||
console.log('样式体系检查通过。')
|
console.log('样式体系检查通过。')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { readFile, writeFile } from 'node:fs/promises'
|
||||||
|
import { resolve } from 'node:path'
|
||||||
|
import { format, resolveConfig } from 'prettier'
|
||||||
|
|
||||||
|
const source = resolve(process.env.OPENCLOUD_API_DIR || '../hono-api', 'contracts/api.ts')
|
||||||
|
const target = resolve('src/types/api-contract.ts')
|
||||||
|
const output = await format(await readFile(source, 'utf8'), {
|
||||||
|
...(await resolveConfig(target)),
|
||||||
|
filepath: target,
|
||||||
|
})
|
||||||
|
if (process.argv.includes('--check')) {
|
||||||
|
if ((await readFile(target, 'utf8')) !== output) {
|
||||||
|
throw new Error('API 契约已变化,请先在后端生成,再运行 npm run api:sync')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await writeFile(target, output)
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { registerHooks } from 'node:module'
|
||||||
|
import { existsSync } from 'node:fs'
|
||||||
|
|
||||||
|
const source = new URL('../src/', import.meta.url)
|
||||||
|
registerHooks({
|
||||||
|
resolve(specifier, context, nextResolve) {
|
||||||
|
if (specifier.startsWith('@/')) {
|
||||||
|
return nextResolve(new URL(`${specifier.slice(2)}.ts`, source).href, context)
|
||||||
|
}
|
||||||
|
if (specifier.startsWith('.') && context.parentURL?.startsWith(source.href)) {
|
||||||
|
const candidate = new URL(`${specifier}.ts`, context.parentURL)
|
||||||
|
if (existsSync(candidate)) return nextResolve(candidate.href, context)
|
||||||
|
}
|
||||||
|
return nextResolve(specifier, context)
|
||||||
|
},
|
||||||
|
})
|
||||||
@@ -1,6 +1,17 @@
|
|||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"skills": {
|
"skills": {
|
||||||
|
"amap-jsapi-skill": {
|
||||||
|
"source": "clawhub.ai",
|
||||||
|
"sourceType": "well-known",
|
||||||
|
"computedHash": "289808e56798f1cd3241f9ab227d0ab41c9ec0d85d853991b30ad61be187d685"
|
||||||
|
},
|
||||||
|
"find-skills": {
|
||||||
|
"source": "vercel-labs/skills",
|
||||||
|
"sourceType": "github",
|
||||||
|
"skillPath": "skills/find-skills/SKILL.md",
|
||||||
|
"computedHash": "913b9d37d0d54047dd65222bb8c67b2bf04e3cb87dcad1729068d7a8b2c8c396"
|
||||||
|
},
|
||||||
"git-commit": {
|
"git-commit": {
|
||||||
"source": "github/awesome-copilot",
|
"source": "github/awesome-copilot",
|
||||||
"sourceType": "github",
|
"sourceType": "github",
|
||||||
|
|||||||
+34
-23
@@ -1,30 +1,41 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { NConfigProvider, NDialogProvider, NGlobalStyle, NMessageProvider, NNotificationProvider } from 'naive-ui'
|
import { computed } from 'vue'
|
||||||
|
import {
|
||||||
|
NConfigProvider,
|
||||||
|
NDialogProvider,
|
||||||
|
NGlobalStyle,
|
||||||
|
NMessageProvider,
|
||||||
|
NNotificationProvider,
|
||||||
|
} from 'naive-ui'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
import AppHeader from '@/components/layout/AppHeader.vue'
|
import AppHeader from '@/components/layout/AppHeader.vue'
|
||||||
import { openCloudThemeOverrides } from '@/lib/theme'
|
import { openCloudThemeOverrides } from '@/lib/theme'
|
||||||
import { Analytics } from "@vercel/analytics/vue"
|
import { Analytics } from '@vercel/analytics/vue'
|
||||||
import { SpeedInsights } from "@vercel/speed-insights/vue"
|
import { SpeedInsights } from '@vercel/speed-insights/vue'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const showAppHeader = computed(() => route.name !== 'admin')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NConfigProvider :theme-overrides="openCloudThemeOverrides">
|
<NConfigProvider :theme-overrides="openCloudThemeOverrides">
|
||||||
<NGlobalStyle />
|
<NGlobalStyle />
|
||||||
<NDialogProvider>
|
<NDialogProvider>
|
||||||
<NNotificationProvider>
|
<NNotificationProvider>
|
||||||
<NMessageProvider>
|
<NMessageProvider>
|
||||||
<div class="oc-app-shell">
|
<div class="oc-app-shell">
|
||||||
<AppHeader />
|
<AppHeader v-if="showAppHeader" />
|
||||||
<main class="relative flex-1">
|
<main class="relative flex-1">
|
||||||
<div class="oc-app-grid"></div>
|
<div class="oc-app-grid"></div>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<RouterView />
|
<RouterView />
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</NMessageProvider>
|
</NMessageProvider>
|
||||||
</NNotificationProvider>
|
</NNotificationProvider>
|
||||||
</NDialogProvider>
|
</NDialogProvider>
|
||||||
</NConfigProvider>
|
</NConfigProvider>
|
||||||
<Analytics />
|
<Analytics />
|
||||||
<SpeedInsights />
|
<SpeedInsights />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,272 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import { NAlert, NButton } from 'naive-ui'
|
|
||||||
import MapPickerModal from '@/components/cloud/MapPickerModal.vue'
|
|
||||||
import type { CloudType } from '@/types/database'
|
|
||||||
|
|
||||||
export interface CloudEditFormValue {
|
|
||||||
cloudCategoryId: number | 'other' | null
|
|
||||||
customCloudType: string
|
|
||||||
capturedAt: string
|
|
||||||
latitude: number | null
|
|
||||||
longitude: number | null
|
|
||||||
locationName: string
|
|
||||||
description: string
|
|
||||||
isPublic: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
|
||||||
open: boolean
|
|
||||||
saving?: boolean
|
|
||||||
error?: string
|
|
||||||
cloudTypes: CloudType[]
|
|
||||||
initialValue: CloudEditFormValue | null
|
|
||||||
}>(), {
|
|
||||||
saving: false,
|
|
||||||
error: '',
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
close: []
|
|
||||||
save: [value: CloudEditFormValue]
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const form = ref<CloudEditFormValue>(createEmptyForm())
|
|
||||||
const mapPickerOpen = ref(false)
|
|
||||||
|
|
||||||
const hasCoordinates = computed(() => form.value.latitude !== null || form.value.longitude !== null)
|
|
||||||
|
|
||||||
function createEmptyForm(): CloudEditFormValue {
|
|
||||||
return {
|
|
||||||
cloudCategoryId: null,
|
|
||||||
customCloudType: '',
|
|
||||||
capturedAt: '',
|
|
||||||
latitude: null,
|
|
||||||
longitude: null,
|
|
||||||
locationName: '',
|
|
||||||
description: '',
|
|
||||||
isPublic: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function cloneForm(value: CloudEditFormValue | null) {
|
|
||||||
return value ? { ...value } : createEmptyForm()
|
|
||||||
}
|
|
||||||
|
|
||||||
function onCategoryChange(event: Event) {
|
|
||||||
const value = (event.target as HTMLSelectElement).value
|
|
||||||
if (value === 'other') {
|
|
||||||
form.value.cloudCategoryId = 'other'
|
|
||||||
} else if (!value) {
|
|
||||||
form.value.cloudCategoryId = null
|
|
||||||
} else {
|
|
||||||
form.value.cloudCategoryId = Number(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onLatInput(event: Event) {
|
|
||||||
const value = Number.parseFloat((event.target as HTMLInputElement).value)
|
|
||||||
form.value.latitude = Number.isNaN(value) ? null : value
|
|
||||||
}
|
|
||||||
|
|
||||||
function onLngInput(event: Event) {
|
|
||||||
const value = Number.parseFloat((event.target as HTMLInputElement).value)
|
|
||||||
form.value.longitude = Number.isNaN(value) ? null : value
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearCoordinates() {
|
|
||||||
form.value.latitude = null
|
|
||||||
form.value.longitude = null
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirmMapPicker(payload: { latitude: number; longitude: number }) {
|
|
||||||
form.value.latitude = payload.latitude
|
|
||||||
form.value.longitude = payload.longitude
|
|
||||||
mapPickerOpen.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
function close() {
|
|
||||||
emit('close')
|
|
||||||
}
|
|
||||||
|
|
||||||
function save() {
|
|
||||||
emit('save', { ...form.value })
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(() => props.open, open => {
|
|
||||||
if (open) {
|
|
||||||
form.value = cloneForm(props.initialValue)
|
|
||||||
} else {
|
|
||||||
mapPickerOpen.value = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(() => props.initialValue, value => {
|
|
||||||
if (props.open) {
|
|
||||||
form.value = cloneForm(value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Teleport to="body">
|
|
||||||
<div
|
|
||||||
v-if="open"
|
|
||||||
class="fixed inset-0 z-[130] flex items-center justify-center bg-slate-950/60 px-4 py-6"
|
|
||||||
@click="close"
|
|
||||||
>
|
|
||||||
<div class="w-full max-w-2xl bg-white shadow-2xl" @click.stop>
|
|
||||||
<div class="flex items-start justify-between border-b border-slate-200 px-6 py-5">
|
|
||||||
<div>
|
|
||||||
<h3 class="text-xl font-semibold text-slate-900">编辑图片信息</h3>
|
|
||||||
<p class="oc-field-help">修改后会同步影响个人主页、画廊和地图中的展示。</p>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="p-2 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700"
|
|
||||||
@click="close"
|
|
||||||
>
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="max-h-[70vh] overflow-y-auto px-6 py-5">
|
|
||||||
<NAlert
|
|
||||||
v-if="error"
|
|
||||||
class="mb-5"
|
|
||||||
type="error"
|
|
||||||
:show-icon="false"
|
|
||||||
:bordered="false"
|
|
||||||
>
|
|
||||||
{{ error }}
|
|
||||||
</NAlert>
|
|
||||||
|
|
||||||
<div class="grid gap-5">
|
|
||||||
<div>
|
|
||||||
<label class="oc-field-label">类别</label>
|
|
||||||
<select
|
|
||||||
:value="form.cloudCategoryId ?? ''"
|
|
||||||
class="oc-field-control"
|
|
||||||
@change="onCategoryChange"
|
|
||||||
>
|
|
||||||
<option value="" disabled>请选择</option>
|
|
||||||
<option v-for="ct in cloudTypes" :key="ct.id" :value="ct.id">
|
|
||||||
{{ ct.name }}({{ ct.name_en }})
|
|
||||||
</option>
|
|
||||||
<option value="other">其他</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="form.cloudCategoryId === 'other'">
|
|
||||||
<label class="oc-field-label">自定义云型</label>
|
|
||||||
<input
|
|
||||||
v-model="form.customCloudType"
|
|
||||||
type="text"
|
|
||||||
class="oc-field-control"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="oc-field-label">拍摄时间</label>
|
|
||||||
<input
|
|
||||||
v-model="form.capturedAt"
|
|
||||||
type="datetime-local"
|
|
||||||
class="oc-field-control"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="oc-field-label">位置名称</label>
|
|
||||||
<input
|
|
||||||
v-model="form.locationName"
|
|
||||||
type="text"
|
|
||||||
class="oc-field-control"
|
|
||||||
placeholder="如:北京、成都"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<div class="mb-1 flex items-center justify-between gap-3">
|
|
||||||
<label class="oc-field-label mb-0">经纬度</label>
|
|
||||||
<button
|
|
||||||
v-if="hasCoordinates"
|
|
||||||
type="button"
|
|
||||||
class="text-xs font-medium text-slate-400 transition-colors hover:text-slate-700"
|
|
||||||
@click="clearCoordinates"
|
|
||||||
>
|
|
||||||
清空
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-2">
|
|
||||||
<input
|
|
||||||
:value="form.latitude !== null ? form.latitude : ''"
|
|
||||||
type="number"
|
|
||||||
step="any"
|
|
||||||
placeholder="纬度"
|
|
||||||
class="oc-field-control"
|
|
||||||
@input="onLatInput"
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
:value="form.longitude !== null ? form.longitude : ''"
|
|
||||||
type="number"
|
|
||||||
step="any"
|
|
||||||
placeholder="经度"
|
|
||||||
class="oc-field-control"
|
|
||||||
@input="onLngInput"
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="flex h-10 w-10 items-center justify-center border border-sky-200 bg-sky-50 text-sky-700 transition-colors hover:bg-sky-100"
|
|
||||||
title="地图选点"
|
|
||||||
aria-label="地图选点"
|
|
||||||
@click="mapPickerOpen = true"
|
|
||||||
>
|
|
||||||
<span class="text-lg leading-none">🗺️</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="oc-field-label">图片描述</label>
|
|
||||||
<textarea
|
|
||||||
v-model="form.description"
|
|
||||||
rows="4"
|
|
||||||
class="w-full resize-none border border-slate-300 px-3 py-2.5 text-sm focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-500"
|
|
||||||
placeholder="描述一下这张图片..."
|
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label class="flex items-center justify-between gap-4 border border-slate-200 bg-slate-50 px-4 py-3">
|
|
||||||
<span>
|
|
||||||
<span class="block text-sm font-medium text-slate-800">公开展示</span>
|
|
||||||
<span class="mt-1 block text-xs text-slate-500">关闭后不会出现在画廊、地图和公开主页中。</span>
|
|
||||||
</span>
|
|
||||||
<input
|
|
||||||
v-model="form.isPublic"
|
|
||||||
type="checkbox"
|
|
||||||
class="h-5 w-5 border-slate-300 text-sky-500 focus:ring-sky-500"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4">
|
|
||||||
<NButton secondary strong type="default" class="oc-panel-button oc-panel-button--neutral" @click="close">取消</NButton>
|
|
||||||
<NButton type="default" secondary strong class="oc-panel-button oc-panel-button--sky" :loading="saving" @click="save">
|
|
||||||
保存修改
|
|
||||||
</NButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Teleport>
|
|
||||||
|
|
||||||
<MapPickerModal
|
|
||||||
:open="mapPickerOpen"
|
|
||||||
:latitude="form.latitude"
|
|
||||||
:longitude="form.longitude"
|
|
||||||
description="点击地图即可回填这张图片的经纬度。"
|
|
||||||
footer-text="保存时会继续做模糊化处理。"
|
|
||||||
@close="mapPickerOpen = false"
|
|
||||||
@confirm="confirmMapPicker"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { computed } from 'vue'
|
|
||||||
import { NCard, NProgress } from 'naive-ui'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
unlockedCount: number
|
|
||||||
totalCount: number
|
|
||||||
percent: number
|
|
||||||
isLoggedIn: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
function lerpHex(a: string, b: string, t: number) {
|
|
||||||
const ah = parseInt(a.slice(1), 16)
|
|
||||||
const bh = parseInt(b.slice(1), 16)
|
|
||||||
const r = Math.round(((ah >> 16) & 0xff) + (((bh >> 16) & 0xff) - ((ah >> 16) & 0xff)) * t)
|
|
||||||
const g = Math.round(((ah >> 8) & 0xff) + (((bh >> 8) & 0xff) - ((ah >> 8) & 0xff)) * t)
|
|
||||||
const bv = Math.round((ah & 0xff) + ((bh & 0xff) - (ah & 0xff)) * t)
|
|
||||||
return `#${((r << 16) | (g << 8) | bv).toString(16).padStart(6, '0')}`
|
|
||||||
}
|
|
||||||
|
|
||||||
function progressColor(pct: number) {
|
|
||||||
const t = Math.min(1, Math.max(0, pct / 100))
|
|
||||||
if (t <= 0.5) return lerpHex('#0ea5e9', '#f59e0b', t * 2)
|
|
||||||
return lerpHex('#f59e0b', '#ef4444', (t - 0.5) * 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
const progressText = computed(() => `${props.unlockedCount}/${props.totalCount}`)
|
|
||||||
const currentColor = computed(() => progressColor(props.isLoggedIn ? props.percent : 0))
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<NCard class="oc-panel-card-soft border border-white/80 bg-white/85 shadow-sm backdrop-blur" :bordered="false">
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<div>
|
|
||||||
<p class="text-sm text-slate-500">当前进度</p>
|
|
||||||
<p class="mt-1 text-3xl font-bold" :style="{ color: currentColor }">{{ progressText }}</p>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="flex h-16 w-16 items-center justify-center border text-xl font-semibold text-white transition-colors duration-500"
|
|
||||||
:style="{ backgroundColor: currentColor, borderColor: currentColor }"
|
|
||||||
>
|
|
||||||
{{ isLoggedIn ? percent : 0 }}%
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<NProgress
|
|
||||||
class="mt-5"
|
|
||||||
type="line"
|
|
||||||
:show-indicator="false"
|
|
||||||
:percentage="isLoggedIn ? percent : 0"
|
|
||||||
:color="{ stops: ['#0ea5e9', currentColor] }"
|
|
||||||
:height="12"
|
|
||||||
rail-color="#e2e8f0"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<p class="mt-4 text-sm text-slate-500">
|
|
||||||
<template v-if="isLoggedIn">
|
|
||||||
已解锁 {{ unlockedCount }} 枚徽章,还差 {{ Math.max(totalCount - unlockedCount, 0) }} 枚。
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
登录后可同步你的个人图鉴进度。
|
|
||||||
</template>
|
|
||||||
</p>
|
|
||||||
</NCard>
|
|
||||||
</template>
|
|
||||||
@@ -1,307 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { InfoCircle, X } from '@vicons/tabler'
|
|
||||||
import { NIcon } from 'naive-ui'
|
|
||||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
|
||||||
open: boolean
|
|
||||||
imageUrl: string
|
|
||||||
thumbnailUrl?: string | null
|
|
||||||
imageAlt: string
|
|
||||||
title: string
|
|
||||||
subtitle?: string
|
|
||||||
badgeLabel?: string
|
|
||||||
badgeClass?: string
|
|
||||||
panelWidth?: string
|
|
||||||
}>(), {
|
|
||||||
subtitle: '',
|
|
||||||
thumbnailUrl: null,
|
|
||||||
badgeLabel: '',
|
|
||||||
badgeClass: '',
|
|
||||||
panelWidth: '',
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
close: []
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const infoOpen = ref(false)
|
|
||||||
const imageLoaded = ref(false)
|
|
||||||
const previewLoaded = ref(false)
|
|
||||||
const naturalWidth = ref(0)
|
|
||||||
const naturalHeight = ref(0)
|
|
||||||
const viewportWidth = ref(0)
|
|
||||||
const viewportHeight = ref(0)
|
|
||||||
const modalVisible = ref(false)
|
|
||||||
const closing = ref(false)
|
|
||||||
let closeTimer: number | null = null
|
|
||||||
const previousBodyOverflow = ref<string | null>(null)
|
|
||||||
const previousDocumentOverflow = ref<string | null>(null)
|
|
||||||
|
|
||||||
function updateViewport() {
|
|
||||||
if (typeof window === 'undefined') return
|
|
||||||
viewportWidth.value = window.innerWidth
|
|
||||||
viewportHeight.value = window.innerHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
const layout = computed(() => {
|
|
||||||
const aspectRatio = naturalWidth.value > 0 && naturalHeight.value > 0
|
|
||||||
? naturalWidth.value / naturalHeight.value
|
|
||||||
: 4 / 3
|
|
||||||
const maxModalWidth = viewportWidth.value > 0
|
|
||||||
? Math.max(Math.min(viewportWidth.value * 0.92, viewportWidth.value - 32), 280)
|
|
||||||
: 320
|
|
||||||
const maxImageHeight = viewportHeight.value > 0
|
|
||||||
? Math.max(viewportHeight.value * 0.86, 240)
|
|
||||||
: 360
|
|
||||||
const imageWidth = Math.min(maxModalWidth, maxImageHeight * aspectRatio)
|
|
||||||
|
|
||||||
return {
|
|
||||||
imageWidth,
|
|
||||||
imageHeight: imageWidth / aspectRatio,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const imageStyle = computed(() => ({
|
|
||||||
width: `${Math.round(layout.value.imageWidth)}px`,
|
|
||||||
height: `${Math.round(layout.value.imageHeight)}px`,
|
|
||||||
}) as Record<string, string>)
|
|
||||||
|
|
||||||
function resetImageState() {
|
|
||||||
imageLoaded.value = false
|
|
||||||
previewLoaded.value = false
|
|
||||||
naturalWidth.value = 0
|
|
||||||
naturalHeight.value = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function lockPageScroll() {
|
|
||||||
if (typeof document === 'undefined' || previousBodyOverflow.value !== null) return
|
|
||||||
previousBodyOverflow.value = document.body.style.overflow
|
|
||||||
previousDocumentOverflow.value = document.documentElement.style.overflow
|
|
||||||
document.body.style.overflow = 'hidden'
|
|
||||||
document.documentElement.style.overflow = 'hidden'
|
|
||||||
}
|
|
||||||
|
|
||||||
function unlockPageScroll() {
|
|
||||||
if (typeof document === 'undefined' || previousBodyOverflow.value === null) return
|
|
||||||
document.body.style.overflow = previousBodyOverflow.value
|
|
||||||
document.documentElement.style.overflow = previousDocumentOverflow.value ?? ''
|
|
||||||
previousBodyOverflow.value = null
|
|
||||||
previousDocumentOverflow.value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(() => props.open, open => {
|
|
||||||
if (open) {
|
|
||||||
if (closeTimer !== null) {
|
|
||||||
window.clearTimeout(closeTimer)
|
|
||||||
closeTimer = null
|
|
||||||
}
|
|
||||||
closing.value = false
|
|
||||||
modalVisible.value = true
|
|
||||||
lockPageScroll()
|
|
||||||
infoOpen.value = false
|
|
||||||
resetImageState()
|
|
||||||
} else {
|
|
||||||
modalVisible.value = false
|
|
||||||
unlockPageScroll()
|
|
||||||
}
|
|
||||||
}, { immediate: true })
|
|
||||||
|
|
||||||
watch(() => props.imageUrl, () => {
|
|
||||||
resetImageState()
|
|
||||||
})
|
|
||||||
|
|
||||||
function close() {
|
|
||||||
if (closing.value) return
|
|
||||||
closing.value = true
|
|
||||||
modalVisible.value = false
|
|
||||||
|
|
||||||
if (typeof window === 'undefined') {
|
|
||||||
unlockPageScroll()
|
|
||||||
emit('close')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
closeTimer = window.setTimeout(() => {
|
|
||||||
closeTimer = null
|
|
||||||
unlockPageScroll()
|
|
||||||
emit('close')
|
|
||||||
}, 180)
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleInfo() {
|
|
||||||
infoOpen.value = !infoOpen.value
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleImageLoad(event: Event) {
|
|
||||||
const target = event.target as HTMLImageElement | null
|
|
||||||
if (!target) return
|
|
||||||
naturalWidth.value = target.naturalWidth
|
|
||||||
naturalHeight.value = target.naturalHeight
|
|
||||||
imageLoaded.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function handlePreviewLoad(event: Event) {
|
|
||||||
const target = event.target as HTMLImageElement | null
|
|
||||||
if (!target) return
|
|
||||||
if (!naturalWidth.value || !naturalHeight.value) {
|
|
||||||
naturalWidth.value = target.naturalWidth
|
|
||||||
naturalHeight.value = target.naturalHeight
|
|
||||||
}
|
|
||||||
previewLoaded.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
updateViewport()
|
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
window.addEventListener('resize', updateViewport)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
if (closeTimer !== null) {
|
|
||||||
window.clearTimeout(closeTimer)
|
|
||||||
}
|
|
||||||
unlockPageScroll()
|
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
window.removeEventListener('resize', updateViewport)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Teleport to="body">
|
|
||||||
<Transition
|
|
||||||
appear
|
|
||||||
name="image-detail-modal"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
v-if="modalVisible"
|
|
||||||
class="fixed inset-0 z-[110] flex items-center justify-center bg-black/85 px-4 py-6"
|
|
||||||
@click="close"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="image-detail-shell relative w-fit max-w-[92vw] overflow-hidden rounded-[30px] shadow-2xl"
|
|
||||||
@click.stop
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
@click="close"
|
|
||||||
class="image-detail-close-button absolute right-4 top-4 z-30 flex h-10 min-h-10 w-10 min-w-10 max-w-10 appearance-none items-center justify-center overflow-hidden border-0 bg-transparent p-0 text-white/70 shadow-none transition-colors hover:text-white [&_svg]:stroke-[2.5]"
|
|
||||||
aria-label="关闭大图"
|
|
||||||
title="关闭大图"
|
|
||||||
>
|
|
||||||
<NIcon size="22">
|
|
||||||
<X />
|
|
||||||
</NIcon>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="relative flex min-h-0 items-center justify-center overflow-hidden bg-slate-950"
|
|
||||||
:style="imageStyle"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
v-if="!previewLoaded && !imageLoaded"
|
|
||||||
class="absolute inset-0 animate-pulse bg-[linear-gradient(110deg,#0f172a_0%,#1e293b_45%,#334155_55%,#0f172a_100%)] bg-[length:220%_100%]"
|
|
||||||
></div>
|
|
||||||
<img
|
|
||||||
v-if="thumbnailUrl"
|
|
||||||
:src="thumbnailUrl"
|
|
||||||
:alt="imageAlt"
|
|
||||||
class="absolute inset-0 block h-full w-full object-contain blur-[1px] transition-opacity duration-300"
|
|
||||||
:class="imageLoaded ? 'opacity-0' : 'opacity-100'"
|
|
||||||
@load="handlePreviewLoad"
|
|
||||||
/>
|
|
||||||
<img
|
|
||||||
:src="imageUrl"
|
|
||||||
:alt="imageAlt"
|
|
||||||
class="relative block h-full w-full object-contain transition-opacity duration-300"
|
|
||||||
:class="imageLoaded ? 'opacity-100' : 'opacity-0'"
|
|
||||||
@load="handleImageLoad"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
@click="toggleInfo"
|
|
||||||
class="absolute bottom-4 right-4 z-30 flex h-11 w-11 items-center justify-center rounded-full bg-transparent text-white drop-shadow-[0_2px_8px_rgba(15,23,42,0.9)] transition-colors hover:text-sky-100"
|
|
||||||
:aria-label="infoOpen ? '隐藏详细信息' : '查看详细信息'"
|
|
||||||
:title="infoOpen ? '隐藏详细信息' : '查看详细信息'"
|
|
||||||
>
|
|
||||||
<NIcon size="30">
|
|
||||||
<InfoCircle />
|
|
||||||
</NIcon>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="infoOpen"
|
|
||||||
class="absolute bottom-16 right-4 z-20 flex max-h-[min(70vh,560px)] w-[min(360px,calc(100%-2rem))] flex-col overflow-hidden border border-white/70 bg-white/95 shadow-2xl backdrop-blur"
|
|
||||||
>
|
|
||||||
<div class="border-b border-slate-200 px-5 py-4">
|
|
||||||
<div class="pr-8">
|
|
||||||
<div class="flex items-center gap-3">
|
|
||||||
<h2 class="text-xl font-bold text-slate-900">{{ title }}</h2>
|
|
||||||
<span
|
|
||||||
v-if="badgeLabel"
|
|
||||||
class="rounded-full border px-3 py-1 text-xs font-medium"
|
|
||||||
:class="badgeClass"
|
|
||||||
>
|
|
||||||
{{ badgeLabel }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<p v-if="subtitle" class="mt-2 text-sm text-slate-500">{{ subtitle }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
@click="infoOpen = false"
|
|
||||||
class="absolute right-3 top-3 rounded-full p-2 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700"
|
|
||||||
aria-label="隐藏详细信息"
|
|
||||||
title="隐藏详细信息"
|
|
||||||
>
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex-1 overflow-y-auto px-5 py-4">
|
|
||||||
<slot />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="$slots.actions" class="border-t border-slate-200 px-5 py-4">
|
|
||||||
<slot name="actions" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Transition>
|
|
||||||
</Teleport>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.image-detail-modal-enter-active,
|
|
||||||
.image-detail-modal-leave-active {
|
|
||||||
transition: opacity 180ms ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.image-detail-modal-enter-active .image-detail-shell,
|
|
||||||
.image-detail-modal-leave-active .image-detail-shell {
|
|
||||||
transition:
|
|
||||||
opacity 220ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
||||||
transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.image-detail-modal-enter-from,
|
|
||||||
.image-detail-modal-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.image-detail-modal-enter-from .image-detail-shell,
|
|
||||||
.image-detail-modal-leave-to .image-detail-shell {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(10px) scale(0.97);
|
|
||||||
}
|
|
||||||
|
|
||||||
.image-detail-close-button.image-detail-close-button {
|
|
||||||
border-radius: 9999px !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
|
||||||
import { NButton } from 'naive-ui'
|
|
||||||
import { loadAMap } from '@/lib/amap'
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
|
||||||
open: boolean
|
|
||||||
latitude: number | null
|
|
||||||
longitude: number | null
|
|
||||||
title?: string
|
|
||||||
description?: string
|
|
||||||
footerText?: string
|
|
||||||
}>(), {
|
|
||||||
title: '地图选点',
|
|
||||||
description: '点击地图即可回填经纬度,也可以继续手动修改。',
|
|
||||||
footerText: '建议点选大致拍摄位置,保存时会继续做模糊化处理。',
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
close: []
|
|
||||||
confirm: [payload: { latitude: number; longitude: number }]
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const errorMsg = ref('')
|
|
||||||
const pickedLat = ref<number | null>(null)
|
|
||||||
const pickedLng = ref<number | null>(null)
|
|
||||||
const mapEl = ref<HTMLDivElement | null>(null)
|
|
||||||
|
|
||||||
let mapPickerAMap: typeof AMap | null = null
|
|
||||||
let mapPickerInstance: AMap.Map | null = null
|
|
||||||
let mapPickerMarker: AMap.Marker | null = null
|
|
||||||
|
|
||||||
function formatCoordinate(value: number | null) {
|
|
||||||
return value === null ? '未选择' : value.toFixed(6)
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroyMapPicker() {
|
|
||||||
mapPickerMarker?.setMap(null)
|
|
||||||
mapPickerMarker = null
|
|
||||||
mapPickerInstance?.destroy()
|
|
||||||
mapPickerInstance = null
|
|
||||||
}
|
|
||||||
|
|
||||||
function placeMarker(longitude: number, latitude: number) {
|
|
||||||
if (!mapPickerAMap || !mapPickerInstance) return
|
|
||||||
|
|
||||||
if (!mapPickerMarker) {
|
|
||||||
mapPickerMarker = new mapPickerAMap.Marker({
|
|
||||||
position: [longitude, latitude],
|
|
||||||
title: '拍摄位置',
|
|
||||||
} as AMap.MarkerOptions)
|
|
||||||
mapPickerMarker.setMap(mapPickerInstance)
|
|
||||||
} else {
|
|
||||||
mapPickerMarker.setPosition([longitude, latitude])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractLngLat(event: unknown) {
|
|
||||||
const payload = event as { lnglat?: { lng?: number; lat?: number } } | undefined
|
|
||||||
const lng = payload?.lnglat?.lng
|
|
||||||
const lat = payload?.lnglat?.lat
|
|
||||||
|
|
||||||
if (typeof lng !== 'number' || typeof lat !== 'number') return null
|
|
||||||
return { lng, lat }
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleMapClick(event: unknown) {
|
|
||||||
const picked = extractLngLat(event)
|
|
||||||
if (!picked) return
|
|
||||||
|
|
||||||
pickedLng.value = picked.lng
|
|
||||||
pickedLat.value = picked.lat
|
|
||||||
placeMarker(picked.lng, picked.lat)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initializeMap() {
|
|
||||||
loading.value = true
|
|
||||||
errorMsg.value = ''
|
|
||||||
pickedLat.value = props.latitude
|
|
||||||
pickedLng.value = props.longitude
|
|
||||||
|
|
||||||
await nextTick()
|
|
||||||
destroyMapPicker()
|
|
||||||
|
|
||||||
try {
|
|
||||||
mapPickerAMap = await loadAMap()
|
|
||||||
|
|
||||||
const hasCoordinates =
|
|
||||||
typeof props.latitude === 'number' &&
|
|
||||||
typeof props.longitude === 'number'
|
|
||||||
|
|
||||||
const center: [number, number] = hasCoordinates
|
|
||||||
? [props.longitude as number, props.latitude as number]
|
|
||||||
: [104.07, 30.67]
|
|
||||||
|
|
||||||
mapPickerInstance = new mapPickerAMap.Map(mapEl.value!, {
|
|
||||||
viewMode: '2D',
|
|
||||||
pitch: 0,
|
|
||||||
rotation: 0,
|
|
||||||
zoom: hasCoordinates ? 11 : 4,
|
|
||||||
center,
|
|
||||||
mapStyle: 'amap://styles/normal',
|
|
||||||
resizeEnable: true,
|
|
||||||
} as AMap.MapOptions)
|
|
||||||
|
|
||||||
mapPickerInstance.on('click', handleMapClick)
|
|
||||||
|
|
||||||
if (hasCoordinates) {
|
|
||||||
placeMarker(props.longitude as number, props.latitude as number)
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
errorMsg.value = error instanceof Error ? error.message : '地图加载失败'
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function close() {
|
|
||||||
emit('close')
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirm() {
|
|
||||||
if (pickedLat.value === null || pickedLng.value === null) return
|
|
||||||
emit('confirm', {
|
|
||||||
latitude: pickedLat.value,
|
|
||||||
longitude: pickedLng.value,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(() => props.open, open => {
|
|
||||||
if (open) {
|
|
||||||
initializeMap()
|
|
||||||
} else {
|
|
||||||
loading.value = false
|
|
||||||
errorMsg.value = ''
|
|
||||||
destroyMapPicker()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
destroyMapPicker()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Teleport to="body">
|
|
||||||
<div
|
|
||||||
v-if="open"
|
|
||||||
class="fixed inset-0 z-[140] flex items-center justify-center bg-slate-950/55 px-4 py-6"
|
|
||||||
@click="close"
|
|
||||||
>
|
|
||||||
<div class="w-full max-w-3xl overflow-hidden bg-white shadow-2xl" @click.stop>
|
|
||||||
<div class="flex items-start justify-between border-b border-slate-200 px-6 py-5">
|
|
||||||
<div>
|
|
||||||
<h3 class="text-xl font-semibold text-slate-900">{{ title }}</h3>
|
|
||||||
<p class="oc-field-help">{{ description }}</p>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="p-2 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700"
|
|
||||||
@click="close"
|
|
||||||
>
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="px-6 py-5">
|
|
||||||
<div class="mb-4 flex flex-wrap items-center gap-3 border border-slate-200 bg-slate-50 px-4 py-3 text-sm text-slate-600">
|
|
||||||
<span>当前选择:</span>
|
|
||||||
<span class="font-medium text-slate-900">纬度 {{ formatCoordinate(pickedLat) }}</span>
|
|
||||||
<span class="font-medium text-slate-900">经度 {{ formatCoordinate(pickedLng) }}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="relative overflow-hidden border border-slate-200 bg-slate-100">
|
|
||||||
<div ref="mapEl" class="h-[420px] w-full"></div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="loading"
|
|
||||||
class="absolute inset-0 flex items-center justify-center bg-white/80 text-sm font-medium text-slate-600"
|
|
||||||
>
|
|
||||||
正在加载地图...
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="errorMsg"
|
|
||||||
class="absolute inset-0 flex items-center justify-center bg-white/90 px-6 text-center text-sm text-red-600"
|
|
||||||
>
|
|
||||||
{{ errorMsg }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center justify-between border-t border-slate-200 px-6 py-4">
|
|
||||||
<p class="text-sm text-slate-500">{{ footerText }}</p>
|
|
||||||
<div class="flex gap-3">
|
|
||||||
<NButton secondary strong type="default" class="oc-panel-button oc-panel-button--neutral" @click="close">取消</NButton>
|
|
||||||
<NButton
|
|
||||||
type="default"
|
|
||||||
secondary
|
|
||||||
strong
|
|
||||||
class="oc-panel-button oc-panel-button--sky"
|
|
||||||
:disabled="pickedLat === null || pickedLng === null"
|
|
||||||
@click="confirm"
|
|
||||||
>
|
|
||||||
使用这个位置
|
|
||||||
</NButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Teleport>
|
|
||||||
</template>
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
|
||||||
import { loadAMap } from '@/lib/amap'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
latitude: number | null
|
|
||||||
longitude: number | null
|
|
||||||
locationName?: string | null
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const mapEl = ref<HTMLDivElement | null>(null)
|
|
||||||
const loading = ref(false)
|
|
||||||
const errorMsg = ref('')
|
|
||||||
|
|
||||||
let amapLib: typeof AMap | null = null
|
|
||||||
let mapInstance: AMap.Map | null = null
|
|
||||||
let marker: AMap.Marker | null = null
|
|
||||||
|
|
||||||
const hasCoordinates = computed(() => {
|
|
||||||
return Number.isFinite(props.latitude) && Number.isFinite(props.longitude)
|
|
||||||
})
|
|
||||||
|
|
||||||
const center = computed<[number, number] | null>(() => {
|
|
||||||
if (!hasCoordinates.value) return null
|
|
||||||
return [props.longitude as number, props.latitude as number]
|
|
||||||
})
|
|
||||||
|
|
||||||
function destroyMap() {
|
|
||||||
marker?.setMap(null)
|
|
||||||
marker = null
|
|
||||||
mapInstance?.destroy()
|
|
||||||
mapInstance = null
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initializeMap() {
|
|
||||||
if (!center.value) {
|
|
||||||
destroyMap()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
loading.value = true
|
|
||||||
errorMsg.value = ''
|
|
||||||
|
|
||||||
await nextTick()
|
|
||||||
destroyMap()
|
|
||||||
|
|
||||||
if (!mapEl.value) {
|
|
||||||
loading.value = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
amapLib = await loadAMap()
|
|
||||||
if ('getConfig' in amapLib) {
|
|
||||||
amapLib.getConfig().appname = 'amap-jsapi-skill'
|
|
||||||
}
|
|
||||||
|
|
||||||
mapInstance = new amapLib.Map(mapEl.value, {
|
|
||||||
viewMode: '2D',
|
|
||||||
zoom: 11,
|
|
||||||
center: center.value,
|
|
||||||
mapStyle: 'amap://styles/normal',
|
|
||||||
features: ['bg', 'road', 'building', 'point'],
|
|
||||||
resizeEnable: true,
|
|
||||||
dragEnable: true,
|
|
||||||
zoomEnable: true,
|
|
||||||
keyboardEnable: false,
|
|
||||||
doubleClickZoom: true,
|
|
||||||
scrollWheel: true,
|
|
||||||
} as AMap.MapOptions)
|
|
||||||
|
|
||||||
mapInstance.addControl(new amapLib.ToolBar({
|
|
||||||
position: 'RT',
|
|
||||||
offset: [8, 8],
|
|
||||||
} as Record<string, unknown>))
|
|
||||||
|
|
||||||
marker = new amapLib.Marker({
|
|
||||||
position: center.value,
|
|
||||||
title: props.locationName || '拍摄位置',
|
|
||||||
content: '<div class="h-4 w-4 rounded-full border-2 border-white bg-teal-500 shadow-[0_0_0_4px_rgba(20,184,166,0.22)]"></div>',
|
|
||||||
offset: new amapLib.Pixel(-8, -8),
|
|
||||||
} as AMap.MarkerOptions)
|
|
||||||
marker.setMap(mapInstance)
|
|
||||||
} catch (error) {
|
|
||||||
errorMsg.value = error instanceof Error ? error.message : '地图加载失败'
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(center, () => {
|
|
||||||
initializeMap()
|
|
||||||
}, { immediate: true })
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
destroyMap()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div v-if="hasCoordinates" class="mt-5 overflow-hidden border border-slate-200 bg-white">
|
|
||||||
<div class="flex items-center justify-between border-b border-slate-200 px-4 py-3">
|
|
||||||
<div>
|
|
||||||
<p class="oc-section-label">位置地图</p>
|
|
||||||
<p class="mt-1 text-sm font-medium text-slate-900">{{ locationName || '拍摄位置' }}</p>
|
|
||||||
</div>
|
|
||||||
<p class="text-right text-[11px] leading-5 text-slate-500">
|
|
||||||
{{ latitude?.toFixed(4) }}<br />
|
|
||||||
{{ longitude?.toFixed(4) }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="relative h-40 bg-sky-50">
|
|
||||||
<div ref="mapEl" class="h-full w-full"></div>
|
|
||||||
<div v-if="loading" class="absolute inset-0 flex items-center justify-center bg-white/70 text-sm text-slate-500">
|
|
||||||
地图加载中...
|
|
||||||
</div>
|
|
||||||
<div v-else-if="errorMsg" class="absolute inset-0 flex items-center justify-center bg-white/85 px-4 text-center text-sm text-slate-500">
|
|
||||||
{{ errorMsg }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -1,402 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
|
||||||
import { NAlert, NButton, NIcon, NProgress } from 'naive-ui'
|
|
||||||
import { CloudUpload, Map as MapIcon, X } from '@vicons/tabler'
|
|
||||||
import MapPickerModal from '@/components/cloud/MapPickerModal.vue'
|
|
||||||
import { useCloudsStore } from '@/stores/clouds'
|
|
||||||
import { useUpload } from '@/composables/useUpload'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
open: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
close: []
|
|
||||||
uploaded: []
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const cloudsStore = useCloudsStore()
|
|
||||||
const {
|
|
||||||
items,
|
|
||||||
uploading,
|
|
||||||
overallProgress,
|
|
||||||
currentItemIndex,
|
|
||||||
totalItems,
|
|
||||||
addFiles,
|
|
||||||
removeItem,
|
|
||||||
clearAll,
|
|
||||||
validateAll,
|
|
||||||
uploadAll,
|
|
||||||
} = useUpload()
|
|
||||||
|
|
||||||
const fileInput = ref<HTMLInputElement | null>(null)
|
|
||||||
const activeId = ref<string | null>(null)
|
|
||||||
const dragOver = ref(false)
|
|
||||||
const errorMsg = ref('')
|
|
||||||
const successMsg = ref(false)
|
|
||||||
const mapPickerOpen = ref(false)
|
|
||||||
|
|
||||||
const activeItem = computed(() => {
|
|
||||||
if (!activeId.value) return null
|
|
||||||
return items.value.find(item => item.id === activeId.value) ?? null
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(() => props.open, open => {
|
|
||||||
if (open) {
|
|
||||||
cloudsStore.fetchCloudTypes()
|
|
||||||
errorMsg.value = ''
|
|
||||||
successMsg.value = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(() => items.value.length, () => {
|
|
||||||
if (items.value.length > 0 && !activeId.value) {
|
|
||||||
activeId.value = items.value[0].id
|
|
||||||
}
|
|
||||||
if (items.value.length === 0) {
|
|
||||||
activeId.value = null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
async function addSelectedFiles(files: File[]) {
|
|
||||||
const previousLength = items.value.length
|
|
||||||
await addFiles(files)
|
|
||||||
if (items.value.length > previousLength) {
|
|
||||||
activeId.value = items.value[previousLength].id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleDrop(event: DragEvent) {
|
|
||||||
dragOver.value = false
|
|
||||||
if (event.dataTransfer?.files) {
|
|
||||||
addSelectedFiles(Array.from(event.dataTransfer.files))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleFileSelect(event: Event) {
|
|
||||||
const target = event.target as HTMLInputElement
|
|
||||||
if (target.files?.length) {
|
|
||||||
addSelectedFiles(Array.from(target.files))
|
|
||||||
}
|
|
||||||
target.value = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRemove(id: string) {
|
|
||||||
removeItem(id)
|
|
||||||
if (activeId.value === id) {
|
|
||||||
activeId.value = items.value[0]?.id ?? null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onCategoryChange(event: Event) {
|
|
||||||
if (!activeItem.value) return
|
|
||||||
const value = (event.target as HTMLSelectElement).value
|
|
||||||
if (value === 'other') {
|
|
||||||
activeItem.value.cloudCategoryId = 'other'
|
|
||||||
} else if (value === '') {
|
|
||||||
activeItem.value.cloudCategoryId = null
|
|
||||||
} else {
|
|
||||||
activeItem.value.cloudCategoryId = Number(value)
|
|
||||||
}
|
|
||||||
activeItem.value.errors = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDatetimeLocal(iso: string): string {
|
|
||||||
const date = new Date(iso)
|
|
||||||
const pad = (value: number) => String(value).padStart(2, '0')
|
|
||||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`
|
|
||||||
}
|
|
||||||
|
|
||||||
function onCapturedAtChange(event: Event) {
|
|
||||||
if (!activeItem.value) return
|
|
||||||
const value = (event.target as HTMLInputElement).value
|
|
||||||
if (!value) return
|
|
||||||
activeItem.value.capturedAt = new Date(value).toISOString()
|
|
||||||
delete activeItem.value.errors.capturedAt
|
|
||||||
}
|
|
||||||
|
|
||||||
function onLatInput(event: Event) {
|
|
||||||
if (!activeItem.value) return
|
|
||||||
const value = Number.parseFloat((event.target as HTMLInputElement).value)
|
|
||||||
activeItem.value.latitude = Number.isNaN(value) ? null : value
|
|
||||||
delete activeItem.value.errors.latitude
|
|
||||||
delete activeItem.value.errors.longitude
|
|
||||||
}
|
|
||||||
|
|
||||||
function onLngInput(event: Event) {
|
|
||||||
if (!activeItem.value) return
|
|
||||||
const value = Number.parseFloat((event.target as HTMLInputElement).value)
|
|
||||||
activeItem.value.longitude = Number.isNaN(value) ? null : value
|
|
||||||
delete activeItem.value.errors.latitude
|
|
||||||
delete activeItem.value.errors.longitude
|
|
||||||
}
|
|
||||||
|
|
||||||
function updatePublicState(isPublic: boolean) {
|
|
||||||
if (!activeItem.value) return
|
|
||||||
activeItem.value.isHidden = !isPublic
|
|
||||||
}
|
|
||||||
|
|
||||||
function openMapPicker() {
|
|
||||||
if (!activeItem.value) return
|
|
||||||
mapPickerOpen.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeMapPicker() {
|
|
||||||
mapPickerOpen.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirmMapPicker(payload: { latitude: number; longitude: number }) {
|
|
||||||
if (!activeItem.value) return
|
|
||||||
activeItem.value.latitude = payload.latitude
|
|
||||||
activeItem.value.longitude = payload.longitude
|
|
||||||
delete activeItem.value.errors.latitude
|
|
||||||
delete activeItem.value.errors.longitude
|
|
||||||
closeMapPicker()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleSubmit() {
|
|
||||||
errorMsg.value = ''
|
|
||||||
successMsg.value = false
|
|
||||||
|
|
||||||
if (!validateAll()) {
|
|
||||||
const firstInvalid = items.value.find(item => Object.keys(item.errors).length > 0)
|
|
||||||
if (firstInvalid) {
|
|
||||||
activeId.value = firstInvalid.id
|
|
||||||
await nextTick()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await uploadAll()
|
|
||||||
if (!result.ok) {
|
|
||||||
errorMsg.value = '上传失败,请稍后重试'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
successMsg.value = true
|
|
||||||
emit('uploaded')
|
|
||||||
}
|
|
||||||
|
|
||||||
function close() {
|
|
||||||
if (uploading.value) return
|
|
||||||
clearAll()
|
|
||||||
errorMsg.value = ''
|
|
||||||
successMsg.value = false
|
|
||||||
mapPickerOpen.value = false
|
|
||||||
emit('close')
|
|
||||||
}
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
clearAll()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Teleport to="body">
|
|
||||||
<div
|
|
||||||
v-if="open"
|
|
||||||
class="fixed inset-0 z-[130] flex items-center justify-center bg-slate-950/55 px-4 py-6 backdrop-blur-sm"
|
|
||||||
@click="close"
|
|
||||||
>
|
|
||||||
<div class="w-full max-w-3xl overflow-hidden border border-slate-200 bg-white shadow-2xl" @click.stop>
|
|
||||||
<div class="flex items-start justify-between border-b border-slate-200 px-5 py-4">
|
|
||||||
<div>
|
|
||||||
<p class="text-xs font-semibold uppercase tracking-[0.22em] text-sky-700">Quick Upload</p>
|
|
||||||
<h2 class="mt-2 text-xl font-bold text-slate-950">快速上传云图</h2>
|
|
||||||
<p class="oc-field-help">从地图当前位置带入经纬度,提交后进入审核队列。</p>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="quick-upload-close flex h-9 w-9 items-center justify-center border border-slate-200 bg-slate-50 text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-800"
|
|
||||||
aria-label="关闭快捷上传"
|
|
||||||
title="关闭快捷上传"
|
|
||||||
@click="close"
|
|
||||||
>
|
|
||||||
<NIcon size="20"><X /></NIcon>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="max-h-[72vh] overflow-y-auto px-5 py-5">
|
|
||||||
<input ref="fileInput" type="file" accept="image/*" class="hidden" @change="handleFileSelect" />
|
|
||||||
|
|
||||||
<NAlert v-if="successMsg" type="success" :bordered="false" title="已提交审核" class="mb-4">
|
|
||||||
图片审核通过后会出现在画廊和地图中。
|
|
||||||
</NAlert>
|
|
||||||
|
|
||||||
<div v-if="uploading" class="mb-4 border border-sky-100 bg-sky-50 p-4">
|
|
||||||
<div class="mb-2 flex items-center justify-between text-sm">
|
|
||||||
<span class="font-medium text-slate-700">正在上传 {{ currentItemIndex }} / {{ totalItems }}</span>
|
|
||||||
<span class="font-medium text-sky-700">{{ overallProgress }}%</span>
|
|
||||||
</div>
|
|
||||||
<NProgress type="line" :percentage="overallProgress" :show-indicator="false" color="#0ea5e9" rail-color="#dbeafe" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="items.length === 0"
|
|
||||||
class="flex cursor-pointer flex-col items-center justify-center border-2 border-dashed px-6 py-12 text-center transition-colors"
|
|
||||||
:class="dragOver ? 'border-sky-400 bg-sky-50' : 'border-slate-300 bg-slate-50 hover:border-sky-300 hover:bg-sky-50'"
|
|
||||||
@click="fileInput?.click()"
|
|
||||||
@dragover.prevent="dragOver = true"
|
|
||||||
@dragleave.prevent="dragOver = false"
|
|
||||||
@drop.prevent="handleDrop"
|
|
||||||
>
|
|
||||||
<NIcon size="42" class="text-sky-600"><CloudUpload /></NIcon>
|
|
||||||
<p class="mt-3 text-base font-semibold text-slate-800">选择一张云图</p>
|
|
||||||
<p class="oc-field-help">支持 JPG、PNG,可点击或拖拽上传。</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<template v-else-if="activeItem">
|
|
||||||
<div class="grid gap-5 md:grid-cols-[220px_minmax(0,1fr)]">
|
|
||||||
<div>
|
|
||||||
<div class="overflow-hidden border border-slate-900 bg-slate-950">
|
|
||||||
<img :src="activeItem.preview" alt="图片预览" class="h-56 w-full object-contain" />
|
|
||||||
</div>
|
|
||||||
<div class="mt-3 flex items-center justify-between gap-2">
|
|
||||||
<button type="button" class="text-sm font-medium text-sky-700 hover:text-sky-900" @click="fileInput?.click()">重新选择</button>
|
|
||||||
<button type="button" class="text-sm font-medium text-rose-600 hover:text-rose-800" @click="handleRemove(activeItem.id)">移除</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="space-y-4">
|
|
||||||
<div>
|
|
||||||
<label class="oc-field-label">类别 <span class="oc-field-required">*</span></label>
|
|
||||||
<select
|
|
||||||
:value="activeItem.cloudCategoryId ?? ''"
|
|
||||||
class="oc-field-control"
|
|
||||||
@change="onCategoryChange"
|
|
||||||
>
|
|
||||||
<option value="" disabled>请选择</option>
|
|
||||||
<option v-for="cloudType in cloudsStore.cloudTypes" :key="cloudType.id" :value="cloudType.id">
|
|
||||||
{{ cloudType.name }}({{ cloudType.name_en }})
|
|
||||||
</option>
|
|
||||||
<option value="other">其他</option>
|
|
||||||
</select>
|
|
||||||
<input
|
|
||||||
v-if="activeItem.cloudCategoryId === 'other'"
|
|
||||||
v-model="activeItem.customCloudType"
|
|
||||||
type="text"
|
|
||||||
placeholder="输入云的类型"
|
|
||||||
class="oc-field-control mt-2"
|
|
||||||
@input="activeItem.errors = {}"
|
|
||||||
/>
|
|
||||||
<p v-if="activeItem.errors.cloudCategory" class="oc-field-error">{{ activeItem.errors.cloudCategory }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="oc-field-label">拍摄时间 <span class="oc-field-required">*</span></label>
|
|
||||||
<input
|
|
||||||
type="datetime-local"
|
|
||||||
:value="formatDatetimeLocal(activeItem.capturedAt)"
|
|
||||||
class="oc-field-control"
|
|
||||||
@change="onCapturedAtChange"
|
|
||||||
/>
|
|
||||||
<p v-if="activeItem.errors.capturedAt" class="oc-field-error">{{ activeItem.errors.capturedAt }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="oc-field-label">经纬度</label>
|
|
||||||
<div class="grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_40px] gap-2">
|
|
||||||
<div>
|
|
||||||
<input
|
|
||||||
:value="activeItem.latitude ?? ''"
|
|
||||||
type="number"
|
|
||||||
step="any"
|
|
||||||
placeholder="纬度"
|
|
||||||
class="oc-field-control"
|
|
||||||
@input="onLatInput"
|
|
||||||
/>
|
|
||||||
<p v-if="activeItem.errors.latitude" class="oc-field-error">{{ activeItem.errors.latitude }}</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input
|
|
||||||
:value="activeItem.longitude ?? ''"
|
|
||||||
type="number"
|
|
||||||
step="any"
|
|
||||||
placeholder="经度"
|
|
||||||
class="oc-field-control"
|
|
||||||
@input="onLngInput"
|
|
||||||
/>
|
|
||||||
<p v-if="activeItem.errors.longitude" class="oc-field-error">{{ activeItem.errors.longitude }}</p>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="flex h-10 w-10 items-center justify-center border border-sky-200 bg-sky-50 text-sky-700 transition-colors hover:bg-sky-100"
|
|
||||||
title="地图选点"
|
|
||||||
aria-label="地图选点"
|
|
||||||
@click="openMapPicker"
|
|
||||||
>
|
|
||||||
<NIcon size="20">
|
|
||||||
<MapIcon />
|
|
||||||
</NIcon>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<p class="mt-1 text-xs text-slate-400">选填,可手动输入,也可以点击右侧地图按钮选点。</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="oc-field-label">位置名称</label>
|
|
||||||
<input
|
|
||||||
v-model="activeItem.locationName"
|
|
||||||
type="text"
|
|
||||||
placeholder="如:北京、成都"
|
|
||||||
class="oc-field-control"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="oc-field-label">图片说明</label>
|
|
||||||
<textarea
|
|
||||||
v-model="activeItem.description"
|
|
||||||
rows="3"
|
|
||||||
placeholder="描述一下这张图片..."
|
|
||||||
class="oc-field-control resize-none"
|
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label class="flex items-center justify-between gap-4 border border-slate-200 bg-slate-50 px-4 py-3">
|
|
||||||
<span>
|
|
||||||
<span class="block text-sm font-medium text-slate-800">公开展示</span>
|
|
||||||
<span class="mt-1 block text-xs text-slate-500">关闭后不会出现在公开地图和画廊中。</span>
|
|
||||||
</span>
|
|
||||||
<input
|
|
||||||
:checked="!activeItem.isHidden"
|
|
||||||
type="checkbox"
|
|
||||||
class="h-5 w-5 border-slate-300 text-sky-600 focus:ring-sky-500"
|
|
||||||
@change="updatePublicState(($event.target as HTMLInputElement).checked)"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<NAlert v-if="errorMsg" class="mt-4" type="error" :show-icon="false" title="上传失败">
|
|
||||||
{{ errorMsg }}
|
|
||||||
</NAlert>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center justify-end gap-3 border-t border-slate-200 bg-slate-50 px-5 py-4">
|
|
||||||
<NButton secondary strong type="default" class="oc-panel-button oc-panel-button--neutral" :disabled="uploading" @click="close">关闭</NButton>
|
|
||||||
<NButton type="default" secondary strong class="oc-panel-button oc-panel-button--sky" :disabled="uploading || items.length === 0" @click="handleSubmit">
|
|
||||||
{{ uploading ? '上传中...' : '提交审核' }}
|
|
||||||
</NButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<MapPickerModal
|
|
||||||
:open="mapPickerOpen"
|
|
||||||
:latitude="activeItem?.latitude ?? null"
|
|
||||||
:longitude="activeItem?.longitude ?? null"
|
|
||||||
description="点击地图即可回填当前图片的经纬度,也可以继续手动修改。"
|
|
||||||
footer-text="建议点选大致拍摄位置,上传时会继续做模糊化处理。"
|
|
||||||
@close="closeMapPicker"
|
|
||||||
@confirm="confirmMapPicker"
|
|
||||||
/>
|
|
||||||
</Teleport>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.quick-upload-close.quick-upload-close {
|
|
||||||
border-radius: 9999px !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
+413
-309
@@ -1,13 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||||
import { NIcon, NSpace } from 'naive-ui'
|
import { NIcon, NSpace, useMessage } from 'naive-ui'
|
||||||
import { Logout, Settings, Shield, User } from '@vicons/tabler'
|
import { ChevronDown, Logout, Settings, Shield, User } from '@vicons/tabler'
|
||||||
import { useAuthStore } from '@/stores/auth'
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
import { RouterLink, useRoute, useRouter } from 'vue-router'
|
import { RouterLink, useRoute, useRouter } from 'vue-router'
|
||||||
|
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const message = useMessage()
|
||||||
const isMapRoute = computed(() => route.name === 'map')
|
const isMapRoute = computed(() => route.name === 'map')
|
||||||
|
|
||||||
const headerHidden = ref(false)
|
const headerHidden = ref(false)
|
||||||
@@ -16,374 +17,477 @@ const accountCardOpen = ref(false)
|
|||||||
const activeNavClass = 'bg-teal-50 text-teal-800 ring-1 ring-teal-100'
|
const activeNavClass = 'bg-teal-50 text-teal-800 ring-1 ring-teal-100'
|
||||||
const inactiveNavClass = 'text-slate-600 hover:bg-teal-50 hover:text-teal-800'
|
const inactiveNavClass = 'text-slate-600 hover:bg-teal-50 hover:text-teal-800'
|
||||||
|
|
||||||
const displayUsername = computed(() => authStore.profile?.username || authStore.user?.email || 'OpenCloud 用户')
|
const displayUsername = computed(
|
||||||
|
() => authStore.profile?.username || authStore.user?.email || 'OpenCloud 用户',
|
||||||
|
)
|
||||||
const userEmail = computed(() => authStore.user?.email || '未绑定邮箱')
|
const userEmail = computed(() => authStore.user?.email || '未绑定邮箱')
|
||||||
|
const avatarFailed = ref(false)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => authStore.user?.image,
|
||||||
|
() => {
|
||||||
|
avatarFailed.value = false
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
let lastScrollY = 0
|
let lastScrollY = 0
|
||||||
let accountCloseTimer: number | null = null
|
let accountCloseTimer: number | null = null
|
||||||
const HIDE_HEADER_EVENT = 'opencloud:hide-header'
|
const HIDE_HEADER_EVENT = 'opencloud:hide-header'
|
||||||
|
|
||||||
function showHeader(pin = false) {
|
function showHeader(pin = false) {
|
||||||
headerHidden.value = false
|
headerHidden.value = false
|
||||||
headerPinnedOpen.value = pin
|
headerPinnedOpen.value = pin
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideHeader() {
|
function hideHeader() {
|
||||||
if (window.scrollY <= 96) return
|
if (window.scrollY <= 96) return
|
||||||
if (headerPinnedOpen.value) return
|
if (headerPinnedOpen.value) return
|
||||||
headerHidden.value = true
|
headerHidden.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function releasePinnedHeader() {
|
function releasePinnedHeader() {
|
||||||
headerPinnedOpen.value = false
|
headerPinnedOpen.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function forceHideHeader() {
|
function forceHideHeader() {
|
||||||
headerPinnedOpen.value = false
|
headerPinnedOpen.value = false
|
||||||
headerHidden.value = true
|
headerHidden.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleScroll() {
|
function handleScroll() {
|
||||||
const currentScrollY = window.scrollY
|
const currentScrollY = window.scrollY
|
||||||
const delta = currentScrollY - lastScrollY
|
const delta = currentScrollY - lastScrollY
|
||||||
|
|
||||||
|
if (isMapRoute.value) {
|
||||||
|
lastScrollY = currentScrollY
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentScrollY <= 64) {
|
||||||
|
showHeader(false)
|
||||||
|
lastScrollY = currentScrollY
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delta > 12) {
|
||||||
|
hideHeader()
|
||||||
|
} else if (delta < -8) {
|
||||||
|
showHeader(false)
|
||||||
|
}
|
||||||
|
|
||||||
if (isMapRoute.value) {
|
|
||||||
lastScrollY = currentScrollY
|
lastScrollY = currentScrollY
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentScrollY <= 64) {
|
|
||||||
showHeader(false)
|
|
||||||
lastScrollY = currentScrollY
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (delta > 12) {
|
|
||||||
hideHeader()
|
|
||||||
} else if (delta < -8) {
|
|
||||||
showHeader(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
lastScrollY = currentScrollY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
lastScrollY = window.scrollY
|
lastScrollY = window.scrollY
|
||||||
window.addEventListener('scroll', handleScroll, { passive: true })
|
window.addEventListener('scroll', handleScroll, { passive: true })
|
||||||
window.addEventListener(HIDE_HEADER_EVENT, forceHideHeader as EventListener)
|
window.addEventListener(HIDE_HEADER_EVENT, forceHideHeader as EventListener)
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener('scroll', handleScroll)
|
window.removeEventListener('scroll', handleScroll)
|
||||||
window.removeEventListener(HIDE_HEADER_EVENT, forceHideHeader as EventListener)
|
window.removeEventListener(HIDE_HEADER_EVENT, forceHideHeader as EventListener)
|
||||||
if (accountCloseTimer !== null) {
|
if (accountCloseTimer !== null) {
|
||||||
window.clearTimeout(accountCloseTimer)
|
window.clearTimeout(accountCloseTimer)
|
||||||
accountCloseTimer = null
|
accountCloseTimer = null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function syncHeaderForRoute() {
|
function syncHeaderForRoute() {
|
||||||
headerPinnedOpen.value = false
|
headerPinnedOpen.value = false
|
||||||
headerHidden.value = false
|
headerHidden.value = false
|
||||||
accountCardOpen.value = false
|
accountCardOpen.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => route.fullPath, () => {
|
watch(
|
||||||
syncHeaderForRoute()
|
() => route.fullPath,
|
||||||
})
|
() => {
|
||||||
|
syncHeaderForRoute()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
watch(isMapRoute, () => {
|
watch(isMapRoute, () => {
|
||||||
syncHeaderForRoute()
|
syncHeaderForRoute()
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
syncHeaderForRoute()
|
syncHeaderForRoute()
|
||||||
})
|
})
|
||||||
|
|
||||||
function openAccountCard() {
|
function openAccountCard() {
|
||||||
if (accountCloseTimer !== null) {
|
if (accountCloseTimer !== null) {
|
||||||
window.clearTimeout(accountCloseTimer)
|
window.clearTimeout(accountCloseTimer)
|
||||||
accountCloseTimer = null
|
accountCloseTimer = null
|
||||||
}
|
}
|
||||||
accountCardOpen.value = true
|
accountCardOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeAccountCard() {
|
function closeAccountCard() {
|
||||||
if (accountCloseTimer !== null) {
|
if (accountCloseTimer !== null) {
|
||||||
window.clearTimeout(accountCloseTimer)
|
window.clearTimeout(accountCloseTimer)
|
||||||
}
|
}
|
||||||
accountCloseTimer = window.setTimeout(() => {
|
accountCloseTimer = window.setTimeout(() => {
|
||||||
accountCardOpen.value = false
|
accountCardOpen.value = false
|
||||||
accountCloseTimer = null
|
accountCloseTimer = null
|
||||||
}, 100)
|
}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleLogout() {
|
async function handleLogout() {
|
||||||
await authStore.logout()
|
try {
|
||||||
closeAccountCard()
|
await authStore.logout()
|
||||||
if (route.meta.requiresAuth) {
|
closeAccountCard()
|
||||||
router.push({ name: 'map' })
|
if (route.meta.requiresAuth) {
|
||||||
}
|
void router.push({ name: 'map' })
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error(error instanceof Error ? error.message : '退出登录失败,请稍后重试。')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="sticky top-0 z-50" :class="isMapRoute ? 'h-0' : 'h-28 md:h-16'">
|
<div class="sticky top-0 z-50" :class="isMapRoute ? 'h-0' : 'h-28 md:h-16'">
|
||||||
<header
|
<header
|
||||||
class="absolute inset-x-0 top-0 border-b border-slate-200/80 bg-white/88 backdrop-blur-xl transition-transform duration-300"
|
class="absolute inset-x-0 top-0 border-b border-slate-200/80 bg-white/88 backdrop-blur-xl transition-transform duration-300"
|
||||||
:class="headerHidden ? '-translate-y-full' : 'translate-y-0'"
|
:class="headerHidden ? '-translate-y-full' : 'translate-y-0'"
|
||||||
@mouseenter="showHeader(true)"
|
@mouseenter="showHeader(true)"
|
||||||
@mouseleave="releasePinnedHeader"
|
@mouseleave="releasePinnedHeader"
|
||||||
>
|
>
|
||||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||||
<div class="flex h-16 items-center justify-between">
|
<div class="flex h-16 items-center justify-between">
|
||||||
<RouterLink to="/" class="flex items-center gap-3">
|
<RouterLink to="/" class="flex items-center gap-3">
|
||||||
<div class="flex h-10 w-10 items-center justify-center border border-slate-300 bg-[linear-gradient(135deg,#ecfeff_0%,#ccfbf1_100%)] shadow-[4px_4px_0_0_rgba(15,23,42,0.08)]">
|
<div class="oc-brand-mark">
|
||||||
<svg
|
<svg
|
||||||
class="h-8 w-8"
|
class="h-8 w-8"
|
||||||
viewBox="0 0 16 16"
|
viewBox="0 0 16 16"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
shape-rendering="crispEdges"
|
shape-rendering="crispEdges"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
<rect x="11" y="3" width="1" height="1" fill="#f59e0b" />
|
<rect x="11" y="3" width="1" height="1" fill="#f59e0b" />
|
||||||
<rect x="10" y="4" width="3" height="1" fill="#fbbf24" />
|
<rect x="10" y="4" width="3" height="1" fill="#fbbf24" />
|
||||||
<rect x="11" y="5" width="1" height="1" fill="#f59e0b" />
|
<rect x="11" y="5" width="1" height="1" fill="#f59e0b" />
|
||||||
|
|
||||||
<rect x="5" y="7" width="7" height="1" fill="#38bdf8" />
|
<rect x="5" y="7" width="7" height="1" fill="#38bdf8" />
|
||||||
<rect x="4" y="8" width="8" height="1" fill="#38bdf8" />
|
<rect x="4" y="8" width="8" height="1" fill="#38bdf8" />
|
||||||
<rect x="4" y="9" width="7" height="1" fill="#38bdf8" />
|
<rect x="4" y="9" width="7" height="1" fill="#38bdf8" />
|
||||||
<rect x="5" y="10" width="4" height="1" fill="#38bdf8" />
|
<rect x="5" y="10" width="4" height="1" fill="#38bdf8" />
|
||||||
|
|
||||||
<rect x="5" y="5" width="4" height="1" fill="#ffffff" />
|
<rect x="5" y="5" width="4" height="1" fill="#ffffff" />
|
||||||
<rect x="4" y="6" width="7" height="1" fill="#ffffff" />
|
<rect x="4" y="6" width="7" height="1" fill="#ffffff" />
|
||||||
<rect x="3" y="7" width="8" height="1" fill="#ffffff" />
|
<rect x="3" y="7" width="8" height="1" fill="#ffffff" />
|
||||||
<rect x="3" y="8" width="7" height="1" fill="#ffffff" />
|
<rect x="3" y="8" width="7" height="1" fill="#ffffff" />
|
||||||
<rect x="4" y="9" width="5" height="1" fill="#ffffff" />
|
<rect x="4" y="9" width="5" height="1" fill="#ffffff" />
|
||||||
|
|
||||||
<rect x="4" y="11" width="8" height="1" fill="#7dd3fc" opacity="0.55" />
|
<rect
|
||||||
</svg>
|
x="4"
|
||||||
</div>
|
y="11"
|
||||||
<div>
|
width="8"
|
||||||
<div class="text-[11px] uppercase tracking-[0.22em] text-slate-500">Live Sky Atlas</div>
|
height="1"
|
||||||
<div class="text-lg font-bold text-slate-900">OpenCloud</div>
|
fill="#7dd3fc"
|
||||||
</div>
|
opacity="0.55"
|
||||||
</RouterLink>
|
/>
|
||||||
|
</svg>
|
||||||
<nav class="hidden items-center gap-2 border border-slate-200 bg-white px-2 py-2 shadow-[6px_6px_0_0_rgba(15,23,42,0.05)] md:flex">
|
|
||||||
<RouterLink
|
|
||||||
to="/"
|
|
||||||
class="px-3 py-2 text-sm font-medium tracking-[0.12em] uppercase transition-colors"
|
|
||||||
:class="route.name === 'map' ? activeNavClass : inactiveNavClass"
|
|
||||||
>
|
|
||||||
地图
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink
|
|
||||||
to="/community"
|
|
||||||
class="px-3 py-2 text-sm font-medium tracking-[0.12em] uppercase transition-colors"
|
|
||||||
:class="route.name === 'community' ? activeNavClass : inactiveNavClass"
|
|
||||||
>
|
|
||||||
社区
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink
|
|
||||||
to="/gallery"
|
|
||||||
class="px-3 py-2 text-sm font-medium tracking-[0.12em] uppercase transition-colors"
|
|
||||||
:class="route.name === 'gallery' ? activeNavClass : inactiveNavClass"
|
|
||||||
>
|
|
||||||
画廊
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink
|
|
||||||
v-if="authStore.isLoggedIn"
|
|
||||||
to="/encyclopedia"
|
|
||||||
class="px-3 py-2 text-sm font-medium tracking-[0.12em] uppercase transition-colors"
|
|
||||||
:class="route.name === 'encyclopedia' || route.name === 'cloud-type' ? activeNavClass : inactiveNavClass"
|
|
||||||
>
|
|
||||||
图鉴
|
|
||||||
</RouterLink>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<NSpace align="center" :size="8" class="shrink-0 md:[&_.n-button]:px-4">
|
|
||||||
<template v-if="!authStore.loading">
|
|
||||||
<RouterLink
|
|
||||||
v-if="authStore.isLoggedIn"
|
|
||||||
to="/upload"
|
|
||||||
class="no-underline"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="inline-flex h-8 items-center border border-sky-200 bg-sky-100 px-3 text-sm font-medium uppercase tracking-[0.12em] text-sky-800 shadow-[4px_4px_0_0_rgba(14,165,233,0.14)] transition-[background-color,color,transform,box-shadow] hover:-translate-x-px hover:-translate-y-px hover:bg-sky-50 hover:text-sky-900 hover:shadow-[5px_5px_0_0_rgba(14,165,233,0.18)] md:h-10 md:px-4"
|
|
||||||
:class="route.name === 'upload' ? 'ring-1 ring-sky-300' : ''"
|
|
||||||
>
|
|
||||||
上传
|
|
||||||
</span>
|
|
||||||
</RouterLink>
|
|
||||||
|
|
||||||
<template v-if="authStore.isLoggedIn">
|
|
||||||
<div
|
|
||||||
class="relative"
|
|
||||||
@mouseenter="openAccountCard"
|
|
||||||
@mouseleave="closeAccountCard"
|
|
||||||
@focusin="openAccountCard"
|
|
||||||
@focusout="closeAccountCard"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="inline-flex h-8 max-w-[8.5rem] items-center gap-2 border border-teal-100 bg-white/80 px-3 text-sm font-medium text-teal-700 shadow-[3px_3px_0_0_rgba(20,184,166,0.08)] transition-[background-color,color,transform,box-shadow,border-color] hover:-translate-x-px hover:-translate-y-px hover:border-teal-200 hover:bg-teal-50/70 hover:text-teal-800 hover:shadow-[4px_4px_0_0_rgba(20,184,166,0.12)] md:h-10 md:max-w-none"
|
|
||||||
:class="route.name === 'profile' || route.name === 'profile-settings' ? 'border-teal-200 bg-teal-50/80 text-teal-800 ring-1 ring-teal-200 shadow-[4px_4px_0_0_rgba(20,184,166,0.12)]' : ''"
|
|
||||||
aria-haspopup="menu"
|
|
||||||
:aria-expanded="accountCardOpen"
|
|
||||||
>
|
|
||||||
<NIcon size="16" class="shrink-0">
|
|
||||||
<User />
|
|
||||||
</NIcon>
|
|
||||||
<span class="truncate">@{{ displayUsername }}</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="accountCardOpen"
|
|
||||||
class="absolute right-0 top-full z-50 w-72 pt-3"
|
|
||||||
role="menu"
|
|
||||||
>
|
|
||||||
<div class="border border-slate-200 bg-white shadow-[8px_8px_0_0_rgba(15,23,42,0.08)]">
|
|
||||||
<div class="border-b border-slate-200 bg-[linear-gradient(180deg,#f0fdfa_0%,#ffffff_100%)] px-4 py-4">
|
|
||||||
<div class="flex items-center gap-3">
|
|
||||||
<div class="flex h-11 w-11 shrink-0 items-center justify-center border border-teal-200 bg-[linear-gradient(135deg,#ecfeff_0%,#ccfbf1_100%)] text-lg font-bold text-teal-800">
|
|
||||||
{{ displayUsername.slice(0, 1).toUpperCase() }}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="min-w-0">
|
<div>
|
||||||
<p class="truncate text-sm font-semibold text-slate-950">@{{ displayUsername }}</p>
|
<div class="text-[11px] uppercase tracking-[0.22em] text-slate-500">
|
||||||
<p class="mt-1 truncate text-xs text-slate-500">{{ userEmail }}</p>
|
Live Sky Atlas
|
||||||
|
</div>
|
||||||
|
<div class="text-lg font-bold text-slate-900">OpenCloud</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</RouterLink>
|
||||||
<div class="mt-3 flex items-center gap-2 text-xs text-slate-500">
|
|
||||||
<!-- <span class="border border-teal-100 bg-teal-50 px-2 py-1 text-teal-700">
|
<nav
|
||||||
|
class="oc-panel-card hidden items-center gap-2 border border-slate-200 bg-white px-2 py-2 md:flex"
|
||||||
|
>
|
||||||
|
<RouterLink
|
||||||
|
to="/"
|
||||||
|
class="oc-nav-link"
|
||||||
|
:class="route.name === 'map' ? activeNavClass : inactiveNavClass"
|
||||||
|
>
|
||||||
|
地图
|
||||||
|
</RouterLink>
|
||||||
|
<RouterLink
|
||||||
|
to="/community"
|
||||||
|
class="oc-nav-link"
|
||||||
|
:class="route.name === 'community' ? activeNavClass : inactiveNavClass"
|
||||||
|
>
|
||||||
|
社区
|
||||||
|
</RouterLink>
|
||||||
|
<RouterLink
|
||||||
|
to="/gallery"
|
||||||
|
class="oc-nav-link"
|
||||||
|
:class="route.name === 'gallery' ? activeNavClass : inactiveNavClass"
|
||||||
|
>
|
||||||
|
画廊
|
||||||
|
</RouterLink>
|
||||||
|
<RouterLink
|
||||||
|
v-if="authStore.isLoggedIn"
|
||||||
|
to="/encyclopedia"
|
||||||
|
class="oc-nav-link"
|
||||||
|
:class="
|
||||||
|
route.name === 'encyclopedia' || route.name === 'cloud-type'
|
||||||
|
? activeNavClass
|
||||||
|
: inactiveNavClass
|
||||||
|
"
|
||||||
|
>
|
||||||
|
百科
|
||||||
|
</RouterLink>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<NSpace align="center" :size="8" class="shrink-0 md:[&_.n-button]:px-4">
|
||||||
|
<template v-if="!authStore.loading">
|
||||||
|
<RouterLink
|
||||||
|
v-if="authStore.isLoggedIn"
|
||||||
|
to="/upload"
|
||||||
|
class="no-underline"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="oc-header-button oc-header-button--sky uppercase tracking-[0.12em]"
|
||||||
|
:class="route.name === 'upload' ? 'ring-1 ring-sky-300' : ''"
|
||||||
|
>
|
||||||
|
上传
|
||||||
|
</span>
|
||||||
|
</RouterLink>
|
||||||
|
|
||||||
|
<template v-if="authStore.isLoggedIn">
|
||||||
|
<div
|
||||||
|
class="relative"
|
||||||
|
@mouseenter="openAccountCard"
|
||||||
|
@mouseleave="closeAccountCard"
|
||||||
|
@focusin="openAccountCard"
|
||||||
|
@focusout="closeAccountCard"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-header-button oc-header-button--teal max-w-[8.5rem] gap-2 md:max-w-none"
|
||||||
|
:class="
|
||||||
|
route.name === 'profile' ||
|
||||||
|
route.name === 'profile-settings'
|
||||||
|
? 'border-teal-200 bg-teal-50/80 text-teal-800 ring-1 ring-teal-200'
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
aria-haspopup="menu"
|
||||||
|
:aria-expanded="accountCardOpen"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
v-if="authStore.user?.image && !avatarFailed"
|
||||||
|
:src="authStore.user.image"
|
||||||
|
alt=""
|
||||||
|
class="h-5 w-5 shrink-0 object-cover"
|
||||||
|
@error="avatarFailed = true"
|
||||||
|
/>
|
||||||
|
<NIcon v-else size="16" class="shrink-0"><User /></NIcon>
|
||||||
|
<span class="truncate">@{{ displayUsername }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="accountCardOpen"
|
||||||
|
class="absolute right-0 top-full z-50 w-72 pt-3"
|
||||||
|
role="menu"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="oc-floating-panel border border-slate-200 bg-white"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="border-b border-slate-200 bg-[linear-gradient(180deg,#f2faf6_0%,#ffffff_100%)] px-4 py-4"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div
|
||||||
|
class="flex h-11 w-11 shrink-0 items-center justify-center border border-teal-200 bg-[linear-gradient(135deg,#eef9f3_0%,#d9efe3_100%)] text-lg font-bold text-teal-800"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
v-if="
|
||||||
|
authStore.user?.image &&
|
||||||
|
!avatarFailed
|
||||||
|
"
|
||||||
|
:src="authStore.user.image"
|
||||||
|
:alt="displayUsername"
|
||||||
|
class="h-full w-full object-cover"
|
||||||
|
@error="avatarFailed = true"
|
||||||
|
/>
|
||||||
|
<template v-else>{{
|
||||||
|
displayUsername
|
||||||
|
.slice(0, 1)
|
||||||
|
.toUpperCase()
|
||||||
|
}}</template>
|
||||||
|
</div>
|
||||||
|
<div class="min-w-0">
|
||||||
|
<p
|
||||||
|
class="truncate text-sm font-semibold text-slate-950"
|
||||||
|
>
|
||||||
|
@{{ displayUsername }}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
class="mt-1 truncate text-xs text-slate-500"
|
||||||
|
>
|
||||||
|
{{ userEmail }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="mt-3 flex items-center gap-2 text-xs text-slate-500"
|
||||||
|
>
|
||||||
|
<!-- <span class="border border-teal-100 bg-teal-50 px-2 py-1 text-teal-700">
|
||||||
{{ authStore.isAdmin ? '管理员' : '观测者' }}
|
{{ authStore.isAdmin ? '管理员' : '观测者' }}
|
||||||
</span>
|
</span>
|
||||||
<span>OpenCloud 账号</span> -->
|
<span>OpenCloud 账号</span> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="py-2">
|
<div class="py-2">
|
||||||
<RouterLink
|
<RouterLink
|
||||||
to="/profile"
|
to="/profile"
|
||||||
class="flex items-center gap-3 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-teal-50 hover:text-teal-800"
|
class="oc-menu-item"
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
>
|
>
|
||||||
<NIcon size="18"><User /></NIcon>
|
<NIcon size="18"><User /></NIcon>
|
||||||
<span>个人中心</span>
|
<span>个人中心</span>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<RouterLink
|
<RouterLink
|
||||||
to="/profile/settings"
|
to="/profile/settings"
|
||||||
class="flex items-center gap-3 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-teal-50 hover:text-teal-800"
|
class="oc-menu-item"
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
>
|
>
|
||||||
<NIcon size="18"><Settings /></NIcon>
|
<NIcon size="18"><Settings /></NIcon>
|
||||||
<span>账号设置</span>
|
<span>账号设置</span>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<RouterLink
|
<RouterLink
|
||||||
v-if="authStore.isAdmin"
|
v-if="authStore.isAdmin"
|
||||||
to="/admin"
|
to="/admin"
|
||||||
class="flex items-center gap-3 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-amber-50 hover:text-amber-700"
|
class="oc-menu-item oc-menu-item--amber"
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
>
|
>
|
||||||
<NIcon size="18"><Shield /></NIcon>
|
<NIcon size="18"><Shield /></NIcon>
|
||||||
<span>管理后台</span>
|
<span>管理后台</span>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="border-t border-slate-200 p-2">
|
<div class="border-t border-slate-200 p-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="flex w-full items-center gap-3 px-2 py-2.5 text-left text-sm font-medium text-rose-600 transition-colors hover:bg-rose-50 hover:text-rose-700"
|
class="oc-menu-item oc-menu-item--danger px-2"
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
@click="handleLogout"
|
@click="handleLogout"
|
||||||
>
|
>
|
||||||
<NIcon size="18"><Logout /></NIcon>
|
<NIcon size="18"><Logout /></NIcon>
|
||||||
<span>登出</span>
|
<span>登出</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<RouterLink to="/login" class="no-underline">
|
||||||
|
<span
|
||||||
|
class="oc-header-button oc-header-button--neutral"
|
||||||
|
:class="
|
||||||
|
route.name === 'login'
|
||||||
|
? 'bg-teal-50 ring-0 ring-teal-100 text-teal-800'
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
>
|
||||||
|
登录
|
||||||
|
</span>
|
||||||
|
</RouterLink>
|
||||||
|
<RouterLink to="/register" class="no-underline">
|
||||||
|
<span
|
||||||
|
class="oc-header-button oc-header-button--sky"
|
||||||
|
:class="
|
||||||
|
route.name === 'register' ? 'ring-0 ring-sky-300' : ''
|
||||||
|
"
|
||||||
|
>
|
||||||
|
注册
|
||||||
|
</span>
|
||||||
|
</RouterLink>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</NSpace>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-else>
|
<nav
|
||||||
<RouterLink
|
class="flex items-center gap-2 overflow-x-auto border-t border-slate-200/80 py-2 md:hidden"
|
||||||
to="/login"
|
|
||||||
class="no-underline"
|
|
||||||
>
|
>
|
||||||
<span
|
<RouterLink
|
||||||
class="inline-flex h-8 items-center border border-slate-200 bg-white/80 px-3 text-sm font-medium text-slate-700 shadow-[3px_3px_0_0_rgba(15,23,42,0.06)] transition-[background-color,color,transform,box-shadow,border-color] hover:-translate-x-px hover:-translate-y-px hover:border-teal-200 hover:bg-teal-50 hover:text-teal-800 hover:shadow-[4px_4px_0_0_rgba(15,23,42,0.08)] md:h-10 md:px-4"
|
to="/"
|
||||||
:class="route.name === 'login' ? 'bg-teal-50 ring-0 ring-teal-100 text-teal-800' : ''"
|
class="oc-nav-link shrink-0"
|
||||||
>
|
:class="route.name === 'map' ? activeNavClass : inactiveNavClass"
|
||||||
登录
|
>
|
||||||
</span>
|
地图
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<RouterLink
|
<RouterLink
|
||||||
to="/register"
|
to="/community"
|
||||||
class="no-underline"
|
class="oc-nav-link shrink-0"
|
||||||
|
:class="route.name === 'community' ? activeNavClass : inactiveNavClass"
|
||||||
|
>
|
||||||
|
社区
|
||||||
|
</RouterLink>
|
||||||
|
<RouterLink
|
||||||
|
to="/gallery"
|
||||||
|
class="oc-nav-link shrink-0"
|
||||||
|
:class="route.name === 'gallery' ? activeNavClass : inactiveNavClass"
|
||||||
|
>
|
||||||
|
画廊
|
||||||
|
</RouterLink>
|
||||||
|
<RouterLink
|
||||||
|
v-if="authStore.isLoggedIn"
|
||||||
|
to="/encyclopedia"
|
||||||
|
class="oc-nav-link shrink-0"
|
||||||
|
:class="
|
||||||
|
route.name === 'encyclopedia' || route.name === 'cloud-type'
|
||||||
|
? activeNavClass
|
||||||
|
: inactiveNavClass
|
||||||
|
"
|
||||||
|
>
|
||||||
|
百科
|
||||||
|
</RouterLink>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<Transition name="header-reveal">
|
||||||
|
<div
|
||||||
|
v-if="headerHidden"
|
||||||
|
class="pointer-events-none absolute inset-x-0 top-3 flex justify-center"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-header-button oc-header-button--neutral pointer-events-auto gap-2 bg-white/94 text-xs tracking-[0.16em] backdrop-blur"
|
||||||
|
@click="showHeader(true)"
|
||||||
>
|
>
|
||||||
<span
|
<NIcon size="15"><ChevronDown /></NIcon>
|
||||||
class="inline-flex h-8 items-center border border-sky-200 bg-sky-100 px-3 text-sm font-medium text-sky-800 shadow-[4px_4px_0_0_rgba(14,165,233,0.14)] transition-[background-color,color,transform,box-shadow] hover:-translate-x-px hover:-translate-y-px hover:bg-sky-50 hover:text-sky-900 hover:shadow-[5px_5px_0_0_rgba(14,165,233,0.18)] md:h-10 md:px-4"
|
<span>展开导航</span>
|
||||||
:class="route.name === 'register' ? 'ring-0 ring-sky-300' : ''"
|
</button>
|
||||||
>
|
</div>
|
||||||
注册
|
</Transition>
|
||||||
</span>
|
</div>
|
||||||
</RouterLink>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</NSpace>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<nav class="flex items-center gap-2 overflow-x-auto border-t border-slate-200/80 py-2 md:hidden">
|
|
||||||
<RouterLink
|
|
||||||
to="/"
|
|
||||||
class="shrink-0 px-3 py-2 text-sm font-medium tracking-[0.12em] uppercase transition-colors"
|
|
||||||
:class="route.name === 'map' ? activeNavClass : inactiveNavClass"
|
|
||||||
>
|
|
||||||
地图
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink
|
|
||||||
to="/community"
|
|
||||||
class="shrink-0 px-3 py-2 text-sm font-medium tracking-[0.12em] uppercase transition-colors"
|
|
||||||
:class="route.name === 'community' ? activeNavClass : inactiveNavClass"
|
|
||||||
>
|
|
||||||
社区
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink
|
|
||||||
to="/gallery"
|
|
||||||
class="shrink-0 px-3 py-2 text-sm font-medium tracking-[0.12em] uppercase transition-colors"
|
|
||||||
:class="route.name === 'gallery' ? activeNavClass : inactiveNavClass"
|
|
||||||
>
|
|
||||||
画廊
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink
|
|
||||||
v-if="authStore.isLoggedIn"
|
|
||||||
to="/encyclopedia"
|
|
||||||
class="shrink-0 px-3 py-2 text-sm font-medium tracking-[0.12em] uppercase transition-colors"
|
|
||||||
:class="route.name === 'encyclopedia' || route.name === 'cloud-type' ? activeNavClass : inactiveNavClass"
|
|
||||||
>
|
|
||||||
图鉴
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink
|
|
||||||
v-if="!authStore.loading && authStore.isLoggedIn"
|
|
||||||
to="/profile"
|
|
||||||
class="shrink-0 px-3 py-2 text-sm font-medium tracking-[0.12em] uppercase transition-colors"
|
|
||||||
:class="route.name === 'profile' ? activeNavClass : inactiveNavClass"
|
|
||||||
>
|
|
||||||
主页
|
|
||||||
</RouterLink>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<button
|
|
||||||
v-if="headerHidden"
|
|
||||||
type="button"
|
|
||||||
class="absolute left-1/2 top-3 flex -translate-x-1/2 items-center gap-2 border border-slate-300 bg-white/94 px-3 py-1.5 text-xs font-medium tracking-[0.16em] text-slate-700 shadow-[4px_4px_0_0_rgba(15,23,42,0.08)] backdrop-blur transition-colors hover:border-slate-900 hover:text-slate-900"
|
|
||||||
@click="showHeader(true)"
|
|
||||||
>
|
|
||||||
<span>▼</span>
|
|
||||||
<span>展开导航</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.header-reveal-enter-active,
|
||||||
|
.header-reveal-leave-active {
|
||||||
|
transition:
|
||||||
|
opacity 240ms ease,
|
||||||
|
transform 240ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-reveal-enter-from,
|
||||||
|
.header-reveal-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-0.75rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.header-reveal-enter-active,
|
||||||
|
.header-reveal-leave-active {
|
||||||
|
transition-duration: 1ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-reveal-enter-from,
|
||||||
|
.header-reveal-leave-to {
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,407 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import { NButton, NSelect } from 'naive-ui'
|
|
||||||
|
|
||||||
export interface ContributionHeatmapCell {
|
|
||||||
date: string
|
|
||||||
count: number
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MonthStat {
|
|
||||||
key: string
|
|
||||||
label: string
|
|
||||||
totalCount: number
|
|
||||||
activeDays: number
|
|
||||||
}
|
|
||||||
|
|
||||||
const today = new Date()
|
|
||||||
const currentYear = today.getFullYear()
|
|
||||||
const currentMonth = today.getMonth() + 1
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
|
||||||
cells: ContributionHeatmapCell[]
|
|
||||||
totalCount: number
|
|
||||||
activeDays: number
|
|
||||||
currentStreak: number
|
|
||||||
bestStreak: number
|
|
||||||
activeDate?: string | null
|
|
||||||
title?: string
|
|
||||||
subtitle?: string
|
|
||||||
}>(), {
|
|
||||||
activeDate: null,
|
|
||||||
title: '上传活跃度',
|
|
||||||
subtitle: '按上传日期统计',
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
selectDate: [date: string]
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const viewMode = ref<'year' | 'month'>('year')
|
|
||||||
const selectedYear = ref(currentYear)
|
|
||||||
const selectedMonth = ref(currentMonth)
|
|
||||||
const hoveredMonthKey = ref<string | null>(null)
|
|
||||||
|
|
||||||
function parseLocalDate(dateString: string) {
|
|
||||||
const [year, month, day] = dateString.split('-').map(Number)
|
|
||||||
return new Date(year, (month || 1) - 1, day || 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDayKey(date: Date) {
|
|
||||||
const month = `${date.getMonth() + 1}`.padStart(2, '0')
|
|
||||||
const day = `${date.getDate()}`.padStart(2, '0')
|
|
||||||
return `${date.getFullYear()}-${month}-${day}`
|
|
||||||
}
|
|
||||||
|
|
||||||
function toMonthKey(dateString: string) {
|
|
||||||
const date = parseLocalDate(dateString)
|
|
||||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`
|
|
||||||
}
|
|
||||||
|
|
||||||
function startOfDay(date: Date) {
|
|
||||||
return new Date(date.getFullYear(), date.getMonth(), date.getDate())
|
|
||||||
}
|
|
||||||
|
|
||||||
function startOfWeek(date: Date) {
|
|
||||||
const result = startOfDay(date)
|
|
||||||
const weekday = result.getDay()
|
|
||||||
const offset = weekday === 0 ? 6 : weekday - 1
|
|
||||||
result.setDate(result.getDate() - offset)
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
const dailyCounts = computed(() => {
|
|
||||||
const counts = new Map<string, number>()
|
|
||||||
for (const cell of props.cells) {
|
|
||||||
counts.set(cell.date, cell.count)
|
|
||||||
}
|
|
||||||
return counts
|
|
||||||
})
|
|
||||||
|
|
||||||
const availableYears = computed(() => {
|
|
||||||
const years = new Set<number>([currentYear])
|
|
||||||
for (const cell of props.cells) {
|
|
||||||
years.add(parseLocalDate(cell.date).getFullYear())
|
|
||||||
}
|
|
||||||
return Array.from(years).sort((a, b) => b - a)
|
|
||||||
})
|
|
||||||
|
|
||||||
const yearOptions = computed(() => {
|
|
||||||
return availableYears.value.map(year => ({
|
|
||||||
label: `${year}年`,
|
|
||||||
value: year,
|
|
||||||
}))
|
|
||||||
})
|
|
||||||
|
|
||||||
const monthOptions = Array.from({ length: 12 }, (_, index) => ({
|
|
||||||
label: `${index + 1}月`,
|
|
||||||
value: index + 1,
|
|
||||||
}))
|
|
||||||
|
|
||||||
watch(availableYears, years => {
|
|
||||||
if (!years.includes(selectedYear.value)) {
|
|
||||||
selectedYear.value = years[0] || currentYear
|
|
||||||
}
|
|
||||||
}, { immediate: true })
|
|
||||||
|
|
||||||
const visibleCells = computed(() => {
|
|
||||||
if (viewMode.value === 'year') {
|
|
||||||
const start = new Date(selectedYear.value, 0, 1)
|
|
||||||
const end = new Date(selectedYear.value, 11, 31)
|
|
||||||
const alignedStart = startOfWeek(start)
|
|
||||||
const alignedEnd = startOfWeek(end)
|
|
||||||
alignedEnd.setDate(alignedEnd.getDate() + 6)
|
|
||||||
|
|
||||||
const cells: Array<ContributionHeatmapCell & { inRange: boolean; isToday: boolean }> = []
|
|
||||||
const cursor = new Date(alignedStart)
|
|
||||||
|
|
||||||
while (cursor <= alignedEnd) {
|
|
||||||
const key = formatDayKey(cursor)
|
|
||||||
const inRange = cursor >= start && cursor <= end
|
|
||||||
cells.push({
|
|
||||||
date: key,
|
|
||||||
count: dailyCounts.value.get(key) || 0,
|
|
||||||
inRange,
|
|
||||||
isToday: key === formatDayKey(today),
|
|
||||||
})
|
|
||||||
cursor.setDate(cursor.getDate() + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return cells
|
|
||||||
}
|
|
||||||
|
|
||||||
const start = new Date(selectedYear.value, selectedMonth.value - 1, 1)
|
|
||||||
const end = new Date(selectedYear.value, selectedMonth.value, 0)
|
|
||||||
const alignedStart = startOfWeek(start)
|
|
||||||
const alignedEnd = startOfWeek(end)
|
|
||||||
alignedEnd.setDate(alignedEnd.getDate() + 6)
|
|
||||||
|
|
||||||
const cells: Array<ContributionHeatmapCell & { inRange: boolean; isToday: boolean }> = []
|
|
||||||
const cursor = new Date(alignedStart)
|
|
||||||
|
|
||||||
while (cursor <= alignedEnd) {
|
|
||||||
const key = formatDayKey(cursor)
|
|
||||||
const inRange = cursor >= start && cursor <= end
|
|
||||||
cells.push({
|
|
||||||
date: key,
|
|
||||||
count: dailyCounts.value.get(key) || 0,
|
|
||||||
inRange,
|
|
||||||
isToday: key === formatDayKey(today),
|
|
||||||
})
|
|
||||||
cursor.setDate(cursor.getDate() + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return cells
|
|
||||||
})
|
|
||||||
|
|
||||||
const maxCount = computed(() => {
|
|
||||||
return visibleCells.value.reduce((max, cell) => Math.max(max, cell.count), 0)
|
|
||||||
})
|
|
||||||
|
|
||||||
function getLevel(count: number) {
|
|
||||||
if (count <= 0) return 0
|
|
||||||
|
|
||||||
const max = Math.max(maxCount.value, 1)
|
|
||||||
const ratio = count / max
|
|
||||||
|
|
||||||
if (ratio >= 0.75 || count >= 8) return 4
|
|
||||||
if (ratio >= 0.5 || count >= 5) return 3
|
|
||||||
if (ratio >= 0.25 || count >= 3) return 2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCellClass(cell: { count: number; inRange: boolean }) {
|
|
||||||
if (!cell.inRange) return 'bg-transparent border-transparent'
|
|
||||||
|
|
||||||
const level = getLevel(cell.count)
|
|
||||||
if (level === 0) return 'bg-zinc-100 border-zinc-200'
|
|
||||||
if (level === 1) return 'bg-[#e0f2fe] border-[#bae6fd]'
|
|
||||||
if (level === 2) return 'bg-[#7dd3fc] border-[#38bdf8]'
|
|
||||||
if (level === 3) return 'bg-[#0ea5e9] border-[#0284c7]'
|
|
||||||
return 'bg-[#0f3d63] border-[#0b2f4d]'
|
|
||||||
}
|
|
||||||
|
|
||||||
const weeks = computed(() => {
|
|
||||||
const buckets: Array<typeof visibleCells.value> = []
|
|
||||||
for (let index = 0; index < visibleCells.value.length; index += 7) {
|
|
||||||
buckets.push(visibleCells.value.slice(index, index + 7))
|
|
||||||
}
|
|
||||||
return buckets
|
|
||||||
})
|
|
||||||
|
|
||||||
const monthStats = computed(() => {
|
|
||||||
const stats = new Map<string, MonthStat>()
|
|
||||||
|
|
||||||
for (const cell of visibleCells.value) {
|
|
||||||
if (!cell.inRange) continue
|
|
||||||
const monthKey = toMonthKey(cell.date)
|
|
||||||
const date = parseLocalDate(cell.date)
|
|
||||||
const label = `${date.getMonth() + 1}月`
|
|
||||||
const existing = stats.get(monthKey)
|
|
||||||
|
|
||||||
if (existing) {
|
|
||||||
existing.totalCount += cell.count
|
|
||||||
if (cell.count > 0) existing.activeDays += 1
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
stats.set(monthKey, {
|
|
||||||
key: monthKey,
|
|
||||||
label,
|
|
||||||
totalCount: cell.count,
|
|
||||||
activeDays: cell.count > 0 ? 1 : 0,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return stats
|
|
||||||
})
|
|
||||||
|
|
||||||
const monthLabels = computed(() => {
|
|
||||||
if (viewMode.value !== 'year') return []
|
|
||||||
|
|
||||||
let lastMonth = -1
|
|
||||||
return weeks.value.map(week => {
|
|
||||||
const firstInRange = week.find(cell => cell.inRange)
|
|
||||||
if (!firstInRange) return null
|
|
||||||
|
|
||||||
const date = parseLocalDate(firstInRange.date)
|
|
||||||
const month = date.getMonth()
|
|
||||||
const labelMonth = month + 1
|
|
||||||
const monthKey = toMonthKey(firstInRange.date)
|
|
||||||
|
|
||||||
if (month === lastMonth) return null
|
|
||||||
|
|
||||||
lastMonth = month
|
|
||||||
return {
|
|
||||||
key: monthKey,
|
|
||||||
label: labelMonth === 1 ? `${selectedYear.value}/1月` : `${labelMonth}月`,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
const monthPreview = computed(() => {
|
|
||||||
if (!hoveredMonthKey.value) return null
|
|
||||||
return monthStats.value.get(hoveredMonthKey.value) || null
|
|
||||||
})
|
|
||||||
|
|
||||||
const panelSummary = computed(() => {
|
|
||||||
if (viewMode.value === 'year') {
|
|
||||||
return `${selectedYear.value} 年完整视图,包含尚未来到的日期。`
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${selectedYear.value} 年 ${selectedMonth.value} 月完整视图。`
|
|
||||||
})
|
|
||||||
|
|
||||||
function formatTooltip(cell: ContributionHeatmapCell & { inRange: boolean; isToday: boolean }) {
|
|
||||||
const date = parseLocalDate(cell.date)
|
|
||||||
const label = date.toLocaleDateString('zh-CN', {
|
|
||||||
year: 'numeric',
|
|
||||||
month: 'long',
|
|
||||||
day: 'numeric',
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!cell.inRange) {
|
|
||||||
return `${label}:不在当前视图范围内`
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cell.count === 0) {
|
|
||||||
return `${label}${cell.isToday ? '(今天)' : ''}:当天没有上传`
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${label}${cell.isToday ? '(今天)' : ''}:上传 ${cell.count} 张`
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleCellClick(cell: ContributionHeatmapCell & { inRange: boolean }) {
|
|
||||||
if (!cell.inRange) return
|
|
||||||
emit('selectDate', cell.date)
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatMonthTooltip(monthKey: string) {
|
|
||||||
const stats = monthStats.value.get(monthKey)
|
|
||||||
if (!stats) return ''
|
|
||||||
return `${stats.label}:共上传 ${stats.totalCount} 张,活跃于 ${stats.activeDays} 天`
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="oc-panel-card border border-slate-200 bg-white p-6 shadow-sm">
|
|
||||||
<div class="flex flex-wrap items-start justify-between gap-6">
|
|
||||||
<div class="min-w-0 flex-1">
|
|
||||||
<h3 class="text-2xl font-bold text-slate-900">{{ title }}</h3>
|
|
||||||
<p class="mt-3 text-sm leading-7 text-slate-500">
|
|
||||||
共上传 {{ totalCount }} 张,活跃于 {{ activeDays }} 天。颜色越深,代表当天上传的照片越多。
|
|
||||||
</p>
|
|
||||||
<p class="mt-2 text-sm text-slate-500">{{ panelSummary }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex flex-wrap items-center justify-end gap-3">
|
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
|
||||||
<NButton
|
|
||||||
secondary
|
|
||||||
strong
|
|
||||||
type="default"
|
|
||||||
:class="viewMode === 'year' ? 'oc-panel-button oc-panel-button--teal' : 'oc-panel-button oc-panel-button--neutral'"
|
|
||||||
@click="viewMode = 'year'"
|
|
||||||
>
|
|
||||||
年度视图
|
|
||||||
</NButton>
|
|
||||||
<NButton
|
|
||||||
secondary
|
|
||||||
strong
|
|
||||||
type="default"
|
|
||||||
:class="viewMode === 'month' ? 'oc-panel-button oc-panel-button--teal' : 'oc-panel-button oc-panel-button--neutral'"
|
|
||||||
@click="viewMode = 'month'"
|
|
||||||
>
|
|
||||||
月度视图
|
|
||||||
</NButton>
|
|
||||||
</div>
|
|
||||||
<NSelect
|
|
||||||
v-model:value="selectedYear"
|
|
||||||
:options="yearOptions"
|
|
||||||
class="w-28"
|
|
||||||
/>
|
|
||||||
<NSelect
|
|
||||||
v-if="viewMode === 'month'"
|
|
||||||
v-model:value="selectedMonth"
|
|
||||||
:options="monthOptions"
|
|
||||||
class="w-24"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-4 flex min-h-6 items-center justify-between gap-4 text-xs text-slate-500">
|
|
||||||
<span>点击某一天可筛选当天上传记录。</span>
|
|
||||||
<span v-if="monthPreview" class="text-right">
|
|
||||||
{{ monthPreview.label }}:{{ monthPreview.totalCount }} 张 / {{ monthPreview.activeDays }} 天
|
|
||||||
</span>
|
|
||||||
<span v-else class="text-right">
|
|
||||||
<template v-if="viewMode === 'year'">悬停月份标签可预览当月上传摘要。</template>
|
|
||||||
<template v-else>当前显示整个月的上传情况。</template>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-8 overflow-x-auto">
|
|
||||||
<div :class="viewMode === 'year' ? 'min-w-[980px]' : 'min-w-[360px]'">
|
|
||||||
<div
|
|
||||||
v-if="viewMode === 'year'"
|
|
||||||
class="mb-2 grid grid-flow-col auto-cols-[14px] gap-1 pl-8 text-[11px] text-slate-400"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
v-for="(month, index) in monthLabels"
|
|
||||||
:key="`${month?.key || 'empty'}-${index}`"
|
|
||||||
class="w-[14px] whitespace-nowrap"
|
|
||||||
:title="month ? formatMonthTooltip(month.key) : ''"
|
|
||||||
@mouseenter="hoveredMonthKey = month?.key || null"
|
|
||||||
@mouseleave="hoveredMonthKey = null"
|
|
||||||
>
|
|
||||||
{{ month?.label || '' }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex gap-3">
|
|
||||||
<div class="grid grid-rows-7 gap-1 pt-[2px] text-[11px] text-slate-400">
|
|
||||||
<span>一</span>
|
|
||||||
<span></span>
|
|
||||||
<span>三</span>
|
|
||||||
<span></span>
|
|
||||||
<span>五</span>
|
|
||||||
<span></span>
|
|
||||||
<span>日</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid grid-flow-col auto-cols-[14px] gap-1">
|
|
||||||
<div
|
|
||||||
v-for="(week, weekIndex) in weeks"
|
|
||||||
:key="weekIndex"
|
|
||||||
class="grid grid-rows-7 gap-1"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
v-for="cell in week"
|
|
||||||
:key="cell.date"
|
|
||||||
type="button"
|
|
||||||
class="relative h-3.5 w-3.5 border transition-transform hover:scale-125"
|
|
||||||
:class="[
|
|
||||||
getCellClass(cell),
|
|
||||||
props.activeDate === cell.date ? 'ring-2 ring-slate-900 ring-offset-1' : '',
|
|
||||||
cell.isToday && cell.inRange ? 'outline outline-1 outline-slate-900 outline-offset-1' : '',
|
|
||||||
]"
|
|
||||||
:title="formatTooltip(cell)"
|
|
||||||
@click="handleCellClick(cell)"
|
|
||||||
></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-5 flex items-center justify-end gap-2 text-xs text-slate-500">
|
|
||||||
<span>少</span>
|
|
||||||
<span class="h-3 w-3 border border-slate-200 bg-slate-100"></span>
|
|
||||||
<span class="h-3 w-3 border border-sky-200 bg-sky-100"></span>
|
|
||||||
<span class="h-3 w-3 border border-sky-400 bg-sky-300"></span>
|
|
||||||
<span class="h-3 w-3 border border-teal-600 bg-teal-500"></span>
|
|
||||||
<span class="h-3 w-3 border border-slate-900 bg-slate-900"></span>
|
|
||||||
<span>多</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -1,234 +0,0 @@
|
|||||||
import { ref } from 'vue'
|
|
||||||
import { apiRequest } from '@/lib/api'
|
|
||||||
import { useAuthStore } from '@/stores/auth'
|
|
||||||
import { useProfileStore } from '@/stores/profile'
|
|
||||||
import type { CloudCreateResponse } from '@/types/api'
|
|
||||||
import type { CloudType } from '@/types/database'
|
|
||||||
|
|
||||||
export interface UploadItem {
|
|
||||||
id: string
|
|
||||||
file: File
|
|
||||||
preview: string
|
|
||||||
cloudCategoryId: number | 'other' | null
|
|
||||||
customCloudType: string
|
|
||||||
locationName: string
|
|
||||||
description: string
|
|
||||||
isHidden: boolean
|
|
||||||
latitude: number | null
|
|
||||||
longitude: number | null
|
|
||||||
capturedAt: string
|
|
||||||
errors: Record<string, string>
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UnlockedBadge {
|
|
||||||
cloudTypeId: number
|
|
||||||
cloudName: string
|
|
||||||
cloudNameEn: string
|
|
||||||
rarity: CloudType['rarity']
|
|
||||||
unlockedAt: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UploadResult {
|
|
||||||
ok: boolean
|
|
||||||
unlockedBadges: UnlockedBadge[]
|
|
||||||
}
|
|
||||||
|
|
||||||
let nextId = 0
|
|
||||||
|
|
||||||
function readFileAsArrayBuffer(file: File): Promise<ArrayBuffer> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const reader = new FileReader()
|
|
||||||
reader.onload = () => resolve(reader.result as ArrayBuffer)
|
|
||||||
reader.onerror = reject
|
|
||||||
reader.readAsArrayBuffer(file)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractExifDate(buffer: ArrayBuffer): string | null {
|
|
||||||
const view = new DataView(buffer)
|
|
||||||
if (view.getUint16(0, false) !== 0xffd8) return null
|
|
||||||
|
|
||||||
let offset = 2
|
|
||||||
while (offset < view.byteLength - 2) {
|
|
||||||
const marker = view.getUint16(offset, false)
|
|
||||||
offset += 2
|
|
||||||
if ((marker & 0xff00) !== 0xff00) break
|
|
||||||
const length = view.getUint16(offset, false)
|
|
||||||
offset += 2
|
|
||||||
|
|
||||||
if (marker === 0xffe1) {
|
|
||||||
const exifStart = offset
|
|
||||||
const header = String.fromCharCode(
|
|
||||||
view.getUint8(exifStart),
|
|
||||||
view.getUint8(exifStart + 1),
|
|
||||||
view.getUint8(exifStart + 2),
|
|
||||||
view.getUint8(exifStart + 3),
|
|
||||||
)
|
|
||||||
if (header !== 'Exif') break
|
|
||||||
|
|
||||||
const tiffStart = exifStart + 6
|
|
||||||
const isLE = view.getUint16(tiffStart, false) === 0x4949
|
|
||||||
const ifdStart = tiffStart + view.getUint32(tiffStart + 4, isLE)
|
|
||||||
const numEntries = view.getUint16(ifdStart, isLE)
|
|
||||||
|
|
||||||
for (let i = 0; i < numEntries; i++) {
|
|
||||||
const entryStart = ifdStart + 2 + i * 12
|
|
||||||
if (entryStart + 12 > buffer.byteLength) break
|
|
||||||
if (view.getUint16(entryStart, isLE) !== 0x9003) continue
|
|
||||||
|
|
||||||
const dataOffset = view.getUint32(entryStart + 8, isLE)
|
|
||||||
const dateStr = Array.from({ length: 20 }, (_, j) =>
|
|
||||||
String.fromCharCode(view.getUint8(tiffStart + dataOffset + j)),
|
|
||||||
).join('')
|
|
||||||
const date = new Date(dateStr.replace(/^(\d{4}):(\d{2}):(\d{2})/, '$1-$2-$3'))
|
|
||||||
if (!isNaN(date.getTime())) return date.toISOString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
offset += length - 2
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
function appendOptional(form: FormData, key: string, value: string | number | null) {
|
|
||||||
if (value !== null && value !== '') form.append(key, String(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useUpload() {
|
|
||||||
const authStore = useAuthStore()
|
|
||||||
const profileStore = useProfileStore()
|
|
||||||
const items = ref<UploadItem[]>([])
|
|
||||||
const uploading = ref(false)
|
|
||||||
const overallProgress = ref(0)
|
|
||||||
const currentItemIndex = ref(0)
|
|
||||||
const totalItems = ref(0)
|
|
||||||
|
|
||||||
async function addFiles(files: File[]) {
|
|
||||||
const imageFiles = files.filter(file => file.type.startsWith('image/'))
|
|
||||||
for (const file of imageFiles) {
|
|
||||||
let capturedAt = new Date().toISOString()
|
|
||||||
try {
|
|
||||||
const exifDate = extractExifDate(await readFileAsArrayBuffer(file))
|
|
||||||
if (exifDate) capturedAt = exifDate
|
|
||||||
} catch {
|
|
||||||
// 无 EXIF 时使用当前时间。
|
|
||||||
}
|
|
||||||
|
|
||||||
items.value.push({
|
|
||||||
id: String(++nextId),
|
|
||||||
file,
|
|
||||||
preview: URL.createObjectURL(file),
|
|
||||||
cloudCategoryId: null,
|
|
||||||
customCloudType: '',
|
|
||||||
locationName: '',
|
|
||||||
description: '',
|
|
||||||
isHidden: false,
|
|
||||||
latitude: null,
|
|
||||||
longitude: null,
|
|
||||||
capturedAt,
|
|
||||||
errors: {},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeItem(id: string) {
|
|
||||||
const index = items.value.findIndex(item => item.id === id)
|
|
||||||
if (index === -1) return
|
|
||||||
URL.revokeObjectURL(items.value[index].preview)
|
|
||||||
items.value.splice(index, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearAll() {
|
|
||||||
items.value.forEach(item => URL.revokeObjectURL(item.preview))
|
|
||||||
items.value = []
|
|
||||||
}
|
|
||||||
|
|
||||||
function validateItem(item: UploadItem) {
|
|
||||||
const errors: Record<string, string> = {}
|
|
||||||
if (!item.cloudCategoryId) errors.cloudCategory = '请选择类别'
|
|
||||||
if (item.cloudCategoryId === 'other' && !item.customCloudType.trim()) {
|
|
||||||
errors.cloudCategory = '请输入自定义云型名称'
|
|
||||||
}
|
|
||||||
if (!item.capturedAt) errors.capturedAt = '请选择拍摄时间'
|
|
||||||
|
|
||||||
const hasLat = typeof item.latitude === 'number' && !isNaN(item.latitude)
|
|
||||||
const hasLng = typeof item.longitude === 'number' && !isNaN(item.longitude)
|
|
||||||
if (hasLat && !hasLng) errors.longitude = '经纬度必须同时填写'
|
|
||||||
if (hasLng && !hasLat) errors.latitude = '经纬度必须同时填写'
|
|
||||||
item.errors = errors
|
|
||||||
return Object.keys(errors).length === 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function validateAll() {
|
|
||||||
return items.value.map(validateItem).every(Boolean)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function uploadAll(): Promise<UploadResult> {
|
|
||||||
if (!validateAll() || !authStore.user) return { ok: false, unlockedBadges: [] }
|
|
||||||
|
|
||||||
uploading.value = true
|
|
||||||
totalItems.value = items.value.length
|
|
||||||
currentItemIndex.value = 0
|
|
||||||
overallProgress.value = 0
|
|
||||||
const badges = new Map<number, UnlockedBadge>()
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (let index = 0; index < items.value.length; index++) {
|
|
||||||
const item = items.value[index]
|
|
||||||
currentItemIndex.value = index + 1
|
|
||||||
overallProgress.value = Math.round(index / items.value.length * 100)
|
|
||||||
|
|
||||||
const form = new FormData()
|
|
||||||
form.append('image', item.file)
|
|
||||||
if (item.cloudCategoryId === 'other') {
|
|
||||||
form.append('custom_cloud_type', item.customCloudType.trim())
|
|
||||||
} else {
|
|
||||||
form.append('cloud_type_id', String(item.cloudCategoryId))
|
|
||||||
}
|
|
||||||
appendOptional(form, 'latitude', item.latitude)
|
|
||||||
appendOptional(form, 'longitude', item.longitude)
|
|
||||||
appendOptional(form, 'location_name', item.locationName.trim())
|
|
||||||
appendOptional(form, 'description', item.description.trim())
|
|
||||||
appendOptional(form, 'captured_at', item.capturedAt)
|
|
||||||
form.append('is_hidden', String(item.isHidden))
|
|
||||||
|
|
||||||
const result = await apiRequest<CloudCreateResponse>('/clouds', {
|
|
||||||
method: 'POST',
|
|
||||||
body: form,
|
|
||||||
})
|
|
||||||
if (result.unlocked_badge) {
|
|
||||||
const badge = result.unlocked_badge
|
|
||||||
badges.set(badge.cloud_type_id, {
|
|
||||||
cloudTypeId: badge.cloud_type_id,
|
|
||||||
cloudName: badge.cloud_name,
|
|
||||||
cloudNameEn: badge.cloud_name_en,
|
|
||||||
rarity: badge.rarity,
|
|
||||||
unlockedAt: badge.unlocked_at,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
overallProgress.value = Math.round((index + 1) / items.value.length * 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
clearAll()
|
|
||||||
profileStore.invalidateUser(authStore.user.id)
|
|
||||||
return { ok: true, unlockedBadges: [...badges.values()] }
|
|
||||||
} catch {
|
|
||||||
return { ok: false, unlockedBadges: [] }
|
|
||||||
} finally {
|
|
||||||
uploading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
items,
|
|
||||||
uploading,
|
|
||||||
overallProgress,
|
|
||||||
currentItemIndex,
|
|
||||||
totalItems,
|
|
||||||
addFiles,
|
|
||||||
removeItem,
|
|
||||||
clearAll,
|
|
||||||
validateItem,
|
|
||||||
validateAll,
|
|
||||||
uploadAll,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import { apiRequest } from '@/lib/api'
|
||||||
|
import { toCloudDetail, toAuthUser } from '@/lib/api-adapters'
|
||||||
|
import { collectPages } from '@/lib/pagination'
|
||||||
|
import type {
|
||||||
|
CloudPageResponse,
|
||||||
|
UserProfileResponse,
|
||||||
|
MessageResponse,
|
||||||
|
CreateCloudTypeBody,
|
||||||
|
UpdateCloudTypeBody,
|
||||||
|
CloudTypeCreateResponse,
|
||||||
|
ReviewCloudsBody,
|
||||||
|
SetUserRoleBody,
|
||||||
|
} from '@/types/api-contract'
|
||||||
|
|
||||||
|
export async function listUsers() {
|
||||||
|
return (await apiRequest<UserProfileResponse[]>('/admin/users')).map(toAuthUser)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function listAdminClouds() {
|
||||||
|
return collectPages(async page => {
|
||||||
|
const result = await apiRequest<CloudPageResponse>('/admin/clouds', {
|
||||||
|
query: { page, page_size: 100 },
|
||||||
|
})
|
||||||
|
return { ...result, items: result.items.map(toCloudDetail) }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function reviewClouds(ids: string[], reviewStatus: ReviewCloudsBody['review_status']) {
|
||||||
|
for (let offset = 0; offset < ids.length; offset += 100) {
|
||||||
|
const body: ReviewCloudsBody = {
|
||||||
|
cloud_ids: ids.slice(offset, offset + 100),
|
||||||
|
review_status: reviewStatus,
|
||||||
|
}
|
||||||
|
await apiRequest<MessageResponse>('/admin/clouds/review', { method: 'POST', body })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteAdminCloud(id: string) {
|
||||||
|
return apiRequest<MessageResponse>(`/admin/clouds/${encodeURIComponent(id)}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setUserRole(id: string, role: SetUserRoleBody['role']) {
|
||||||
|
return apiRequest<MessageResponse>(`/admin/users/${encodeURIComponent(id)}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
body: { role },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setUserPassword(id: string, newPassword: string) {
|
||||||
|
return apiRequest<MessageResponse>(`/admin/users/${encodeURIComponent(id)}/password`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
body: { new_password: newPassword },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createCloudType(body: CreateCloudTypeBody) {
|
||||||
|
return apiRequest<CloudTypeCreateResponse>('/admin/cloud-types', { method: 'POST', body })
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateCloudType(id: number, body: UpdateCloudTypeBody) {
|
||||||
|
return apiRequest<MessageResponse>(`/admin/cloud-types/${id}`, { method: 'PATCH', body })
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteCloudTypeRecord(id: number) {
|
||||||
|
return apiRequest<MessageResponse>(`/admin/cloud-types/${id}`, { method: 'DELETE' })
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
|||||||
|
import { createAuthClient } from 'better-auth/client'
|
||||||
|
import { API_URL } from '@/lib/api'
|
||||||
|
|
||||||
|
export const authClient = createAuthClient({
|
||||||
|
baseURL: `${API_URL}/auth`,
|
||||||
|
fetchOptions: { credentials: 'include' },
|
||||||
|
})
|
||||||
|
|
||||||
|
interface AuthClientFailure {
|
||||||
|
code?: string
|
||||||
|
message?: string
|
||||||
|
status?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AuthClientError extends Error {
|
||||||
|
code?: string
|
||||||
|
status?: number
|
||||||
|
|
||||||
|
constructor(failure: AuthClientFailure, fallback: string) {
|
||||||
|
super(
|
||||||
|
failure.code === 'EMAIL_NOT_VERIFIED'
|
||||||
|
? '邮箱尚未验证,请先查收验证邮件。'
|
||||||
|
: failure.status === 429
|
||||||
|
? '操作过于频繁,请稍后重试。'
|
||||||
|
: fallback,
|
||||||
|
)
|
||||||
|
this.name = 'AuthClientError'
|
||||||
|
this.code = failure.code
|
||||||
|
this.status = failure.status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function assertAuthResult(result: { error?: AuthClientFailure | null }, fallback: string) {
|
||||||
|
if (result.error) throw new AuthClientError(result.error, fallback)
|
||||||
|
}
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { AUTH_EXPIRED_EVENT } from '@/lib/api'
|
||||||
|
import { assertAuthResult, authClient } from '@/features/auth/authClient'
|
||||||
|
import { getMyProfile, updateMyUsername } from '@/features/profile/api'
|
||||||
|
import type { AuthUser } from '@/types/view-models'
|
||||||
|
import type { Profile } from '@/types/models'
|
||||||
|
|
||||||
|
export const useAuthStore = defineStore('auth', () => {
|
||||||
|
const user = ref<AuthUser | null>(null)
|
||||||
|
const profile = ref<Profile | null>(null)
|
||||||
|
const loading = ref(true)
|
||||||
|
let listenerAttached = false
|
||||||
|
|
||||||
|
const isLoggedIn = computed(() => !!user.value)
|
||||||
|
const isAdmin = computed(() => profile.value?.role === 'admin')
|
||||||
|
|
||||||
|
function applyProfile(normalized: AuthUser) {
|
||||||
|
user.value = normalized
|
||||||
|
profile.value = {
|
||||||
|
id: normalized.id,
|
||||||
|
username: normalized.username,
|
||||||
|
image: normalized.image,
|
||||||
|
role: normalized.role,
|
||||||
|
is_disabled: normalized.is_disabled,
|
||||||
|
created_at: normalized.created_at,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearAuth() {
|
||||||
|
user.value = null
|
||||||
|
profile.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchMe() {
|
||||||
|
const backendProfile = await getMyProfile()
|
||||||
|
applyProfile(backendProfile)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function login(email: string, password: string) {
|
||||||
|
assertAuthResult(
|
||||||
|
await authClient.signIn.email({ email, password }),
|
||||||
|
'登录失败,请检查邮箱和密码。',
|
||||||
|
)
|
||||||
|
const session = await authClient.getSession()
|
||||||
|
assertAuthResult(session, '获取登录会话失败,请稍后重试。')
|
||||||
|
if (!session.data) throw new Error('未能建立登录会话,请稍后重试。')
|
||||||
|
await fetchMe()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function register(name: string, email: string, password: string) {
|
||||||
|
assertAuthResult(
|
||||||
|
await authClient.signUp.email({ name, email, password }),
|
||||||
|
'注册失败,请稍后重试。',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resendConfirmation(email: string) {
|
||||||
|
assertAuthResult(
|
||||||
|
await authClient.sendVerificationEmail({ email }),
|
||||||
|
'验证邮件发送失败,请稍后重试。',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function confirmEmail(token: string) {
|
||||||
|
assertAuthResult(
|
||||||
|
await authClient.$fetch('/verify-email', {
|
||||||
|
method: 'GET',
|
||||||
|
query: { token },
|
||||||
|
}),
|
||||||
|
'确认链接无效或已过期。',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sendPasswordReset(email: string) {
|
||||||
|
assertAuthResult(
|
||||||
|
await authClient.requestPasswordReset({ email }),
|
||||||
|
'重置邮件发送失败,请稍后重试。',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resetPassword(token: string, newPassword: string) {
|
||||||
|
assertAuthResult(
|
||||||
|
await authClient.resetPassword({ token, newPassword }),
|
||||||
|
'密码重置失败,请重新申请重置邮件。',
|
||||||
|
)
|
||||||
|
clearAuth()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function logout() {
|
||||||
|
const result = await authClient.signOut()
|
||||||
|
if (result.error?.status === 401) {
|
||||||
|
clearAuth()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
assertAuthResult(result, '退出登录失败,请稍后重试。')
|
||||||
|
clearAuth()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateUsername(username: string) {
|
||||||
|
const backendProfile = await updateMyUsername(username)
|
||||||
|
applyProfile(backendProfile)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updatePassword(currentPassword: string, newPassword: string) {
|
||||||
|
assertAuthResult(
|
||||||
|
await authClient.changePassword({
|
||||||
|
currentPassword,
|
||||||
|
newPassword,
|
||||||
|
revokeOtherSessions: true,
|
||||||
|
}),
|
||||||
|
'密码更新失败,请检查当前密码。',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initialize() {
|
||||||
|
if (!listenerAttached) {
|
||||||
|
window.addEventListener(AUTH_EXPIRED_EVENT, clearAuth)
|
||||||
|
listenerAttached = true
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const session = await authClient.getSession()
|
||||||
|
assertAuthResult(session, '获取登录会话失败,请稍后重试。')
|
||||||
|
if (session.data) await fetchMe()
|
||||||
|
else clearAuth()
|
||||||
|
} catch {
|
||||||
|
clearAuth()
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
user,
|
||||||
|
profile,
|
||||||
|
loading,
|
||||||
|
isLoggedIn,
|
||||||
|
isAdmin,
|
||||||
|
login,
|
||||||
|
register,
|
||||||
|
resendConfirmation,
|
||||||
|
confirmEmail,
|
||||||
|
sendPasswordReset,
|
||||||
|
resetPassword,
|
||||||
|
logout,
|
||||||
|
updateUsername,
|
||||||
|
refreshProfile: fetchMe,
|
||||||
|
updatePassword,
|
||||||
|
initialize,
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, onUnmounted, ref } from 'vue'
|
||||||
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { NButton, NCard, NResult, NSpin } from 'naive-ui'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
|
const state = ref<'loading' | 'success' | 'failed'>('loading')
|
||||||
|
const error = ref('')
|
||||||
|
const countdown = ref(5)
|
||||||
|
const token = typeof route.query.token === 'string' ? route.query.token : ''
|
||||||
|
let timer: ReturnType<typeof setInterval> | null = null
|
||||||
|
|
||||||
|
if (route.query.token !== undefined) {
|
||||||
|
window.history.replaceState(window.history.state, '', route.path)
|
||||||
|
}
|
||||||
|
|
||||||
|
function startCountdown() {
|
||||||
|
timer = setInterval(() => {
|
||||||
|
countdown.value--
|
||||||
|
if (countdown.value <= 0) {
|
||||||
|
if (timer) clearInterval(timer)
|
||||||
|
void router.push('/login')
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (!token) {
|
||||||
|
error.value = '确认链接缺少验证信息'
|
||||||
|
state.value = 'failed'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await authStore.confirmEmail(token)
|
||||||
|
state.value = 'success'
|
||||||
|
startCountdown()
|
||||||
|
} catch (e: unknown) {
|
||||||
|
error.value = e instanceof Error ? e.message : '确认链接无效或已过期'
|
||||||
|
state.value = 'failed'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (timer) clearInterval(timer)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="min-h-[calc(100vh-4rem)] px-4 py-10">
|
||||||
|
<div class="mx-auto max-w-3xl">
|
||||||
|
<NCard class="oc-panel-card-xl">
|
||||||
|
<NResult
|
||||||
|
v-if="state === 'success'"
|
||||||
|
status="success"
|
||||||
|
title="邮箱确认成功"
|
||||||
|
description="现在可以使用邮箱和密码登录。"
|
||||||
|
>
|
||||||
|
<template #footer>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<p class="text-sm text-slate-500">
|
||||||
|
{{ countdown }} 秒后自动前往登录页面
|
||||||
|
</p>
|
||||||
|
<RouterLink to="/login" class="no-underline"
|
||||||
|
><NButton
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--teal"
|
||||||
|
>立即登录</NButton
|
||||||
|
></RouterLink
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NResult>
|
||||||
|
<NResult
|
||||||
|
v-else-if="state === 'failed'"
|
||||||
|
status="error"
|
||||||
|
title="邮箱确认失败"
|
||||||
|
:description="error"
|
||||||
|
>
|
||||||
|
<template #footer>
|
||||||
|
<RouterLink to="/resend-confirmation" class="no-underline"
|
||||||
|
><NButton type="default" class="oc-panel-button oc-panel-button--sky"
|
||||||
|
>重新发送验证邮件</NButton
|
||||||
|
></RouterLink
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</NResult>
|
||||||
|
<div v-else class="flex flex-col items-center justify-center py-12 text-center">
|
||||||
|
<NSpin size="large" />
|
||||||
|
<h1 class="mt-6 text-2xl font-bold text-slate-900">正在确认邮箱...</h1>
|
||||||
|
<p class="mt-2 text-slate-500">请稍候</p>
|
||||||
|
</div>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, onUnmounted, ref } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import { NAlert, NButton, NCard, NForm, NFormItem, NInput, NResult } from 'naive-ui'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const route = useRoute()
|
||||||
|
const email = ref(typeof route.query.email === 'string' ? route.query.email : '')
|
||||||
|
const error = ref('')
|
||||||
|
const loading = ref(false)
|
||||||
|
const submitted = ref(false)
|
||||||
|
const cooldown = ref(0)
|
||||||
|
let timer: ReturnType<typeof setInterval> | null = null
|
||||||
|
|
||||||
|
const buttonLabel = computed(() =>
|
||||||
|
loading.value
|
||||||
|
? '发送中...'
|
||||||
|
: cooldown.value > 0
|
||||||
|
? `重新发送(${cooldown.value}s)`
|
||||||
|
: '重新发送',
|
||||||
|
)
|
||||||
|
|
||||||
|
function startCooldown() {
|
||||||
|
if (timer) clearInterval(timer)
|
||||||
|
cooldown.value = 60
|
||||||
|
timer = setInterval(() => {
|
||||||
|
cooldown.value--
|
||||||
|
if (cooldown.value <= 0 && timer) {
|
||||||
|
clearInterval(timer)
|
||||||
|
timer = null
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submit() {
|
||||||
|
error.value = ''
|
||||||
|
const value = email.value.trim()
|
||||||
|
if (!value || value.length > 64) {
|
||||||
|
error.value = '请输入不超过 64 个字符的有效邮箱'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
await authStore.sendPasswordReset(value)
|
||||||
|
email.value = value
|
||||||
|
submitted.value = true
|
||||||
|
startCooldown()
|
||||||
|
} catch (e: unknown) {
|
||||||
|
error.value = e instanceof Error ? e.message : '重置邮件发送失败,请稍后重试'
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (timer) clearInterval(timer)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="min-h-[calc(100vh-4rem)] px-4 py-10">
|
||||||
|
<div class="mx-auto max-w-2xl">
|
||||||
|
<NCard class="oc-panel-card-xl">
|
||||||
|
<NResult
|
||||||
|
v-if="submitted"
|
||||||
|
status="success"
|
||||||
|
title="请求已受理"
|
||||||
|
description="如果该邮箱符合条件,我们会发送密码重置邮件。"
|
||||||
|
>
|
||||||
|
<template #footer>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<p class="text-sm text-slate-500">
|
||||||
|
目标邮箱:<span class="font-semibold text-slate-700">{{
|
||||||
|
email
|
||||||
|
}}</span>
|
||||||
|
</p>
|
||||||
|
<div class="flex flex-wrap justify-center gap-3">
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
:disabled="cooldown > 0"
|
||||||
|
:loading="loading"
|
||||||
|
@click="submit"
|
||||||
|
>{{ buttonLabel }}</NButton
|
||||||
|
>
|
||||||
|
<RouterLink
|
||||||
|
:to="{ path: '/login', query: { email } }"
|
||||||
|
class="no-underline"
|
||||||
|
><NButton
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
>返回登录</NButton
|
||||||
|
></RouterLink
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NResult>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<div class="mb-8">
|
||||||
|
<div class="text-sm uppercase tracking-[0.22em] text-slate-500">
|
||||||
|
Password Recovery
|
||||||
|
</div>
|
||||||
|
<h1 class="mt-3 text-3xl font-bold text-slate-900">忘记密码</h1>
|
||||||
|
<p class="mt-2 text-sm text-slate-500">
|
||||||
|
输入注册邮箱,我们会发送有效期为 1 小时的重置链接。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<NForm @submit.prevent="submit">
|
||||||
|
<NFormItem label="邮箱">
|
||||||
|
<NInput
|
||||||
|
v-model:value="email"
|
||||||
|
maxlength="64"
|
||||||
|
type="text"
|
||||||
|
placeholder="your@email.com"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'email',
|
||||||
|
inputmode: 'email',
|
||||||
|
name: 'email',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</NFormItem>
|
||||||
|
<NAlert v-if="error" type="error" class="mb-4">{{ error }}</NAlert>
|
||||||
|
<NButton
|
||||||
|
attr-type="submit"
|
||||||
|
type="primary"
|
||||||
|
block
|
||||||
|
size="large"
|
||||||
|
class="oc-primary-button oc-primary-button--sky"
|
||||||
|
:loading="loading"
|
||||||
|
>{{ loading ? '发送中...' : '发送重置邮件' }}</NButton
|
||||||
|
>
|
||||||
|
</NForm>
|
||||||
|
<p class="mt-6 text-sm text-slate-500">
|
||||||
|
<RouterLink
|
||||||
|
:to="{ path: '/login', query: { email } }"
|
||||||
|
class="font-semibold text-sky-700 hover:text-sky-800"
|
||||||
|
>返回登录</RouterLink
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
</template>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
|
import { NAlert, NButton, NCard, NForm, NFormItem, NInput } from 'naive-ui'
|
||||||
|
import { AuthClientError } from '@/features/auth/authClient'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const email = ref(typeof route.query.email === 'string' ? route.query.email : '')
|
||||||
|
const password = ref('')
|
||||||
|
const error = ref('')
|
||||||
|
const loading = ref(false)
|
||||||
|
const needsEmailConfirmation = ref(false)
|
||||||
|
|
||||||
|
function getSafeRedirect(value: unknown) {
|
||||||
|
if (typeof value !== 'string' || !value.startsWith('/')) return '/'
|
||||||
|
|
||||||
|
try {
|
||||||
|
const target = new URL(value, window.location.origin)
|
||||||
|
return target.origin === window.location.origin
|
||||||
|
? `${target.pathname}${target.search}${target.hash}`
|
||||||
|
: '/'
|
||||||
|
} catch {
|
||||||
|
return '/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleLogin() {
|
||||||
|
error.value = ''
|
||||||
|
needsEmailConfirmation.value = false
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
await authStore.login(email.value, password.value)
|
||||||
|
void router.push(getSafeRedirect(route.query.redirect))
|
||||||
|
} catch (e: unknown) {
|
||||||
|
needsEmailConfirmation.value =
|
||||||
|
e instanceof AuthClientError && e.code === 'EMAIL_NOT_VERIFIED'
|
||||||
|
error.value = e instanceof Error ? e.message : '登录失败,请稍后重试'
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="min-h-[calc(100vh-4rem)] px-4 py-10">
|
||||||
|
<div
|
||||||
|
class="mx-auto grid min-w-0 max-w-6xl gap-8 lg:grid-cols-[1.1fr_0.9fr] lg:items-stretch"
|
||||||
|
>
|
||||||
|
<section
|
||||||
|
class="oc-panel-card-xl flex min-w-0 h-full flex-col justify-between overflow-hidden border border-slate-200 bg-[linear-gradient(135deg,#f2faf6_0%,#ffffff_48%,#eff6ff_100%)] p-6 sm:p-8"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<p class="text-sm uppercase tracking-[0.26em] text-teal-700">Sky Log In</p>
|
||||||
|
<h1
|
||||||
|
class="mt-4 max-w-xl break-words text-4xl font-black leading-[1.05] text-slate-900 sm:text-5xl"
|
||||||
|
>
|
||||||
|
登录后继续记录
|
||||||
|
<span class="block text-teal-700">你眼中的每一朵云</span>
|
||||||
|
</h1>
|
||||||
|
<!-- <p class="mt-6 max-w-lg text-base leading-8 text-slate-600">
|
||||||
|
在地图、百科和画廊之间浏览观测记录。上传新的云图后,审核通过的作品会进入公开画廊与地图。
|
||||||
|
</p> -->
|
||||||
|
</div>
|
||||||
|
<div class="mt-8 grid min-w-0 grid-cols-2 gap-4">
|
||||||
|
<div class="min-w-0 border border-slate-200 bg-white px-4 py-3">
|
||||||
|
<div class="oc-stat-label">Collection</div>
|
||||||
|
<div class="oc-stat-value">10</div>
|
||||||
|
<div class="oc-field-help">基础云属资料</div>
|
||||||
|
</div>
|
||||||
|
<div class="min-w-0 border border-slate-200 bg-white px-4 py-3">
|
||||||
|
<div class="oc-stat-label">Mode</div>
|
||||||
|
<div class="oc-stat-value">Atlas</div>
|
||||||
|
<div class="oc-field-help">地图、百科、画廊一体</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<NCard class="oc-panel-card-xl min-w-0 h-full">
|
||||||
|
<div class="mb-8">
|
||||||
|
<div class="text-sm uppercase tracking-[0.22em] text-slate-500">
|
||||||
|
Member Access
|
||||||
|
</div>
|
||||||
|
<h2 class="mt-3 text-3xl font-bold text-slate-900">登录 OpenCloud</h2>
|
||||||
|
<p class="mt-2 text-sm text-slate-500">输入邮箱和密码,继续你的天空档案。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<NForm @submit.prevent="handleLogin">
|
||||||
|
<NFormItem label="邮箱">
|
||||||
|
<NInput
|
||||||
|
v-model:value="email"
|
||||||
|
type="text"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'username',
|
||||||
|
inputmode: 'email',
|
||||||
|
name: 'username',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
placeholder="your@email.com"
|
||||||
|
/>
|
||||||
|
</NFormItem>
|
||||||
|
|
||||||
|
<NFormItem label="密码">
|
||||||
|
<NInput
|
||||||
|
v-model:value="password"
|
||||||
|
type="password"
|
||||||
|
show-password-on="click"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'current-password',
|
||||||
|
name: 'current-password',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
placeholder="输入密码"
|
||||||
|
/>
|
||||||
|
</NFormItem>
|
||||||
|
|
||||||
|
<NAlert v-if="error" type="error" class="mb-4">
|
||||||
|
{{ error }}
|
||||||
|
<div v-if="needsEmailConfirmation" class="mt-2">
|
||||||
|
<RouterLink
|
||||||
|
:to="{ path: '/resend-confirmation', query: { email } }"
|
||||||
|
class="font-semibold text-rose-700 underline underline-offset-2"
|
||||||
|
>
|
||||||
|
重新发送验证邮件
|
||||||
|
</RouterLink>
|
||||||
|
</div>
|
||||||
|
</NAlert>
|
||||||
|
|
||||||
|
<NButton
|
||||||
|
attr-type="submit"
|
||||||
|
type="primary"
|
||||||
|
block
|
||||||
|
size="large"
|
||||||
|
class="oc-primary-button oc-primary-button--teal"
|
||||||
|
:loading="loading"
|
||||||
|
>
|
||||||
|
{{ loading ? '登录中...' : '登录' }}
|
||||||
|
</NButton>
|
||||||
|
</NForm>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="mt-6 flex flex-wrap items-center justify-between gap-3 text-sm text-slate-500"
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
还没有账号?
|
||||||
|
<RouterLink
|
||||||
|
to="/register"
|
||||||
|
class="font-semibold text-sky-700 hover:text-sky-800"
|
||||||
|
>立即注册</RouterLink
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
<RouterLink
|
||||||
|
:to="{ path: '/forgot-password', query: { email } }"
|
||||||
|
class="font-semibold text-teal-700 hover:text-teal-800"
|
||||||
|
>
|
||||||
|
忘记密码
|
||||||
|
</RouterLink>
|
||||||
|
</div>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,240 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import { NAlert, NButton, NCard, NForm, NFormItem, NInput, NResult } from 'naive-ui'
|
||||||
|
import { AuthClientError } from '@/features/auth/authClient'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const name = ref('')
|
||||||
|
const email = ref(typeof route.query.email === 'string' ? route.query.email : '')
|
||||||
|
const password = ref('')
|
||||||
|
const confirmPassword = ref('')
|
||||||
|
const error = ref('')
|
||||||
|
const loading = ref(false)
|
||||||
|
const registered = ref(false)
|
||||||
|
const registerConflict = ref(false)
|
||||||
|
|
||||||
|
async function handleRegister() {
|
||||||
|
error.value = ''
|
||||||
|
registerConflict.value = false
|
||||||
|
const trimmedName = name.value.trim()
|
||||||
|
const trimmedEmail = email.value.trim()
|
||||||
|
|
||||||
|
if (!trimmedName) {
|
||||||
|
error.value = '请输入用户名'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (trimmedName.length > 16) {
|
||||||
|
error.value = '用户名不能超过 16 个字符'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!trimmedEmail || trimmedEmail.length > 64) {
|
||||||
|
error.value = '请输入不超过 64 个字符的有效邮箱'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (password.value.length < 8) {
|
||||||
|
error.value = '密码至少需要 8 位'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (password.value !== confirmPassword.value) {
|
||||||
|
error.value = '两次输入的密码不一致'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
await authStore.register(trimmedName, trimmedEmail, password.value)
|
||||||
|
email.value = trimmedEmail
|
||||||
|
registered.value = true
|
||||||
|
} catch (e: unknown) {
|
||||||
|
if (
|
||||||
|
e instanceof AuthClientError &&
|
||||||
|
(e.status === 409 || e.code === 'USER_ALREADY_EXISTS')
|
||||||
|
) {
|
||||||
|
registerConflict.value = true
|
||||||
|
error.value = '邮箱或用户名已被占用;若邮箱尚未验证,可以尝试重发验证邮件。'
|
||||||
|
} else {
|
||||||
|
error.value = e instanceof Error ? e.message : '注册失败,请稍后重试'
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="min-h-[calc(100vh-4rem)] px-4 py-10">
|
||||||
|
<div
|
||||||
|
class="mx-auto grid min-w-0 max-w-6xl gap-8 lg:grid-cols-[1.1fr_0.9fr] lg:items-stretch"
|
||||||
|
>
|
||||||
|
<section
|
||||||
|
class="oc-panel-card-xl flex min-w-0 h-full flex-col justify-between overflow-hidden border border-slate-200 bg-[linear-gradient(135deg,#eff6ff_0%,#ffffff_42%,#f2faf6_100%)] p-6 sm:p-8"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<p class="text-sm uppercase tracking-[0.26em] text-sky-700">Observer Join</p>
|
||||||
|
<h1
|
||||||
|
class="mt-4 max-w-xl break-words text-4xl font-black leading-[1.05] text-slate-900 sm:text-5xl"
|
||||||
|
>
|
||||||
|
加入天空探索者
|
||||||
|
<span class="block text-sky-700">建立你的云图档案</span>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div class="mt-8 grid min-w-0 grid-cols-2 gap-4">
|
||||||
|
<div class="min-w-0 border border-slate-200 bg-white px-4 py-3">
|
||||||
|
<div class="oc-stat-label">Step 1</div>
|
||||||
|
<div class="oc-stat-value">Join</div>
|
||||||
|
<div class="oc-field-help">填写账号资料</div>
|
||||||
|
</div>
|
||||||
|
<div class="min-w-0 border border-slate-200 bg-white px-4 py-3">
|
||||||
|
<div class="oc-stat-label">Step 2</div>
|
||||||
|
<div class="oc-stat-value">Verify</div>
|
||||||
|
<div class="oc-field-help">通过邮件确认邮箱</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<NCard class="oc-panel-card-xl min-w-0 h-full">
|
||||||
|
<NResult
|
||||||
|
v-if="registered"
|
||||||
|
status="success"
|
||||||
|
title="确认你的邮箱"
|
||||||
|
description="如该邮箱可以注册,请查收验证邮件并点击链接。验证后请重新登录。"
|
||||||
|
>
|
||||||
|
<template #footer>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<p class="text-sm text-slate-500">
|
||||||
|
目标邮箱:<span class="font-semibold text-slate-700">{{
|
||||||
|
email
|
||||||
|
}}</span>
|
||||||
|
</p>
|
||||||
|
<div class="flex flex-wrap justify-center gap-3">
|
||||||
|
<RouterLink
|
||||||
|
:to="{ path: '/resend-confirmation', query: { email } }"
|
||||||
|
class="no-underline"
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
>重发验证邮件</NButton
|
||||||
|
>
|
||||||
|
</RouterLink>
|
||||||
|
<RouterLink
|
||||||
|
:to="{ path: '/login', query: { email } }"
|
||||||
|
class="no-underline"
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--teal"
|
||||||
|
>去登录</NButton
|
||||||
|
>
|
||||||
|
</RouterLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NResult>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<div class="mb-8">
|
||||||
|
<div class="text-sm uppercase tracking-[0.22em] text-slate-500">
|
||||||
|
Create Account
|
||||||
|
</div>
|
||||||
|
<h2 class="mt-3 text-3xl font-bold text-slate-900">注册 OpenCloud</h2>
|
||||||
|
<p class="mt-2 text-sm text-slate-500">
|
||||||
|
注册后,请先通过邮件确认邮箱再登录。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<NForm @submit.prevent="handleRegister">
|
||||||
|
<NFormItem label="用户名">
|
||||||
|
<NInput
|
||||||
|
v-model:value="name"
|
||||||
|
maxlength="16"
|
||||||
|
show-count
|
||||||
|
placeholder="最多 16 个字符"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'username',
|
||||||
|
name: 'username',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</NFormItem>
|
||||||
|
<NFormItem label="邮箱">
|
||||||
|
<NInput
|
||||||
|
v-model:value="email"
|
||||||
|
maxlength="64"
|
||||||
|
type="text"
|
||||||
|
placeholder="your@email.com"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'email',
|
||||||
|
inputmode: 'email',
|
||||||
|
name: 'email',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</NFormItem>
|
||||||
|
<NFormItem label="密码">
|
||||||
|
<NInput
|
||||||
|
v-model:value="password"
|
||||||
|
type="password"
|
||||||
|
show-password-on="click"
|
||||||
|
placeholder="至少 8 位"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'new-password',
|
||||||
|
name: 'new-password',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</NFormItem>
|
||||||
|
<NFormItem label="确认密码">
|
||||||
|
<NInput
|
||||||
|
v-model:value="confirmPassword"
|
||||||
|
type="password"
|
||||||
|
show-password-on="click"
|
||||||
|
placeholder="再次输入密码"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'new-password',
|
||||||
|
name: 'confirm-new-password',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</NFormItem>
|
||||||
|
|
||||||
|
<NAlert v-if="error" type="error" class="mb-4">
|
||||||
|
{{ error }}
|
||||||
|
<div v-if="registerConflict" class="mt-2">
|
||||||
|
<RouterLink
|
||||||
|
:to="{ path: '/resend-confirmation', query: { email } }"
|
||||||
|
class="font-semibold text-rose-700 underline underline-offset-2"
|
||||||
|
>重发验证邮件</RouterLink
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</NAlert>
|
||||||
|
|
||||||
|
<NButton
|
||||||
|
attr-type="submit"
|
||||||
|
type="primary"
|
||||||
|
block
|
||||||
|
size="large"
|
||||||
|
class="oc-primary-button oc-primary-button--sky"
|
||||||
|
:loading="loading"
|
||||||
|
>
|
||||||
|
{{ loading ? '注册中...' : '注册' }}
|
||||||
|
</NButton>
|
||||||
|
</NForm>
|
||||||
|
|
||||||
|
<p class="mt-6 text-sm text-slate-500">
|
||||||
|
已有账号?
|
||||||
|
<RouterLink
|
||||||
|
:to="{ path: '/login', query: { email } }"
|
||||||
|
class="font-semibold text-sky-700 hover:text-sky-800"
|
||||||
|
>去登录</RouterLink
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
</template>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, onUnmounted, ref } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import { NAlert, NButton, NCard, NForm, NFormItem, NInput, NResult } from 'naive-ui'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const route = useRoute()
|
||||||
|
const email = ref(typeof route.query.email === 'string' ? route.query.email : '')
|
||||||
|
const error = ref('')
|
||||||
|
const loading = ref(false)
|
||||||
|
const submitted = ref(false)
|
||||||
|
const cooldown = ref(0)
|
||||||
|
let timer: ReturnType<typeof setInterval> | null = null
|
||||||
|
|
||||||
|
const buttonLabel = computed(() =>
|
||||||
|
loading.value
|
||||||
|
? '发送中...'
|
||||||
|
: cooldown.value > 0
|
||||||
|
? `重新发送(${cooldown.value}s)`
|
||||||
|
: '重新发送',
|
||||||
|
)
|
||||||
|
|
||||||
|
function startCooldown() {
|
||||||
|
if (timer) clearInterval(timer)
|
||||||
|
cooldown.value = 60
|
||||||
|
timer = setInterval(() => {
|
||||||
|
cooldown.value--
|
||||||
|
if (cooldown.value <= 0 && timer) {
|
||||||
|
clearInterval(timer)
|
||||||
|
timer = null
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submit() {
|
||||||
|
error.value = ''
|
||||||
|
const value = email.value.trim()
|
||||||
|
if (!value || value.length > 64) {
|
||||||
|
error.value = '请输入不超过 64 个字符的有效邮箱'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
await authStore.resendConfirmation(value)
|
||||||
|
email.value = value
|
||||||
|
submitted.value = true
|
||||||
|
startCooldown()
|
||||||
|
} catch (e: unknown) {
|
||||||
|
error.value = e instanceof Error ? e.message : '验证邮件发送失败,请稍后重试'
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (timer) clearInterval(timer)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="min-h-[calc(100vh-4rem)] px-4 py-10">
|
||||||
|
<div class="mx-auto max-w-2xl">
|
||||||
|
<NCard class="oc-panel-card-xl">
|
||||||
|
<NResult
|
||||||
|
v-if="submitted"
|
||||||
|
status="success"
|
||||||
|
title="请求已受理"
|
||||||
|
description="如果该邮箱符合条件,我们会发送新的验证邮件。"
|
||||||
|
>
|
||||||
|
<template #footer>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<p class="text-sm text-slate-500">
|
||||||
|
目标邮箱:<span class="font-semibold text-slate-700">{{
|
||||||
|
email
|
||||||
|
}}</span>
|
||||||
|
</p>
|
||||||
|
<div class="flex flex-wrap justify-center gap-3">
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
:disabled="cooldown > 0"
|
||||||
|
:loading="loading"
|
||||||
|
@click="submit"
|
||||||
|
>{{ buttonLabel }}</NButton
|
||||||
|
>
|
||||||
|
<RouterLink
|
||||||
|
:to="{ path: '/login', query: { email } }"
|
||||||
|
class="no-underline"
|
||||||
|
><NButton
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--teal"
|
||||||
|
>返回登录</NButton
|
||||||
|
></RouterLink
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NResult>
|
||||||
|
<template v-else>
|
||||||
|
<div class="mb-8">
|
||||||
|
<div class="text-sm uppercase tracking-[0.22em] text-slate-500">
|
||||||
|
Email Verification
|
||||||
|
</div>
|
||||||
|
<h1 class="mt-3 text-3xl font-bold text-slate-900">重发验证邮件</h1>
|
||||||
|
<p class="mt-2 text-sm text-slate-500">
|
||||||
|
输入注册邮箱。为保护账号,系统不会透露邮箱是否存在或已验证。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<NForm @submit.prevent="submit">
|
||||||
|
<NFormItem label="邮箱"
|
||||||
|
><NInput
|
||||||
|
v-model:value="email"
|
||||||
|
maxlength="64"
|
||||||
|
type="text"
|
||||||
|
placeholder="your@email.com"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'email',
|
||||||
|
inputmode: 'email',
|
||||||
|
name: 'email',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
/></NFormItem>
|
||||||
|
<NAlert v-if="error" type="error" class="mb-4">{{ error }}</NAlert>
|
||||||
|
<NButton
|
||||||
|
attr-type="submit"
|
||||||
|
type="primary"
|
||||||
|
block
|
||||||
|
size="large"
|
||||||
|
class="oc-primary-button oc-primary-button--sky"
|
||||||
|
:loading="loading"
|
||||||
|
>{{ loading ? '发送中...' : '发送验证邮件' }}</NButton
|
||||||
|
>
|
||||||
|
</NForm>
|
||||||
|
</template>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, onUnmounted, ref } from 'vue'
|
||||||
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { NAlert, NButton, NCard, NForm, NFormItem, NInput, NResult } from 'naive-ui'
|
||||||
|
import { AuthClientError } from '@/features/auth/authClient'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
|
const email = typeof route.query.email === 'string' ? route.query.email : ''
|
||||||
|
const token = typeof route.query.token === 'string' ? route.query.token : ''
|
||||||
|
const password = ref('')
|
||||||
|
const confirmPassword = ref('')
|
||||||
|
const error = ref(!token ? '密码重置链接缺少必要信息,请重新发送邮件。' : '')
|
||||||
|
const invalid = ref(!token)
|
||||||
|
const success = ref(false)
|
||||||
|
const loading = ref(false)
|
||||||
|
const countdown = ref(5)
|
||||||
|
let timer: ReturnType<typeof setInterval> | null = null
|
||||||
|
|
||||||
|
if (route.query.token !== undefined || route.query.email !== undefined) {
|
||||||
|
window.history.replaceState(window.history.state, '', route.path)
|
||||||
|
}
|
||||||
|
|
||||||
|
const canSubmit = computed(
|
||||||
|
() => !invalid.value && password.value.length >= 8 && password.value === confirmPassword.value,
|
||||||
|
)
|
||||||
|
|
||||||
|
function startCountdown() {
|
||||||
|
timer = setInterval(() => {
|
||||||
|
countdown.value--
|
||||||
|
if (countdown.value <= 0) {
|
||||||
|
if (timer) clearInterval(timer)
|
||||||
|
void router.push({ path: '/login', query: { email } })
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submit() {
|
||||||
|
error.value = ''
|
||||||
|
if (password.value.length < 8) {
|
||||||
|
error.value = '新密码至少需要 8 位'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (password.value !== confirmPassword.value) {
|
||||||
|
error.value = '两次输入的密码不一致'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
await authStore.resetPassword(token, password.value)
|
||||||
|
success.value = true
|
||||||
|
startCountdown()
|
||||||
|
} catch (e: unknown) {
|
||||||
|
error.value = e instanceof Error ? e.message : '密码重置失败,请稍后重试'
|
||||||
|
if (e instanceof AuthClientError && (e.status === 400 || e.code === 'INVALID_TOKEN'))
|
||||||
|
invalid.value = true
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (timer) clearInterval(timer)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="min-h-[calc(100vh-4rem)] px-4 py-10">
|
||||||
|
<div class="mx-auto max-w-2xl">
|
||||||
|
<NCard class="oc-panel-card-xl">
|
||||||
|
<NResult
|
||||||
|
v-if="success"
|
||||||
|
status="success"
|
||||||
|
title="密码已重置"
|
||||||
|
description="请使用新密码重新登录。"
|
||||||
|
>
|
||||||
|
<template #footer>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<p class="text-sm text-slate-500">
|
||||||
|
{{ countdown }} 秒后自动前往登录页面
|
||||||
|
</p>
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--teal"
|
||||||
|
@click="router.push({ path: '/login', query: { email } })"
|
||||||
|
>立即登录</NButton
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NResult>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<div class="mb-8">
|
||||||
|
<div class="text-sm uppercase tracking-[0.22em] text-slate-500">
|
||||||
|
Password Recovery
|
||||||
|
</div>
|
||||||
|
<h1 class="mt-3 text-3xl font-bold text-slate-900">设置新密码</h1>
|
||||||
|
<p class="mt-2 text-sm text-slate-500">
|
||||||
|
提交成功后,此重置链接和现有登录会话都会失效。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<NForm @submit.prevent="submit">
|
||||||
|
<NFormItem label="新密码"
|
||||||
|
><NInput
|
||||||
|
v-model:value="password"
|
||||||
|
type="password"
|
||||||
|
show-password-on="click"
|
||||||
|
placeholder="至少 8 位"
|
||||||
|
:disabled="invalid"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'new-password',
|
||||||
|
name: 'new-password',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
/></NFormItem>
|
||||||
|
<NFormItem label="确认新密码"
|
||||||
|
><NInput
|
||||||
|
v-model:value="confirmPassword"
|
||||||
|
type="password"
|
||||||
|
show-password-on="click"
|
||||||
|
placeholder="再次输入新密码"
|
||||||
|
:disabled="invalid"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'new-password',
|
||||||
|
name: 'confirm-new-password',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
/></NFormItem>
|
||||||
|
<NAlert v-if="error" type="error" class="mb-4">{{ error }}</NAlert>
|
||||||
|
<RouterLink
|
||||||
|
v-if="invalid"
|
||||||
|
:to="{ path: '/forgot-password', query: { email } }"
|
||||||
|
class="mb-4 block text-sm font-semibold text-teal-700 hover:text-teal-800"
|
||||||
|
>重新发送密码重置邮件</RouterLink
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
attr-type="submit"
|
||||||
|
type="primary"
|
||||||
|
block
|
||||||
|
size="large"
|
||||||
|
class="oc-primary-button oc-primary-button--teal"
|
||||||
|
:disabled="!canSubmit"
|
||||||
|
:loading="loading"
|
||||||
|
>保存新密码</NButton
|
||||||
|
>
|
||||||
|
</NForm>
|
||||||
|
</template>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
import { apiRequest } from '@/lib/api'
|
||||||
|
import { imageUrl, toCloudDetail, toCloudType } from '@/lib/api-adapters'
|
||||||
|
import { collectPages } from '@/lib/pagination'
|
||||||
|
import type {
|
||||||
|
CloudResponse,
|
||||||
|
CloudPageResponse,
|
||||||
|
CloudTypeResponse,
|
||||||
|
CloudCreateResponse,
|
||||||
|
MessageResponse,
|
||||||
|
PublicCloudListQuery,
|
||||||
|
CloudMapQuery,
|
||||||
|
UpdateCloudBody,
|
||||||
|
UploadCloudForm,
|
||||||
|
PaginationQuery,
|
||||||
|
} from '@/types/api-contract'
|
||||||
|
|
||||||
|
export { imageUrl }
|
||||||
|
|
||||||
|
export async function listClouds(query: PublicCloudListQuery) {
|
||||||
|
const page = await apiRequest<CloudPageResponse>('/clouds', { query, auth: false })
|
||||||
|
return { ...page, items: page.items.map(toCloudDetail) }
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listCloudsByType(cloudTypeId: number, query: PaginationQuery) {
|
||||||
|
const page = await apiRequest<CloudPageResponse>(`/cloud-types/${cloudTypeId}/clouds`, {
|
||||||
|
query,
|
||||||
|
auth: false,
|
||||||
|
})
|
||||||
|
return { ...page, items: page.items.map(toCloudDetail) }
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listMapClouds(query: CloudMapQuery) {
|
||||||
|
const rows = await apiRequest<CloudResponse[]>('/clouds/map', { query, auth: false })
|
||||||
|
return rows.map(toCloudDetail)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getCloud(cloudId: string, auth = true) {
|
||||||
|
return toCloudDetail(
|
||||||
|
await apiRequest<CloudResponse>(`/clouds/${encodeURIComponent(cloudId)}`, { auth }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listCloudTypeRecords() {
|
||||||
|
return apiRequest<CloudTypeResponse[]>('/cloud-types', { auth: false })
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listCloudTypes() {
|
||||||
|
return (await listCloudTypeRecords()).map(toCloudType)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateCloud(cloudId: string, body: UpdateCloudBody) {
|
||||||
|
return apiRequest<MessageResponse>(`/clouds/${encodeURIComponent(cloudId)}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
body,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteClouds(cloudIds: string[], onDeleted?: (ids: string[]) => void) {
|
||||||
|
for (let offset = 0; offset < cloudIds.length; offset += 100) {
|
||||||
|
const ids = cloudIds.slice(offset, offset + 100)
|
||||||
|
await apiRequest<MessageResponse>('/clouds', { method: 'DELETE', body: { cloud_ids: ids } })
|
||||||
|
onDeleted?.(ids)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function uploadCloud(input: UploadCloudForm) {
|
||||||
|
const form = new FormData()
|
||||||
|
for (const [key, value] of Object.entries(input)) {
|
||||||
|
if (value !== undefined) form.append(key, value instanceof Blob ? value : String(value))
|
||||||
|
}
|
||||||
|
return apiRequest<CloudCreateResponse>('/clouds', { method: 'POST', body: form })
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setCloudLike(cloudId: string, liked: boolean) {
|
||||||
|
return apiRequest<MessageResponse>(`/clouds/${encodeURIComponent(cloudId)}/like`, {
|
||||||
|
method: liked ? 'PUT' : 'DELETE',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listLikedClouds() {
|
||||||
|
return collectPages(async page => {
|
||||||
|
const result = await apiRequest<CloudPageResponse>('/profiles/me/likes', {
|
||||||
|
query: { page, page_size: 100 },
|
||||||
|
})
|
||||||
|
return { ...result, items: result.items.map(toCloudDetail) }
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
export const CLOUD_TYPES = [
|
||||||
|
{ id: 1, name: '积云' },
|
||||||
|
{ id: 2, name: '层云' },
|
||||||
|
{ id: 3, name: '卷云' },
|
||||||
|
{ id: 4, name: '积雨云' },
|
||||||
|
{ id: 5, name: '层积云' },
|
||||||
|
{ id: 6, name: '高积云' },
|
||||||
|
{ id: 7, name: '高层云' },
|
||||||
|
{ id: 8, name: '雨层云' },
|
||||||
|
{ id: 9, name: '卷层云' },
|
||||||
|
{ id: 10, name: '卷积云' },
|
||||||
|
] as const
|
||||||
|
|
||||||
|
export function getCloudTypeName(id: string | string[]) {
|
||||||
|
const cloudTypeId = Number(Array.isArray(id) ? id[0] : id)
|
||||||
|
return CLOUD_TYPES.find(item => item.id === cloudTypeId)?.name ?? '云型详情'
|
||||||
|
}
|
||||||
@@ -0,0 +1,265 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
|
import { NAlert, NButton, NIcon } from 'naive-ui'
|
||||||
|
import { Map as MapIcon, X } from '@vicons/tabler'
|
||||||
|
import MapPickerModal from '@/shared/map/components/MapPickerModal.vue'
|
||||||
|
import type { CloudType } from '@/types/models'
|
||||||
|
|
||||||
|
export interface CloudEditFormValue {
|
||||||
|
cloudCategoryId: number | null
|
||||||
|
capturedAt: string
|
||||||
|
latitude: number | null
|
||||||
|
longitude: number | null
|
||||||
|
description: string
|
||||||
|
isPublic: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
open: boolean
|
||||||
|
saving?: boolean
|
||||||
|
error?: string
|
||||||
|
cloudTypes: CloudType[]
|
||||||
|
initialValue: CloudEditFormValue | null
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
saving: false,
|
||||||
|
error: '',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
close: []
|
||||||
|
save: [value: CloudEditFormValue]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const form = ref<CloudEditFormValue>(createEmptyForm())
|
||||||
|
const mapPickerOpen = ref(false)
|
||||||
|
|
||||||
|
function createEmptyForm(): CloudEditFormValue {
|
||||||
|
return {
|
||||||
|
cloudCategoryId: null,
|
||||||
|
capturedAt: '',
|
||||||
|
latitude: null,
|
||||||
|
longitude: null,
|
||||||
|
description: '',
|
||||||
|
isPublic: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cloneForm(value: CloudEditFormValue | null) {
|
||||||
|
return value ? { ...value } : createEmptyForm()
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCategoryChange(event: Event) {
|
||||||
|
const value = (event.target as HTMLSelectElement).value
|
||||||
|
if (!value) {
|
||||||
|
form.value.cloudCategoryId = null
|
||||||
|
} else {
|
||||||
|
form.value.cloudCategoryId = Number(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onLatInput(event: Event) {
|
||||||
|
const value = Number.parseFloat((event.target as HTMLInputElement).value)
|
||||||
|
form.value.latitude = Number.isNaN(value) ? null : value
|
||||||
|
}
|
||||||
|
|
||||||
|
function onLngInput(event: Event) {
|
||||||
|
const value = Number.parseFloat((event.target as HTMLInputElement).value)
|
||||||
|
form.value.longitude = Number.isNaN(value) ? null : value
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmMapPicker(payload: { latitude: number; longitude: number }) {
|
||||||
|
form.value.latitude = payload.latitude
|
||||||
|
form.value.longitude = payload.longitude
|
||||||
|
mapPickerOpen.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
|
||||||
|
function save() {
|
||||||
|
emit('save', { ...form.value })
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.open,
|
||||||
|
open => {
|
||||||
|
if (open) {
|
||||||
|
form.value = cloneForm(props.initialValue)
|
||||||
|
} else {
|
||||||
|
mapPickerOpen.value = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.initialValue,
|
||||||
|
value => {
|
||||||
|
if (props.open) {
|
||||||
|
form.value = cloneForm(value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Teleport to="body">
|
||||||
|
<div
|
||||||
|
v-if="open"
|
||||||
|
class="fixed inset-0 z-[130] flex items-center justify-center bg-slate-950/60 px-4 py-6"
|
||||||
|
@click="close"
|
||||||
|
>
|
||||||
|
<div class="oc-modal-shell w-full max-w-2xl" @click.stop>
|
||||||
|
<div class="flex items-start justify-between border-b border-slate-200 px-6 py-5">
|
||||||
|
<div>
|
||||||
|
<h3 class="text-xl font-semibold text-slate-900">编辑图片信息</h3>
|
||||||
|
<p class="oc-field-help">修改后会同步影响个人主页、画廊和地图中的展示。</p>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-icon-button"
|
||||||
|
aria-label="关闭编辑窗口"
|
||||||
|
title="关闭编辑窗口"
|
||||||
|
@click="close"
|
||||||
|
>
|
||||||
|
<NIcon size="20"><X /></NIcon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="max-h-[70vh] overflow-y-auto px-6 py-5">
|
||||||
|
<NAlert
|
||||||
|
v-if="error"
|
||||||
|
class="mb-5"
|
||||||
|
type="error"
|
||||||
|
:show-icon="false"
|
||||||
|
:bordered="false"
|
||||||
|
>
|
||||||
|
{{ error }}
|
||||||
|
</NAlert>
|
||||||
|
|
||||||
|
<div class="grid gap-5">
|
||||||
|
<div>
|
||||||
|
<label class="oc-field-label">类别</label>
|
||||||
|
<select
|
||||||
|
:value="form.cloudCategoryId ?? ''"
|
||||||
|
class="oc-field-control"
|
||||||
|
@change="onCategoryChange"
|
||||||
|
>
|
||||||
|
<option value="" disabled>请选择</option>
|
||||||
|
<option v-for="ct in cloudTypes" :key="ct.id" :value="ct.id">
|
||||||
|
{{ ct.name }}{{ ct.genus ? '(' + ct.genus + ')' : '' }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="oc-field-label">拍摄时间</label>
|
||||||
|
<input
|
||||||
|
v-model="form.capturedAt"
|
||||||
|
type="datetime-local"
|
||||||
|
class="oc-field-control"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="oc-field-label"
|
||||||
|
>经纬度 <span class="oc-field-required">*</span></label
|
||||||
|
>
|
||||||
|
<div class="grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-2">
|
||||||
|
<input
|
||||||
|
:value="form.latitude !== null ? form.latitude : ''"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
placeholder="纬度"
|
||||||
|
class="oc-field-control"
|
||||||
|
@input="onLatInput"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
:value="form.longitude !== null ? form.longitude : ''"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
placeholder="经度"
|
||||||
|
class="oc-field-control"
|
||||||
|
@input="onLngInput"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-icon-button oc-icon-button--sky"
|
||||||
|
title="地图选点"
|
||||||
|
aria-label="地图选点"
|
||||||
|
@click="mapPickerOpen = true"
|
||||||
|
>
|
||||||
|
<NIcon size="20"><MapIcon /></NIcon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="oc-field-label">图片描述</label>
|
||||||
|
<textarea
|
||||||
|
v-model="form.description"
|
||||||
|
rows="4"
|
||||||
|
class="oc-field-control resize-none"
|
||||||
|
placeholder="描述一下这张图片..."
|
||||||
|
></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label
|
||||||
|
class="flex items-center justify-between gap-4 border border-slate-200 bg-slate-50 px-4 py-3"
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
<span class="block text-sm font-medium text-slate-800"
|
||||||
|
>公开展示</span
|
||||||
|
>
|
||||||
|
<span class="mt-1 block text-xs text-slate-500"
|
||||||
|
>关闭后不会出现在画廊、地图和公开主页中。</span
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
v-model="form.isPublic"
|
||||||
|
type="checkbox"
|
||||||
|
class="h-5 w-5 border-slate-300 text-sky-500 focus:ring-sky-500"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4"
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
@click="close"
|
||||||
|
>取消</NButton
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
:loading="saving"
|
||||||
|
@click="save"
|
||||||
|
>
|
||||||
|
保存修改
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
|
||||||
|
<MapPickerModal
|
||||||
|
:open="mapPickerOpen"
|
||||||
|
:latitude="form.latitude"
|
||||||
|
:longitude="form.longitude"
|
||||||
|
description="点击地图即可回填这张图片的经纬度。"
|
||||||
|
footer-text="保存时会继续做模糊化处理。"
|
||||||
|
@close="mapPickerOpen = false"
|
||||||
|
@confirm="confirmMapPicker"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref, watch } from 'vue'
|
||||||
|
import { NButton, NIcon, useMessage } from 'naive-ui'
|
||||||
|
import { Heart } from '@vicons/tabler'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
import { useLikesStore } from '@/features/clouds/stores/likes'
|
||||||
|
|
||||||
|
const props = defineProps<{ cloudId: string; count: number }>()
|
||||||
|
const route = useRoute()
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const likesStore = useLikesStore()
|
||||||
|
const message = useMessage()
|
||||||
|
const loading = ref(false)
|
||||||
|
const error = ref('')
|
||||||
|
|
||||||
|
const liked = computed(() => likesStore.isLiked(props.cloudId))
|
||||||
|
const count = computed(() => likesStore.countFor(props.cloudId, props.count))
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [authStore.user?.id, props.cloudId],
|
||||||
|
async ([userId]) => {
|
||||||
|
error.value = ''
|
||||||
|
if (!userId) return
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
await likesStore.ensureLoaded()
|
||||||
|
} catch (e) {
|
||||||
|
error.value = e instanceof Error ? e.message : '点赞状态加载失败'
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
async function toggleLike() {
|
||||||
|
error.value = ''
|
||||||
|
try {
|
||||||
|
await likesStore.toggle(props.cloudId, props.count)
|
||||||
|
message.success(liked.value ? '已点赞' : '已取消点赞')
|
||||||
|
} catch (e) {
|
||||||
|
error.value = e instanceof Error ? e.message : '点赞操作失败'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="mt-5 flex flex-wrap items-center gap-3">
|
||||||
|
<NButton
|
||||||
|
v-if="authStore.isLoggedIn"
|
||||||
|
type="default"
|
||||||
|
:class="[
|
||||||
|
'oc-panel-button',
|
||||||
|
liked ? 'oc-panel-button--teal' : 'oc-panel-button--neutral',
|
||||||
|
]"
|
||||||
|
:loading="loading || likesStore.isPending(cloudId)"
|
||||||
|
@click="toggleLike"
|
||||||
|
>
|
||||||
|
<template #icon
|
||||||
|
><NIcon><Heart /></NIcon
|
||||||
|
></template>
|
||||||
|
{{ liked ? '取消点赞' : '点赞' }}
|
||||||
|
</NButton>
|
||||||
|
<RouterLink
|
||||||
|
v-else
|
||||||
|
:to="{ path: '/login', query: { redirect: route.fullPath } }"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral no-underline"
|
||||||
|
>登录后点赞</RouterLink
|
||||||
|
>
|
||||||
|
<span class="text-sm text-slate-600">{{ count }} 次点赞</span>
|
||||||
|
<span v-if="error" class="text-sm text-rose-700">{{ error }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,322 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { InfoCircle, X } from '@vicons/tabler'
|
||||||
|
import { NIcon } from 'naive-ui'
|
||||||
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
open: boolean
|
||||||
|
imageUrl: string
|
||||||
|
thumbnailUrl?: string | null
|
||||||
|
imageAlt: string
|
||||||
|
title: string
|
||||||
|
subtitle?: string
|
||||||
|
badgeLabel?: string
|
||||||
|
badgeClass?: string
|
||||||
|
panelWidth?: string
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
subtitle: '',
|
||||||
|
thumbnailUrl: null,
|
||||||
|
badgeLabel: '',
|
||||||
|
badgeClass: '',
|
||||||
|
panelWidth: '',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
close: []
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const infoOpen = ref(false)
|
||||||
|
const imageLoaded = ref(false)
|
||||||
|
const previewLoaded = ref(false)
|
||||||
|
const naturalWidth = ref(0)
|
||||||
|
const naturalHeight = ref(0)
|
||||||
|
const viewportWidth = ref(0)
|
||||||
|
const viewportHeight = ref(0)
|
||||||
|
const modalVisible = ref(false)
|
||||||
|
const closing = ref(false)
|
||||||
|
let closeTimer: number | null = null
|
||||||
|
const previousBodyOverflow = ref<string | null>(null)
|
||||||
|
const previousDocumentOverflow = ref<string | null>(null)
|
||||||
|
|
||||||
|
function updateViewport() {
|
||||||
|
if (typeof window === 'undefined') return
|
||||||
|
viewportWidth.value = window.innerWidth
|
||||||
|
viewportHeight.value = window.innerHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
const layout = computed(() => {
|
||||||
|
const aspectRatio =
|
||||||
|
naturalWidth.value > 0 && naturalHeight.value > 0
|
||||||
|
? naturalWidth.value / naturalHeight.value
|
||||||
|
: 4 / 3
|
||||||
|
const maxModalWidth =
|
||||||
|
viewportWidth.value > 0
|
||||||
|
? Math.max(Math.min(viewportWidth.value * 0.95, viewportWidth.value - 32), 280)
|
||||||
|
: 320
|
||||||
|
const maxImageHeight =
|
||||||
|
viewportHeight.value > 0 ? Math.max(viewportHeight.value * 0.9, 240) : 360
|
||||||
|
const imageWidth = Math.min(maxModalWidth, maxImageHeight * aspectRatio)
|
||||||
|
|
||||||
|
return {
|
||||||
|
imageWidth,
|
||||||
|
imageHeight: imageWidth / aspectRatio,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const imageStyle = computed(
|
||||||
|
() =>
|
||||||
|
({
|
||||||
|
width: `${Math.round(layout.value.imageWidth)}px`,
|
||||||
|
height: `${Math.round(layout.value.imageHeight)}px`,
|
||||||
|
}) as Record<string, string>,
|
||||||
|
)
|
||||||
|
|
||||||
|
function resetImageState() {
|
||||||
|
imageLoaded.value = false
|
||||||
|
previewLoaded.value = false
|
||||||
|
naturalWidth.value = 0
|
||||||
|
naturalHeight.value = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function lockPageScroll() {
|
||||||
|
if (typeof document === 'undefined' || previousBodyOverflow.value !== null) return
|
||||||
|
previousBodyOverflow.value = document.body.style.overflow
|
||||||
|
previousDocumentOverflow.value = document.documentElement.style.overflow
|
||||||
|
document.body.style.overflow = 'hidden'
|
||||||
|
document.documentElement.style.overflow = 'hidden'
|
||||||
|
}
|
||||||
|
|
||||||
|
function unlockPageScroll() {
|
||||||
|
if (typeof document === 'undefined' || previousBodyOverflow.value === null) return
|
||||||
|
document.body.style.overflow = previousBodyOverflow.value
|
||||||
|
document.documentElement.style.overflow = previousDocumentOverflow.value ?? ''
|
||||||
|
previousBodyOverflow.value = null
|
||||||
|
previousDocumentOverflow.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.open,
|
||||||
|
open => {
|
||||||
|
if (open) {
|
||||||
|
if (closeTimer !== null) {
|
||||||
|
window.clearTimeout(closeTimer)
|
||||||
|
closeTimer = null
|
||||||
|
}
|
||||||
|
closing.value = false
|
||||||
|
modalVisible.value = true
|
||||||
|
lockPageScroll()
|
||||||
|
infoOpen.value = false
|
||||||
|
resetImageState()
|
||||||
|
} else {
|
||||||
|
modalVisible.value = false
|
||||||
|
unlockPageScroll()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.imageUrl,
|
||||||
|
() => {
|
||||||
|
resetImageState()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
if (closing.value) return
|
||||||
|
closing.value = true
|
||||||
|
modalVisible.value = false
|
||||||
|
|
||||||
|
if (typeof window === 'undefined') {
|
||||||
|
unlockPageScroll()
|
||||||
|
emit('close')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
closeTimer = window.setTimeout(() => {
|
||||||
|
closeTimer = null
|
||||||
|
unlockPageScroll()
|
||||||
|
emit('close')
|
||||||
|
}, 180)
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleInfo() {
|
||||||
|
infoOpen.value = !infoOpen.value
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleImageLoad(event: Event) {
|
||||||
|
const target = event.target as HTMLImageElement | null
|
||||||
|
if (!target) return
|
||||||
|
naturalWidth.value = target.naturalWidth
|
||||||
|
naturalHeight.value = target.naturalHeight
|
||||||
|
imageLoaded.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlePreviewLoad(event: Event) {
|
||||||
|
const target = event.target as HTMLImageElement | null
|
||||||
|
if (!target) return
|
||||||
|
if (!naturalWidth.value || !naturalHeight.value) {
|
||||||
|
naturalWidth.value = target.naturalWidth
|
||||||
|
naturalHeight.value = target.naturalHeight
|
||||||
|
}
|
||||||
|
previewLoaded.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
updateViewport()
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
window.addEventListener('resize', updateViewport)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
if (closeTimer !== null) {
|
||||||
|
window.clearTimeout(closeTimer)
|
||||||
|
}
|
||||||
|
unlockPageScroll()
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
window.removeEventListener('resize', updateViewport)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Teleport to="body">
|
||||||
|
<Transition appear name="image-detail-modal">
|
||||||
|
<div
|
||||||
|
v-if="modalVisible"
|
||||||
|
class="fixed inset-0 z-[110] flex items-center justify-center bg-black/85 px-4 py-6"
|
||||||
|
@click="close"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="image-detail-shell relative w-fit max-w-[92vw] overflow-hidden shadow-2xl"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-overlay-button absolute right-3 top-3 z-30 h-9 w-9 opacity-0 drop-shadow-[0_2px_8px_rgba(15,23,42,0.9)] transition-opacity duration-200 hover:opacity-100 focus-visible:opacity-100"
|
||||||
|
aria-label="关闭大图"
|
||||||
|
title="关闭大图"
|
||||||
|
@click="close"
|
||||||
|
>
|
||||||
|
<NIcon size="20">
|
||||||
|
<X />
|
||||||
|
</NIcon>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="relative flex min-h-0 items-center justify-center overflow-hidden bg-slate-950"
|
||||||
|
:style="imageStyle"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="!previewLoaded && !imageLoaded"
|
||||||
|
class="absolute inset-0 animate-pulse bg-[linear-gradient(110deg,#0f172a_0%,#1e293b_45%,#334155_55%,#0f172a_100%)] bg-[length:220%_100%]"
|
||||||
|
></div>
|
||||||
|
<img
|
||||||
|
v-if="thumbnailUrl"
|
||||||
|
:src="thumbnailUrl"
|
||||||
|
:alt="imageAlt"
|
||||||
|
class="absolute inset-0 block h-full w-full object-contain blur-[1px] transition-opacity duration-300"
|
||||||
|
:class="imageLoaded ? 'opacity-0' : 'opacity-100'"
|
||||||
|
@load="handlePreviewLoad"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
:src="imageUrl"
|
||||||
|
:alt="imageAlt"
|
||||||
|
class="relative block h-full w-full object-contain transition-opacity duration-300"
|
||||||
|
:class="imageLoaded ? 'opacity-100' : 'opacity-0'"
|
||||||
|
@load="handleImageLoad"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="image-detail-info-button oc-overlay-button absolute bottom-4 right-4 z-30 h-11 w-11 drop-shadow-[0_2px_8px_rgba(15,23,42,0.9)]"
|
||||||
|
:aria-label="infoOpen ? '隐藏详细信息' : '查看详细信息'"
|
||||||
|
:title="infoOpen ? '隐藏详细信息' : '查看详细信息'"
|
||||||
|
@click="toggleInfo"
|
||||||
|
>
|
||||||
|
<NIcon size="30">
|
||||||
|
<InfoCircle />
|
||||||
|
</NIcon>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="infoOpen"
|
||||||
|
class="absolute bottom-16 right-4 z-20 flex max-h-[min(70vh,560px)] w-[min(360px,calc(100%-2rem))] flex-col overflow-hidden border border-white/70 bg-white/95 shadow-2xl backdrop-blur"
|
||||||
|
>
|
||||||
|
<div class="border-b border-slate-200 px-5 py-4">
|
||||||
|
<div class="pr-8">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<h2 class="text-xl font-bold text-slate-900">
|
||||||
|
{{ title }}
|
||||||
|
</h2>
|
||||||
|
<span
|
||||||
|
v-if="badgeLabel"
|
||||||
|
class="border px-3 py-1 text-xs font-medium"
|
||||||
|
:class="badgeClass"
|
||||||
|
>
|
||||||
|
{{ badgeLabel }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p v-if="subtitle" class="mt-2 text-sm text-slate-500">
|
||||||
|
{{ subtitle }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="image-detail-panel-close oc-icon-button oc-icon-button--small absolute right-3 top-3"
|
||||||
|
aria-label="隐藏详细信息"
|
||||||
|
title="隐藏详细信息"
|
||||||
|
@click="infoOpen = false"
|
||||||
|
>
|
||||||
|
<NIcon size="16"><X /></NIcon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex-1 overflow-y-auto px-5 py-4">
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="$slots.actions" class="border-t border-slate-200 px-5 py-4">
|
||||||
|
<slot name="actions" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.image-detail-modal-enter-active,
|
||||||
|
.image-detail-modal-leave-active {
|
||||||
|
transition: opacity 180ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-detail-modal-enter-active .image-detail-shell,
|
||||||
|
.image-detail-modal-leave-active .image-detail-shell {
|
||||||
|
transition:
|
||||||
|
opacity 220ms cubic-bezier(0.22, 1, 0.36, 1),
|
||||||
|
transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-detail-modal-enter-from,
|
||||||
|
.image-detail-modal-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-detail-modal-enter-from .image-detail-shell,
|
||||||
|
.image-detail-modal-leave-to .image-detail-shell {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(10px) scale(0.97);
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-detail-info-button.image-detail-info-button {
|
||||||
|
border-radius: 9999px !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { listCloudTypes } from '@/features/clouds/api'
|
||||||
|
import type { CloudType } from '@/types/models'
|
||||||
|
|
||||||
|
export const useCloudsStore = defineStore('clouds', () => {
|
||||||
|
const cloudTypes = ref<CloudType[]>([])
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
|
async function fetchCloudTypes() {
|
||||||
|
if (cloudTypes.value.length > 0) return
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
cloudTypes.value = await listCloudTypes()
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCloudTypes(types: CloudType[]) {
|
||||||
|
cloudTypes.value = types
|
||||||
|
}
|
||||||
|
|
||||||
|
return { cloudTypes, loading, fetchCloudTypes, setCloudTypes }
|
||||||
|
})
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import { ref, watch } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { getCloud, listLikedClouds, setCloudLike } from '@/features/clouds/api'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
|
||||||
|
export const useLikesStore = defineStore('likes', () => {
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const likedIds = ref<Set<string>>(new Set())
|
||||||
|
const counts = ref<Record<string, number>>({})
|
||||||
|
const pendingIds = ref<Set<string>>(new Set())
|
||||||
|
const loadedForUser = ref<string | null>(null)
|
||||||
|
let loadPromise: Promise<void> | null = null
|
||||||
|
let loadingForUser: string | null = null
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => authStore.user?.id,
|
||||||
|
() => {
|
||||||
|
likedIds.value = new Set()
|
||||||
|
counts.value = {}
|
||||||
|
pendingIds.value = new Set()
|
||||||
|
loadedForUser.value = null
|
||||||
|
loadPromise = null
|
||||||
|
loadingForUser = null
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
function isLiked(cloudId: string) {
|
||||||
|
return likedIds.value.has(cloudId)
|
||||||
|
}
|
||||||
|
|
||||||
|
function countFor(cloudId: string, initialCount: number) {
|
||||||
|
return counts.value[cloudId] ?? initialCount
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPending(cloudId: string) {
|
||||||
|
return pendingIds.value.has(cloudId)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ensureLoaded() {
|
||||||
|
const userId = authStore.user?.id
|
||||||
|
if (!userId || loadedForUser.value === userId) return
|
||||||
|
if (loadPromise && loadingForUser === userId) return loadPromise
|
||||||
|
|
||||||
|
loadingForUser = userId
|
||||||
|
const request = (async () => {
|
||||||
|
const rows = await listLikedClouds()
|
||||||
|
const nextIds = new Set(rows.map(row => row.id))
|
||||||
|
if (authStore.user?.id === userId) {
|
||||||
|
likedIds.value = nextIds
|
||||||
|
loadedForUser.value = userId
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
loadPromise = request
|
||||||
|
try {
|
||||||
|
await request
|
||||||
|
} finally {
|
||||||
|
if (loadPromise === request) {
|
||||||
|
loadPromise = null
|
||||||
|
loadingForUser = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toggle(cloudId: string, initialCount: number) {
|
||||||
|
const userId = authStore.user?.id
|
||||||
|
if (!userId) throw new Error('请先登录后点赞。')
|
||||||
|
await ensureLoaded()
|
||||||
|
if (authStore.user?.id !== userId) throw new Error('登录状态已改变,请重试。')
|
||||||
|
if (isPending(cloudId)) return
|
||||||
|
|
||||||
|
const wasLiked = isLiked(cloudId)
|
||||||
|
pendingIds.value = new Set(pendingIds.value).add(cloudId)
|
||||||
|
try {
|
||||||
|
await setCloudLike(cloudId, !wasLiked)
|
||||||
|
if (authStore.user?.id !== userId) return
|
||||||
|
|
||||||
|
const nextIds = new Set(likedIds.value)
|
||||||
|
if (wasLiked) nextIds.delete(cloudId)
|
||||||
|
else nextIds.add(cloudId)
|
||||||
|
likedIds.value = nextIds
|
||||||
|
counts.value[cloudId] = Math.max(
|
||||||
|
0,
|
||||||
|
countFor(cloudId, initialCount) + (wasLiked ? -1 : 1),
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cloud = await getCloud(cloudId, false)
|
||||||
|
if (authStore.user?.id !== userId) return
|
||||||
|
counts.value[cloudId] = cloud.received_like_count
|
||||||
|
if (cloud.owner?.id === authStore.user?.id) await authStore.refreshProfile()
|
||||||
|
} catch {
|
||||||
|
// The mutation succeeded; keep the local count if a refresh fails.
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
const nextPending = new Set(pendingIds.value)
|
||||||
|
nextPending.delete(cloudId)
|
||||||
|
pendingIds.value = nextPending
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { isLiked, countFor, isPending, ensureLoaded, toggle }
|
||||||
|
})
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="min-h-[calc(100vh-4rem)] bg-[linear-gradient(180deg,#f2faf6_0%,#f8fafc_100%)] px-4 py-16"
|
||||||
|
>
|
||||||
|
<section class="oc-panel-card-xl mx-auto max-w-4xl border border-slate-200 bg-white p-10">
|
||||||
|
<p class="text-sm font-semibold uppercase tracking-[0.24em] text-teal-700">Community</p>
|
||||||
|
<h1 class="mt-4 text-4xl font-bold text-slate-900">社区</h1>
|
||||||
|
<p class="mt-5 max-w-2xl text-sm leading-7 text-slate-600">
|
||||||
|
社区模块正在规划中。后续这里会承载话题讨论、观测活动和用户互动内容。
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { listCloudTypes } from '@/features/clouds/api'
|
||||||
|
import type { CloudType } from '@/types/models'
|
||||||
|
|
||||||
|
export const useEncyclopediaStore = defineStore('encyclopedia', () => {
|
||||||
|
const cloudTypes = ref<CloudType[]>([])
|
||||||
|
const loadingCloudTypes = ref(false)
|
||||||
|
const cloudTypesLoaded = ref(false)
|
||||||
|
|
||||||
|
async function fetchCloudTypes(force = false) {
|
||||||
|
if (cloudTypesLoaded.value && !force) return
|
||||||
|
loadingCloudTypes.value = true
|
||||||
|
try {
|
||||||
|
cloudTypes.value = await listCloudTypes()
|
||||||
|
cloudTypesLoaded.value = true
|
||||||
|
} finally {
|
||||||
|
loadingCloudTypes.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCloudTypes(types: CloudType[]) {
|
||||||
|
cloudTypes.value = types
|
||||||
|
cloudTypesLoaded.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
cloudTypes,
|
||||||
|
loadingCloudTypes,
|
||||||
|
fetchCloudTypes,
|
||||||
|
setCloudTypes,
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,250 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, onMounted, ref, watch } from 'vue'
|
||||||
|
import { NAlert, NButton, NEmpty, NSkeleton } from 'naive-ui'
|
||||||
|
import { RouterLink, useRoute } from 'vue-router'
|
||||||
|
import ImageDetailModal from '@/features/clouds/components/ImageDetailModal.vue'
|
||||||
|
import CloudLikeButton from '@/features/clouds/components/CloudLikeButton.vue'
|
||||||
|
import MiniLocationMap from '@/shared/map/components/MiniLocationMap.vue'
|
||||||
|
import { imageUrl, listCloudsByType } from '@/features/clouds/api'
|
||||||
|
import { useEncyclopediaStore } from '@/features/encyclopedia/stores/encyclopedia'
|
||||||
|
import type { CloudDetail } from '@/types/view-models'
|
||||||
|
|
||||||
|
const PAGE_SIZE = 24
|
||||||
|
const route = useRoute()
|
||||||
|
const encyclopediaStore = useEncyclopediaStore()
|
||||||
|
const loading = ref(true)
|
||||||
|
const loadError = ref('')
|
||||||
|
const gallery = ref<CloudDetail[]>([])
|
||||||
|
const selectedItem = ref<CloudDetail | null>(null)
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const hasNextPage = ref(false)
|
||||||
|
|
||||||
|
const cloudTypeId = computed(() => Number(route.params.id))
|
||||||
|
const cloudType = computed(
|
||||||
|
() => encyclopediaStore.cloudTypes.find(item => item.id === cloudTypeId.value) ?? null,
|
||||||
|
)
|
||||||
|
const heroImage = computed(() =>
|
||||||
|
cloudType.value?.icon_id ? imageUrl(cloudType.value.icon_id, 'original') : null,
|
||||||
|
)
|
||||||
|
|
||||||
|
function formatDateTime(iso: string | null) {
|
||||||
|
if (!iso) return '未记录拍摄时间'
|
||||||
|
return new Date(iso).toLocaleString('zh-CN', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'numeric',
|
||||||
|
day: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadGallery(page: number) {
|
||||||
|
const result = await listCloudsByType(cloudTypeId.value, { page, page_size: PAGE_SIZE })
|
||||||
|
gallery.value = result.items
|
||||||
|
currentPage.value = page
|
||||||
|
hasNextPage.value = result.has_more
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadPage(page = 1) {
|
||||||
|
if (!Number.isInteger(cloudTypeId.value) || cloudTypeId.value <= 0) {
|
||||||
|
loadError.value = '云类型不存在'
|
||||||
|
loading.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
loadError.value = ''
|
||||||
|
selectedItem.value = null
|
||||||
|
try {
|
||||||
|
await encyclopediaStore.fetchCloudTypes()
|
||||||
|
if (!cloudType.value) {
|
||||||
|
loadError.value = '云类型不存在'
|
||||||
|
gallery.value = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await loadGallery(page)
|
||||||
|
} catch (error) {
|
||||||
|
loadError.value = error instanceof Error ? error.message : '详情加载失败'
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => loadPage())
|
||||||
|
watch(
|
||||||
|
() => route.params.id,
|
||||||
|
() => loadPage(),
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="oc-container oc-container--content py-8">
|
||||||
|
<RouterLink to="/encyclopedia">
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
>← 返回百科总览</NButton
|
||||||
|
>
|
||||||
|
</RouterLink>
|
||||||
|
|
||||||
|
<div v-if="loading" class="mt-6 space-y-6">
|
||||||
|
<NSkeleton class="h-80 w-full" />
|
||||||
|
<div class="grid gap-4 md:grid-cols-3">
|
||||||
|
<NSkeleton v-for="n in 6" :key="n" class="h-56 w-full" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<NAlert
|
||||||
|
v-else-if="loadError"
|
||||||
|
class="mt-6"
|
||||||
|
type="error"
|
||||||
|
:show-icon="false"
|
||||||
|
:bordered="false"
|
||||||
|
title="详情加载失败"
|
||||||
|
>
|
||||||
|
{{ loadError }}
|
||||||
|
</NAlert>
|
||||||
|
|
||||||
|
<template v-else-if="cloudType">
|
||||||
|
<section class="oc-panel-card mt-6 overflow-hidden border border-slate-200 bg-white">
|
||||||
|
<div class="grid lg:grid-cols-[1.05fr_0.95fr]">
|
||||||
|
<div class="relative min-h-80 bg-sky-50">
|
||||||
|
<img
|
||||||
|
v-if="heroImage"
|
||||||
|
:src="heroImage"
|
||||||
|
:alt="cloudType.name"
|
||||||
|
class="absolute inset-0 h-full w-full object-cover"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="absolute inset-0 flex items-center justify-center pb-20 text-sm font-medium text-slate-500"
|
||||||
|
>
|
||||||
|
无图片
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="heroImage"
|
||||||
|
class="absolute inset-0 bg-gradient-to-t from-slate-950/75 via-slate-950/10 to-transparent"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
class="absolute bottom-7 left-7 right-7"
|
||||||
|
:class="heroImage ? 'text-white' : 'text-slate-900'"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="border px-2.5 py-1 text-xs"
|
||||||
|
:class="
|
||||||
|
heroImage
|
||||||
|
? 'border-white/35 bg-slate-950/25 backdrop-blur'
|
||||||
|
: 'border-slate-200 bg-white'
|
||||||
|
"
|
||||||
|
>稀有度 {{ cloudType.rarity }}</span
|
||||||
|
>
|
||||||
|
<h1 class="mt-4 text-4xl font-bold">{{ cloudType.name }}</h1>
|
||||||
|
<p class="mt-2" :class="heroImage ? 'text-white/80' : 'text-slate-600'">
|
||||||
|
{{ cloudType.genus || '未提供云属名称' }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="p-8">
|
||||||
|
<p class="oc-section-label">Meteorology Note</p>
|
||||||
|
<p class="mt-5 text-base leading-8 text-slate-700">
|
||||||
|
{{ cloudType.description || '暂未提供识别说明。' }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="mt-8">
|
||||||
|
<div class="mb-5 flex items-end justify-between gap-4">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-2xl font-bold text-slate-900">公开观测</h2>
|
||||||
|
<p class="oc-field-help">
|
||||||
|
第 {{ currentPage }} 页,每页最多 {{ PAGE_SIZE }} 张。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-3">
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
:disabled="currentPage === 1"
|
||||||
|
@click="loadPage(currentPage - 1)"
|
||||||
|
>上一页</NButton
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
:disabled="!hasNextPage"
|
||||||
|
@click="loadPage(currentPage + 1)"
|
||||||
|
>下一页</NButton
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="gallery.length"
|
||||||
|
class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
v-for="item in gallery"
|
||||||
|
:key="item.id"
|
||||||
|
type="button"
|
||||||
|
class="oc-interactive-card overflow-hidden border border-slate-200 bg-white text-left"
|
||||||
|
@click="selectedItem = item"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
:src="item.thumbnail_url || item.image_url"
|
||||||
|
:alt="cloudType.name"
|
||||||
|
class="h-48 w-full object-cover"
|
||||||
|
/>
|
||||||
|
<div class="p-4">
|
||||||
|
<p class="font-medium text-slate-900">@{{ item.username }}</p>
|
||||||
|
<p class="mt-1 text-xs text-slate-500">
|
||||||
|
{{ formatDateTime(item.captured_at || item.created_at) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="oc-empty-card border border-dashed border-slate-300 bg-white p-10"
|
||||||
|
>
|
||||||
|
<NEmpty description="这一页暂无公开云图" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<ImageDetailModal
|
||||||
|
v-if="selectedItem && cloudType"
|
||||||
|
:open="true"
|
||||||
|
:image-url="selectedItem.image_url"
|
||||||
|
:thumbnail-url="selectedItem.thumbnail_url"
|
||||||
|
:image-alt="cloudType.name"
|
||||||
|
:title="cloudType.name"
|
||||||
|
:subtitle="
|
||||||
|
selectedItem.captured_at
|
||||||
|
? `拍摄于 ${formatDateTime(selectedItem.captured_at)}`
|
||||||
|
: `上传于 ${formatDateTime(selectedItem.created_at)}`
|
||||||
|
"
|
||||||
|
:badge-label="`稀有度 ${cloudType.rarity}`"
|
||||||
|
badge-class="border-slate-200 bg-slate-50 text-slate-600"
|
||||||
|
@close="selectedItem = null"
|
||||||
|
>
|
||||||
|
<p class="text-sm leading-7 text-slate-700">
|
||||||
|
{{ selectedItem.description || '上传者没有留下额外说明。' }}
|
||||||
|
</p>
|
||||||
|
<MiniLocationMap
|
||||||
|
:latitude="selectedItem.latitude"
|
||||||
|
:longitude="selectedItem.longitude"
|
||||||
|
/>
|
||||||
|
<CloudLikeButton
|
||||||
|
:cloud-id="selectedItem.id"
|
||||||
|
:count="selectedItem.received_like_count"
|
||||||
|
/>
|
||||||
|
</ImageDetailModal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted } from 'vue'
|
||||||
|
import { NEmpty, NSkeleton } from 'naive-ui'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import { imageUrl } from '@/features/clouds/api'
|
||||||
|
import { useEncyclopediaStore } from '@/features/encyclopedia/stores/encyclopedia'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const encyclopediaStore = useEncyclopediaStore()
|
||||||
|
|
||||||
|
function typeImageUrl(iconId: string | null) {
|
||||||
|
return iconId ? imageUrl(iconId, 'preview') : ''
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => encyclopediaStore.fetchCloudTypes())
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="relative">
|
||||||
|
<div class="oc-page-hero">
|
||||||
|
<div class="oc-container oc-container--content oc-page-hero__inner">
|
||||||
|
<p class="oc-page-eyebrow">Cloud Encyclopedia</p>
|
||||||
|
<h1 class="oc-page-title">云朵百科</h1>
|
||||||
|
<p class="oc-page-description">
|
||||||
|
浏览后端提供的云类型资料,了解云属名称、识别说明和社区公开观测记录。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="oc-container oc-container--content oc-page-content">
|
||||||
|
<div
|
||||||
|
v-if="encyclopediaStore.loadingCloudTypes"
|
||||||
|
class="grid gap-5 md:grid-cols-2 lg:grid-cols-3"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="n in 6"
|
||||||
|
:key="n"
|
||||||
|
class="oc-panel-card overflow-hidden border border-slate-200 bg-white"
|
||||||
|
>
|
||||||
|
<NSkeleton class="h-80 w-full" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="encyclopediaStore.cloudTypes.length"
|
||||||
|
class="grid gap-5 md:grid-cols-2 lg:grid-cols-3"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
v-for="cloudType in encyclopediaStore.cloudTypes"
|
||||||
|
:key="cloudType.id"
|
||||||
|
type="button"
|
||||||
|
class="oc-interactive-card oc-panel-card relative isolate min-h-80 overflow-hidden border border-slate-200 bg-sky-50 text-left"
|
||||||
|
@click="router.push(`/encyclopedia/${cloudType.id}`)"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
v-if="cloudType.icon_id"
|
||||||
|
:src="typeImageUrl(cloudType.icon_id)"
|
||||||
|
:alt="`${cloudType.name}介绍图`"
|
||||||
|
class="absolute inset-0 -z-20 h-full w-full object-cover"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-if="cloudType.icon_id"
|
||||||
|
class="absolute inset-0 -z-10 bg-gradient-to-t from-slate-950/90 via-slate-950/55 to-slate-950/25"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="absolute inset-0 -z-10 flex items-center justify-center text-sm font-medium text-slate-500"
|
||||||
|
>
|
||||||
|
无图片
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex min-h-80 flex-col p-5">
|
||||||
|
<div class="flex items-start justify-between gap-4">
|
||||||
|
<div>
|
||||||
|
<p
|
||||||
|
class="oc-section-label"
|
||||||
|
:class="cloudType.icon_id ? 'text-white/70' : 'text-slate-500'"
|
||||||
|
>
|
||||||
|
Cloud Genus
|
||||||
|
</p>
|
||||||
|
<h2
|
||||||
|
class="mt-2 text-xl font-bold"
|
||||||
|
:class="cloudType.icon_id ? 'text-white' : 'text-slate-900'"
|
||||||
|
>
|
||||||
|
{{ cloudType.name }}
|
||||||
|
</h2>
|
||||||
|
<p
|
||||||
|
class="mt-1 font-mono text-xs uppercase tracking-[0.12em]"
|
||||||
|
:class="cloudType.icon_id ? 'text-white/75' : 'text-slate-500'"
|
||||||
|
>
|
||||||
|
{{ cloudType.genus || '未提供云属名称' }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
class="shrink-0 border px-2.5 py-1 text-xs font-medium"
|
||||||
|
:class="
|
||||||
|
cloudType.icon_id
|
||||||
|
? 'border-white/35 bg-slate-950/25 text-white backdrop-blur'
|
||||||
|
: 'border-slate-200 bg-white text-slate-600'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
稀有度 {{ cloudType.rarity }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p
|
||||||
|
class="mt-auto line-clamp-3 pt-16 text-sm leading-6"
|
||||||
|
:class="cloudType.icon_id ? 'text-white/85' : 'text-slate-600'"
|
||||||
|
>
|
||||||
|
{{ cloudType.description || '暂未提供识别说明。' }}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
class="mt-4 border-t pt-4 text-xs font-semibold"
|
||||||
|
:class="
|
||||||
|
cloudType.icon_id
|
||||||
|
? 'border-white/25 text-white'
|
||||||
|
: 'border-slate-200 text-sky-700'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
查看类型资料与公开云图 →
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="oc-empty-card border border-dashed border-slate-300 bg-white px-6 py-12"
|
||||||
|
>
|
||||||
|
<NEmpty description="暂时还没有云类型资料" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,660 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||||
|
import { RouterLink } from 'vue-router'
|
||||||
|
import { NAlert, NButton, NDropdown, NEmpty, NIcon, NSkeleton, NTag, useMessage } from 'naive-ui'
|
||||||
|
import { Clock, Location, Search, Settings, User, X } from '@vicons/tabler'
|
||||||
|
import CloudEditModal, {
|
||||||
|
type CloudEditFormValue,
|
||||||
|
} from '@/features/clouds/components/CloudEditModal.vue'
|
||||||
|
import CloudLikeButton from '@/features/clouds/components/CloudLikeButton.vue'
|
||||||
|
import ImageDetailModal from '@/features/clouds/components/ImageDetailModal.vue'
|
||||||
|
import MiniLocationMap from '@/shared/map/components/MiniLocationMap.vue'
|
||||||
|
import { ApiError } from '@/lib/api'
|
||||||
|
import { listClouds } from '@/features/clouds/api'
|
||||||
|
import type { PublicCloudListQuery } from '@/types/api-contract'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
import { useCloudsStore } from '@/features/clouds/stores/clouds'
|
||||||
|
import { useProfileStore } from '@/features/profile/stores/profile'
|
||||||
|
|
||||||
|
import type { CloudDetail } from '@/types/view-models'
|
||||||
|
|
||||||
|
interface GalleryCloud {
|
||||||
|
id: string
|
||||||
|
user_id: string
|
||||||
|
cloud_type_id: number | null
|
||||||
|
image_url: string
|
||||||
|
thumbnail_url: string | null
|
||||||
|
description: string | null
|
||||||
|
latitude: number | null
|
||||||
|
longitude: number | null
|
||||||
|
captured_at: string | null
|
||||||
|
created_at: string
|
||||||
|
status: 'pending' | 'approved' | 'rejected'
|
||||||
|
is_hidden: boolean
|
||||||
|
cloudTypeName: string
|
||||||
|
cloudTypeRarity: number
|
||||||
|
username: string
|
||||||
|
receivedLikeCount: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const PAGE_SIZE = 50
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const cloudsStore = useCloudsStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const loading = ref(true)
|
||||||
|
const loadError = ref('')
|
||||||
|
const galleryItems = ref<GalleryCloud[]>([])
|
||||||
|
const selectedTypeId = ref<number | 'all'>('all')
|
||||||
|
const searchQuery = ref('')
|
||||||
|
const selectedCloud = ref<GalleryCloud | null>(null)
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const hasNextPage = ref(false)
|
||||||
|
const manageError = ref('')
|
||||||
|
const editModalOpen = ref(false)
|
||||||
|
const editSaving = ref(false)
|
||||||
|
const editInitialValue = ref<CloudEditFormValue | null>(null)
|
||||||
|
|
||||||
|
let searchTimer: number | null = null
|
||||||
|
|
||||||
|
const rarityChip = 'border-slate-200 bg-slate-50 text-slate-600'
|
||||||
|
|
||||||
|
function formatDateTime(iso: string | null) {
|
||||||
|
if (!iso) return '未知时间'
|
||||||
|
return new Date(iso).toLocaleString('zh-CN', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'numeric',
|
||||||
|
day: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatUploadTime(cloud: GalleryCloud) {
|
||||||
|
return formatDateTime(cloud.created_at)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatCapturedTime(cloud: GalleryCloud) {
|
||||||
|
return formatDateTime(cloud.captured_at)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatCoordinate(value: number | null) {
|
||||||
|
return value === null ? '未记录' : value.toFixed(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalizedSearch = computed(() => searchQuery.value.trim())
|
||||||
|
const isUserSearch = computed(() => normalizedSearch.value.startsWith('@'))
|
||||||
|
|
||||||
|
function toGalleryCloud(row: CloudDetail) {
|
||||||
|
return {
|
||||||
|
id: row.id,
|
||||||
|
user_id: row.user_id,
|
||||||
|
cloud_type_id: row.cloud_type_id,
|
||||||
|
image_url: row.image_url,
|
||||||
|
thumbnail_url: row.thumbnail_url,
|
||||||
|
description: row.description,
|
||||||
|
latitude: row.latitude,
|
||||||
|
longitude: row.longitude,
|
||||||
|
captured_at: row.captured_at,
|
||||||
|
created_at: row.created_at,
|
||||||
|
status: row.status,
|
||||||
|
is_hidden: row.is_hidden,
|
||||||
|
cloudTypeName: row.cloud_type_name || '未知',
|
||||||
|
cloudTypeRarity: row.cloud_type_rarity ?? 0,
|
||||||
|
username: row.username || '匿名',
|
||||||
|
receivedLikeCount: row.received_like_count,
|
||||||
|
} satisfies GalleryCloud
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadPage(page: number) {
|
||||||
|
loading.value = true
|
||||||
|
loadError.value = ''
|
||||||
|
|
||||||
|
try {
|
||||||
|
const query: PublicCloudListQuery = { page, page_size: PAGE_SIZE }
|
||||||
|
if (normalizedSearch.value) {
|
||||||
|
query.filter = isUserSearch.value ? 'owner' : 'type'
|
||||||
|
query.value = normalizedSearch.value
|
||||||
|
} else if (selectedTypeId.value !== 'all') {
|
||||||
|
const typeName = cloudsStore.cloudTypes.find(
|
||||||
|
type => type.id === selectedTypeId.value,
|
||||||
|
)?.name
|
||||||
|
if (typeName) {
|
||||||
|
query.filter = 'type'
|
||||||
|
query.value = typeName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await listClouds(query)
|
||||||
|
galleryItems.value = result.items.map(toGalleryCloud)
|
||||||
|
hasNextPage.value = result.has_more
|
||||||
|
currentPage.value = page
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof ApiError && error.status === 404 && isUserSearch.value) {
|
||||||
|
galleryItems.value = []
|
||||||
|
hasNextPage.value = false
|
||||||
|
currentPage.value = page
|
||||||
|
return
|
||||||
|
}
|
||||||
|
loadError.value = error instanceof Error ? error.message : '画廊加载失败'
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function goToPage(page: number) {
|
||||||
|
if (page < 1 || page === currentPage.value || (page > currentPage.value && !hasNextPage.value))
|
||||||
|
return
|
||||||
|
await loadPage(page)
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||||
|
}
|
||||||
|
|
||||||
|
function openDetail(cloud: GalleryCloud) {
|
||||||
|
selectedCloud.value = cloud
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeDetail() {
|
||||||
|
selectedCloud.value = null
|
||||||
|
editModalOpen.value = false
|
||||||
|
manageError.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectedCloudIsMine = computed(() => {
|
||||||
|
return !!selectedCloud.value && selectedCloud.value.user_id === authStore.user?.id
|
||||||
|
})
|
||||||
|
|
||||||
|
const cloudActionOptions = computed(() => [
|
||||||
|
{ label: '编辑图片信息', key: 'edit' },
|
||||||
|
{ label: '删除', key: 'delete' },
|
||||||
|
{ label: '更改为私密', key: 'toggle-privacy' },
|
||||||
|
])
|
||||||
|
|
||||||
|
function formatDatetimeLocal(iso: string | null) {
|
||||||
|
if (!iso) return ''
|
||||||
|
const date = new Date(iso)
|
||||||
|
const pad = (value: number) => String(value).padStart(2, '0')
|
||||||
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function blurCoordinate(value: number): number {
|
||||||
|
return Math.round(value * 100) / 100
|
||||||
|
}
|
||||||
|
|
||||||
|
function openEditModal() {
|
||||||
|
if (!selectedCloud.value) return
|
||||||
|
|
||||||
|
manageError.value = ''
|
||||||
|
editInitialValue.value = {
|
||||||
|
cloudCategoryId: selectedCloud.value.cloud_type_id,
|
||||||
|
capturedAt: formatDatetimeLocal(selectedCloud.value.captured_at),
|
||||||
|
latitude: selectedCloud.value.latitude,
|
||||||
|
longitude: selectedCloud.value.longitude,
|
||||||
|
description: selectedCloud.value.description || '',
|
||||||
|
isPublic: !selectedCloud.value.is_hidden,
|
||||||
|
}
|
||||||
|
editModalOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeEditModal() {
|
||||||
|
editModalOpen.value = false
|
||||||
|
editSaving.value = false
|
||||||
|
manageError.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function patchGalleryCloud(updated: GalleryCloud) {
|
||||||
|
galleryItems.value = galleryItems.value.map(item => (item.id === updated.id ? updated : item))
|
||||||
|
if (selectedCloud.value?.id === updated.id) {
|
||||||
|
selectedCloud.value = updated
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitEditModal(value: CloudEditFormValue) {
|
||||||
|
if (!selectedCloud.value || !authStore.user?.id) return
|
||||||
|
|
||||||
|
if (!value.cloudCategoryId) {
|
||||||
|
manageError.value = '请选择云型类别。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const hasLat = typeof value.latitude === 'number' && !Number.isNaN(value.latitude)
|
||||||
|
const hasLng = typeof value.longitude === 'number' && !Number.isNaN(value.longitude)
|
||||||
|
if (!hasLat || !hasLng) {
|
||||||
|
manageError.value = '经纬度为必填项。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (value.description.trim().length > 128) {
|
||||||
|
manageError.value = '图片描述不能超过 128 个字符。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const current = selectedCloud.value
|
||||||
|
editSaving.value = true
|
||||||
|
manageError.value = ''
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updated = await profileStore.updateCloud(authStore.user.id, current.id, {
|
||||||
|
cloud_type_id: value.cloudCategoryId,
|
||||||
|
latitude: blurCoordinate(value.latitude as number),
|
||||||
|
longitude: blurCoordinate(value.longitude as number),
|
||||||
|
description: value.description.trim(),
|
||||||
|
...(value.capturedAt ? { captured_at: new Date(value.capturedAt).toISOString() } : {}),
|
||||||
|
is_hidden: !value.isPublic,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (updated.is_hidden || updated.status !== 'approved') {
|
||||||
|
removeGalleryCloud(updated.id)
|
||||||
|
} else {
|
||||||
|
patchGalleryCloud({
|
||||||
|
...current,
|
||||||
|
...updated,
|
||||||
|
user_id: current.user_id,
|
||||||
|
username: current.username,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
closeEditModal()
|
||||||
|
message.success('图片信息已更新')
|
||||||
|
} catch (error) {
|
||||||
|
manageError.value = error instanceof Error ? error.message : '图片信息更新失败'
|
||||||
|
message.error(manageError.value)
|
||||||
|
} finally {
|
||||||
|
editSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeGalleryCloud(cloudId: string) {
|
||||||
|
galleryItems.value = galleryItems.value.filter(item => item.id !== cloudId)
|
||||||
|
if (selectedCloud.value?.id === cloudId) {
|
||||||
|
selectedCloud.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteSelectedCloud() {
|
||||||
|
if (!selectedCloud.value || !authStore.user?.id) return
|
||||||
|
const cloudId = selectedCloud.value.id
|
||||||
|
const confirmed = window.confirm('确定删除这张图片吗?删除后无法在页面中恢复。')
|
||||||
|
if (!confirmed) return
|
||||||
|
|
||||||
|
manageError.value = ''
|
||||||
|
|
||||||
|
try {
|
||||||
|
const deletedCount = await profileStore.deleteClouds(authStore.user.id, [cloudId])
|
||||||
|
removeGalleryCloud(cloudId)
|
||||||
|
message.success(`已成功删除 ${deletedCount} 张照片`)
|
||||||
|
} catch (error) {
|
||||||
|
manageError.value = error instanceof Error ? error.message : '图片删除失败'
|
||||||
|
message.error(manageError.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function hideSelectedCloud() {
|
||||||
|
if (!selectedCloud.value || !authStore.user?.id) return
|
||||||
|
const cloudId = selectedCloud.value.id
|
||||||
|
|
||||||
|
manageError.value = ''
|
||||||
|
|
||||||
|
try {
|
||||||
|
await profileStore.updateCloudVisibility(authStore.user.id, cloudId, true)
|
||||||
|
removeGalleryCloud(cloudId)
|
||||||
|
message.success('已更改为私密图片')
|
||||||
|
} catch (error) {
|
||||||
|
manageError.value = error instanceof Error ? error.message : '私密状态更新失败'
|
||||||
|
message.error(manageError.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCloudAction(key: string | number) {
|
||||||
|
if (key === 'edit') openEditModal()
|
||||||
|
if (key === 'delete') deleteSelectedCloud()
|
||||||
|
if (key === 'toggle-privacy') hideSelectedCloud()
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearSearch() {
|
||||||
|
searchQuery.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const filterTabs = computed(() => [
|
||||||
|
{ id: 'all' as const, label: '全部' },
|
||||||
|
...cloudsStore.cloudTypes.map(type => ({ id: type.id, label: type.name })),
|
||||||
|
])
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await cloudsStore.fetchCloudTypes()
|
||||||
|
await loadPage(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(selectedTypeId, async () => {
|
||||||
|
selectedCloud.value = null
|
||||||
|
await loadPage(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(searchQuery, () => {
|
||||||
|
if (searchTimer !== null) {
|
||||||
|
window.clearTimeout(searchTimer)
|
||||||
|
}
|
||||||
|
searchTimer = window.setTimeout(async () => {
|
||||||
|
selectedCloud.value = null
|
||||||
|
await loadPage(1)
|
||||||
|
searchTimer = null
|
||||||
|
}, 250)
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (searchTimer !== null) {
|
||||||
|
window.clearTimeout(searchTimer)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<section class="oc-page-hero">
|
||||||
|
<div class="oc-container oc-container--content oc-page-hero__inner">
|
||||||
|
<p class="oc-page-eyebrow">Community Gallery</p>
|
||||||
|
<h1 class="oc-page-title">云图画廊</h1>
|
||||||
|
<p class="oc-page-description">
|
||||||
|
按上传时间倒序浏览社区云图。瀑布流会尽量保留图片原始比例,悬停即可快速查看基本信息,点开可看大图和详细记录。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="oc-container oc-container--content oc-page-content">
|
||||||
|
<section>
|
||||||
|
<div class="oc-panel-card mb-4 border border-slate-200 bg-white p-3">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<NIcon size="20" class="shrink-0 text-slate-400">
|
||||||
|
<Search />
|
||||||
|
</NIcon>
|
||||||
|
<input
|
||||||
|
v-model="searchQuery"
|
||||||
|
type="text"
|
||||||
|
class="min-w-0 flex-1 bg-transparent text-sm text-slate-800 outline-none placeholder:text-slate-400"
|
||||||
|
placeholder="输入完整云类型名称,或 @用户名进行精确搜索"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
v-if="searchQuery"
|
||||||
|
type="button"
|
||||||
|
class="oc-icon-button oc-icon-button--small"
|
||||||
|
title="清空搜索"
|
||||||
|
aria-label="清空搜索"
|
||||||
|
@click="clearSearch"
|
||||||
|
>
|
||||||
|
<NIcon size="18">
|
||||||
|
<X />
|
||||||
|
</NIcon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p v-if="normalizedSearch" class="mt-2 text-xs text-slate-500">
|
||||||
|
<template v-if="isUserSearch">
|
||||||
|
正在按上传者搜索:{{ normalizedSearch.slice(1) || '请输入用户名' }}
|
||||||
|
</template>
|
||||||
|
<template v-else> 正在精确匹配云型名称:{{ normalizedSearch }} </template>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex gap-3 overflow-x-auto pb-2">
|
||||||
|
<NButton
|
||||||
|
v-for="tab in filterTabs"
|
||||||
|
:key="tab.id"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="shrink-0"
|
||||||
|
:class="
|
||||||
|
selectedTypeId === tab.id
|
||||||
|
? 'oc-panel-button oc-panel-button--sky'
|
||||||
|
: 'oc-panel-button oc-panel-button--neutral'
|
||||||
|
"
|
||||||
|
type="default"
|
||||||
|
@click="selectedTypeId = tab.id"
|
||||||
|
>
|
||||||
|
{{ tab.label }}
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<NAlert
|
||||||
|
v-if="loadError"
|
||||||
|
class="mt-6"
|
||||||
|
type="error"
|
||||||
|
:show-icon="false"
|
||||||
|
:bordered="false"
|
||||||
|
title="画廊加载失败"
|
||||||
|
>
|
||||||
|
{{ loadError }}
|
||||||
|
</NAlert>
|
||||||
|
|
||||||
|
<NAlert
|
||||||
|
v-if="manageError"
|
||||||
|
class="mt-6"
|
||||||
|
type="error"
|
||||||
|
:show-icon="false"
|
||||||
|
:bordered="false"
|
||||||
|
title="操作失败"
|
||||||
|
>
|
||||||
|
{{ manageError }}
|
||||||
|
</NAlert>
|
||||||
|
|
||||||
|
<section
|
||||||
|
v-if="loading"
|
||||||
|
class="mt-6 columns-2 gap-3 md:columns-3 xl:columns-4 [column-gap:0.75rem]"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="n in 8"
|
||||||
|
:key="n"
|
||||||
|
class="oc-panel-card mb-3 break-inside-avoid border border-slate-200 bg-white p-3"
|
||||||
|
>
|
||||||
|
<NSkeleton class="h-44 w-full" />
|
||||||
|
<NSkeleton class="mt-4 h-4 w-3/5" />
|
||||||
|
<NSkeleton class="mt-3 h-3 w-2/5" />
|
||||||
|
<NSkeleton class="mt-2 h-3 w-4/5" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section
|
||||||
|
v-else-if="galleryItems.length"
|
||||||
|
class="mt-6 columns-2 gap-3 md:columns-3 xl:columns-4 [column-gap:0.75rem]"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
v-for="cloud in galleryItems"
|
||||||
|
:key="cloud.id"
|
||||||
|
type="button"
|
||||||
|
class="oc-interactive-card group relative mb-3 block w-full break-inside-avoid overflow-hidden border border-slate-200 bg-slate-200 text-left transition-transform duration-300 hover:-translate-y-1"
|
||||||
|
@click="openDetail(cloud)"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
:src="cloud.thumbnail_url || cloud.image_url"
|
||||||
|
:alt="cloud.cloudTypeName"
|
||||||
|
class="block h-auto w-full object-cover transition duration-500 group-hover:scale-[1.04]"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="absolute inset-x-0 bottom-0 h-28 bg-gradient-to-t from-slate-950/88 via-slate-950/45 to-transparent opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
class="absolute inset-x-0 bottom-0 p-4 text-white opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<div class="flex items-center justify-between gap-3">
|
||||||
|
<p class="truncate text-sm font-semibold">
|
||||||
|
{{ cloud.cloudTypeName }}
|
||||||
|
</p>
|
||||||
|
<NTag
|
||||||
|
size="small"
|
||||||
|
:bordered="false"
|
||||||
|
class="shrink-0 bg-white/12 text-white backdrop-blur"
|
||||||
|
>
|
||||||
|
稀有度 {{ cloud.cloudTypeRarity }}
|
||||||
|
</NTag>
|
||||||
|
</div>
|
||||||
|
<p
|
||||||
|
class="mt-2 flex items-center gap-1.5 truncate text-xs text-white/82"
|
||||||
|
>
|
||||||
|
<NIcon size="14">
|
||||||
|
<User />
|
||||||
|
</NIcon>
|
||||||
|
<span class="truncate">{{ cloud.username }}</span>
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
class="mt-1 flex items-center gap-1.5 truncate text-xs text-white/82"
|
||||||
|
>
|
||||||
|
<NIcon size="14">
|
||||||
|
<Clock />
|
||||||
|
</NIcon>
|
||||||
|
<span class="truncate">{{ formatUploadTime(cloud) }}</span>
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
class="mt-1 flex items-center gap-1.5 truncate text-xs text-white/82"
|
||||||
|
>
|
||||||
|
<NIcon size="14">
|
||||||
|
<Location />
|
||||||
|
</NIcon>
|
||||||
|
<span class="truncate"
|
||||||
|
>{{ formatCoordinate(cloud.latitude) }},
|
||||||
|
{{ formatCoordinate(cloud.longitude) }}</span
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section
|
||||||
|
v-else
|
||||||
|
class="oc-empty-card mt-6 border border-dashed border-slate-300 bg-white px-6 py-12"
|
||||||
|
>
|
||||||
|
<NEmpty description="还没有符合条件的云图">
|
||||||
|
<template #extra>
|
||||||
|
<p class="text-sm text-slate-500">
|
||||||
|
换个云型筛选试试,或者等社区上传更多作品。
|
||||||
|
</p>
|
||||||
|
</template>
|
||||||
|
</NEmpty>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="currentPage > 1 || hasNextPage"
|
||||||
|
class="mt-8 flex items-center justify-center gap-2"
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
:disabled="currentPage <= 1"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
@click="goToPage(currentPage - 1)"
|
||||||
|
>
|
||||||
|
上一页
|
||||||
|
</NButton>
|
||||||
|
|
||||||
|
<span class="border border-slate-200 bg-white px-4 py-2 text-sm text-slate-600"
|
||||||
|
>第 {{ currentPage }} 页</span
|
||||||
|
>
|
||||||
|
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
:disabled="!hasNextPage"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
@click="goToPage(currentPage + 1)"
|
||||||
|
>
|
||||||
|
下一页
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ImageDetailModal
|
||||||
|
v-if="selectedCloud"
|
||||||
|
:open="!!selectedCloud"
|
||||||
|
:image-url="selectedCloud.image_url"
|
||||||
|
:thumbnail-url="selectedCloud.thumbnail_url"
|
||||||
|
:image-alt="selectedCloud.cloudTypeName"
|
||||||
|
:title="selectedCloud.cloudTypeName"
|
||||||
|
:subtitle="`上传者:${selectedCloud.username}`"
|
||||||
|
:badge-label="`稀有度 ${selectedCloud.cloudTypeRarity}`"
|
||||||
|
:badge-class="rarityChip"
|
||||||
|
@close="closeDetail"
|
||||||
|
>
|
||||||
|
<div class="grid gap-4 sm:grid-cols-2">
|
||||||
|
<div class="oc-inset-panel">
|
||||||
|
<p class="oc-section-label">上传时间</p>
|
||||||
|
<p class="mt-2 text-sm font-medium text-slate-900">
|
||||||
|
{{ formatUploadTime(selectedCloud) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="oc-inset-panel">
|
||||||
|
<p class="oc-section-label">拍摄时间</p>
|
||||||
|
<p class="mt-2 text-sm font-medium text-slate-900">
|
||||||
|
{{ formatCapturedTime(selectedCloud) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="oc-inset-panel">
|
||||||
|
<p class="oc-section-label">位置</p>
|
||||||
|
<p class="mt-2 text-sm font-medium text-slate-900">已记录经纬度</p>
|
||||||
|
</div>
|
||||||
|
<div class="oc-inset-panel">
|
||||||
|
<p class="oc-section-label">模糊化经纬度</p>
|
||||||
|
<p class="mt-2 text-sm font-medium text-slate-900">
|
||||||
|
纬度 {{ formatCoordinate(selectedCloud.latitude) }} / 经度
|
||||||
|
{{ formatCoordinate(selectedCloud.longitude) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-5 border border-slate-200 bg-white p-5">
|
||||||
|
<p class="oc-section-label">图片说明</p>
|
||||||
|
<p class="mt-3 text-sm leading-7 text-slate-700">
|
||||||
|
{{ selectedCloud.description || '上传者没有留下额外说明。' }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<RouterLink
|
||||||
|
:to="{ name: 'user-profile', params: { id: selectedCloud.username } }"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral mt-5 inline-flex"
|
||||||
|
>
|
||||||
|
查看 @{{ selectedCloud.username }} 的公开主页
|
||||||
|
</RouterLink>
|
||||||
|
<MiniLocationMap
|
||||||
|
:latitude="selectedCloud.latitude"
|
||||||
|
:longitude="selectedCloud.longitude"
|
||||||
|
/>
|
||||||
|
<CloudLikeButton
|
||||||
|
:cloud-id="selectedCloud.id"
|
||||||
|
:count="selectedCloud.receivedLikeCount"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<template v-if="selectedCloudIsMine" #actions>
|
||||||
|
<div class="flex items-center justify-between gap-3">
|
||||||
|
<NDropdown
|
||||||
|
trigger="click"
|
||||||
|
placement="top-start"
|
||||||
|
:options="cloudActionOptions"
|
||||||
|
@select="handleCloudAction"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-icon-button"
|
||||||
|
title="图片管理"
|
||||||
|
aria-label="图片管理"
|
||||||
|
>
|
||||||
|
<NIcon size="20">
|
||||||
|
<Settings />
|
||||||
|
</NIcon>
|
||||||
|
</button>
|
||||||
|
</NDropdown>
|
||||||
|
<!-- <span class="text-xs text-slate-500">这是你上传的公开图片</span> -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ImageDetailModal>
|
||||||
|
|
||||||
|
<CloudEditModal
|
||||||
|
:open="editModalOpen && !!selectedCloud"
|
||||||
|
:saving="editSaving"
|
||||||
|
:error="manageError"
|
||||||
|
:cloud-types="cloudsStore.cloudTypes"
|
||||||
|
:initial-value="editInitialValue"
|
||||||
|
@close="closeEditModal"
|
||||||
|
@save="submitEditModal"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,44 @@
|
|||||||
|
import { apiRequest, ApiError } from '@/lib/api'
|
||||||
|
import { toCloudDetail, toAuthUser } from '@/lib/api-adapters'
|
||||||
|
import { collectPages } from '@/lib/pagination'
|
||||||
|
import { listClouds } from '@/features/clouds/api'
|
||||||
|
import type { CloudPageResponse, UserProfileResponse } from '@/types/api-contract'
|
||||||
|
|
||||||
|
export async function getMyProfile() {
|
||||||
|
return toAuthUser(await apiRequest<UserProfileResponse>('/profiles/me'))
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateMyUsername(username: string) {
|
||||||
|
return toAuthUser(
|
||||||
|
await apiRequest<UserProfileResponse>('/profiles/me', {
|
||||||
|
method: 'PATCH',
|
||||||
|
body: { username },
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getUserProfile(userId: string) {
|
||||||
|
return toAuthUser(
|
||||||
|
await apiRequest<UserProfileResponse>(`/profiles/${encodeURIComponent(userId)}`),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function listMyClouds() {
|
||||||
|
return collectPages(async page => {
|
||||||
|
const result = await apiRequest<CloudPageResponse>('/profiles/me/clouds', {
|
||||||
|
query: { page, page_size: 100 },
|
||||||
|
})
|
||||||
|
return { ...result, items: result.items.map(toCloudDetail) }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listPublicClouds(username: string) {
|
||||||
|
try {
|
||||||
|
return await collectPages(page =>
|
||||||
|
listClouds({ page, page_size: 100, filter: 'owner', value: `@${username}` }),
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof ApiError && error.status === 404) return []
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,468 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref, watch } from 'vue'
|
||||||
|
import { NButton, NSelect } from 'naive-ui'
|
||||||
|
|
||||||
|
export interface ContributionHeatmapCell {
|
||||||
|
date: string
|
||||||
|
count: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MonthStat {
|
||||||
|
key: string
|
||||||
|
label: string
|
||||||
|
totalCount: number
|
||||||
|
activeDays: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const today = new Date()
|
||||||
|
const currentYear = today.getFullYear()
|
||||||
|
const currentMonth = today.getMonth() + 1
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
cells: ContributionHeatmapCell[]
|
||||||
|
totalCount: number
|
||||||
|
activeDays: number
|
||||||
|
activeDate?: string | null
|
||||||
|
title?: string
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
activeDate: null,
|
||||||
|
title: '上传活跃度',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
selectDate: [date: string]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const viewMode = ref<'year' | 'month'>('year')
|
||||||
|
const selectedYear = ref(currentYear)
|
||||||
|
const selectedMonth = ref(currentMonth)
|
||||||
|
const hoveredMonthKey = ref<string | null>(null)
|
||||||
|
|
||||||
|
function parseLocalDate(dateString: string) {
|
||||||
|
const [year, month, day] = dateString.split('-').map(Number)
|
||||||
|
return new Date(year, (month || 1) - 1, day || 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDayKey(date: Date) {
|
||||||
|
const month = `${date.getMonth() + 1}`.padStart(2, '0')
|
||||||
|
const day = `${date.getDate()}`.padStart(2, '0')
|
||||||
|
return `${date.getFullYear()}-${month}-${day}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function toMonthKey(dateString: string) {
|
||||||
|
const date = parseLocalDate(dateString)
|
||||||
|
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function startOfDay(date: Date) {
|
||||||
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate())
|
||||||
|
}
|
||||||
|
|
||||||
|
function startOfWeek(date: Date) {
|
||||||
|
const result = startOfDay(date)
|
||||||
|
const weekday = result.getDay()
|
||||||
|
const offset = weekday === 0 ? 6 : weekday - 1
|
||||||
|
result.setDate(result.getDate() - offset)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
const dailyCounts = computed(() => {
|
||||||
|
const counts = new Map<string, number>()
|
||||||
|
for (const cell of props.cells) {
|
||||||
|
counts.set(cell.date, cell.count)
|
||||||
|
}
|
||||||
|
return counts
|
||||||
|
})
|
||||||
|
|
||||||
|
const availableYears = computed(() => {
|
||||||
|
const years = new Set<number>([currentYear])
|
||||||
|
for (const cell of props.cells) {
|
||||||
|
years.add(parseLocalDate(cell.date).getFullYear())
|
||||||
|
}
|
||||||
|
return Array.from(years).sort((a, b) => b - a)
|
||||||
|
})
|
||||||
|
|
||||||
|
const yearOptions = computed(() => {
|
||||||
|
return availableYears.value.map(year => ({
|
||||||
|
label: `${year}年`,
|
||||||
|
value: year,
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
const monthOptions = Array.from({ length: 12 }, (_, index) => ({
|
||||||
|
label: `${index + 1}月`,
|
||||||
|
value: index + 1,
|
||||||
|
}))
|
||||||
|
|
||||||
|
watch(
|
||||||
|
availableYears,
|
||||||
|
years => {
|
||||||
|
if (!years.includes(selectedYear.value)) {
|
||||||
|
selectedYear.value = years[0] || currentYear
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
const visibleCells = computed(() => {
|
||||||
|
if (viewMode.value === 'year') {
|
||||||
|
const start = new Date(selectedYear.value, 0, 1)
|
||||||
|
const end = new Date(selectedYear.value, 11, 31)
|
||||||
|
const alignedStart = startOfWeek(start)
|
||||||
|
const alignedEnd = startOfWeek(end)
|
||||||
|
alignedEnd.setDate(alignedEnd.getDate() + 6)
|
||||||
|
|
||||||
|
const cells: Array<ContributionHeatmapCell & { inRange: boolean; isToday: boolean }> = []
|
||||||
|
const cursor = new Date(alignedStart)
|
||||||
|
|
||||||
|
while (cursor <= alignedEnd) {
|
||||||
|
const key = formatDayKey(cursor)
|
||||||
|
const inRange = cursor >= start && cursor <= end
|
||||||
|
cells.push({
|
||||||
|
date: key,
|
||||||
|
count: dailyCounts.value.get(key) || 0,
|
||||||
|
inRange,
|
||||||
|
isToday: key === formatDayKey(today),
|
||||||
|
})
|
||||||
|
cursor.setDate(cursor.getDate() + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cells
|
||||||
|
}
|
||||||
|
|
||||||
|
const start = new Date(selectedYear.value, selectedMonth.value - 1, 1)
|
||||||
|
const end = new Date(selectedYear.value, selectedMonth.value, 0)
|
||||||
|
const alignedStart = startOfWeek(start)
|
||||||
|
const alignedEnd = startOfWeek(end)
|
||||||
|
alignedEnd.setDate(alignedEnd.getDate() + 6)
|
||||||
|
|
||||||
|
const cells: Array<ContributionHeatmapCell & { inRange: boolean; isToday: boolean }> = []
|
||||||
|
const cursor = new Date(alignedStart)
|
||||||
|
|
||||||
|
while (cursor <= alignedEnd) {
|
||||||
|
const key = formatDayKey(cursor)
|
||||||
|
const inRange = cursor >= start && cursor <= end
|
||||||
|
cells.push({
|
||||||
|
date: key,
|
||||||
|
count: dailyCounts.value.get(key) || 0,
|
||||||
|
inRange,
|
||||||
|
isToday: key === formatDayKey(today),
|
||||||
|
})
|
||||||
|
cursor.setDate(cursor.getDate() + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cells
|
||||||
|
})
|
||||||
|
|
||||||
|
const contributionQuartiles = computed(() => {
|
||||||
|
const counts = visibleCells.value
|
||||||
|
.filter(cell => cell.inRange && cell.count > 0)
|
||||||
|
.map(cell => cell.count)
|
||||||
|
.sort((a, b) => a - b)
|
||||||
|
|
||||||
|
if (!counts.length) return [0, 0, 0] as const
|
||||||
|
|
||||||
|
const percentile = (value: number) => {
|
||||||
|
const index = Math.ceil(counts.length * value) - 1
|
||||||
|
return counts[Math.max(0, index)] || 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return [percentile(0.25), percentile(0.5), percentile(0.75)] as const
|
||||||
|
})
|
||||||
|
|
||||||
|
function getLevel(count: number) {
|
||||||
|
if (count <= 0) return 0
|
||||||
|
|
||||||
|
const [firstQuartile, secondQuartile, thirdQuartile] = contributionQuartiles.value
|
||||||
|
|
||||||
|
if (count <= firstQuartile) return 1
|
||||||
|
if (count <= secondQuartile) return 2
|
||||||
|
if (count <= thirdQuartile) return 3
|
||||||
|
return 4
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCellClass(cell: { count: number; inRange: boolean }) {
|
||||||
|
if (!cell.inRange) return 'bg-transparent border-transparent'
|
||||||
|
|
||||||
|
const level = getLevel(cell.count)
|
||||||
|
return `oc-heatmap-cell--level-${level}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const weeks = computed(() => {
|
||||||
|
const buckets: Array<typeof visibleCells.value> = []
|
||||||
|
for (let index = 0; index < visibleCells.value.length; index += 7) {
|
||||||
|
buckets.push(visibleCells.value.slice(index, index + 7))
|
||||||
|
}
|
||||||
|
return buckets
|
||||||
|
})
|
||||||
|
|
||||||
|
const monthStats = computed(() => {
|
||||||
|
const stats = new Map<string, MonthStat>()
|
||||||
|
|
||||||
|
for (const cell of visibleCells.value) {
|
||||||
|
if (!cell.inRange) continue
|
||||||
|
const monthKey = toMonthKey(cell.date)
|
||||||
|
const date = parseLocalDate(cell.date)
|
||||||
|
const label = `${date.getMonth() + 1}月`
|
||||||
|
const existing = stats.get(monthKey)
|
||||||
|
|
||||||
|
if (existing) {
|
||||||
|
existing.totalCount += cell.count
|
||||||
|
if (cell.count > 0) existing.activeDays += 1
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
stats.set(monthKey, {
|
||||||
|
key: monthKey,
|
||||||
|
label,
|
||||||
|
totalCount: cell.count,
|
||||||
|
activeDays: cell.count > 0 ? 1 : 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return stats
|
||||||
|
})
|
||||||
|
|
||||||
|
const monthLabels = computed(() => {
|
||||||
|
if (viewMode.value !== 'year') return []
|
||||||
|
|
||||||
|
let lastMonth = -1
|
||||||
|
return weeks.value.map(week => {
|
||||||
|
const firstInRange = week.find(cell => cell.inRange)
|
||||||
|
if (!firstInRange) return null
|
||||||
|
|
||||||
|
const date = parseLocalDate(firstInRange.date)
|
||||||
|
const month = date.getMonth()
|
||||||
|
const labelMonth = month + 1
|
||||||
|
const monthKey = toMonthKey(firstInRange.date)
|
||||||
|
|
||||||
|
if (month === lastMonth) return null
|
||||||
|
|
||||||
|
lastMonth = month
|
||||||
|
return {
|
||||||
|
key: monthKey,
|
||||||
|
label: labelMonth === 1 ? `${selectedYear.value}/1月` : `${labelMonth}月`,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
const monthPreview = computed(() => {
|
||||||
|
if (!hoveredMonthKey.value) return null
|
||||||
|
return monthStats.value.get(hoveredMonthKey.value) || null
|
||||||
|
})
|
||||||
|
|
||||||
|
const panelSummary = computed(() => {
|
||||||
|
if (viewMode.value === 'year') {
|
||||||
|
return `${selectedYear.value} 年完整视图,包含尚未来到的日期。`
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${selectedYear.value} 年 ${selectedMonth.value} 月完整视图。`
|
||||||
|
})
|
||||||
|
|
||||||
|
function formatTooltip(cell: ContributionHeatmapCell & { inRange: boolean; isToday: boolean }) {
|
||||||
|
const date = parseLocalDate(cell.date)
|
||||||
|
const label = date.toLocaleDateString('zh-CN', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric',
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!cell.inRange) {
|
||||||
|
return `${label}:不在当前视图范围内`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cell.count === 0) {
|
||||||
|
return `${label}${cell.isToday ? '(今天)' : ''}:当天没有上传`
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${label}${cell.isToday ? '(今天)' : ''}:上传 ${cell.count} 张`
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCellClick(cell: ContributionHeatmapCell & { inRange: boolean }) {
|
||||||
|
if (!cell.inRange) return
|
||||||
|
emit('selectDate', cell.date)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatMonthTooltip(monthKey: string) {
|
||||||
|
const stats = monthStats.value.get(monthKey)
|
||||||
|
if (!stats) return ''
|
||||||
|
return `${stats.label}:共上传 ${stats.totalCount} 张,活跃于 ${stats.activeDays} 天`
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="oc-panel-card border border-slate-200 bg-white p-6">
|
||||||
|
<div class="flex flex-wrap items-start justify-between gap-6">
|
||||||
|
<div class="min-w-0 flex-1">
|
||||||
|
<h3 class="text-2xl font-bold text-slate-900">{{ title }}</h3>
|
||||||
|
<p class="mt-3 text-sm leading-7 text-slate-500">
|
||||||
|
共上传 {{ totalCount }} 张,活跃于
|
||||||
|
{{ activeDays }} 天。颜色越深,代表当天上传的照片越多。
|
||||||
|
</p>
|
||||||
|
<p class="mt-2 text-sm text-slate-500">{{ panelSummary }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-wrap items-center justify-end gap-3">
|
||||||
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
:class="
|
||||||
|
viewMode === 'year'
|
||||||
|
? 'oc-panel-button oc-panel-button--teal'
|
||||||
|
: 'oc-panel-button oc-panel-button--neutral'
|
||||||
|
"
|
||||||
|
@click="viewMode = 'year'"
|
||||||
|
>
|
||||||
|
年度视图
|
||||||
|
</NButton>
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
:class="
|
||||||
|
viewMode === 'month'
|
||||||
|
? 'oc-panel-button oc-panel-button--teal'
|
||||||
|
: 'oc-panel-button oc-panel-button--neutral'
|
||||||
|
"
|
||||||
|
@click="viewMode = 'month'"
|
||||||
|
>
|
||||||
|
月度视图
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
<NSelect v-model:value="selectedYear" :options="yearOptions" class="w-28" />
|
||||||
|
<NSelect
|
||||||
|
v-if="viewMode === 'month'"
|
||||||
|
v-model:value="selectedMonth"
|
||||||
|
:options="monthOptions"
|
||||||
|
class="w-24"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4 flex min-h-6 items-center justify-between gap-4 text-xs text-slate-500">
|
||||||
|
<span>点击某一天可筛选当天上传记录。</span>
|
||||||
|
<span v-if="monthPreview" class="text-right">
|
||||||
|
{{ monthPreview.label }}:{{ monthPreview.totalCount }} 张 /
|
||||||
|
{{ monthPreview.activeDays }} 天
|
||||||
|
</span>
|
||||||
|
<span v-else class="text-right">
|
||||||
|
<template v-if="viewMode === 'year'">悬停月份标签可预览当月上传摘要。</template>
|
||||||
|
<template v-else>当前显示整个月的上传情况。</template>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-8 overflow-x-auto">
|
||||||
|
<div :class="viewMode === 'year' ? 'min-w-[980px]' : 'min-w-[360px]'">
|
||||||
|
<div
|
||||||
|
v-if="viewMode === 'year'"
|
||||||
|
class="mb-2 grid grid-flow-col auto-cols-[14px] gap-1 pl-8 text-[11px] text-slate-400"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(month, index) in monthLabels"
|
||||||
|
:key="`${month?.key || 'empty'}-${index}`"
|
||||||
|
class="w-[14px] whitespace-nowrap"
|
||||||
|
:title="month ? formatMonthTooltip(month.key) : ''"
|
||||||
|
@mouseenter="hoveredMonthKey = month?.key || null"
|
||||||
|
@mouseleave="hoveredMonthKey = null"
|
||||||
|
>
|
||||||
|
{{ month?.label || '' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex gap-3">
|
||||||
|
<div class="grid grid-rows-7 gap-1 pt-[2px] text-[11px] text-slate-400">
|
||||||
|
<span>一</span>
|
||||||
|
<span></span>
|
||||||
|
<span>三</span>
|
||||||
|
<span></span>
|
||||||
|
<span>五</span>
|
||||||
|
<span></span>
|
||||||
|
<span>日</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-flow-col auto-cols-[14px] gap-1">
|
||||||
|
<div
|
||||||
|
v-for="(week, weekIndex) in weeks"
|
||||||
|
:key="weekIndex"
|
||||||
|
class="grid grid-rows-7 gap-1"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
v-for="cell in week"
|
||||||
|
:key="cell.date"
|
||||||
|
type="button"
|
||||||
|
class="oc-heatmap-cell relative h-3.5 w-3.5 border hover:scale-125"
|
||||||
|
:class="[
|
||||||
|
getCellClass(cell),
|
||||||
|
props.activeDate === cell.date
|
||||||
|
? 'ring-2 ring-slate-900 ring-offset-1'
|
||||||
|
: '',
|
||||||
|
cell.isToday && cell.inRange
|
||||||
|
? 'outline outline-1 outline-slate-900 outline-offset-1'
|
||||||
|
: '',
|
||||||
|
]"
|
||||||
|
:title="formatTooltip(cell)"
|
||||||
|
@click="handleCellClick(cell)"
|
||||||
|
></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-5 flex items-center justify-end gap-2 text-xs text-slate-500">
|
||||||
|
<span>少</span>
|
||||||
|
<span class="oc-heatmap-legend-cell oc-heatmap-cell--level-0"></span>
|
||||||
|
<span class="oc-heatmap-legend-cell oc-heatmap-cell--level-1"></span>
|
||||||
|
<span class="oc-heatmap-legend-cell oc-heatmap-cell--level-2"></span>
|
||||||
|
<span class="oc-heatmap-legend-cell oc-heatmap-cell--level-3"></span>
|
||||||
|
<span class="oc-heatmap-legend-cell oc-heatmap-cell--level-4"></span>
|
||||||
|
<span>多</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.oc-heatmap-cell,
|
||||||
|
.oc-heatmap-legend-cell {
|
||||||
|
transition:
|
||||||
|
background-color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
border-color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
transform var(--oc-duration-fast) var(--oc-ease-standard);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-heatmap-legend-cell {
|
||||||
|
width: 0.75rem;
|
||||||
|
height: 0.75rem;
|
||||||
|
border-width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-heatmap-cell--level-0 {
|
||||||
|
background: var(--oc-heatmap-empty);
|
||||||
|
border-color: var(--oc-heatmap-empty-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-heatmap-cell--level-1 {
|
||||||
|
background: var(--oc-heatmap-level-1);
|
||||||
|
border-color: var(--oc-heatmap-level-1-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-heatmap-cell--level-2 {
|
||||||
|
background: var(--oc-heatmap-level-2);
|
||||||
|
border-color: var(--oc-heatmap-level-2-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-heatmap-cell--level-3 {
|
||||||
|
background: var(--oc-heatmap-level-3);
|
||||||
|
border-color: var(--oc-heatmap-level-3-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-heatmap-cell--level-4 {
|
||||||
|
background: var(--oc-heatmap-level-4);
|
||||||
|
border-color: var(--oc-heatmap-level-4-border);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { getUserProfile, listMyClouds, listPublicClouds } from '@/features/profile/api'
|
||||||
|
import {
|
||||||
|
getCloud,
|
||||||
|
updateCloud as patchCloud,
|
||||||
|
deleteClouds as deleteCloudRecords,
|
||||||
|
} from '@/features/clouds/api'
|
||||||
|
import type { UpdateCloudBody } from '@/types/api-contract'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
import type { CloudDetail, AuthUser } from '@/types/view-models'
|
||||||
|
import type { Profile } from '@/types/models'
|
||||||
|
|
||||||
|
export interface ProfileCloudItem {
|
||||||
|
id: string
|
||||||
|
cloud_type_id: number
|
||||||
|
image_url: string
|
||||||
|
thumbnail_url: string
|
||||||
|
latitude: number
|
||||||
|
longitude: number
|
||||||
|
description: string | null
|
||||||
|
captured_at: string | null
|
||||||
|
created_at: string
|
||||||
|
status: 'pending' | 'approved' | 'rejected'
|
||||||
|
is_hidden: boolean
|
||||||
|
cloudTypeName: string
|
||||||
|
cloudTypeRarity: number
|
||||||
|
receivedLikeCount: number
|
||||||
|
}
|
||||||
|
|
||||||
|
function toProfileCloud(row: CloudDetail): ProfileCloudItem {
|
||||||
|
return {
|
||||||
|
id: row.id,
|
||||||
|
cloud_type_id: row.cloud_type_id as number,
|
||||||
|
image_url: row.image_url,
|
||||||
|
thumbnail_url: row.thumbnail_url as string,
|
||||||
|
latitude: row.latitude as number,
|
||||||
|
longitude: row.longitude as number,
|
||||||
|
description: row.description,
|
||||||
|
captured_at: row.captured_at,
|
||||||
|
created_at: row.created_at,
|
||||||
|
status: row.status,
|
||||||
|
is_hidden: row.is_hidden,
|
||||||
|
cloudTypeName: row.cloud_type_name || '未知',
|
||||||
|
cloudTypeRarity: row.cloud_type_rarity ?? 0,
|
||||||
|
receivedLikeCount: row.received_like_count,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useProfileStore = defineStore('profile-page', () => {
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const profilesByKey = ref<Record<string, Profile>>({})
|
||||||
|
const cloudsByKey = ref<Record<string, ProfileCloudItem[]>>({})
|
||||||
|
const loadingKeys = ref<Record<string, boolean>>({})
|
||||||
|
const errorByKey = ref<Record<string, string>>({})
|
||||||
|
|
||||||
|
const makeKey = (identifier: string, isOwnProfile: boolean) =>
|
||||||
|
`${identifier}:${isOwnProfile ? 'own' : 'public'}`
|
||||||
|
|
||||||
|
function getProfile(identifier: string | null) {
|
||||||
|
return identifier ? (profilesByKey.value[identifier] ?? null) : null
|
||||||
|
}
|
||||||
|
|
||||||
|
function getClouds(identifier: string | null, isOwnProfile: boolean) {
|
||||||
|
return identifier ? (cloudsByKey.value[makeKey(identifier, isOwnProfile)] ?? []) : []
|
||||||
|
}
|
||||||
|
|
||||||
|
function getError(identifier: string | null, isOwnProfile: boolean) {
|
||||||
|
return identifier ? (errorByKey.value[makeKey(identifier, isOwnProfile)] ?? '') : ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLoaded(identifier: string | null, isOwnProfile: boolean) {
|
||||||
|
return !!identifier && makeKey(identifier, isOwnProfile) in cloudsByKey.value
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchProfilePage(identifier: string, isOwnProfile: boolean, force = false) {
|
||||||
|
const key = makeKey(identifier, isOwnProfile)
|
||||||
|
if (!force && key in cloudsByKey.value && profilesByKey.value[identifier]) return
|
||||||
|
|
||||||
|
loadingKeys.value[key] = true
|
||||||
|
errorByKey.value[key] = ''
|
||||||
|
try {
|
||||||
|
const backendRows = isOwnProfile
|
||||||
|
? await listMyClouds()
|
||||||
|
: await listPublicClouds(identifier)
|
||||||
|
const cloudRows = backendRows.map(toProfileCloud)
|
||||||
|
|
||||||
|
if (isOwnProfile && authStore.profile) {
|
||||||
|
profilesByKey.value[identifier] = authStore.profile
|
||||||
|
} else if (identifier === authStore.profile?.username && authStore.profile) {
|
||||||
|
profilesByKey.value[identifier] = authStore.profile
|
||||||
|
} else {
|
||||||
|
const owner = backendRows[0]?.owner
|
||||||
|
let publicProfile: AuthUser | null = null
|
||||||
|
if (owner?.id && authStore.isLoggedIn) {
|
||||||
|
try {
|
||||||
|
publicProfile = await getUserProfile(owner.id)
|
||||||
|
} catch {
|
||||||
|
// Public clouds can still be displayed if the profile lookup fails.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
profilesByKey.value[identifier] = {
|
||||||
|
id: owner?.id || identifier,
|
||||||
|
username: owner?.username || identifier,
|
||||||
|
image: publicProfile?.image ?? null,
|
||||||
|
role: 'user',
|
||||||
|
is_disabled: false,
|
||||||
|
created_at: '',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cloudsByKey.value[key] = cloudRows
|
||||||
|
} catch (error) {
|
||||||
|
errorByKey.value[key] = error instanceof Error ? error.message : '个人主页加载失败'
|
||||||
|
cloudsByKey.value[key] = []
|
||||||
|
} finally {
|
||||||
|
loadingKeys.value[key] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLoading(identifier: string | null, isOwnProfile: boolean) {
|
||||||
|
return !!identifier && !!loadingKeys.value[makeKey(identifier, isOwnProfile)]
|
||||||
|
}
|
||||||
|
|
||||||
|
function patchCachedCloud(
|
||||||
|
identifier: string,
|
||||||
|
cloudId: string,
|
||||||
|
patch: Partial<ProfileCloudItem>,
|
||||||
|
) {
|
||||||
|
for (const isOwnProfile of [true, false]) {
|
||||||
|
const key = makeKey(identifier, isOwnProfile)
|
||||||
|
const current = cloudsByKey.value[key]
|
||||||
|
if (!current) continue
|
||||||
|
cloudsByKey.value[key] = current
|
||||||
|
.map(item => (item.id === cloudId ? { ...item, ...patch } : item))
|
||||||
|
.filter(item => isOwnProfile || (item.status === 'approved' && !item.is_hidden))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeCachedClouds(identifier: string, cloudIds: string[]) {
|
||||||
|
const ids = new Set(cloudIds)
|
||||||
|
for (const isOwnProfile of [true, false]) {
|
||||||
|
const key = makeKey(identifier, isOwnProfile)
|
||||||
|
const current = cloudsByKey.value[key]
|
||||||
|
if (current) cloudsByKey.value[key] = current.filter(item => !ids.has(item.id))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function invalidateUser(identifier: string) {
|
||||||
|
delete cloudsByKey.value[makeKey(identifier, true)]
|
||||||
|
delete cloudsByKey.value[makeKey(identifier, false)]
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateCloud(identifier: string, cloudId: string, patch: UpdateCloudBody) {
|
||||||
|
await patchCloud(cloudId, patch)
|
||||||
|
const updated = toProfileCloud(await getCloud(cloudId))
|
||||||
|
patchCachedCloud(identifier, cloudId, updated)
|
||||||
|
return updated
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateCloudVisibility(identifier: string, cloudId: string, isHidden: boolean) {
|
||||||
|
await patchCloud(cloudId, { is_hidden: isHidden })
|
||||||
|
patchCachedCloud(identifier, cloudId, { is_hidden: isHidden })
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteClouds(identifier: string, cloudIds: string[]) {
|
||||||
|
if (!cloudIds.length) return 0
|
||||||
|
|
||||||
|
await deleteCloudRecords(cloudIds, deletedIds => removeCachedClouds(identifier, deletedIds))
|
||||||
|
return cloudIds.length
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
getProfile,
|
||||||
|
getClouds,
|
||||||
|
getError,
|
||||||
|
isLoaded,
|
||||||
|
isLoading,
|
||||||
|
fetchProfilePage,
|
||||||
|
invalidateUser,
|
||||||
|
updateCloud,
|
||||||
|
updateCloudVisibility,
|
||||||
|
deleteClouds,
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,217 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import { RouterLink } from 'vue-router'
|
||||||
|
import { NAlert, NButton, NCard, NForm, NInput, useMessage } from 'naive-ui'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const usernameDraft = ref('')
|
||||||
|
const currentPassword = ref('')
|
||||||
|
const newPassword = ref('')
|
||||||
|
const confirmNewPassword = ref('')
|
||||||
|
const error = ref('')
|
||||||
|
const success = ref('')
|
||||||
|
const usernameSaving = ref(false)
|
||||||
|
const passwordSaving = ref(false)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
usernameDraft.value = authStore.profile?.username || ''
|
||||||
|
})
|
||||||
|
|
||||||
|
async function saveUsername() {
|
||||||
|
const nextUsername = usernameDraft.value.trim()
|
||||||
|
|
||||||
|
error.value = ''
|
||||||
|
success.value = ''
|
||||||
|
|
||||||
|
if (!nextUsername) {
|
||||||
|
error.value = '昵称不能为空。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (nextUsername.length > 16) {
|
||||||
|
error.value = '昵称不能超过 16 个字符。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (nextUsername === authStore.profile?.username) {
|
||||||
|
success.value = '昵称没有变化。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
usernameSaving.value = true
|
||||||
|
try {
|
||||||
|
await authStore.updateUsername(nextUsername)
|
||||||
|
success.value = '昵称已更新。'
|
||||||
|
message.success('昵称已更新')
|
||||||
|
} catch (e) {
|
||||||
|
error.value = e instanceof Error ? e.message : '昵称更新失败'
|
||||||
|
} finally {
|
||||||
|
usernameSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function savePassword() {
|
||||||
|
error.value = ''
|
||||||
|
success.value = ''
|
||||||
|
|
||||||
|
if (newPassword.value.length < 8) {
|
||||||
|
error.value = '新密码至少需要 8 位。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (newPassword.value !== confirmNewPassword.value) {
|
||||||
|
error.value = '两次输入的新密码不一致。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!currentPassword.value) {
|
||||||
|
error.value = '请输入当前密码。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
passwordSaving.value = true
|
||||||
|
try {
|
||||||
|
await authStore.updatePassword(currentPassword.value, newPassword.value)
|
||||||
|
currentPassword.value = ''
|
||||||
|
newPassword.value = ''
|
||||||
|
confirmNewPassword.value = ''
|
||||||
|
success.value = '密码已更新。其他设备上的会话已退出。'
|
||||||
|
message.success('密码已更新')
|
||||||
|
} catch (e) {
|
||||||
|
error.value = e instanceof Error ? e.message : '密码更新失败'
|
||||||
|
} finally {
|
||||||
|
passwordSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="min-h-[calc(100vh-4rem)] bg-[linear-gradient(180deg,#e0f2fe_0%,#f8fafc_100%)] py-10"
|
||||||
|
>
|
||||||
|
<div class="oc-container oc-container--content">
|
||||||
|
<RouterLink to="/profile">
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
>← 返回个人主页</NButton
|
||||||
|
>
|
||||||
|
</RouterLink>
|
||||||
|
|
||||||
|
<div class="mt-6">
|
||||||
|
<p class="oc-page-eyebrow">Account Settings</p>
|
||||||
|
<h1 class="oc-page-title">个人资料设置</h1>
|
||||||
|
<p class="oc-page-description">
|
||||||
|
修改公开昵称和登录密码。昵称会显示在画廊、百科和地图中,且不能与其他用户重复。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-8 grid gap-6">
|
||||||
|
<NAlert v-if="error" type="error" :show-icon="false" :bordered="false">
|
||||||
|
{{ error }}
|
||||||
|
</NAlert>
|
||||||
|
<NAlert v-if="success" type="success" :show-icon="false" :bordered="false">
|
||||||
|
{{ success }}
|
||||||
|
</NAlert>
|
||||||
|
|
||||||
|
<NCard class="oc-panel-card border border-slate-200 bg-white" :bordered="false">
|
||||||
|
<div class="grid gap-5 lg:grid-cols-[0.8fr_1.2fr] lg:items-start">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-2xl font-bold text-slate-900">公开昵称</h2>
|
||||||
|
<p class="mt-2 text-sm leading-6 text-slate-500">
|
||||||
|
用于公开展示你的上传记录。保存前会检查是否与其他用户重复。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="grid gap-3 sm:grid-cols-[minmax(0,1fr)_auto]">
|
||||||
|
<NInput
|
||||||
|
v-model:value="usernameDraft"
|
||||||
|
placeholder="输入新的昵称"
|
||||||
|
maxlength="16"
|
||||||
|
show-count
|
||||||
|
/>
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--teal"
|
||||||
|
:loading="usernameSaving"
|
||||||
|
@click="saveUsername"
|
||||||
|
>
|
||||||
|
保存昵称
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</NCard>
|
||||||
|
|
||||||
|
<NCard class="oc-panel-card border border-slate-200 bg-white" :bordered="false">
|
||||||
|
<div class="grid gap-5 lg:grid-cols-[0.8fr_1.2fr] lg:items-start">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-2xl font-bold text-slate-900">登录密码</h2>
|
||||||
|
<p class="mt-2 text-sm leading-6 text-slate-500">
|
||||||
|
修改后下次登录需要使用新密码。建议使用至少 8 位且不易猜测的密码。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<NForm class="grid gap-3" @submit.prevent="savePassword">
|
||||||
|
<input
|
||||||
|
:value="authStore.user?.email || ''"
|
||||||
|
type="text"
|
||||||
|
name="username"
|
||||||
|
autocomplete="username"
|
||||||
|
class="sr-only"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-label="账户邮箱"
|
||||||
|
readonly
|
||||||
|
/>
|
||||||
|
<NInput
|
||||||
|
v-model:value="currentPassword"
|
||||||
|
type="password"
|
||||||
|
show-password-on="click"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'current-password',
|
||||||
|
name: 'current-password',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
placeholder="当前密码"
|
||||||
|
/>
|
||||||
|
<NInput
|
||||||
|
v-model:value="newPassword"
|
||||||
|
type="password"
|
||||||
|
show-password-on="click"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'new-password',
|
||||||
|
name: 'new-password',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
placeholder="新密码"
|
||||||
|
/>
|
||||||
|
<NInput
|
||||||
|
v-model:value="confirmNewPassword"
|
||||||
|
type="password"
|
||||||
|
show-password-on="click"
|
||||||
|
:input-props="{
|
||||||
|
autocomplete: 'new-password',
|
||||||
|
name: 'confirm-new-password',
|
||||||
|
required: true,
|
||||||
|
}"
|
||||||
|
placeholder="确认新密码"
|
||||||
|
/>
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
attr-type="submit"
|
||||||
|
class="oc-panel-button oc-panel-button--teal"
|
||||||
|
:loading="passwordSaving"
|
||||||
|
>
|
||||||
|
保存密码
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
</NForm>
|
||||||
|
</div>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,937 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, nextTick, ref, watch } from 'vue'
|
||||||
|
import { RouterLink, useRoute } from 'vue-router'
|
||||||
|
import { NAlert, NButton, NCard, NDropdown, NEmpty, NIcon, NSkeleton, useMessage } from 'naive-ui'
|
||||||
|
import { Settings } from '@vicons/tabler'
|
||||||
|
import CloudEditModal, {
|
||||||
|
type CloudEditFormValue,
|
||||||
|
} from '@/features/clouds/components/CloudEditModal.vue'
|
||||||
|
import CloudLikeButton from '@/features/clouds/components/CloudLikeButton.vue'
|
||||||
|
import ImageDetailModal from '@/features/clouds/components/ImageDetailModal.vue'
|
||||||
|
import MiniLocationMap from '@/shared/map/components/MiniLocationMap.vue'
|
||||||
|
import ContributionHeatmap from '@/features/profile/components/ContributionHeatmap.vue'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
import { useCloudsStore } from '@/features/clouds/stores/clouds'
|
||||||
|
import { useProfileStore, type ProfileCloudItem } from '@/features/profile/stores/profile'
|
||||||
|
import type { Profile } from '@/types/models'
|
||||||
|
|
||||||
|
interface TimelineGroup {
|
||||||
|
key: string
|
||||||
|
label: string
|
||||||
|
items: ProfileCloudItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const cloudsStore = useCloudsStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const selectedCloud = ref<ProfileCloudItem | null>(null)
|
||||||
|
const selectedUploadDate = ref<string | null>(null)
|
||||||
|
const timelineSectionRef = ref<HTMLElement | null>(null)
|
||||||
|
const selectionMode = ref(false)
|
||||||
|
const selectedCloudIds = ref<Set<string>>(new Set())
|
||||||
|
const editModalOpen = ref(false)
|
||||||
|
const editSaving = ref(false)
|
||||||
|
const manageError = ref('')
|
||||||
|
const editInitialValue = ref<CloudEditFormValue | null>(null)
|
||||||
|
|
||||||
|
const rarityChip = 'border-slate-200 bg-slate-50 text-slate-600'
|
||||||
|
|
||||||
|
const statusMeta = {
|
||||||
|
approved: { label: '已通过', chip: 'bg-emerald-100 text-emerald-700 border-emerald-200' },
|
||||||
|
pending: { label: '待审核', chip: 'bg-amber-100 text-amber-700 border-amber-200' },
|
||||||
|
rejected: { label: '未通过', chip: 'bg-rose-100 text-rose-700 border-rose-200' },
|
||||||
|
} satisfies Record<ProfileCloudItem['status'], { label: string; chip: string }>
|
||||||
|
|
||||||
|
const viewedIdentifier = computed(() => {
|
||||||
|
const routeUsername = typeof route.params.id === 'string' ? route.params.id : null
|
||||||
|
return routeUsername || authStore.user?.id || null
|
||||||
|
})
|
||||||
|
|
||||||
|
const isOwnProfile = computed(() => typeof route.params.id !== 'string')
|
||||||
|
|
||||||
|
const loading = computed(() => profileStore.isLoading(viewedIdentifier.value, isOwnProfile.value))
|
||||||
|
const errorMsg = computed(() => {
|
||||||
|
if (!viewedIdentifier.value) return '未找到要查看的用户。'
|
||||||
|
return profileStore.getError(viewedIdentifier.value, isOwnProfile.value)
|
||||||
|
})
|
||||||
|
const profileData = computed<Profile | null>(() =>
|
||||||
|
isOwnProfile.value ? authStore.profile : profileStore.getProfile(viewedIdentifier.value),
|
||||||
|
)
|
||||||
|
const profileImageFailed = ref(false)
|
||||||
|
watch(
|
||||||
|
() => profileData.value?.image,
|
||||||
|
() => {
|
||||||
|
profileImageFailed.value = false
|
||||||
|
},
|
||||||
|
)
|
||||||
|
const clouds = computed<ProfileCloudItem[]>(() =>
|
||||||
|
profileStore.getClouds(viewedIdentifier.value, isOwnProfile.value),
|
||||||
|
)
|
||||||
|
const receivedLikes = computed(() =>
|
||||||
|
isOwnProfile.value ? authStore.user?.received_like_count || 0 : 0,
|
||||||
|
)
|
||||||
|
|
||||||
|
const pageTitle = computed(() => {
|
||||||
|
return isOwnProfile.value
|
||||||
|
? '我的天空日志'
|
||||||
|
: `${profileData.value?.username || '这位用户'}的天空日志`
|
||||||
|
})
|
||||||
|
|
||||||
|
const totalShots = computed(() => clouds.value.length)
|
||||||
|
|
||||||
|
const approvedShots = computed(() => {
|
||||||
|
return clouds.value.filter(item => item.status === 'approved').length
|
||||||
|
})
|
||||||
|
|
||||||
|
const selectedCloudCount = computed(() => selectedCloudIds.value.size)
|
||||||
|
|
||||||
|
const cloudActionOptions = computed(() => {
|
||||||
|
if (!selectedCloud.value) return []
|
||||||
|
|
||||||
|
return [
|
||||||
|
{ label: '编辑', key: 'edit' },
|
||||||
|
{ label: '删除', key: 'delete' },
|
||||||
|
{
|
||||||
|
label: selectedCloud.value.is_hidden ? '更改为公开' : '更改为私密',
|
||||||
|
key: 'toggle-privacy',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
const shootingDays = computed(() => {
|
||||||
|
return new Set(clouds.value.map(item => toDayKey(item.captured_at || item.created_at))).size
|
||||||
|
})
|
||||||
|
|
||||||
|
const uploadDayCounts = computed(() => {
|
||||||
|
const counts = new Map<string, number>()
|
||||||
|
|
||||||
|
for (const item of clouds.value) {
|
||||||
|
const key = toDayKey(item.created_at)
|
||||||
|
counts.set(key, (counts.get(key) || 0) + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return counts
|
||||||
|
})
|
||||||
|
|
||||||
|
const mostCommonCloudType = computed(() => {
|
||||||
|
const counts = new Map<string, number>()
|
||||||
|
for (const item of clouds.value) {
|
||||||
|
counts.set(item.cloudTypeName, (counts.get(item.cloudTypeName) || 0) + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
let winner = '还没有记录'
|
||||||
|
let maxCount = 0
|
||||||
|
for (const [name, count] of counts.entries()) {
|
||||||
|
if (count > maxCount) {
|
||||||
|
winner = name
|
||||||
|
maxCount = count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: winner,
|
||||||
|
count: maxCount,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const filteredClouds = computed(() => {
|
||||||
|
if (!selectedUploadDate.value) return clouds.value
|
||||||
|
|
||||||
|
return clouds.value.filter(item => toDayKey(item.created_at) === selectedUploadDate.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
const timelineGroups = computed<TimelineGroup[]>(() => {
|
||||||
|
const groups = new Map<string, TimelineGroup>()
|
||||||
|
|
||||||
|
for (const item of filteredClouds.value) {
|
||||||
|
const date = new Date(item.captured_at || item.created_at)
|
||||||
|
const key = `${date.getFullYear()}-${date.getMonth() + 1}`
|
||||||
|
const existing = groups.get(key)
|
||||||
|
|
||||||
|
if (existing) {
|
||||||
|
existing.items.push(item)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
groups.set(key, {
|
||||||
|
key,
|
||||||
|
label: `${date.getFullYear()}年${date.getMonth() + 1}月`,
|
||||||
|
items: [item],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return Array.from(groups.values())
|
||||||
|
})
|
||||||
|
|
||||||
|
const selectedUploadCount = computed(() => {
|
||||||
|
if (!selectedUploadDate.value) return 0
|
||||||
|
return uploadDayCounts.value.get(selectedUploadDate.value) || 0
|
||||||
|
})
|
||||||
|
|
||||||
|
const contributionCells = computed(() => {
|
||||||
|
return Array.from(uploadDayCounts.value.entries())
|
||||||
|
.map(([date, count]) => ({ date, count }))
|
||||||
|
.sort((a, b) => a.date.localeCompare(b.date))
|
||||||
|
})
|
||||||
|
|
||||||
|
const activeUploadDays = computed(() => {
|
||||||
|
return contributionCells.value.filter(cell => cell.count > 0).length
|
||||||
|
})
|
||||||
|
|
||||||
|
function toDayKey(iso: string) {
|
||||||
|
const date = new Date(iso)
|
||||||
|
return toLocalDayKey(date)
|
||||||
|
}
|
||||||
|
|
||||||
|
function toLocalDayKey(date: Date) {
|
||||||
|
const month = `${date.getMonth() + 1}`.padStart(2, '0')
|
||||||
|
const day = `${date.getDate()}`.padStart(2, '0')
|
||||||
|
return `${date.getFullYear()}-${month}-${day}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(iso: string | null) {
|
||||||
|
if (!iso) return '未知时间'
|
||||||
|
return new Date(iso).toLocaleDateString('zh-CN', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDayKey(dayKey: string | null) {
|
||||||
|
if (!dayKey) return ''
|
||||||
|
const [year, month, day] = dayKey.split('-').map(Number)
|
||||||
|
return new Date(year, (month || 1) - 1, day || 1).toLocaleDateString('zh-CN', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDateTime(iso: string | null) {
|
||||||
|
if (!iso) return '未知时间'
|
||||||
|
return new Date(iso).toLocaleString('zh-CN', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'numeric',
|
||||||
|
day: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatCoordinate(value: number | null) {
|
||||||
|
return value === null ? '未记录' : value.toFixed(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatCloudTime(item: ProfileCloudItem) {
|
||||||
|
return item.captured_at
|
||||||
|
? `拍摄于 ${formatDateTime(item.captured_at)}`
|
||||||
|
: `上传于 ${formatDateTime(item.created_at)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function getProfileInitial(profile: Profile | null) {
|
||||||
|
return profile?.username?.slice(0, 1).toUpperCase() || '云'
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleSelectedUploadDate(date: string) {
|
||||||
|
selectedUploadDate.value = selectedUploadDate.value === date ? null : date
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearSelectedUploadDate() {
|
||||||
|
selectedUploadDate.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSelectedCloudIds(nextIds: Iterable<string>) {
|
||||||
|
selectedCloudIds.value = new Set(nextIds)
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCloudSelection(cloudId: string, checked: boolean) {
|
||||||
|
const nextIds = new Set(selectedCloudIds.value)
|
||||||
|
if (checked) {
|
||||||
|
nextIds.add(cloudId)
|
||||||
|
} else {
|
||||||
|
nextIds.delete(cloudId)
|
||||||
|
}
|
||||||
|
setSelectedCloudIds(nextIds)
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearCloudSelection() {
|
||||||
|
setSelectedCloudIds([])
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleSelectionMode() {
|
||||||
|
selectionMode.value = !selectionMode.value
|
||||||
|
if (!selectionMode.value) {
|
||||||
|
clearCloudSelection()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDatetimeLocal(iso: string | null) {
|
||||||
|
if (!iso) return ''
|
||||||
|
const date = new Date(iso)
|
||||||
|
const pad = (value: number) => String(value).padStart(2, '0')
|
||||||
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function openEditModal(cloud: ProfileCloudItem) {
|
||||||
|
manageError.value = ''
|
||||||
|
editInitialValue.value = {
|
||||||
|
cloudCategoryId: cloud.cloud_type_id,
|
||||||
|
capturedAt: formatDatetimeLocal(cloud.captured_at),
|
||||||
|
latitude: cloud.latitude,
|
||||||
|
longitude: cloud.longitude,
|
||||||
|
description: cloud.description || '',
|
||||||
|
isPublic: !cloud.is_hidden,
|
||||||
|
}
|
||||||
|
editModalOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeEditModal() {
|
||||||
|
editModalOpen.value = false
|
||||||
|
editSaving.value = false
|
||||||
|
manageError.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function blurCoordinate(value: number): number {
|
||||||
|
return Math.round(value * 100) / 100
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitEditModal(value: CloudEditFormValue) {
|
||||||
|
if (!selectedCloud.value || !viewedIdentifier.value) return
|
||||||
|
|
||||||
|
if (!value.cloudCategoryId) {
|
||||||
|
manageError.value = '请选择云型类别。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const hasLat = typeof value.latitude === 'number' && !Number.isNaN(value.latitude)
|
||||||
|
const hasLng = typeof value.longitude === 'number' && !Number.isNaN(value.longitude)
|
||||||
|
if (!hasLat || !hasLng) {
|
||||||
|
manageError.value = '经纬度为必填项。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (value.description.trim().length > 128) {
|
||||||
|
manageError.value = '图片描述不能超过 128 个字符。'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
editSaving.value = true
|
||||||
|
manageError.value = ''
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updated = await profileStore.updateCloud(
|
||||||
|
viewedIdentifier.value,
|
||||||
|
selectedCloud.value.id,
|
||||||
|
{
|
||||||
|
cloud_type_id: value.cloudCategoryId,
|
||||||
|
latitude: blurCoordinate(value.latitude as number),
|
||||||
|
longitude: blurCoordinate(value.longitude as number),
|
||||||
|
description: value.description.trim(),
|
||||||
|
...(value.capturedAt
|
||||||
|
? { captured_at: new Date(value.capturedAt).toISOString() }
|
||||||
|
: {}),
|
||||||
|
is_hidden: !value.isPublic,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
selectedCloud.value = updated
|
||||||
|
closeEditModal()
|
||||||
|
} catch (error) {
|
||||||
|
manageError.value = error instanceof Error ? error.message : '图片信息更新失败'
|
||||||
|
} finally {
|
||||||
|
editSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toggleSelectedCloudPrivacy() {
|
||||||
|
if (!selectedCloud.value || !viewedIdentifier.value) return
|
||||||
|
|
||||||
|
manageError.value = ''
|
||||||
|
const nextHidden = !selectedCloud.value.is_hidden
|
||||||
|
|
||||||
|
try {
|
||||||
|
await profileStore.updateCloudVisibility(
|
||||||
|
viewedIdentifier.value,
|
||||||
|
selectedCloud.value.id,
|
||||||
|
nextHidden,
|
||||||
|
)
|
||||||
|
selectedCloud.value = { ...selectedCloud.value, is_hidden: nextHidden }
|
||||||
|
} catch (error) {
|
||||||
|
manageError.value = error instanceof Error ? error.message : '私密状态更新失败'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteCloudByIds(cloudIds: string[]) {
|
||||||
|
if (!viewedIdentifier.value || !cloudIds.length) return
|
||||||
|
const confirmed = window.confirm(
|
||||||
|
`确定删除 ${cloudIds.length} 张图片吗?删除后无法在页面中恢复。`,
|
||||||
|
)
|
||||||
|
if (!confirmed) return
|
||||||
|
|
||||||
|
manageError.value = ''
|
||||||
|
|
||||||
|
try {
|
||||||
|
const deletedCount = await profileStore.deleteClouds(viewedIdentifier.value, cloudIds)
|
||||||
|
if (selectedCloud.value && cloudIds.includes(selectedCloud.value.id)) {
|
||||||
|
selectedCloud.value = null
|
||||||
|
closeEditModal()
|
||||||
|
}
|
||||||
|
const nextSelected = new Set(selectedCloudIds.value)
|
||||||
|
for (const cloudId of cloudIds) nextSelected.delete(cloudId)
|
||||||
|
setSelectedCloudIds(nextSelected)
|
||||||
|
message.success(`已成功删除 ${deletedCount} 张照片`)
|
||||||
|
} catch (error) {
|
||||||
|
manageError.value = error instanceof Error ? error.message : '图片删除失败'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCloudAction(key: string | number) {
|
||||||
|
if (!selectedCloud.value) return
|
||||||
|
if (key === 'edit') openEditModal(selectedCloud.value)
|
||||||
|
if (key === 'delete') deleteCloudByIds([selectedCloud.value.id])
|
||||||
|
if (key === 'toggle-privacy') toggleSelectedCloudPrivacy()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadProfilePage(force = false) {
|
||||||
|
selectedCloud.value = null
|
||||||
|
selectedUploadDate.value = null
|
||||||
|
clearCloudSelection()
|
||||||
|
selectionMode.value = false
|
||||||
|
|
||||||
|
const targetIdentifier = viewedIdentifier.value
|
||||||
|
|
||||||
|
if (!targetIdentifier) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await profileStore.fetchProfilePage(targetIdentifier, isOwnProfile.value, force)
|
||||||
|
|
||||||
|
if (isOwnProfile.value) {
|
||||||
|
await cloudsStore.fetchCloudTypes()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [route.params.id, authStore.user?.id],
|
||||||
|
() => {
|
||||||
|
loadProfilePage()
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(selectedUploadDate, async newValue => {
|
||||||
|
if (!newValue) return
|
||||||
|
await nextTick()
|
||||||
|
timelineSectionRef.value?.scrollIntoView({
|
||||||
|
behavior: 'smooth',
|
||||||
|
block: 'start',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="relative">
|
||||||
|
<div class="oc-page-hero">
|
||||||
|
<div class="oc-container oc-container--content oc-page-hero__inner">
|
||||||
|
<div v-if="loading" class="oc-page-hero__split">
|
||||||
|
<NCard class="oc-panel-card h-full border border-slate-200" :bordered="false">
|
||||||
|
<NSkeleton class="h-6 w-1/3" />
|
||||||
|
<NSkeleton class="mt-4 h-10 w-2/3" />
|
||||||
|
<NSkeleton class="mt-5 h-4 w-full" :repeat="2" />
|
||||||
|
</NCard>
|
||||||
|
<div
|
||||||
|
v-if="isOwnProfile"
|
||||||
|
class="grid grid-cols-2 gap-3 min-[900px]:h-full min-[900px]:grid-rows-2"
|
||||||
|
>
|
||||||
|
<NCard
|
||||||
|
v-for="n in 4"
|
||||||
|
:key="n"
|
||||||
|
class="oc-panel-card-soft h-full border border-white/80 bg-white/85 backdrop-blur"
|
||||||
|
:bordered="false"
|
||||||
|
>
|
||||||
|
<NSkeleton class="h-3 w-2/3" />
|
||||||
|
<NSkeleton class="mt-3 h-7 w-1/2" />
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<NCard
|
||||||
|
v-else
|
||||||
|
class="oc-panel-card-soft h-full border border-white/80 bg-white/85 backdrop-blur"
|
||||||
|
:bordered="false"
|
||||||
|
>
|
||||||
|
<NSkeleton class="h-5 w-1/3" />
|
||||||
|
<NSkeleton class="mt-4 h-8 w-1/2" />
|
||||||
|
<NSkeleton class="mt-5 h-3 w-full" />
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="oc-page-hero__split oc-page-hero__split--stretch">
|
||||||
|
<NCard
|
||||||
|
class="oc-panel-card h-full border border-slate-200 bg-white/90 backdrop-blur"
|
||||||
|
:bordered="false"
|
||||||
|
>
|
||||||
|
<div class="flex gap-5">
|
||||||
|
<div
|
||||||
|
class="profile-avatar flex h-20 w-20 shrink-0 items-center justify-center border border-slate-300 bg-[linear-gradient(135deg,#eef9f3_0%,#d9efe3_100%)] text-3xl font-bold text-slate-900"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
v-if="profileData?.image && !profileImageFailed"
|
||||||
|
:src="profileData.image"
|
||||||
|
:alt="profileData.username"
|
||||||
|
class="h-full w-full object-cover"
|
||||||
|
@error="profileImageFailed = true"
|
||||||
|
/>
|
||||||
|
<template v-else>
|
||||||
|
{{ getProfileInitial(profileData) }}
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="min-w-0">
|
||||||
|
<p class="oc-page-eyebrow">Sky Journal</p>
|
||||||
|
<h1 class="oc-page-title">
|
||||||
|
{{ pageTitle }}
|
||||||
|
</h1>
|
||||||
|
<div class="mt-3 flex flex-wrap items-center gap-3">
|
||||||
|
<p class="text-lg font-medium text-slate-700">
|
||||||
|
@{{ profileData?.username || '未知用户' }}
|
||||||
|
</p>
|
||||||
|
<RouterLink v-if="isOwnProfile" to="/profile/settings">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-icon-button oc-icon-button--small"
|
||||||
|
title="个人资料设置"
|
||||||
|
aria-label="个人资料设置"
|
||||||
|
>
|
||||||
|
<NIcon size="17">
|
||||||
|
<Settings />
|
||||||
|
</NIcon>
|
||||||
|
</button>
|
||||||
|
</RouterLink>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="mt-5 flex flex-wrap items-center gap-3 text-sm text-slate-500"
|
||||||
|
>
|
||||||
|
<span v-if="isOwnProfile"
|
||||||
|
>注册于
|
||||||
|
{{ formatDate(profileData?.created_at || null) }}</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</NCard>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="isOwnProfile"
|
||||||
|
class="grid grid-cols-2 gap-3 min-[900px]:h-full min-[900px]:grid-rows-2"
|
||||||
|
>
|
||||||
|
<NCard
|
||||||
|
class="oc-panel-card-soft h-full border border-white/80 bg-white/85 backdrop-blur"
|
||||||
|
:bordered="false"
|
||||||
|
>
|
||||||
|
<p class="oc-stat-label">总拍摄数</p>
|
||||||
|
<p class="oc-stat-value">{{ totalShots }}</p>
|
||||||
|
</NCard>
|
||||||
|
<NCard
|
||||||
|
class="oc-panel-card-soft h-full border border-white/80 bg-white/85 backdrop-blur"
|
||||||
|
:bordered="false"
|
||||||
|
>
|
||||||
|
<p class="oc-stat-label">最常拍云型</p>
|
||||||
|
<p class="mt-2 truncate text-xl font-bold text-slate-900">
|
||||||
|
{{ mostCommonCloudType.name }}
|
||||||
|
</p>
|
||||||
|
</NCard>
|
||||||
|
<NCard
|
||||||
|
class="oc-panel-card-soft h-full border border-white/80 bg-white/85 backdrop-blur"
|
||||||
|
:bordered="false"
|
||||||
|
>
|
||||||
|
<p class="oc-stat-label">拍摄天数</p>
|
||||||
|
<p class="oc-stat-value">{{ shootingDays }}</p>
|
||||||
|
</NCard>
|
||||||
|
<NCard
|
||||||
|
class="oc-panel-card-soft h-full border border-white/80 bg-white/85 backdrop-blur"
|
||||||
|
:bordered="false"
|
||||||
|
>
|
||||||
|
<p class="oc-stat-label">被点赞数</p>
|
||||||
|
<p class="oc-stat-value">{{ receivedLikes }}</p>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<NCard
|
||||||
|
v-if="!isOwnProfile"
|
||||||
|
class="oc-panel-card-soft h-full border border-white/80 bg-white/85 backdrop-blur"
|
||||||
|
:bordered="false"
|
||||||
|
>
|
||||||
|
<p class="text-sm text-slate-500">公开贡献</p>
|
||||||
|
<p class="mt-3 text-3xl font-bold text-slate-900">{{ approvedShots }}</p>
|
||||||
|
<p class="mt-2 text-sm text-slate-500">当前公开可见的云图数量</p>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="oc-container oc-container--content oc-page-content">
|
||||||
|
<NAlert
|
||||||
|
v-if="errorMsg"
|
||||||
|
type="error"
|
||||||
|
:show-icon="false"
|
||||||
|
:bordered="false"
|
||||||
|
title="个人主页加载失败"
|
||||||
|
>
|
||||||
|
{{ errorMsg }}
|
||||||
|
</NAlert>
|
||||||
|
|
||||||
|
<NAlert
|
||||||
|
v-if="manageError"
|
||||||
|
class="mb-5"
|
||||||
|
type="error"
|
||||||
|
:show-icon="false"
|
||||||
|
:bordered="false"
|
||||||
|
title="操作失败"
|
||||||
|
>
|
||||||
|
{{ manageError }}
|
||||||
|
</NAlert>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<section ref="timelineSectionRef">
|
||||||
|
<ContributionHeatmap
|
||||||
|
:cells="contributionCells"
|
||||||
|
:total-count="totalShots"
|
||||||
|
:active-days="activeUploadDays"
|
||||||
|
:active-date="selectedUploadDate"
|
||||||
|
:title="isOwnProfile ? '上传活跃度' : '公开活跃度'"
|
||||||
|
@select-date="toggleSelectedUploadDate"
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="mt-8">
|
||||||
|
<div class="mb-5 flex items-end justify-between gap-4">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-2xl font-bold text-slate-900">天空日志</h2>
|
||||||
|
<p class="oc-field-help">
|
||||||
|
按拍摄时间展示;未记录拍摄时间时回退为上传时间。热力图按上传日期计算。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<NButton
|
||||||
|
v-if="isOwnProfile && selectedCloudCount"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--danger"
|
||||||
|
@click="deleteCloudByIds(Array.from(selectedCloudIds))"
|
||||||
|
>
|
||||||
|
删除已选 {{ selectedCloudCount }}
|
||||||
|
</NButton>
|
||||||
|
<NButton
|
||||||
|
v-if="isOwnProfile"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
@click="toggleSelectionMode"
|
||||||
|
>
|
||||||
|
{{ selectionMode ? '取消选择' : '选择图片' }}
|
||||||
|
</NButton>
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
@click="loadProfilePage(true)"
|
||||||
|
>
|
||||||
|
刷新数据
|
||||||
|
</NButton>
|
||||||
|
<NButton
|
||||||
|
v-if="selectedUploadDate"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
@click="clearSelectedUploadDate"
|
||||||
|
>
|
||||||
|
清除筛选
|
||||||
|
</NButton>
|
||||||
|
<RouterLink
|
||||||
|
v-if="isOwnProfile"
|
||||||
|
to="/upload"
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
>
|
||||||
|
继续上传
|
||||||
|
</RouterLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="selectedUploadDate"
|
||||||
|
class="mb-5 border border-sky-200 bg-sky-50 px-4 py-3 text-sm text-sky-800"
|
||||||
|
>
|
||||||
|
当前正在查看
|
||||||
|
<span class="font-semibold">{{ formatDayKey(selectedUploadDate) }}</span>
|
||||||
|
上传的图片, 共
|
||||||
|
<span class="font-semibold">{{ selectedUploadCount }}</span> 张。
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="loading" class="space-y-8">
|
||||||
|
<div v-for="n in 2" :key="n">
|
||||||
|
<NSkeleton class="h-6 w-40" />
|
||||||
|
<div class="mt-4 grid gap-5 md:grid-cols-2 xl:grid-cols-3">
|
||||||
|
<NCard
|
||||||
|
v-for="m in 3"
|
||||||
|
:key="m"
|
||||||
|
class="oc-panel-card border border-slate-200"
|
||||||
|
:bordered="false"
|
||||||
|
>
|
||||||
|
<NSkeleton class="h-52 w-full" />
|
||||||
|
<NSkeleton class="mt-4 h-5 w-2/3" />
|
||||||
|
<NSkeleton class="mt-3 h-4 w-1/2" />
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else-if="timelineGroups.length" class="space-y-10">
|
||||||
|
<section v-for="group in timelineGroups" :key="group.key">
|
||||||
|
<div class="flex items-center gap-4">
|
||||||
|
<h3 class="text-xl font-bold text-slate-900">{{ group.label }}</h3>
|
||||||
|
<div class="h-px flex-1 bg-slate-200"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-5 grid gap-5 md:grid-cols-2 xl:grid-cols-3">
|
||||||
|
<button
|
||||||
|
v-for="item in group.items"
|
||||||
|
:key="item.id"
|
||||||
|
type="button"
|
||||||
|
class="oc-interactive-card group overflow-hidden border bg-white text-left transition-all hover:-translate-y-1"
|
||||||
|
:class="
|
||||||
|
selectedUploadDate &&
|
||||||
|
toDayKey(item.created_at) === selectedUploadDate
|
||||||
|
? 'oc-interactive-card--selected'
|
||||||
|
: 'border-slate-200'
|
||||||
|
"
|
||||||
|
@click="selectedCloud = item"
|
||||||
|
>
|
||||||
|
<div class="relative">
|
||||||
|
<img
|
||||||
|
:src="item.thumbnail_url || item.image_url"
|
||||||
|
:alt="item.cloudTypeName"
|
||||||
|
class="h-56 w-full object-cover transition duration-500 group-hover:scale-[1.03]"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="absolute inset-x-0 bottom-0 h-28 bg-gradient-to-t from-slate-950/82 via-slate-950/32 to-transparent"
|
||||||
|
></div>
|
||||||
|
<div class="absolute left-4 top-4 flex flex-wrap gap-2">
|
||||||
|
<label
|
||||||
|
v-if="isOwnProfile && selectionMode"
|
||||||
|
class="inline-flex items-center border border-white/60 bg-white/90 px-2 py-1 text-xs font-medium text-slate-700"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
class="mr-2 h-3.5 w-3.5 border-slate-300 text-sky-500 focus:ring-sky-500"
|
||||||
|
:checked="selectedCloudIds.has(item.id)"
|
||||||
|
@change="
|
||||||
|
toggleCloudSelection(
|
||||||
|
item.id,
|
||||||
|
($event.target as HTMLInputElement)
|
||||||
|
.checked,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
选择
|
||||||
|
</label>
|
||||||
|
<span
|
||||||
|
class="inline-flex border px-3 py-1 text-xs font-medium"
|
||||||
|
:class="rarityChip"
|
||||||
|
>
|
||||||
|
稀有度 {{ item.cloudTypeRarity }}
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
v-if="isOwnProfile"
|
||||||
|
class="inline-flex border px-3 py-1 text-xs font-medium"
|
||||||
|
:class="statusMeta[item.status].chip"
|
||||||
|
>
|
||||||
|
{{ statusMeta[item.status].label }}
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
v-if="isOwnProfile"
|
||||||
|
class="inline-flex border px-3 py-1 text-xs font-medium"
|
||||||
|
:class="
|
||||||
|
item.is_hidden
|
||||||
|
? 'border-slate-200 bg-slate-100 text-slate-600'
|
||||||
|
: 'border-emerald-200 bg-emerald-100 text-emerald-700'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ item.is_hidden ? '私密' : '公开' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="absolute bottom-4 left-4 right-4 text-white">
|
||||||
|
<p class="truncate text-lg font-semibold">
|
||||||
|
{{ item.cloudTypeName }}
|
||||||
|
</p>
|
||||||
|
<p class="mt-1 truncate text-xs text-white/80">
|
||||||
|
{{ formatCloudTime(item) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="p-5">
|
||||||
|
<p class="truncate text-sm font-medium text-slate-900">
|
||||||
|
纬度 {{ formatCoordinate(item.latitude) }} / 经度
|
||||||
|
{{ formatCoordinate(item.longitude) }}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
class="mt-3 line-clamp-3 text-sm leading-6 text-slate-500"
|
||||||
|
>
|
||||||
|
{{ item.description || '没有留下额外说明。' }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="oc-empty-card border border-dashed border-slate-300 bg-white p-10"
|
||||||
|
>
|
||||||
|
<NEmpty
|
||||||
|
:description="
|
||||||
|
selectedUploadDate
|
||||||
|
? '这一天没有上传记录'
|
||||||
|
: isOwnProfile
|
||||||
|
? '还没有上传任何云图'
|
||||||
|
: '该用户暂无公开云图'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<template #extra>
|
||||||
|
<RouterLink
|
||||||
|
v-if="isOwnProfile && !selectedUploadDate"
|
||||||
|
to="/upload"
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
>
|
||||||
|
去上传第一张
|
||||||
|
</RouterLink>
|
||||||
|
<NButton
|
||||||
|
v-else-if="selectedUploadDate"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
@click="clearSelectedUploadDate"
|
||||||
|
>返回全部记录</NButton
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</NEmpty>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ImageDetailModal
|
||||||
|
v-if="selectedCloud"
|
||||||
|
:open="!!selectedCloud"
|
||||||
|
:image-url="selectedCloud.image_url"
|
||||||
|
:thumbnail-url="selectedCloud.thumbnail_url"
|
||||||
|
:image-alt="selectedCloud.cloudTypeName"
|
||||||
|
:title="selectedCloud.cloudTypeName"
|
||||||
|
:subtitle="formatCloudTime(selectedCloud)"
|
||||||
|
:badge-label="`稀有度 ${selectedCloud.cloudTypeRarity}`"
|
||||||
|
:badge-class="rarityChip"
|
||||||
|
@close="selectedCloud = null"
|
||||||
|
>
|
||||||
|
<div class="grid gap-4 sm:grid-cols-2">
|
||||||
|
<div class="oc-inset-panel">
|
||||||
|
<p class="oc-section-label">上传时间</p>
|
||||||
|
<p class="mt-2 text-sm font-medium text-slate-900">
|
||||||
|
{{ formatDateTime(selectedCloud.created_at) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="oc-inset-panel">
|
||||||
|
<p class="oc-section-label">拍摄时间</p>
|
||||||
|
<p class="mt-2 text-sm font-medium text-slate-900">
|
||||||
|
{{ formatDateTime(selectedCloud.captured_at) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="oc-inset-panel">
|
||||||
|
<p class="oc-section-label">位置</p>
|
||||||
|
<p class="mt-2 text-sm font-medium text-slate-900">已记录经纬度</p>
|
||||||
|
</div>
|
||||||
|
<div class="oc-inset-panel">
|
||||||
|
<p class="oc-section-label">模糊化经纬度</p>
|
||||||
|
<p class="mt-2 text-sm font-medium text-slate-900">
|
||||||
|
纬度 {{ formatCoordinate(selectedCloud.latitude) }} / 经度
|
||||||
|
{{ formatCoordinate(selectedCloud.longitude) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="oc-inset-panel">
|
||||||
|
<p class="oc-section-label">{{ isOwnProfile ? '审核状态' : '可见性' }}</p>
|
||||||
|
<p class="mt-2 text-sm font-medium text-slate-900">
|
||||||
|
<template v-if="isOwnProfile">
|
||||||
|
{{ statusMeta[selectedCloud.status].label }} /
|
||||||
|
{{ selectedCloud.is_hidden ? '私密' : '公开' }}
|
||||||
|
</template>
|
||||||
|
<template v-else>公开可见</template>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-5 border border-slate-200 bg-white p-5">
|
||||||
|
<p class="oc-section-label">图片说明</p>
|
||||||
|
<p class="mt-3 text-sm leading-7 text-slate-700">
|
||||||
|
{{ selectedCloud.description || '上传者没有留下额外说明。' }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<MiniLocationMap
|
||||||
|
:latitude="selectedCloud.latitude"
|
||||||
|
:longitude="selectedCloud.longitude"
|
||||||
|
/>
|
||||||
|
<CloudLikeButton
|
||||||
|
v-if="selectedCloud.status === 'approved' && !selectedCloud.is_hidden"
|
||||||
|
:cloud-id="selectedCloud.id"
|
||||||
|
:count="selectedCloud.receivedLikeCount"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<template v-if="isOwnProfile" #actions>
|
||||||
|
<div class="flex items-center justify-between gap-3">
|
||||||
|
<NDropdown
|
||||||
|
trigger="click"
|
||||||
|
placement="top-start"
|
||||||
|
:options="cloudActionOptions"
|
||||||
|
@select="handleCloudAction"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-icon-button"
|
||||||
|
title="图片管理"
|
||||||
|
aria-label="图片管理"
|
||||||
|
>
|
||||||
|
<NIcon size="20">
|
||||||
|
<Settings />
|
||||||
|
</NIcon>
|
||||||
|
</button>
|
||||||
|
</NDropdown>
|
||||||
|
<!-- <span class="text-xs text-slate-500">
|
||||||
|
{{ selectedCloud.is_hidden ? '当前为私密图片' : '当前会公开展示' }}
|
||||||
|
</span> -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ImageDetailModal>
|
||||||
|
|
||||||
|
<CloudEditModal
|
||||||
|
:open="editModalOpen && !!selectedCloud"
|
||||||
|
:saving="editSaving"
|
||||||
|
:error="manageError"
|
||||||
|
:cloud-types="cloudsStore.cloudTypes"
|
||||||
|
:initial-value="editInitialValue"
|
||||||
|
@close="closeEditModal"
|
||||||
|
@save="submitEditModal"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.profile-avatar {
|
||||||
|
box-shadow: var(--oc-shadow-sm);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { NButton, NIcon } from 'naive-ui'
|
||||||
|
import { Lock } from '@vicons/tabler'
|
||||||
|
import { RouterLink, useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const redirect = computed(() => {
|
||||||
|
const value = route.query.redirect
|
||||||
|
return typeof value === 'string' && value.startsWith('/') ? value : '/'
|
||||||
|
})
|
||||||
|
|
||||||
|
const title = computed(() => {
|
||||||
|
if (redirect.value === '/upload') {
|
||||||
|
return '上传前先登录'
|
||||||
|
}
|
||||||
|
|
||||||
|
return '需要先登录'
|
||||||
|
})
|
||||||
|
|
||||||
|
const description = computed(() => {
|
||||||
|
if (redirect.value === '/upload') {
|
||||||
|
return '上传云图、使用地图快捷上传都需要先登录账号。登录后再回来,这里的上传入口就会开放。'
|
||||||
|
}
|
||||||
|
|
||||||
|
return '这个页面需要先登录才能继续访问。登录成功后可以返回刚才的目标页面继续操作。'
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="oc-system-page">
|
||||||
|
<div class="oc-system-card">
|
||||||
|
<NIcon size="72" class="text-sky-600"><Lock /></NIcon>
|
||||||
|
<p class="mt-6 text-sm font-medium uppercase tracking-[0.24em] text-sky-600">
|
||||||
|
401 Login Required
|
||||||
|
</p>
|
||||||
|
<h1 class="oc-page-title">{{ title }}</h1>
|
||||||
|
<p class="oc-page-description mx-auto max-w-xl">
|
||||||
|
{{ description }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="mt-8 flex flex-wrap items-center justify-center gap-3">
|
||||||
|
<RouterLink
|
||||||
|
:to="{ path: '/login', query: redirect !== '/' ? { redirect } : undefined }"
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
>前往登录</NButton
|
||||||
|
>
|
||||||
|
</RouterLink>
|
||||||
|
<RouterLink to="/">
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
>返回地图</NButton
|
||||||
|
>
|
||||||
|
</RouterLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { NButton, NIcon } from 'naive-ui'
|
||||||
|
import { HandStop } from '@vicons/tabler'
|
||||||
|
import { RouterLink } from 'vue-router'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="oc-system-page">
|
||||||
|
<div class="oc-system-card">
|
||||||
|
<NIcon size="72" class="text-rose-600"><HandStop /></NIcon>
|
||||||
|
<p class="mt-6 text-sm font-medium uppercase tracking-[0.24em] text-rose-600">
|
||||||
|
403 Forbidden
|
||||||
|
</p>
|
||||||
|
<h1 class="oc-page-title">这里不让进</h1>
|
||||||
|
<p class="oc-page-description mx-auto max-w-xl">
|
||||||
|
你当前没有访问这个页面的权限。通常是因为这个区域只对管理员开放。
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="mt-8 flex flex-wrap items-center justify-center gap-3">
|
||||||
|
<RouterLink to="/">
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
>返回地图</NButton
|
||||||
|
>
|
||||||
|
</RouterLink>
|
||||||
|
<RouterLink to="/profile">
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
>前往个人主页</NButton
|
||||||
|
>
|
||||||
|
</RouterLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { NButton, NIcon } from 'naive-ui'
|
||||||
|
import { Help } from '@vicons/tabler'
|
||||||
|
import { RouterLink } from 'vue-router'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="oc-system-page">
|
||||||
|
<div class="oc-system-card">
|
||||||
|
<NIcon size="72" class="text-amber-600"><Help /></NIcon>
|
||||||
|
<p class="mt-6 text-sm font-medium uppercase tracking-[0.24em] text-amber-600">
|
||||||
|
404 Not Found
|
||||||
|
</p>
|
||||||
|
<h1 class="oc-page-title">我也没想明白</h1>
|
||||||
|
<p class="oc-page-description mx-auto max-w-xl">
|
||||||
|
这个页面不存在,或者它已经被移动到了别的地方。换个入口再试一次。
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="mt-8 flex flex-wrap items-center justify-center gap-3">
|
||||||
|
<RouterLink to="/">
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
>返回地图</NButton
|
||||||
|
>
|
||||||
|
</RouterLink>
|
||||||
|
<RouterLink to="/gallery">
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
>去画廊看看</NButton
|
||||||
|
>
|
||||||
|
</RouterLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,495 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
||||||
|
import { NAlert, NButton, NIcon, NProgress } from 'naive-ui'
|
||||||
|
import { CloudUpload, Map as MapIcon, X } from '@vicons/tabler'
|
||||||
|
import MapPickerModal from '@/shared/map/components/MapPickerModal.vue'
|
||||||
|
import { useCloudsStore } from '@/features/clouds/stores/clouds'
|
||||||
|
import { useUpload } from '@/features/upload/composables/useUpload'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
open: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
close: []
|
||||||
|
uploaded: []
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const cloudsStore = useCloudsStore()
|
||||||
|
const {
|
||||||
|
items,
|
||||||
|
uploading,
|
||||||
|
overallProgress,
|
||||||
|
currentItemIndex,
|
||||||
|
totalItems,
|
||||||
|
addFiles,
|
||||||
|
removeItem,
|
||||||
|
clearAll,
|
||||||
|
validateAll,
|
||||||
|
uploadAll,
|
||||||
|
} = useUpload()
|
||||||
|
|
||||||
|
const fileInput = ref<HTMLInputElement | null>(null)
|
||||||
|
const activeId = ref<string | null>(null)
|
||||||
|
const dragOver = ref(false)
|
||||||
|
const errorMsg = ref('')
|
||||||
|
const successMsg = ref(false)
|
||||||
|
const mapPickerOpen = ref(false)
|
||||||
|
|
||||||
|
const activeItem = computed(() => {
|
||||||
|
if (!activeId.value) return null
|
||||||
|
return items.value.find(item => item.id === activeId.value) ?? null
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.open,
|
||||||
|
open => {
|
||||||
|
if (open) {
|
||||||
|
cloudsStore.fetchCloudTypes()
|
||||||
|
errorMsg.value = ''
|
||||||
|
successMsg.value = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => items.value.length,
|
||||||
|
() => {
|
||||||
|
if (items.value.length > 0 && !activeId.value) {
|
||||||
|
activeId.value = items.value[0].id
|
||||||
|
}
|
||||||
|
if (items.value.length === 0) {
|
||||||
|
activeId.value = null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
async function addSelectedFiles(files: File[]) {
|
||||||
|
const previousLength = items.value.length
|
||||||
|
await addFiles(files)
|
||||||
|
if (items.value.length > previousLength) {
|
||||||
|
activeId.value = items.value[previousLength].id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDrop(event: DragEvent) {
|
||||||
|
dragOver.value = false
|
||||||
|
if (event.dataTransfer?.files) {
|
||||||
|
addSelectedFiles(Array.from(event.dataTransfer.files))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFileSelect(event: Event) {
|
||||||
|
const target = event.target as HTMLInputElement
|
||||||
|
if (target.files?.length) {
|
||||||
|
addSelectedFiles(Array.from(target.files))
|
||||||
|
}
|
||||||
|
target.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRemove(id: string) {
|
||||||
|
removeItem(id)
|
||||||
|
if (activeId.value === id) {
|
||||||
|
activeId.value = items.value[0]?.id ?? null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCategoryChange(event: Event) {
|
||||||
|
if (!activeItem.value) return
|
||||||
|
const value = (event.target as HTMLSelectElement).value
|
||||||
|
if (value === '') {
|
||||||
|
activeItem.value.cloudCategoryId = null
|
||||||
|
} else {
|
||||||
|
activeItem.value.cloudCategoryId = Number(value)
|
||||||
|
}
|
||||||
|
activeItem.value.errors = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDatetimeLocal(iso: string): string {
|
||||||
|
if (!iso) return ''
|
||||||
|
const date = new Date(iso)
|
||||||
|
const pad = (value: number) => String(value).padStart(2, '0')
|
||||||
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCapturedAtChange(event: Event) {
|
||||||
|
if (!activeItem.value) return
|
||||||
|
const value = (event.target as HTMLInputElement).value
|
||||||
|
activeItem.value.capturedAt = value ? new Date(value).toISOString() : ''
|
||||||
|
delete activeItem.value.errors.capturedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
function onLatInput(event: Event) {
|
||||||
|
if (!activeItem.value) return
|
||||||
|
const value = Number.parseFloat((event.target as HTMLInputElement).value)
|
||||||
|
activeItem.value.latitude = Number.isNaN(value) ? null : value
|
||||||
|
delete activeItem.value.errors.latitude
|
||||||
|
delete activeItem.value.errors.longitude
|
||||||
|
}
|
||||||
|
|
||||||
|
function onLngInput(event: Event) {
|
||||||
|
if (!activeItem.value) return
|
||||||
|
const value = Number.parseFloat((event.target as HTMLInputElement).value)
|
||||||
|
activeItem.value.longitude = Number.isNaN(value) ? null : value
|
||||||
|
delete activeItem.value.errors.latitude
|
||||||
|
delete activeItem.value.errors.longitude
|
||||||
|
}
|
||||||
|
|
||||||
|
function updatePublicState(isPublic: boolean) {
|
||||||
|
if (!activeItem.value) return
|
||||||
|
activeItem.value.isHidden = !isPublic
|
||||||
|
}
|
||||||
|
|
||||||
|
function openMapPicker() {
|
||||||
|
if (!activeItem.value) return
|
||||||
|
mapPickerOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeMapPicker() {
|
||||||
|
mapPickerOpen.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmMapPicker(payload: { latitude: number; longitude: number }) {
|
||||||
|
if (!activeItem.value) return
|
||||||
|
activeItem.value.latitude = payload.latitude
|
||||||
|
activeItem.value.longitude = payload.longitude
|
||||||
|
delete activeItem.value.errors.latitude
|
||||||
|
delete activeItem.value.errors.longitude
|
||||||
|
closeMapPicker()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
errorMsg.value = ''
|
||||||
|
successMsg.value = false
|
||||||
|
|
||||||
|
if (!validateAll()) {
|
||||||
|
const firstInvalid = items.value.find(item => Object.keys(item.errors).length > 0)
|
||||||
|
if (firstInvalid) {
|
||||||
|
activeId.value = firstInvalid.id
|
||||||
|
await nextTick()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await uploadAll()
|
||||||
|
if (!result.ok) {
|
||||||
|
errorMsg.value = result.errorMessage || '上传失败,请稍后重试'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
successMsg.value = true
|
||||||
|
emit('uploaded')
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
if (uploading.value) return
|
||||||
|
clearAll()
|
||||||
|
errorMsg.value = ''
|
||||||
|
successMsg.value = false
|
||||||
|
mapPickerOpen.value = false
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
clearAll()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Teleport to="body">
|
||||||
|
<div
|
||||||
|
v-if="open"
|
||||||
|
class="fixed inset-0 z-[130] flex items-center justify-center bg-slate-950/55 px-4 py-6 backdrop-blur-sm"
|
||||||
|
@click="close"
|
||||||
|
>
|
||||||
|
<div class="oc-modal-shell w-full max-w-3xl overflow-hidden" @click.stop>
|
||||||
|
<div class="flex items-start justify-between border-b border-slate-200 px-5 py-4">
|
||||||
|
<div>
|
||||||
|
<p class="text-xs font-semibold uppercase tracking-[0.22em] text-sky-700">
|
||||||
|
Quick Upload
|
||||||
|
</p>
|
||||||
|
<h2 class="mt-2 text-xl font-bold text-slate-950">快速上传云图</h2>
|
||||||
|
<p class="oc-field-help">从地图当前位置带入经纬度,提交后进入审核队列。</p>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-icon-button"
|
||||||
|
aria-label="关闭快捷上传"
|
||||||
|
title="关闭快捷上传"
|
||||||
|
@click="close"
|
||||||
|
>
|
||||||
|
<NIcon size="20"><X /></NIcon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="max-h-[72vh] overflow-y-auto px-5 py-5">
|
||||||
|
<input
|
||||||
|
ref="fileInput"
|
||||||
|
type="file"
|
||||||
|
accept="image/jpeg,image/png,image/webp"
|
||||||
|
class="hidden"
|
||||||
|
@change="handleFileSelect"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<NAlert
|
||||||
|
v-if="successMsg"
|
||||||
|
type="success"
|
||||||
|
:bordered="false"
|
||||||
|
title="已提交审核"
|
||||||
|
class="mb-4"
|
||||||
|
>
|
||||||
|
图片审核通过后会出现在画廊和地图中。
|
||||||
|
</NAlert>
|
||||||
|
|
||||||
|
<div v-if="uploading" class="mb-4 border border-sky-100 bg-sky-50 p-4">
|
||||||
|
<div class="mb-2 flex items-center justify-between text-sm">
|
||||||
|
<span class="font-medium text-slate-700"
|
||||||
|
>正在上传 {{ currentItemIndex }} / {{ totalItems }}</span
|
||||||
|
>
|
||||||
|
<span class="font-medium text-sky-700">{{ overallProgress }}%</span>
|
||||||
|
</div>
|
||||||
|
<NProgress
|
||||||
|
type="line"
|
||||||
|
:percentage="overallProgress"
|
||||||
|
:show-indicator="false"
|
||||||
|
color="var(--oc-color-info)"
|
||||||
|
rail-color="var(--oc-color-border)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="items.length === 0"
|
||||||
|
class="flex cursor-pointer flex-col items-center justify-center border-2 border-dashed px-6 py-12 text-center transition-colors"
|
||||||
|
:class="
|
||||||
|
dragOver
|
||||||
|
? 'border-sky-400 bg-sky-50'
|
||||||
|
: 'border-slate-300 bg-slate-50 hover:border-sky-300 hover:bg-sky-50'
|
||||||
|
"
|
||||||
|
@click="fileInput?.click()"
|
||||||
|
@dragover.prevent="dragOver = true"
|
||||||
|
@dragleave.prevent="dragOver = false"
|
||||||
|
@drop.prevent="handleDrop"
|
||||||
|
>
|
||||||
|
<NIcon size="42" class="text-sky-600"><CloudUpload /></NIcon>
|
||||||
|
<p class="mt-3 text-base font-semibold text-slate-800">选择一张云图</p>
|
||||||
|
<p class="oc-field-help">支持 JPEG、PNG、WebP,图片不超过 20MB。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-else-if="activeItem">
|
||||||
|
<div class="grid gap-5 md:grid-cols-[220px_minmax(0,1fr)]">
|
||||||
|
<div>
|
||||||
|
<div class="overflow-hidden border border-slate-900 bg-slate-950">
|
||||||
|
<img
|
||||||
|
:src="activeItem.preview"
|
||||||
|
alt="图片预览"
|
||||||
|
class="h-56 w-full object-contain"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 flex items-center gap-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral flex-1"
|
||||||
|
@click="fileInput?.click()"
|
||||||
|
>
|
||||||
|
重新选择
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-panel-button oc-panel-button--danger flex-1"
|
||||||
|
@click="handleRemove(activeItem.id)"
|
||||||
|
>
|
||||||
|
移除
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div>
|
||||||
|
<label class="oc-field-label"
|
||||||
|
>类别 <span class="oc-field-required">*</span></label
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
:value="activeItem.cloudCategoryId ?? ''"
|
||||||
|
class="oc-field-control"
|
||||||
|
@change="onCategoryChange"
|
||||||
|
>
|
||||||
|
<option value="" disabled>请选择</option>
|
||||||
|
<option
|
||||||
|
v-for="cloudType in cloudsStore.cloudTypes"
|
||||||
|
:key="cloudType.id"
|
||||||
|
:value="cloudType.id"
|
||||||
|
>
|
||||||
|
{{ cloudType.name
|
||||||
|
}}{{
|
||||||
|
cloudType.genus ? '(' + cloudType.genus + ')' : ''
|
||||||
|
}}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<p
|
||||||
|
v-if="activeItem.errors.cloudCategory"
|
||||||
|
class="oc-field-error"
|
||||||
|
>
|
||||||
|
{{ activeItem.errors.cloudCategory }}
|
||||||
|
</p>
|
||||||
|
<p v-if="activeItem.errors.file" class="oc-field-error">
|
||||||
|
{{ activeItem.errors.file }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="oc-field-label">拍摄时间</label>
|
||||||
|
<input
|
||||||
|
type="datetime-local"
|
||||||
|
:value="formatDatetimeLocal(activeItem.capturedAt)"
|
||||||
|
class="oc-field-control"
|
||||||
|
@change="onCapturedAtChange"
|
||||||
|
/>
|
||||||
|
<p v-if="activeItem.errors.capturedAt" class="oc-field-error">
|
||||||
|
{{ activeItem.errors.capturedAt }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="oc-field-label"
|
||||||
|
>经纬度 <span class="oc-field-required">*</span></label
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_40px] gap-2"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<input
|
||||||
|
:value="activeItem.latitude ?? ''"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
placeholder="纬度"
|
||||||
|
class="oc-field-control"
|
||||||
|
@input="onLatInput"
|
||||||
|
/>
|
||||||
|
<p
|
||||||
|
v-if="activeItem.errors.latitude"
|
||||||
|
class="oc-field-error"
|
||||||
|
>
|
||||||
|
{{ activeItem.errors.latitude }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input
|
||||||
|
:value="activeItem.longitude ?? ''"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
placeholder="经度"
|
||||||
|
class="oc-field-control"
|
||||||
|
@input="onLngInput"
|
||||||
|
/>
|
||||||
|
<p
|
||||||
|
v-if="activeItem.errors.longitude"
|
||||||
|
class="oc-field-error"
|
||||||
|
>
|
||||||
|
{{ activeItem.errors.longitude }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-icon-button oc-icon-button--sky"
|
||||||
|
title="地图选点"
|
||||||
|
aria-label="地图选点"
|
||||||
|
@click="openMapPicker"
|
||||||
|
>
|
||||||
|
<NIcon size="20">
|
||||||
|
<MapIcon />
|
||||||
|
</NIcon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p class="mt-1 text-xs text-slate-400">
|
||||||
|
必填,可手动输入,也可以点击右侧地图按钮选点。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="oc-field-label">图片说明</label>
|
||||||
|
<textarea
|
||||||
|
v-model="activeItem.description"
|
||||||
|
rows="3"
|
||||||
|
maxlength="128"
|
||||||
|
placeholder="描述一下这张图片..."
|
||||||
|
class="oc-field-control resize-none"
|
||||||
|
></textarea>
|
||||||
|
<p v-if="activeItem.errors.description" class="oc-field-error">
|
||||||
|
{{ activeItem.errors.description }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label
|
||||||
|
class="flex items-center justify-between gap-4 border border-slate-200 bg-slate-50 px-4 py-3"
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
<span class="block text-sm font-medium text-slate-800"
|
||||||
|
>公开展示</span
|
||||||
|
>
|
||||||
|
<span class="mt-1 block text-xs text-slate-500"
|
||||||
|
>关闭后不会出现在公开地图和画廊中。</span
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
:checked="!activeItem.isHidden"
|
||||||
|
type="checkbox"
|
||||||
|
class="h-5 w-5 border-slate-300 text-sky-600 focus:ring-sky-500"
|
||||||
|
@change="
|
||||||
|
updatePublicState(
|
||||||
|
($event.target as HTMLInputElement).checked,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<NAlert
|
||||||
|
v-if="errorMsg"
|
||||||
|
class="mt-4"
|
||||||
|
type="error"
|
||||||
|
:show-icon="false"
|
||||||
|
title="上传失败"
|
||||||
|
>
|
||||||
|
{{ errorMsg }}
|
||||||
|
</NAlert>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="flex items-center justify-end gap-3 border-t border-slate-200 bg-slate-50 px-5 py-4"
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
:disabled="uploading"
|
||||||
|
@click="close"
|
||||||
|
>关闭</NButton
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
:disabled="uploading || items.length === 0"
|
||||||
|
@click="handleSubmit"
|
||||||
|
>
|
||||||
|
{{ uploading ? '上传中...' : '提交审核' }}
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<MapPickerModal
|
||||||
|
:open="mapPickerOpen"
|
||||||
|
:latitude="activeItem?.latitude ?? null"
|
||||||
|
:longitude="activeItem?.longitude ?? null"
|
||||||
|
description="点击地图即可回填当前图片的经纬度,也可以继续手动修改。"
|
||||||
|
footer-text="建议点选大致拍摄位置,上传时会继续做模糊化处理。"
|
||||||
|
@close="closeMapPicker"
|
||||||
|
@confirm="confirmMapPicker"
|
||||||
|
/>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { uploadCloud } from '@/features/clouds/api'
|
||||||
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
import { useProfileStore } from '@/features/profile/stores/profile'
|
||||||
|
|
||||||
|
export interface UploadItem {
|
||||||
|
id: string
|
||||||
|
file: File
|
||||||
|
preview: string
|
||||||
|
cloudCategoryId: number | null
|
||||||
|
description: string
|
||||||
|
isHidden: boolean
|
||||||
|
latitude: number | null
|
||||||
|
longitude: number | null
|
||||||
|
capturedAt: string
|
||||||
|
errors: Record<string, string>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UploadResult {
|
||||||
|
ok: boolean
|
||||||
|
errorMessage?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
let nextId = 0
|
||||||
|
|
||||||
|
function readFileAsArrayBuffer(file: File): Promise<ArrayBuffer> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader()
|
||||||
|
reader.onload = () => resolve(reader.result as ArrayBuffer)
|
||||||
|
reader.onerror = reject
|
||||||
|
reader.readAsArrayBuffer(file)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractExifDate(buffer: ArrayBuffer): string | null {
|
||||||
|
const view = new DataView(buffer)
|
||||||
|
if (view.byteLength < 4 || view.getUint16(0, false) !== 0xffd8) return null
|
||||||
|
|
||||||
|
let offset = 2
|
||||||
|
while (offset < view.byteLength - 2) {
|
||||||
|
const marker = view.getUint16(offset, false)
|
||||||
|
offset += 2
|
||||||
|
if ((marker & 0xff00) !== 0xff00) break
|
||||||
|
const length = view.getUint16(offset, false)
|
||||||
|
offset += 2
|
||||||
|
|
||||||
|
if (marker === 0xffe1) {
|
||||||
|
const exifStart = offset
|
||||||
|
const header = String.fromCharCode(
|
||||||
|
view.getUint8(exifStart),
|
||||||
|
view.getUint8(exifStart + 1),
|
||||||
|
view.getUint8(exifStart + 2),
|
||||||
|
view.getUint8(exifStart + 3),
|
||||||
|
)
|
||||||
|
if (header !== 'Exif') break
|
||||||
|
|
||||||
|
const tiffStart = exifStart + 6
|
||||||
|
const isLE = view.getUint16(tiffStart, false) === 0x4949
|
||||||
|
const ifdStart = tiffStart + view.getUint32(tiffStart + 4, isLE)
|
||||||
|
const numEntries = view.getUint16(ifdStart, isLE)
|
||||||
|
|
||||||
|
for (let i = 0; i < numEntries; i++) {
|
||||||
|
const entryStart = ifdStart + 2 + i * 12
|
||||||
|
if (entryStart + 12 > buffer.byteLength) break
|
||||||
|
if (view.getUint16(entryStart, isLE) !== 0x9003) continue
|
||||||
|
|
||||||
|
const dataOffset = view.getUint32(entryStart + 8, isLE)
|
||||||
|
const dateStr = Array.from({ length: 20 }, (_, j) =>
|
||||||
|
String.fromCharCode(view.getUint8(tiffStart + dataOffset + j)),
|
||||||
|
).join('')
|
||||||
|
const date = new Date(dateStr.replace(/^(\d{4}):(\d{2}):(\d{2})/, '$1-$2-$3'))
|
||||||
|
if (!isNaN(date.getTime())) return date.toISOString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
offset += length - 2
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUpload() {
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
const items = ref<UploadItem[]>([])
|
||||||
|
const uploading = ref(false)
|
||||||
|
const overallProgress = ref(0)
|
||||||
|
const currentItemIndex = ref(0)
|
||||||
|
const totalItems = ref(0)
|
||||||
|
|
||||||
|
async function addFiles(files: File[]) {
|
||||||
|
const imageFiles = files.filter(file =>
|
||||||
|
['image/jpeg', 'image/png', 'image/webp'].includes(file.type),
|
||||||
|
)
|
||||||
|
for (const file of imageFiles) {
|
||||||
|
let capturedAt: string
|
||||||
|
try {
|
||||||
|
capturedAt = extractExifDate(await readFileAsArrayBuffer(file)) || ''
|
||||||
|
} catch {
|
||||||
|
capturedAt = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
items.value.push({
|
||||||
|
id: String(++nextId),
|
||||||
|
file,
|
||||||
|
preview: URL.createObjectURL(file),
|
||||||
|
cloudCategoryId: null,
|
||||||
|
description: '',
|
||||||
|
isHidden: false,
|
||||||
|
latitude: null,
|
||||||
|
longitude: null,
|
||||||
|
capturedAt,
|
||||||
|
errors: {},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeItem(id: string) {
|
||||||
|
const index = items.value.findIndex(item => item.id === id)
|
||||||
|
if (index === -1) return
|
||||||
|
URL.revokeObjectURL(items.value[index].preview)
|
||||||
|
items.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearAll() {
|
||||||
|
items.value.forEach(item => URL.revokeObjectURL(item.preview))
|
||||||
|
items.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateItem(item: UploadItem) {
|
||||||
|
const errors: Record<string, string> = {}
|
||||||
|
if (!item.cloudCategoryId) errors.cloudCategory = '请选择类别'
|
||||||
|
if (item.file.size === 0) errors.file = '图片文件为空'
|
||||||
|
if (item.file.size > 20 * 1024 * 1024) errors.file = '图片不能超过 20MB'
|
||||||
|
if (!['image/jpeg', 'image/png', 'image/webp'].includes(item.file.type)) {
|
||||||
|
errors.file = '仅支持 JPEG、PNG、WebP 格式'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.latitude === null || Number.isNaN(item.latitude)) {
|
||||||
|
errors.latitude = '请填写纬度'
|
||||||
|
} else if (item.latitude < -90 || item.latitude > 90) {
|
||||||
|
errors.latitude = '纬度范围为 -90 到 90'
|
||||||
|
}
|
||||||
|
if (item.longitude === null || Number.isNaN(item.longitude)) {
|
||||||
|
errors.longitude = '请填写经度'
|
||||||
|
} else if (item.longitude < -180 || item.longitude > 180) {
|
||||||
|
errors.longitude = '经度范围为 -180 到 180'
|
||||||
|
}
|
||||||
|
if (item.description.trim().length > 128) errors.description = '图片描述不能超过 128 个字符'
|
||||||
|
|
||||||
|
item.errors = errors
|
||||||
|
return Object.keys(errors).length === 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateAll() {
|
||||||
|
return items.value.map(validateItem).every(Boolean)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uploadAll(): Promise<UploadResult> {
|
||||||
|
if (!validateAll() || !authStore.user) return { ok: false }
|
||||||
|
|
||||||
|
uploading.value = true
|
||||||
|
totalItems.value = items.value.length
|
||||||
|
currentItemIndex.value = 0
|
||||||
|
overallProgress.value = 0
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (let index = 0; index < items.value.length; index++) {
|
||||||
|
const item = items.value[index]
|
||||||
|
currentItemIndex.value = index + 1
|
||||||
|
overallProgress.value = Math.round((index / items.value.length) * 100)
|
||||||
|
|
||||||
|
await uploadCloud({
|
||||||
|
image: item.file,
|
||||||
|
cloud_type_id: item.cloudCategoryId!,
|
||||||
|
latitude: item.latitude!,
|
||||||
|
longitude: item.longitude!,
|
||||||
|
description: item.description.trim() || undefined,
|
||||||
|
captured_at: item.capturedAt.trim() || undefined,
|
||||||
|
is_hidden: item.isHidden,
|
||||||
|
})
|
||||||
|
overallProgress.value = Math.round(((index + 1) / items.value.length) * 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
clearAll()
|
||||||
|
profileStore.invalidateUser(authStore.user.id)
|
||||||
|
return { ok: true }
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
ok: false,
|
||||||
|
errorMessage: error instanceof Error ? error.message : '上传失败,请稍后重试',
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
uploading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
items,
|
||||||
|
uploading,
|
||||||
|
overallProgress,
|
||||||
|
currentItemIndex,
|
||||||
|
totalItems,
|
||||||
|
addFiles,
|
||||||
|
removeItem,
|
||||||
|
clearAll,
|
||||||
|
validateItem,
|
||||||
|
validateAll,
|
||||||
|
uploadAll,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,560 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, computed, onMounted, onUnmounted, nextTick, watch } from 'vue'
|
||||||
|
import { NAlert, NButton, NCard, NIcon, NProgress, NResult } from 'naive-ui'
|
||||||
|
import { CloudUpload, Map as MapIcon, X } from '@vicons/tabler'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import { useCloudsStore } from '@/features/clouds/stores/clouds'
|
||||||
|
import { useUpload } from '@/features/upload/composables/useUpload'
|
||||||
|
import MapPickerModal from '@/shared/map/components/MapPickerModal.vue'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const cloudsStore = useCloudsStore()
|
||||||
|
const {
|
||||||
|
items,
|
||||||
|
uploading,
|
||||||
|
overallProgress,
|
||||||
|
currentItemIndex,
|
||||||
|
totalItems,
|
||||||
|
addFiles,
|
||||||
|
removeItem,
|
||||||
|
clearAll,
|
||||||
|
validateAll,
|
||||||
|
uploadAll,
|
||||||
|
} = useUpload()
|
||||||
|
|
||||||
|
const activeId = ref<string | null>(null)
|
||||||
|
const dragOver = ref(false)
|
||||||
|
const successMsg = ref(false)
|
||||||
|
const errorMsg = ref('')
|
||||||
|
const fileInput = ref<HTMLInputElement | null>(null)
|
||||||
|
const mapPickerOpen = ref(false)
|
||||||
|
|
||||||
|
const activeItem = computed(() => {
|
||||||
|
if (!activeId.value) return null
|
||||||
|
return items.value.find(i => i.id === activeId.value) ?? null
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => items.value.length,
|
||||||
|
() => {
|
||||||
|
if (items.value.length > 0 && !activeId.value) {
|
||||||
|
activeId.value = items.value[0].id
|
||||||
|
}
|
||||||
|
if (items.value.length === 0) {
|
||||||
|
activeId.value = null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
function selectItem(id: string) {
|
||||||
|
activeId.value = id
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDrop(e: DragEvent) {
|
||||||
|
dragOver.value = false
|
||||||
|
if (e.dataTransfer?.files) {
|
||||||
|
addFiles(Array.from(e.dataTransfer.files))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFileSelect(e: Event) {
|
||||||
|
const target = e.target as HTMLInputElement
|
||||||
|
if (target.files && target.files.length > 0) {
|
||||||
|
addFiles(Array.from(target.files))
|
||||||
|
}
|
||||||
|
target.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRemove(id: string) {
|
||||||
|
removeItem(id)
|
||||||
|
if (activeId.value === id) {
|
||||||
|
activeId.value = items.value[0]?.id ?? null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateActiveCoordinates(latitude: number | null, longitude: number | null) {
|
||||||
|
if (!activeItem.value) return
|
||||||
|
|
||||||
|
activeItem.value.latitude = latitude
|
||||||
|
activeItem.value.longitude = longitude
|
||||||
|
|
||||||
|
if (activeItem.value.errors.latitude) delete activeItem.value.errors.latitude
|
||||||
|
if (activeItem.value.errors.longitude) delete activeItem.value.errors.longitude
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openMapPicker() {
|
||||||
|
if (!activeItem.value) return
|
||||||
|
|
||||||
|
mapPickerOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeMapPicker() {
|
||||||
|
mapPickerOpen.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmMapPicker(payload: { latitude: number; longitude: number }) {
|
||||||
|
updateActiveCoordinates(payload.latitude, payload.longitude)
|
||||||
|
closeMapPicker()
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateActivePublicState(isPublic: boolean) {
|
||||||
|
if (!activeItem.value) return
|
||||||
|
activeItem.value.isHidden = !isPublic
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
errorMsg.value = ''
|
||||||
|
const allValid = validateAll()
|
||||||
|
if (!allValid) {
|
||||||
|
const firstInvalid = items.value.find(i => Object.keys(i.errors).length > 0)
|
||||||
|
if (firstInvalid) {
|
||||||
|
activeId.value = firstInvalid.id
|
||||||
|
await nextTick()
|
||||||
|
const el = document.getElementById(`field-${firstInvalid.id}-cloudCategory`)
|
||||||
|
el?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await uploadAll()
|
||||||
|
if (result.ok) {
|
||||||
|
successMsg.value = true
|
||||||
|
} else {
|
||||||
|
errorMsg.value = result.errorMessage || '上传失败,请稍后重试'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetAfterSuccess() {
|
||||||
|
successMsg.value = false
|
||||||
|
errorMsg.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function onLatInput(e: Event) {
|
||||||
|
const val = parseFloat((e.target as HTMLInputElement).value)
|
||||||
|
if (activeItem.value) {
|
||||||
|
activeItem.value.latitude = isNaN(val) ? null : val
|
||||||
|
if (activeItem.value.errors.latitude) delete activeItem.value.errors.latitude
|
||||||
|
if (activeItem.value.errors.longitude) delete activeItem.value.errors.longitude
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onLngInput(e: Event) {
|
||||||
|
const val = parseFloat((e.target as HTMLInputElement).value)
|
||||||
|
if (activeItem.value) {
|
||||||
|
activeItem.value.longitude = isNaN(val) ? null : val
|
||||||
|
if (activeItem.value.errors.latitude) delete activeItem.value.errors.latitude
|
||||||
|
if (activeItem.value.errors.longitude) delete activeItem.value.errors.longitude
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDatetimeLocal(iso: string): string {
|
||||||
|
if (!iso) return ''
|
||||||
|
const d = new Date(iso)
|
||||||
|
const pad = (n: number) => String(n).padStart(2, '0')
|
||||||
|
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCapturedAtChange(e: Event) {
|
||||||
|
const val = (e.target as HTMLInputElement).value
|
||||||
|
if (activeItem.value) {
|
||||||
|
activeItem.value.capturedAt = val ? new Date(val).toISOString() : ''
|
||||||
|
if (activeItem.value.errors.capturedAt) {
|
||||||
|
delete activeItem.value.errors.capturedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCategoryChange(e: Event) {
|
||||||
|
const val = (e.target as HTMLSelectElement).value
|
||||||
|
if (!activeItem.value) return
|
||||||
|
if (val === '') {
|
||||||
|
activeItem.value.cloudCategoryId = null
|
||||||
|
} else {
|
||||||
|
activeItem.value.cloudCategoryId = Number(val)
|
||||||
|
}
|
||||||
|
activeItem.value.errors = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
cloudsStore.fetchCloudTypes()
|
||||||
|
})
|
||||||
|
onUnmounted(() => {
|
||||||
|
for (const item of items.value) URL.revokeObjectURL(item.preview)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<section class="oc-page-hero">
|
||||||
|
<div class="oc-container oc-container--content oc-page-hero__inner">
|
||||||
|
<p class="oc-page-eyebrow">Cloud Upload</p>
|
||||||
|
<h1 class="oc-page-title">上传云图</h1>
|
||||||
|
<p class="oc-page-description">
|
||||||
|
批量整理你的云图记录。类别和经纬度必填;拍摄时间可留空,也可以从图片 EXIF
|
||||||
|
自动读取。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="oc-container oc-container--content oc-page-content">
|
||||||
|
<input
|
||||||
|
ref="fileInput"
|
||||||
|
type="file"
|
||||||
|
accept="image/jpeg,image/png,image/webp"
|
||||||
|
multiple
|
||||||
|
class="hidden"
|
||||||
|
@change="handleFileSelect"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div v-if="successMsg" class="flex items-center justify-center min-h-[60vh]">
|
||||||
|
<div class="w-full max-w-5xl">
|
||||||
|
<NResult status="success" title="已提交审核" />
|
||||||
|
|
||||||
|
<div class="mt-8 flex flex-wrap items-center justify-center gap-3">
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
@click="resetAfterSuccess"
|
||||||
|
>继续上传</NButton
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
@click="router.push('/encyclopedia')"
|
||||||
|
>前往百科</NButton
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
@click="router.push('/profile')"
|
||||||
|
>返回个人主页</NButton
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<div
|
||||||
|
v-if="uploading"
|
||||||
|
class="oc-panel-card mb-6 border border-slate-200 bg-white p-5"
|
||||||
|
>
|
||||||
|
<div class="flex items-center justify-between mb-2">
|
||||||
|
<span class="text-sm font-medium text-slate-700"
|
||||||
|
>正在上传 {{ currentItemIndex }} / {{ totalItems }}...</span
|
||||||
|
>
|
||||||
|
<span class="text-sm font-medium text-sky-600">{{ overallProgress }}%</span>
|
||||||
|
</div>
|
||||||
|
<NProgress
|
||||||
|
type="line"
|
||||||
|
:show-indicator="false"
|
||||||
|
:percentage="overallProgress"
|
||||||
|
color="var(--oc-color-info)"
|
||||||
|
rail-color="var(--oc-color-border)"
|
||||||
|
:height="10"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="items.length === 0"
|
||||||
|
class="oc-panel-card flex cursor-pointer flex-col items-center justify-center border-2 border-dashed bg-white py-20 transition-colors"
|
||||||
|
:class="
|
||||||
|
dragOver
|
||||||
|
? 'border-sky-400 bg-sky-50'
|
||||||
|
: 'border-slate-300 hover:border-sky-400 hover:bg-slate-50'
|
||||||
|
"
|
||||||
|
@dragover.prevent="dragOver = true"
|
||||||
|
@dragleave.prevent="dragOver = false"
|
||||||
|
@drop.prevent="handleDrop"
|
||||||
|
@click="fileInput?.click()"
|
||||||
|
>
|
||||||
|
<NIcon size="48" class="mb-4 text-sky-600"><CloudUpload /></NIcon>
|
||||||
|
<p class="mb-1 text-lg font-medium text-slate-700">点击或拖拽图片到此处</p>
|
||||||
|
<p class="text-sm text-slate-400">
|
||||||
|
支持 JPEG、PNG、WebP,单张不超过 20MB,可一次选择多张
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<div class="flex min-w-0 flex-col gap-6 lg:flex-row">
|
||||||
|
<div class="w-full min-w-0 lg:w-[480px] lg:flex-shrink-0">
|
||||||
|
<div
|
||||||
|
v-if="activeItem"
|
||||||
|
class="mb-3 overflow-hidden border border-slate-900 bg-slate-900"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
:src="activeItem.preview"
|
||||||
|
alt="预览"
|
||||||
|
class="h-64 w-full object-contain sm:h-[360px]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-2 overflow-x-auto pb-2">
|
||||||
|
<div
|
||||||
|
v-for="item in items"
|
||||||
|
:key="item.id"
|
||||||
|
class="relative flex-shrink-0 w-16 h-16 overflow-hidden cursor-pointer border-2 transition-colors bg-white"
|
||||||
|
:class="
|
||||||
|
activeId === item.id
|
||||||
|
? 'border-sky-500'
|
||||||
|
: 'border-transparent hover:border-slate-300'
|
||||||
|
"
|
||||||
|
@click="selectItem(item.id)"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
:src="item.preview"
|
||||||
|
alt=""
|
||||||
|
class="w-full h-full object-cover"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-if="Object.keys(item.errors).length > 0"
|
||||||
|
class="absolute top-0 right-0 w-2.5 h-2.5 bg-red-500"
|
||||||
|
></div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-icon-button oc-icon-button--danger oc-icon-button--tiny absolute -right-1 -top-1"
|
||||||
|
title="移除图片"
|
||||||
|
aria-label="移除图片"
|
||||||
|
@click.stop="handleRemove(item.id)"
|
||||||
|
>
|
||||||
|
<NIcon size="12"><X /></NIcon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="flex h-16 w-16 flex-shrink-0 cursor-pointer items-center justify-center border-2 border-dashed border-slate-300 bg-white transition-colors hover:border-sky-400 hover:bg-slate-50"
|
||||||
|
@click="fileInput?.click()"
|
||||||
|
>
|
||||||
|
<span class="text-xl text-slate-400">+</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="activeItem" class="flex-1 min-w-0">
|
||||||
|
<NCard class="oc-panel-card border border-slate-200">
|
||||||
|
<div class="space-y-5">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h2 class="text-lg font-semibold text-slate-900">
|
||||||
|
图片信息
|
||||||
|
</h2>
|
||||||
|
<span class="text-sm text-slate-400"
|
||||||
|
>{{ items.findIndex(i => i.id === activeId) + 1 }} /
|
||||||
|
{{ items.length }}</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 类别 * -->
|
||||||
|
<div :id="`field-${activeItem.id}-cloudCategory`">
|
||||||
|
<label class="oc-field-label">
|
||||||
|
类别 <span class="oc-field-required">*</span>
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
:value="activeItem.cloudCategoryId ?? ''"
|
||||||
|
class="oc-field-control"
|
||||||
|
@change="onCategoryChange"
|
||||||
|
>
|
||||||
|
<option value="" disabled>请选择</option>
|
||||||
|
<option
|
||||||
|
v-for="ct in cloudsStore.cloudTypes"
|
||||||
|
:key="ct.id"
|
||||||
|
:value="ct.id"
|
||||||
|
>
|
||||||
|
{{ ct.name
|
||||||
|
}}{{ ct.genus ? '(' + ct.genus + ')' : '' }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<p
|
||||||
|
v-if="activeItem.errors.cloudCategory"
|
||||||
|
class="oc-field-error"
|
||||||
|
>
|
||||||
|
{{ activeItem.errors.cloudCategory }}
|
||||||
|
</p>
|
||||||
|
<p v-if="activeItem.errors.file" class="oc-field-error">
|
||||||
|
{{ activeItem.errors.file }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 拍摄时间 -->
|
||||||
|
<div>
|
||||||
|
<label class="oc-field-label">拍摄时间</label>
|
||||||
|
<input
|
||||||
|
type="datetime-local"
|
||||||
|
:value="formatDatetimeLocal(activeItem.capturedAt)"
|
||||||
|
class="oc-field-control"
|
||||||
|
@change="onCapturedAtChange"
|
||||||
|
/>
|
||||||
|
<p
|
||||||
|
v-if="activeItem.errors.capturedAt"
|
||||||
|
class="oc-field-error"
|
||||||
|
>
|
||||||
|
{{ activeItem.errors.capturedAt }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 经纬度 * -->
|
||||||
|
<div>
|
||||||
|
<label class="oc-field-label"
|
||||||
|
>经纬度 <span class="oc-field-required">*</span></label
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-2"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<input
|
||||||
|
:value="
|
||||||
|
activeItem.latitude !== null
|
||||||
|
? activeItem.latitude
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
placeholder="纬度(如 39.90)"
|
||||||
|
class="oc-field-control"
|
||||||
|
@input="onLatInput"
|
||||||
|
/>
|
||||||
|
<p
|
||||||
|
v-if="activeItem.errors.latitude"
|
||||||
|
class="oc-field-error"
|
||||||
|
>
|
||||||
|
{{ activeItem.errors.latitude }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input
|
||||||
|
:value="
|
||||||
|
activeItem.longitude !== null
|
||||||
|
? activeItem.longitude
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
placeholder="经度(如 116.40)"
|
||||||
|
class="oc-field-control"
|
||||||
|
@input="onLngInput"
|
||||||
|
/>
|
||||||
|
<p
|
||||||
|
v-if="activeItem.errors.longitude"
|
||||||
|
class="oc-field-error"
|
||||||
|
>
|
||||||
|
{{ activeItem.errors.longitude }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
title="地图选点"
|
||||||
|
aria-label="地图选点"
|
||||||
|
class="oc-icon-button oc-icon-button--sky"
|
||||||
|
@click="openMapPicker"
|
||||||
|
>
|
||||||
|
<NIcon size="20"><MapIcon /></NIcon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="mt-1 text-xs text-slate-400">
|
||||||
|
必填,可手动输入,或点击右侧地图图标选择
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 图片描述 -->
|
||||||
|
<div>
|
||||||
|
<label class="oc-field-label">图片描述</label>
|
||||||
|
<textarea
|
||||||
|
v-model="activeItem.description"
|
||||||
|
rows="3"
|
||||||
|
maxlength="128"
|
||||||
|
placeholder="描述一下这张图片..."
|
||||||
|
class="oc-field-control resize-none"
|
||||||
|
></textarea>
|
||||||
|
<p
|
||||||
|
v-if="activeItem.errors.description"
|
||||||
|
class="oc-field-error"
|
||||||
|
>
|
||||||
|
{{ activeItem.errors.description }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 公开状态 -->
|
||||||
|
<div class="border border-slate-200 bg-slate-50 px-4 py-3">
|
||||||
|
<div class="flex items-center justify-between gap-4">
|
||||||
|
<div>
|
||||||
|
<p class="text-sm font-medium text-slate-800">
|
||||||
|
公开展示
|
||||||
|
</p>
|
||||||
|
<p class="mt-1 text-xs text-slate-500">
|
||||||
|
关闭后不会出现在画廊、地图和公开主页中。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
:id="'isPublic-' + activeItem.id"
|
||||||
|
:checked="!activeItem.isHidden"
|
||||||
|
type="checkbox"
|
||||||
|
class="h-5 w-5 border-slate-300 text-sky-500 focus:ring-sky-500"
|
||||||
|
@change="
|
||||||
|
updateActivePublicState(
|
||||||
|
($event.target as HTMLInputElement).checked,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="mt-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"
|
||||||
|
>
|
||||||
|
<p class="text-sm text-slate-500">共 {{ items.length }} 张图片</p>
|
||||||
|
<div class="flex flex-wrap gap-3">
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
:disabled="uploading"
|
||||||
|
@click="clearAll()"
|
||||||
|
>清空</NButton
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
:disabled="uploading"
|
||||||
|
@click="handleSubmit"
|
||||||
|
>
|
||||||
|
{{ uploading ? '上传中...' : '提交上传' }}
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<NAlert
|
||||||
|
v-if="errorMsg"
|
||||||
|
class="mt-3"
|
||||||
|
type="error"
|
||||||
|
:show-icon="false"
|
||||||
|
:bordered="false"
|
||||||
|
title="上传失败"
|
||||||
|
>
|
||||||
|
{{ errorMsg }}
|
||||||
|
</NAlert>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<MapPickerModal
|
||||||
|
:open="mapPickerOpen"
|
||||||
|
:latitude="activeItem?.latitude ?? null"
|
||||||
|
:longitude="activeItem?.longitude ?? null"
|
||||||
|
description="点击地图即可回填当前图片的经纬度,也可以继续手动修改。"
|
||||||
|
footer-text="建议点选大致拍摄位置,上传时会继续做模糊化处理。"
|
||||||
|
@close="closeMapPicker"
|
||||||
|
@confirm="confirmMapPicker"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import AMapLoader from '@amap/amap-jsapi-loader'
|
|
||||||
|
|
||||||
export function loadAMap() {
|
|
||||||
return AMapLoader.load({
|
|
||||||
key: import.meta.env.VITE_AMAP_KEY,
|
|
||||||
version: '2.0',
|
|
||||||
plugins: [
|
|
||||||
'AMap.Scale',
|
|
||||||
'AMap.ToolBar',
|
|
||||||
'AMap.ControlBar',
|
|
||||||
'AMap.Geolocation',
|
|
||||||
'AMap.Marker',
|
|
||||||
'AMap.InfoWindow',
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import { API_URL } from './api'
|
||||||
|
import type { CloudResponse, CloudTypeResponse, UserProfileResponse } from '@/types/api-contract'
|
||||||
|
import type { CloudDetail, AuthUser } from '@/types/view-models'
|
||||||
|
import type { CloudType } from '@/types/models'
|
||||||
|
|
||||||
|
export function imageUrl(id: string, variant: 'preview' | 'original' = 'preview') {
|
||||||
|
return `${API_URL}/images/${encodeURIComponent(id)}/${variant}`
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toAuthUser(profile: UserProfileResponse): AuthUser {
|
||||||
|
return {
|
||||||
|
id: profile.id,
|
||||||
|
email: profile.email,
|
||||||
|
username: profile.username,
|
||||||
|
image: profile.image,
|
||||||
|
role: profile.role,
|
||||||
|
is_disabled: profile.is_disabled,
|
||||||
|
cloud_count: profile.cloud_count,
|
||||||
|
received_like_count: profile.received_like_count,
|
||||||
|
created_at: profile.created_at,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toCloudType(row: CloudTypeResponse): CloudType {
|
||||||
|
return {
|
||||||
|
id: row.id,
|
||||||
|
name: row.name,
|
||||||
|
genus: row.genus || '',
|
||||||
|
icon_id: row.icon_id,
|
||||||
|
rarity: row.rarity,
|
||||||
|
description: row.description,
|
||||||
|
created_at: row.created_at,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toCloudDetail(row: CloudResponse): CloudDetail {
|
||||||
|
return {
|
||||||
|
id: row.id,
|
||||||
|
user_id: row.owner.id,
|
||||||
|
cloud_type_id: row.cloud_type.id,
|
||||||
|
image_url: imageUrl(row.id, 'original'),
|
||||||
|
thumbnail_url: imageUrl(row.id, 'preview'),
|
||||||
|
latitude: row.latitude,
|
||||||
|
longitude: row.longitude,
|
||||||
|
description: row.description,
|
||||||
|
captured_at: row.captured_at,
|
||||||
|
status: row.review_status,
|
||||||
|
is_hidden: row.is_hidden,
|
||||||
|
created_at: row.uploaded_at,
|
||||||
|
updated_at: row.updated_at,
|
||||||
|
cloud_type: {
|
||||||
|
id: row.cloud_type.id,
|
||||||
|
name: row.cloud_type.name,
|
||||||
|
rarity: row.cloud_type.rarity,
|
||||||
|
},
|
||||||
|
owner: { id: row.owner.id, username: row.owner.username },
|
||||||
|
cloud_type_name: row.cloud_type.name,
|
||||||
|
cloud_type_rarity: row.cloud_type.rarity,
|
||||||
|
username: row.owner.username,
|
||||||
|
received_like_count: row.received_like_count,
|
||||||
|
}
|
||||||
|
}
|
||||||
+76
-106
@@ -1,134 +1,104 @@
|
|||||||
import type { AuthResponse } from '@/types/api'
|
const DEFAULT_API_URL = 'http://localhost:3000'
|
||||||
|
|
||||||
const DEFAULT_API_URL = 'http://localhost:8000/api/v1'
|
export const API_URL = (import.meta.env?.VITE_API_URL || DEFAULT_API_URL).replace(/\/$/, '')
|
||||||
|
|
||||||
export const API_URL = (import.meta.env.VITE_API_URL || DEFAULT_API_URL).replace(/\/$/, '')
|
|
||||||
export const AUTH_UPDATED_EVENT = 'opencloud:auth-updated'
|
|
||||||
export const AUTH_EXPIRED_EVENT = 'opencloud:auth-expired'
|
export const AUTH_EXPIRED_EVENT = 'opencloud:auth-expired'
|
||||||
|
|
||||||
let accessToken: string | null = null
|
|
||||||
let refreshPromise: Promise<AuthResponse> | null = null
|
|
||||||
|
|
||||||
export class ApiError extends Error {
|
export class ApiError extends Error {
|
||||||
status: number
|
status: number
|
||||||
detail: unknown
|
detail: unknown
|
||||||
|
|
||||||
constructor(message: string, status: number, detail?: unknown) {
|
constructor(message: string, status: number, detail?: unknown) {
|
||||||
super(message)
|
super(message)
|
||||||
this.name = 'ApiError'
|
this.name = 'ApiError'
|
||||||
this.status = status
|
this.status = status
|
||||||
this.detail = detail
|
this.detail = detail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ApiRequestOptions extends Omit<RequestInit, 'body'> {
|
interface ApiRequestOptions extends Omit<RequestInit, 'body'> {
|
||||||
body?: BodyInit | Record<string, unknown> | null
|
body?: BodyInit | Record<string, unknown> | null
|
||||||
auth?: boolean
|
query?: Record<string, string | number | boolean | undefined>
|
||||||
retry?: boolean
|
auth?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
function isJsonBody(body: ApiRequestOptions['body']): body is Record<string, unknown> {
|
function isJsonBody(body: ApiRequestOptions['body']): body is Record<string, unknown> {
|
||||||
return !!body
|
if (!body || typeof body !== 'object') return false
|
||||||
&& typeof body === 'object'
|
const prototype = Object.getPrototypeOf(body)
|
||||||
&& !(body instanceof FormData)
|
return prototype === Object.prototype || prototype === null
|
||||||
&& !(body instanceof Blob)
|
|
||||||
&& !(body instanceof URLSearchParams)
|
|
||||||
&& !(body instanceof ArrayBuffer)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function detailToMessage(detail: unknown, fallback: string) {
|
function errorMessage(payload: unknown, fallback: string) {
|
||||||
if (typeof detail === 'string') return detail
|
return payload &&
|
||||||
if (Array.isArray(detail)) {
|
typeof payload === 'object' &&
|
||||||
const messages = detail
|
'message' in payload &&
|
||||||
.map(item => item && typeof item === 'object' && 'msg' in item ? String(item.msg) : '')
|
typeof payload.message === 'string'
|
||||||
.filter(Boolean)
|
? payload.message
|
||||||
if (messages.length) return messages.join(';')
|
: fallback
|
||||||
}
|
}
|
||||||
return fallback
|
|
||||||
|
async function readPayload(response: Response) {
|
||||||
|
const text = await response.text()
|
||||||
|
if (!text) return undefined
|
||||||
|
|
||||||
|
const contentType = response.headers.get('content-type') || ''
|
||||||
|
if (!contentType.includes('json')) return text
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(text) as unknown
|
||||||
|
} catch {
|
||||||
|
return text
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toApiError(response: Response) {
|
async function toApiError(response: Response) {
|
||||||
let detail: unknown
|
const payload = await readPayload(response)
|
||||||
try {
|
const fallback =
|
||||||
const payload = await response.json() as { detail?: unknown }
|
typeof payload === 'string' && payload.trim()
|
||||||
detail = payload.detail
|
? payload.trim()
|
||||||
} catch {
|
: `请求失败(${response.status})`
|
||||||
detail = undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ApiError(
|
return new ApiError(errorMessage(payload, fallback), response.status, payload)
|
||||||
detailToMessage(detail, `请求失败(${response.status})`),
|
|
||||||
response.status,
|
|
||||||
detail,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setAccessToken(token: string | null) {
|
|
||||||
accessToken = token
|
|
||||||
}
|
|
||||||
|
|
||||||
export function clearAccessToken() {
|
|
||||||
accessToken = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function request<T>(path: string, options: ApiRequestOptions = {}) {
|
async function request<T>(path: string, options: ApiRequestOptions = {}) {
|
||||||
const { body, auth = true, retry = true, ...requestOptions } = options
|
const { body, query, auth = true, ...requestOptions } = options
|
||||||
const headers = new Headers(requestOptions.headers)
|
const headers = new Headers(requestOptions.headers)
|
||||||
let requestBody: BodyInit | null | undefined = body as BodyInit | null | undefined
|
let requestBody: BodyInit | null | undefined = body as BodyInit | null | undefined
|
||||||
|
|
||||||
if (isJsonBody(body)) {
|
if (isJsonBody(body)) {
|
||||||
headers.set('Content-Type', 'application/json')
|
headers.set('Content-Type', 'application/json')
|
||||||
requestBody = JSON.stringify(body)
|
requestBody = JSON.stringify(body)
|
||||||
}
|
|
||||||
|
|
||||||
if (auth && accessToken) {
|
|
||||||
headers.set('Authorization', `Bearer ${accessToken}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(`${API_URL}${path}`, {
|
|
||||||
...requestOptions,
|
|
||||||
body: requestBody,
|
|
||||||
headers,
|
|
||||||
credentials: 'include',
|
|
||||||
})
|
|
||||||
|
|
||||||
if (response.status === 401 && auth && accessToken && retry) {
|
|
||||||
try {
|
|
||||||
const authResponse = await refreshSession()
|
|
||||||
window.dispatchEvent(new CustomEvent<AuthResponse>(AUTH_UPDATED_EVENT, { detail: authResponse }))
|
|
||||||
return request<T>(path, { ...options, retry: false })
|
|
||||||
} catch {
|
|
||||||
clearAccessToken()
|
|
||||||
window.dispatchEvent(new Event(AUTH_EXPIRED_EVENT))
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!response.ok) throw await toApiError(response)
|
const search = new URLSearchParams()
|
||||||
if (response.status === 204) return undefined as T
|
for (const [key, value] of Object.entries(query ?? {})) {
|
||||||
|
if (value !== undefined) search.set(key, String(value))
|
||||||
|
}
|
||||||
|
const url = `${API_URL}${path}${search.size ? `?${search}` : ''}`
|
||||||
|
const response = await fetch(url, {
|
||||||
|
...requestOptions,
|
||||||
|
body: requestBody,
|
||||||
|
headers,
|
||||||
|
credentials: 'include',
|
||||||
|
})
|
||||||
|
|
||||||
return response.json() as Promise<T>
|
if (response.status === 401 && auth && typeof window !== 'undefined') {
|
||||||
|
window.dispatchEvent(new Event(AUTH_EXPIRED_EVENT))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!response.ok) throw await toApiError(response)
|
||||||
|
if (response.status === 204) return undefined as T
|
||||||
|
const payload = await readPayload(response)
|
||||||
|
if (
|
||||||
|
!response.headers.get('content-type')?.includes('json') ||
|
||||||
|
typeof payload === 'string' ||
|
||||||
|
payload === undefined
|
||||||
|
) {
|
||||||
|
throw new ApiError('服务器返回了无效的 JSON 响应', response.status, payload)
|
||||||
|
}
|
||||||
|
return payload as T
|
||||||
}
|
}
|
||||||
|
|
||||||
export function apiRequest<T>(path: string, options: ApiRequestOptions = {}) {
|
export function apiRequest<T>(path: string, options: ApiRequestOptions = {}) {
|
||||||
return request<T>(path, options)
|
return request<T>(path, options)
|
||||||
}
|
|
||||||
|
|
||||||
export function refreshSession() {
|
|
||||||
if (!refreshPromise) {
|
|
||||||
refreshPromise = (async () => {
|
|
||||||
const response = await fetch(`${API_URL}/auth/refresh`, {
|
|
||||||
method: 'POST',
|
|
||||||
credentials: 'include',
|
|
||||||
})
|
|
||||||
if (!response.ok) throw await toApiError(response)
|
|
||||||
|
|
||||||
const authResponse = await response.json() as AuthResponse
|
|
||||||
setAccessToken(authResponse.access_token)
|
|
||||||
return authResponse
|
|
||||||
})().finally(() => {
|
|
||||||
refreshPromise = null
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return refreshPromise
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
const PATCH_FLAG = '__openCloudWillReadFrequentlyPatched__'
|
|
||||||
|
|
||||||
type CanvasLikePrototype = {
|
|
||||||
getContext?: (contextId: string, options?: unknown) => unknown
|
|
||||||
[PATCH_FLAG]?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
function patch2DContextOptions(ctor: typeof HTMLCanvasElement | typeof OffscreenCanvas | undefined) {
|
|
||||||
const prototype = ctor?.prototype as CanvasLikePrototype | undefined
|
|
||||||
if (!prototype?.getContext || prototype[PATCH_FLAG]) return
|
|
||||||
|
|
||||||
const originalGetContext = prototype.getContext
|
|
||||||
|
|
||||||
prototype.getContext = function getContextWithReadHint(contextId: string, options?: unknown) {
|
|
||||||
if (contextId === '2d') {
|
|
||||||
const nextOptions =
|
|
||||||
options && typeof options === 'object'
|
|
||||||
? { ...options as Record<string, unknown>, willReadFrequently: true }
|
|
||||||
: { willReadFrequently: true }
|
|
||||||
|
|
||||||
return originalGetContext.call(this, contextId, nextOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
return originalGetContext.call(this, contextId, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
prototype[PATCH_FLAG] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
export function enableCanvasReadbackHint() {
|
|
||||||
if (typeof window === 'undefined') return
|
|
||||||
|
|
||||||
patch2DContextOptions(window.HTMLCanvasElement)
|
|
||||||
if (typeof window.OffscreenCanvas !== 'undefined') {
|
|
||||||
patch2DContextOptions(window.OffscreenCanvas)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
export type BadgeRarity = 'common' | 'uncommon' | 'rare'
|
|
||||||
|
|
||||||
export interface CloudBadgeCardInput {
|
|
||||||
cloudName: string
|
|
||||||
cloudNameEn: string
|
|
||||||
unlockedAt: string
|
|
||||||
username: string
|
|
||||||
rarity: BadgeRarity
|
|
||||||
}
|
|
||||||
|
|
||||||
const rarityTheme = {
|
|
||||||
common: {
|
|
||||||
from: '#dbeafe',
|
|
||||||
to: '#f8fafc',
|
|
||||||
accent: '#0284c7',
|
|
||||||
shadow: 'rgba(2, 132, 199, 0.18)',
|
|
||||||
},
|
|
||||||
uncommon: {
|
|
||||||
from: '#fef3c7',
|
|
||||||
to: '#fff7ed',
|
|
||||||
accent: '#d97706',
|
|
||||||
shadow: 'rgba(217, 119, 6, 0.22)',
|
|
||||||
},
|
|
||||||
rare: {
|
|
||||||
from: '#fee2e2',
|
|
||||||
to: '#fff7ed',
|
|
||||||
accent: '#dc2626',
|
|
||||||
shadow: 'rgba(220, 38, 38, 0.22)',
|
|
||||||
},
|
|
||||||
} satisfies Record<BadgeRarity, { from: string; to: string; accent: string; shadow: string }>
|
|
||||||
|
|
||||||
function formatDate(iso: string) {
|
|
||||||
return new Date(iso).toLocaleDateString('zh-CN', {
|
|
||||||
year: 'numeric',
|
|
||||||
month: 'long',
|
|
||||||
day: 'numeric',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeDownloadName(name: string) {
|
|
||||||
return `opencloud-badge-${name}.png`
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function downloadCloudBadgeCard(input: CloudBadgeCardInput) {
|
|
||||||
const canvas = document.createElement('canvas')
|
|
||||||
canvas.width = 1200
|
|
||||||
canvas.height = 630
|
|
||||||
|
|
||||||
const ctx = canvas.getContext('2d')
|
|
||||||
if (!ctx) return
|
|
||||||
|
|
||||||
const theme = rarityTheme[input.rarity]
|
|
||||||
const gradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height)
|
|
||||||
gradient.addColorStop(0, theme.from)
|
|
||||||
gradient.addColorStop(1, theme.to)
|
|
||||||
|
|
||||||
ctx.fillStyle = gradient
|
|
||||||
ctx.fillRect(0, 0, canvas.width, canvas.height)
|
|
||||||
|
|
||||||
ctx.fillStyle = 'rgba(255,255,255,0.72)'
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.arc(1010, 120, 140, 0, Math.PI * 2)
|
|
||||||
ctx.fill()
|
|
||||||
|
|
||||||
ctx.fillStyle = 'rgba(255,255,255,0.45)'
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.arc(160, 520, 180, 0, Math.PI * 2)
|
|
||||||
ctx.fill()
|
|
||||||
|
|
||||||
ctx.fillStyle = '#0f172a'
|
|
||||||
ctx.font = '700 44px sans-serif'
|
|
||||||
ctx.fillText('OpenCloud 云朵图鉴', 72, 88)
|
|
||||||
|
|
||||||
ctx.fillStyle = 'rgba(15, 23, 42, 0.62)'
|
|
||||||
ctx.font = '400 24px sans-serif'
|
|
||||||
ctx.fillText('新徽章已解锁', 72, 126)
|
|
||||||
|
|
||||||
ctx.shadowColor = theme.shadow
|
|
||||||
ctx.shadowBlur = 28
|
|
||||||
ctx.fillStyle = '#ffffff'
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.roundRect(72, 170, 1056, 380, 32)
|
|
||||||
ctx.fill()
|
|
||||||
ctx.shadowBlur = 0
|
|
||||||
|
|
||||||
ctx.fillStyle = theme.accent
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.arc(210, 360, 92, 0, Math.PI * 2)
|
|
||||||
ctx.fill()
|
|
||||||
|
|
||||||
ctx.fillStyle = '#ffffff'
|
|
||||||
ctx.font = '700 82px sans-serif'
|
|
||||||
ctx.textAlign = 'center'
|
|
||||||
ctx.textBaseline = 'middle'
|
|
||||||
ctx.fillText(input.cloudName.slice(0, 1), 210, 360)
|
|
||||||
|
|
||||||
ctx.textAlign = 'left'
|
|
||||||
ctx.textBaseline = 'alphabetic'
|
|
||||||
ctx.fillStyle = '#0f172a'
|
|
||||||
ctx.font = '700 64px sans-serif'
|
|
||||||
ctx.fillText(input.cloudName, 340, 300)
|
|
||||||
|
|
||||||
ctx.fillStyle = 'rgba(15, 23, 42, 0.62)'
|
|
||||||
ctx.font = '400 30px sans-serif'
|
|
||||||
ctx.fillText(input.cloudNameEn, 340, 346)
|
|
||||||
|
|
||||||
ctx.fillStyle = theme.accent
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.roundRect(340, 382, 168, 48, 24)
|
|
||||||
ctx.fill()
|
|
||||||
|
|
||||||
ctx.fillStyle = '#ffffff'
|
|
||||||
ctx.font = '600 24px sans-serif'
|
|
||||||
ctx.fillText(input.rarity === 'common' ? '常见' : input.rarity === 'uncommon' ? '少见' : '罕见', 384, 414)
|
|
||||||
|
|
||||||
ctx.fillStyle = '#334155'
|
|
||||||
ctx.font = '400 28px sans-serif'
|
|
||||||
ctx.fillText(`解锁者:${input.username}`, 340, 476)
|
|
||||||
ctx.fillText(`解锁日期:${formatDate(input.unlockedAt)}`, 340, 518)
|
|
||||||
|
|
||||||
const blob = await new Promise<Blob | null>(resolve => canvas.toBlob(resolve, 'image/png'))
|
|
||||||
if (!blob) return
|
|
||||||
|
|
||||||
const url = URL.createObjectURL(blob)
|
|
||||||
const link = document.createElement('a')
|
|
||||||
link.href = url
|
|
||||||
link.download = makeDownloadName(input.cloudNameEn.toLowerCase())
|
|
||||||
link.click()
|
|
||||||
URL.revokeObjectURL(url)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
export const CLOUD_TYPES = [
|
|
||||||
{ id: 1, name: '积云', nameEn: 'Cumulus' },
|
|
||||||
{ id: 2, name: '层云', nameEn: 'Stratus' },
|
|
||||||
{ id: 3, name: '卷云', nameEn: 'Cirrus' },
|
|
||||||
{ id: 4, name: '积雨云', nameEn: 'Cumulonimbus' },
|
|
||||||
{ id: 5, name: '层积云', nameEn: 'Stratocumulus' },
|
|
||||||
{ id: 6, name: '高积云', nameEn: 'Altocumulus' },
|
|
||||||
{ id: 7, name: '高层云', nameEn: 'Altostratus' },
|
|
||||||
{ id: 8, name: '雨层云', nameEn: 'Nimbostratus' },
|
|
||||||
{ id: 9, name: '卷层云', nameEn: 'Cirrostratus' },
|
|
||||||
{ id: 10, name: '卷积云', nameEn: 'Cirrocumulus' },
|
|
||||||
] as const
|
|
||||||
|
|
||||||
export function getCloudTypeName(id: string | string[]) {
|
|
||||||
const cloudTypeId = Number(Array.isArray(id) ? id[0] : id)
|
|
||||||
return CLOUD_TYPES.find(item => item.id === cloudTypeId)?.name ?? '云型详情'
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
export interface Page<T> {
|
||||||
|
items: T[]
|
||||||
|
page: number
|
||||||
|
page_size: number
|
||||||
|
has_more: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Collect only for screens that need a complete set (heatmaps, likes, admin). */
|
||||||
|
export async function collectPages<T>(load: (page: number) => Promise<Page<T>>): Promise<T[]> {
|
||||||
|
const items: T[] = []
|
||||||
|
for (let page = 1; ; page++) {
|
||||||
|
const result = await load(page)
|
||||||
|
items.push(...result.items)
|
||||||
|
if (!result.has_more) return items
|
||||||
|
}
|
||||||
|
}
|
||||||
+45
-41
@@ -4,60 +4,64 @@ const defaultTitle = 'OpenCloud'
|
|||||||
const defaultDescription = 'OpenCloud - 活的天空地图,拍云、识别、收藏'
|
const defaultDescription = 'OpenCloud - 活的天空地图,拍云、识别、收藏'
|
||||||
|
|
||||||
function resolveSiteUrl() {
|
function resolveSiteUrl() {
|
||||||
return (import.meta.env.VITE_SITE_URL || window.location.origin).replace(/\/$/, '')
|
return (import.meta.env.VITE_SITE_URL || window.location.origin).replace(/\/$/, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
function upsertMeta(name: string, content: string) {
|
function upsertMeta(name: string, content: string) {
|
||||||
let element = document.querySelector<HTMLMetaElement>(`meta[name="${name}"]`)
|
let element = document.querySelector<HTMLMetaElement>(`meta[name="${name}"]`)
|
||||||
if (!element) {
|
if (!element) {
|
||||||
element = document.createElement('meta')
|
element = document.createElement('meta')
|
||||||
element.name = name
|
element.name = name
|
||||||
document.head.appendChild(element)
|
document.head.appendChild(element)
|
||||||
}
|
}
|
||||||
element.content = content
|
element.content = content
|
||||||
}
|
}
|
||||||
|
|
||||||
function upsertPropertyMeta(property: string, content: string) {
|
function upsertPropertyMeta(property: string, content: string) {
|
||||||
let element = document.querySelector<HTMLMetaElement>(`meta[property="${property}"]`)
|
let element = document.querySelector<HTMLMetaElement>(`meta[property="${property}"]`)
|
||||||
if (!element) {
|
if (!element) {
|
||||||
element = document.createElement('meta')
|
element = document.createElement('meta')
|
||||||
element.setAttribute('property', property)
|
element.setAttribute('property', property)
|
||||||
document.head.appendChild(element)
|
document.head.appendChild(element)
|
||||||
}
|
}
|
||||||
element.content = content
|
element.content = content
|
||||||
}
|
}
|
||||||
|
|
||||||
function upsertCanonical(href: string) {
|
function upsertCanonical(href: string) {
|
||||||
let element = document.querySelector<HTMLLinkElement>('link[rel="canonical"]')
|
let element = document.querySelector<HTMLLinkElement>('link[rel="canonical"]')
|
||||||
if (!element) {
|
if (!element) {
|
||||||
element = document.createElement('link')
|
element = document.createElement('link')
|
||||||
element.rel = 'canonical'
|
element.rel = 'canonical'
|
||||||
document.head.appendChild(element)
|
document.head.appendChild(element)
|
||||||
}
|
}
|
||||||
element.href = href
|
element.href = href
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyRouteSeo(route: RouteLocationNormalizedLoaded) {
|
export function applyRouteSeo(route: RouteLocationNormalizedLoaded) {
|
||||||
const title = typeof route.meta.title === 'function' ? route.meta.title(route) : route.meta.title
|
const title =
|
||||||
const description = typeof route.meta.description === 'function' ? route.meta.description(route) : route.meta.description
|
typeof route.meta.title === 'function' ? route.meta.title(route) : route.meta.title
|
||||||
const robots = route.meta.noindex ? 'noindex, nofollow' : 'index, follow'
|
const description =
|
||||||
const canonicalPath = route.meta.canonicalPath || route.path
|
typeof route.meta.description === 'function'
|
||||||
const canonical = `${resolveSiteUrl()}${canonicalPath}`
|
? route.meta.description(route)
|
||||||
const pageTitle = title ? `${title} | OpenCloud` : defaultTitle
|
: route.meta.description
|
||||||
const pageDescription = description || defaultDescription
|
const robots = route.meta.noindex ? 'noindex, nofollow' : 'index, follow'
|
||||||
|
const canonicalPath = route.meta.canonicalPath || route.path
|
||||||
|
const canonical = `${resolveSiteUrl()}${canonicalPath}`
|
||||||
|
const pageTitle = title ? `${title} | OpenCloud` : defaultTitle
|
||||||
|
const pageDescription = description || defaultDescription
|
||||||
|
|
||||||
document.title = pageTitle
|
document.title = pageTitle
|
||||||
upsertMeta('description', pageDescription)
|
upsertMeta('description', pageDescription)
|
||||||
upsertMeta('robots', robots)
|
upsertMeta('robots', robots)
|
||||||
upsertCanonical(canonical)
|
upsertCanonical(canonical)
|
||||||
|
|
||||||
upsertPropertyMeta('og:site_name', 'OpenCloud')
|
upsertPropertyMeta('og:site_name', 'OpenCloud')
|
||||||
upsertPropertyMeta('og:type', 'website')
|
upsertPropertyMeta('og:type', 'website')
|
||||||
upsertPropertyMeta('og:title', pageTitle)
|
upsertPropertyMeta('og:title', pageTitle)
|
||||||
upsertPropertyMeta('og:description', pageDescription)
|
upsertPropertyMeta('og:description', pageDescription)
|
||||||
upsertPropertyMeta('og:url', canonical)
|
upsertPropertyMeta('og:url', canonical)
|
||||||
|
|
||||||
upsertMeta('twitter:card', 'summary')
|
upsertMeta('twitter:card', 'summary')
|
||||||
upsertMeta('twitter:title', pageTitle)
|
upsertMeta('twitter:title', pageTitle)
|
||||||
upsertMeta('twitter:description', pageDescription)
|
upsertMeta('twitter:description', pageDescription)
|
||||||
}
|
}
|
||||||
|
|||||||
+52
-49
@@ -2,54 +2,57 @@ import type { GlobalThemeOverrides } from 'naive-ui'
|
|||||||
|
|
||||||
/** Keep these values aligned with the semantic tokens in styles/tokens.css. */
|
/** Keep these values aligned with the semantic tokens in styles/tokens.css. */
|
||||||
export const openCloudThemeOverrides: GlobalThemeOverrides = {
|
export const openCloudThemeOverrides: GlobalThemeOverrides = {
|
||||||
common: {
|
common: {
|
||||||
primaryColor: '#0f766e',
|
primaryColor: '#34745d',
|
||||||
primaryColorHover: '#115e59',
|
primaryColorHover: '#2d5f4e',
|
||||||
primaryColorPressed: '#134e4a',
|
primaryColorPressed: '#274c40',
|
||||||
primaryColorSuppl: '#0f766e',
|
primaryColorSuppl: '#34745d',
|
||||||
infoColor: '#0369a1',
|
infoColor: '#0369a1',
|
||||||
successColor: '#0f766e',
|
successColor: '#4d7f3b',
|
||||||
warningColor: '#d97706',
|
successColorHover: '#3f6633',
|
||||||
errorColor: '#dc2626',
|
successColorPressed: '#35522c',
|
||||||
borderRadius: '0px',
|
successColorSuppl: '#4d7f3b',
|
||||||
borderRadiusSmall: '0px',
|
warningColor: '#d97706',
|
||||||
fontFamily: '"IBM Plex Sans", "Noto Sans SC", "PingFang SC", sans-serif',
|
errorColor: '#dc2626',
|
||||||
fontFamilyMono: '"IBM Plex Mono", "SFMono-Regular", monospace',
|
borderRadius: '0px',
|
||||||
bodyColor: '#f3f7fb',
|
borderRadiusSmall: '0px',
|
||||||
cardColor: '#ffffff',
|
fontFamily: '"IBM Plex Sans", "Noto Sans SC", "PingFang SC", sans-serif',
|
||||||
modalColor: '#ffffff',
|
fontFamilyMono: '"IBM Plex Mono", "SFMono-Regular", monospace',
|
||||||
popoverColor: '#ffffff',
|
bodyColor: '#eef4f8',
|
||||||
tableColor: '#ffffff',
|
cardColor: '#ffffff',
|
||||||
textColorBase: '#0f172a',
|
modalColor: '#ffffff',
|
||||||
textColor1: '#0f172a',
|
popoverColor: '#ffffff',
|
||||||
textColor2: '#334155',
|
tableColor: '#ffffff',
|
||||||
textColor3: '#64748b',
|
textColorBase: '#0f172a',
|
||||||
textColorDisabled: '#94a3b8',
|
textColor1: '#0f172a',
|
||||||
dividerColor: '#d9e3ee',
|
textColor2: '#334155',
|
||||||
borderColor: '#d9e3ee',
|
textColor3: '#64748b',
|
||||||
inputColor: '#ffffff',
|
textColorDisabled: 'var(--oc-color-text-disabled)',
|
||||||
},
|
dividerColor: '#d9e3ee',
|
||||||
Button: {
|
borderColor: '#d9e3ee',
|
||||||
borderRadiusTiny: '0px',
|
inputColor: '#ffffff',
|
||||||
borderRadiusSmall: '0px',
|
|
||||||
borderRadiusMedium: '0px',
|
|
||||||
borderRadiusLarge: '0px',
|
|
||||||
textColorPrimary: '#0f172a',
|
|
||||||
textColorHoverPrimary: '#0f172a',
|
|
||||||
},
|
|
||||||
Card: {
|
|
||||||
borderRadius: '0px',
|
|
||||||
borderRadiusEmbedded: '0px',
|
|
||||||
paddingMedium: '24px',
|
|
||||||
},
|
|
||||||
Input: { borderRadius: '0px' },
|
|
||||||
Select: {
|
|
||||||
peers: {
|
|
||||||
InternalSelection: { borderRadius: '0px' },
|
|
||||||
},
|
},
|
||||||
},
|
Button: {
|
||||||
Tabs: { tabBorderRadius: '0px' },
|
borderRadiusTiny: '0px',
|
||||||
Tag: { borderRadius: '0px' },
|
borderRadiusSmall: '0px',
|
||||||
Alert: { borderRadius: '0px' },
|
borderRadiusMedium: '0px',
|
||||||
Modal: { borderRadius: '0px' },
|
borderRadiusLarge: '0px',
|
||||||
|
textColorPrimary: '#0f172a',
|
||||||
|
textColorHoverPrimary: '#0f172a',
|
||||||
|
},
|
||||||
|
Card: {
|
||||||
|
borderRadius: '0px',
|
||||||
|
borderRadiusEmbedded: '0px',
|
||||||
|
paddingMedium: '24px',
|
||||||
|
},
|
||||||
|
Input: { borderRadius: '0px' },
|
||||||
|
Select: {
|
||||||
|
peers: {
|
||||||
|
InternalSelection: { borderRadius: '0px' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Tabs: { tabBorderRadius: '0px' },
|
||||||
|
Tag: { borderRadius: '0px' },
|
||||||
|
Alert: { borderRadius: '0px' },
|
||||||
|
Modal: { borderRadius: '0px' },
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-6
@@ -2,12 +2,9 @@ import { createApp } from 'vue'
|
|||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
import { useAuthStore } from './stores/auth'
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
import { enableCanvasReadbackHint } from './lib/canvas'
|
|
||||||
import './style.css'
|
import './style.css'
|
||||||
|
|
||||||
enableCanvasReadbackHint()
|
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
@@ -15,6 +12,6 @@ app.use(pinia)
|
|||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
authStore.initialize().then(() => {
|
authStore.initialize().then(() => {
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
})
|
})
|
||||||
|
|||||||
+162
-153
@@ -1,168 +1,177 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router'
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
import { getCloudTypeName } from '@/lib/cloudTypes'
|
import { getCloudTypeName } from '@/features/clouds/cloudTypes'
|
||||||
import { applyRouteSeo } from '@/lib/seo'
|
import { applyRouteSeo } from '@/lib/seo'
|
||||||
import { useAuthStore } from '@/stores/auth'
|
import { useAuthStore } from '@/features/auth/stores/auth'
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'map',
|
name: 'map',
|
||||||
component: () => import('@/views/map/MapView.vue'),
|
component: () => import('@/features/map/views/MapView.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '实时云图地图',
|
title: '实时云图地图',
|
||||||
description: '在 OpenCloud 地图上浏览社区拍摄的云图,按位置查看天空观测记录。',
|
description: '在 OpenCloud 地图上浏览社区拍摄的云图,按位置查看天空观测记录。',
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/login',
|
||||||
|
name: 'login',
|
||||||
|
component: () => import('@/features/auth/views/LoginView.vue'),
|
||||||
|
meta: { title: '登录', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/register',
|
||||||
|
name: 'register',
|
||||||
|
component: () => import('@/features/auth/views/RegisterView.vue'),
|
||||||
|
meta: { title: '注册', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/resend-confirmation',
|
||||||
|
name: 'resend-confirmation',
|
||||||
|
component: () => import('@/features/auth/views/ResendConfirmationView.vue'),
|
||||||
|
meta: { title: '重发验证邮件', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/forgot-password',
|
||||||
|
name: 'forgot-password',
|
||||||
|
component: () => import('@/features/auth/views/ForgotPasswordView.vue'),
|
||||||
|
meta: { title: '忘记密码', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/verify-email',
|
||||||
|
alias: '/auth/confirm',
|
||||||
|
name: 'auth-confirm',
|
||||||
|
component: () => import('@/features/auth/views/AuthConfirmView.vue'),
|
||||||
|
meta: { title: '确认邮箱', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/reset-password',
|
||||||
|
alias: '/auth/reset-password',
|
||||||
|
name: 'auth-reset-password',
|
||||||
|
component: () => import('@/features/auth/views/ResetPasswordView.vue'),
|
||||||
|
meta: { title: '重置密码', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/upload',
|
||||||
|
name: 'upload',
|
||||||
|
component: () => import('@/features/upload/views/UploadView.vue'),
|
||||||
|
meta: { requiresAuth: true, title: '上传云图', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/encyclopedia',
|
||||||
|
name: 'encyclopedia',
|
||||||
|
component: () => import('@/features/encyclopedia/views/EncyclopediaView.vue'),
|
||||||
|
meta: {
|
||||||
|
requiresAuth: true,
|
||||||
|
title: '云朵百科',
|
||||||
|
description: '浏览基础云属,了解云型特征和社区公开观测记录。',
|
||||||
|
noindex: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/encyclopedia/:id',
|
||||||
|
name: 'cloud-type',
|
||||||
|
component: () => import('@/features/encyclopedia/views/CloudTypeView.vue'),
|
||||||
|
meta: {
|
||||||
|
requiresAuth: true,
|
||||||
|
title: route => getCloudTypeName(route.params.id),
|
||||||
|
description: route =>
|
||||||
|
`查看 ${getCloudTypeName(route.params.id)} 的识别要点、公开云图和社区观测记录。`,
|
||||||
|
noindex: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/gallery',
|
||||||
|
name: 'gallery',
|
||||||
|
component: () => import('@/features/gallery/views/GalleryView.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '云图画廊',
|
||||||
|
description: '按时间浏览 OpenCloud 社区公开分享的云图照片和观测记录。',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/community',
|
||||||
|
name: 'community',
|
||||||
|
component: () => import('@/features/community/views/CommunityView.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '社区',
|
||||||
|
description: '查看 OpenCloud 社区动态,发现更多天空观测和云图收藏。',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/profile',
|
||||||
|
name: 'profile',
|
||||||
|
component: () => import('@/features/profile/views/ProfileView.vue'),
|
||||||
|
meta: { requiresAuth: true, title: '个人主页', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/profile/settings',
|
||||||
|
name: 'profile-settings',
|
||||||
|
component: () => import('@/features/profile/views/ProfileSettingsView.vue'),
|
||||||
|
meta: { requiresAuth: true, title: '账号设置', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/profile/:id',
|
||||||
|
name: 'user-profile',
|
||||||
|
component: () => import('@/features/profile/views/ProfileView.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '用户云图档案',
|
||||||
|
description: '按用户名查看用户公开分享的云图记录和拍摄时间线。',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/admin',
|
||||||
|
name: 'admin',
|
||||||
|
component: () => import('@/features/admin/views/AdminView.vue'),
|
||||||
|
meta: { requiresAuth: true, requiresAdmin: true, title: '管理后台', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/403',
|
||||||
|
name: 'forbidden',
|
||||||
|
component: () => import('@/features/system/views/ForbiddenView.vue'),
|
||||||
|
meta: { title: '无权访问', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/401',
|
||||||
|
name: 'auth-required',
|
||||||
|
component: () => import('@/features/system/views/AuthRequiredView.vue'),
|
||||||
|
meta: { title: '需要登录', noindex: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/:pathMatch(.*)*',
|
||||||
|
name: 'not-found',
|
||||||
|
component: () => import('@/features/system/views/NotFoundView.vue'),
|
||||||
|
meta: { title: '页面不存在', noindex: true },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
scrollBehavior() {
|
||||||
|
return { top: 0 }
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/login',
|
|
||||||
name: 'login',
|
|
||||||
component: () => import('@/views/auth/LoginView.vue'),
|
|
||||||
meta: { title: '登录', noindex: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/register',
|
|
||||||
name: 'register',
|
|
||||||
component: () => import('@/views/auth/RegisterView.vue'),
|
|
||||||
meta: { title: '注册', noindex: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/forgot-password',
|
|
||||||
name: 'forgot-password',
|
|
||||||
component: () => import('@/views/auth/ForgotPasswordView.vue'),
|
|
||||||
meta: { title: '忘记密码', noindex: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/auth/confirm',
|
|
||||||
name: 'auth-confirm',
|
|
||||||
component: () => import('@/views/auth/AuthConfirmView.vue'),
|
|
||||||
meta: { title: '确认邮箱', noindex: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/auth/reset-password',
|
|
||||||
name: 'auth-reset-password',
|
|
||||||
component: () => import('@/views/auth/ResetPasswordView.vue'),
|
|
||||||
meta: { title: '重置密码', noindex: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/upload',
|
|
||||||
name: 'upload',
|
|
||||||
component: () => import('@/views/upload/UploadView.vue'),
|
|
||||||
meta: { requiresAuth: true, title: '上传云图', noindex: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/encyclopedia',
|
|
||||||
name: 'encyclopedia',
|
|
||||||
component: () => import('@/views/encyclopedia/EncyclopediaView.vue'),
|
|
||||||
meta: {
|
|
||||||
requiresAuth: true,
|
|
||||||
title: '云朵图鉴',
|
|
||||||
description: '浏览 10 种基础云属,了解云型特征,并通过拍摄云图点亮个人图鉴。',
|
|
||||||
noindex: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/encyclopedia/:id',
|
|
||||||
name: 'cloud-type',
|
|
||||||
component: () => import('@/views/encyclopedia/CloudTypeView.vue'),
|
|
||||||
meta: {
|
|
||||||
requiresAuth: true,
|
|
||||||
title: route => getCloudTypeName(route.params.id),
|
|
||||||
description: route => `查看 ${getCloudTypeName(route.params.id)} 的识别要点、公开云图和社区观测记录。`,
|
|
||||||
noindex: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/gallery',
|
|
||||||
name: 'gallery',
|
|
||||||
component: () => import('@/views/gallery/GalleryView.vue'),
|
|
||||||
meta: {
|
|
||||||
title: '云图画廊',
|
|
||||||
description: '按时间浏览 OpenCloud 社区公开分享的云图照片和观测记录。',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/community',
|
|
||||||
name: 'community',
|
|
||||||
component: () => import('@/views/community/CommunityView.vue'),
|
|
||||||
meta: {
|
|
||||||
title: '社区',
|
|
||||||
description: '查看 OpenCloud 社区动态,发现更多天空观测和云图收藏。',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/profile',
|
|
||||||
name: 'profile',
|
|
||||||
component: () => import('@/views/profile/ProfileView.vue'),
|
|
||||||
meta: { requiresAuth: true, title: '个人主页', noindex: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/profile/settings',
|
|
||||||
name: 'profile-settings',
|
|
||||||
component: () => import('@/views/profile/ProfileSettingsView.vue'),
|
|
||||||
meta: { requiresAuth: true, title: '账号设置', noindex: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/profile/:id',
|
|
||||||
name: 'user-profile',
|
|
||||||
component: () => import('@/views/profile/ProfileView.vue'),
|
|
||||||
meta: {
|
|
||||||
title: '用户云图档案',
|
|
||||||
description: '查看用户公开分享的云图记录、图鉴进度和拍摄时间线。',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/admin',
|
|
||||||
name: 'admin',
|
|
||||||
component: () => import('@/views/admin/AdminView.vue'),
|
|
||||||
meta: { requiresAuth: true, requiresAdmin: true, title: '管理后台', noindex: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/403',
|
|
||||||
name: 'forbidden',
|
|
||||||
component: () => import('@/views/system/ForbiddenView.vue'),
|
|
||||||
meta: { title: '无权访问', noindex: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/401',
|
|
||||||
name: 'auth-required',
|
|
||||||
component: () => import('@/views/system/AuthRequiredView.vue'),
|
|
||||||
meta: { title: '需要登录', noindex: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/:pathMatch(.*)*',
|
|
||||||
name: 'not-found',
|
|
||||||
component: () => import('@/views/system/NotFoundView.vue'),
|
|
||||||
meta: { title: '页面不存在', noindex: true },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
scrollBehavior() {
|
|
||||||
return { top: 0 }
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
router.beforeEach((to, _from, next) => {
|
router.beforeEach((to, _from, next) => {
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
if (to.meta.requiresAuth && !authStore.isLoggedIn) {
|
if (to.meta.requiresAuth && !authStore.isLoggedIn) {
|
||||||
next({
|
next({
|
||||||
name: 'auth-required',
|
name: 'auth-required',
|
||||||
query: {
|
query: {
|
||||||
redirect: to.fullPath,
|
redirect: to.fullPath,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else if (to.meta.requiresAdmin && !authStore.isAdmin) {
|
} else if (to.meta.requiresAdmin && !authStore.isAdmin) {
|
||||||
next({ name: 'forbidden' })
|
next({ name: 'forbidden' })
|
||||||
} else if ((to.name === 'login' || to.name === 'register') && authStore.isLoggedIn) {
|
} else if ((to.name === 'login' || to.name === 'register') && authStore.isLoggedIn) {
|
||||||
next({ name: 'map' })
|
next({ name: 'map' })
|
||||||
} else {
|
} else {
|
||||||
next()
|
next()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.afterEach(to => {
|
router.afterEach(to => {
|
||||||
applyRouteSeo(to)
|
applyRouteSeo(to)
|
||||||
})
|
})
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import AMapLoader from '@amap/amap-jsapi-loader'
|
||||||
|
|
||||||
|
export function loadAMap() {
|
||||||
|
return AMapLoader.load({
|
||||||
|
key: import.meta.env.VITE_AMAP_KEY,
|
||||||
|
version: '2.0',
|
||||||
|
plugins: [
|
||||||
|
'AMap.Scale',
|
||||||
|
'AMap.ToolBar',
|
||||||
|
'AMap.ControlBar',
|
||||||
|
'AMap.Geolocation',
|
||||||
|
'AMap.Marker',
|
||||||
|
'AMap.InfoWindow',
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,238 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
||||||
|
import { NButton, NIcon } from 'naive-ui'
|
||||||
|
import { X } from '@vicons/tabler'
|
||||||
|
import { loadAMap } from '@/shared/map/amap'
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
open: boolean
|
||||||
|
latitude: number | null
|
||||||
|
longitude: number | null
|
||||||
|
title?: string
|
||||||
|
description?: string
|
||||||
|
footerText?: string
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
title: '地图选点',
|
||||||
|
description: '点击地图即可回填经纬度,也可以继续手动修改。',
|
||||||
|
footerText: '建议点选大致拍摄位置,保存时会继续做模糊化处理。',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
close: []
|
||||||
|
confirm: [payload: { latitude: number; longitude: number }]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const errorMsg = ref('')
|
||||||
|
const pickedLat = ref<number | null>(null)
|
||||||
|
const pickedLng = ref<number | null>(null)
|
||||||
|
const mapEl = ref<HTMLDivElement | null>(null)
|
||||||
|
|
||||||
|
let mapPickerAMap: typeof AMap | null = null
|
||||||
|
let mapPickerInstance: AMap.Map | null = null
|
||||||
|
let mapPickerMarker: AMap.Marker | null = null
|
||||||
|
|
||||||
|
function formatCoordinate(value: number | null) {
|
||||||
|
return value === null ? '未选择' : value.toFixed(6)
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroyMapPicker() {
|
||||||
|
mapPickerMarker?.setMap(null)
|
||||||
|
mapPickerMarker = null
|
||||||
|
mapPickerInstance?.destroy()
|
||||||
|
mapPickerInstance = null
|
||||||
|
}
|
||||||
|
|
||||||
|
function placeMarker(longitude: number, latitude: number) {
|
||||||
|
if (!mapPickerAMap || !mapPickerInstance) return
|
||||||
|
|
||||||
|
if (!mapPickerMarker) {
|
||||||
|
mapPickerMarker = new mapPickerAMap.Marker({
|
||||||
|
position: [longitude, latitude],
|
||||||
|
title: '拍摄位置',
|
||||||
|
content:
|
||||||
|
'<div aria-hidden="true" class="h-4 w-4 rounded-full border-2 border-white bg-teal-500 shadow-[0_0_0_4px_rgba(52,116,93,0.24)]"></div>',
|
||||||
|
offset: new mapPickerAMap.Pixel(-8, -8),
|
||||||
|
} as AMap.MarkerOptions)
|
||||||
|
mapPickerMarker.setMap(mapPickerInstance)
|
||||||
|
} else {
|
||||||
|
mapPickerMarker.setPosition([longitude, latitude])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractLngLat(event: unknown) {
|
||||||
|
const payload = event as { lnglat?: { lng?: number; lat?: number } } | undefined
|
||||||
|
const lng = payload?.lnglat?.lng
|
||||||
|
const lat = payload?.lnglat?.lat
|
||||||
|
|
||||||
|
if (typeof lng !== 'number' || typeof lat !== 'number') return null
|
||||||
|
return { lng, lat }
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMapClick(event: unknown) {
|
||||||
|
const picked = extractLngLat(event)
|
||||||
|
if (!picked) return
|
||||||
|
|
||||||
|
pickedLng.value = picked.lng
|
||||||
|
pickedLat.value = picked.lat
|
||||||
|
placeMarker(picked.lng, picked.lat)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initializeMap() {
|
||||||
|
loading.value = true
|
||||||
|
errorMsg.value = ''
|
||||||
|
pickedLat.value = props.latitude
|
||||||
|
pickedLng.value = props.longitude
|
||||||
|
|
||||||
|
await nextTick()
|
||||||
|
destroyMapPicker()
|
||||||
|
|
||||||
|
try {
|
||||||
|
mapPickerAMap = await loadAMap()
|
||||||
|
mapPickerAMap.getConfig().appname = 'amap-jsapi-skill'
|
||||||
|
|
||||||
|
const hasCoordinates =
|
||||||
|
typeof props.latitude === 'number' && typeof props.longitude === 'number'
|
||||||
|
|
||||||
|
const center: [number, number] = hasCoordinates
|
||||||
|
? [props.longitude as number, props.latitude as number]
|
||||||
|
: [104.07, 30.67]
|
||||||
|
|
||||||
|
mapPickerInstance = new mapPickerAMap.Map(mapEl.value!, {
|
||||||
|
viewMode: '2D',
|
||||||
|
pitch: 0,
|
||||||
|
rotation: 0,
|
||||||
|
zoom: hasCoordinates ? 11 : 4,
|
||||||
|
center,
|
||||||
|
mapStyle: 'amap://styles/normal',
|
||||||
|
resizeEnable: true,
|
||||||
|
} as AMap.MapOptions)
|
||||||
|
|
||||||
|
mapPickerInstance.on('click', handleMapClick)
|
||||||
|
|
||||||
|
if (hasCoordinates) {
|
||||||
|
placeMarker(props.longitude as number, props.latitude as number)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
errorMsg.value = error instanceof Error ? error.message : '地图加载失败'
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirm() {
|
||||||
|
if (pickedLat.value === null || pickedLng.value === null) return
|
||||||
|
emit('confirm', {
|
||||||
|
latitude: pickedLat.value,
|
||||||
|
longitude: pickedLng.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.open,
|
||||||
|
open => {
|
||||||
|
if (open) {
|
||||||
|
initializeMap()
|
||||||
|
} else {
|
||||||
|
loading.value = false
|
||||||
|
errorMsg.value = ''
|
||||||
|
destroyMapPicker()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
destroyMapPicker()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Teleport to="body">
|
||||||
|
<div
|
||||||
|
v-if="open"
|
||||||
|
class="fixed inset-0 z-[140] flex items-center justify-center bg-slate-950/55 px-4 py-6"
|
||||||
|
@click="close"
|
||||||
|
>
|
||||||
|
<div class="oc-modal-shell w-full max-w-3xl overflow-hidden" @click.stop>
|
||||||
|
<div class="flex items-start justify-between border-b border-slate-200 px-6 py-5">
|
||||||
|
<div>
|
||||||
|
<h3 class="text-xl font-semibold text-slate-900">{{ title }}</h3>
|
||||||
|
<p class="oc-field-help">{{ description }}</p>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oc-icon-button"
|
||||||
|
aria-label="关闭地图选点窗口"
|
||||||
|
title="关闭地图选点窗口"
|
||||||
|
@click="close"
|
||||||
|
>
|
||||||
|
<NIcon size="20"><X /></NIcon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="px-6 py-5">
|
||||||
|
<div
|
||||||
|
class="mb-4 flex flex-wrap items-center gap-3 border border-slate-200 bg-slate-50 px-4 py-3 text-sm text-slate-600"
|
||||||
|
>
|
||||||
|
<span>当前选择:</span>
|
||||||
|
<span class="font-medium text-slate-900"
|
||||||
|
>纬度 {{ formatCoordinate(pickedLat) }}</span
|
||||||
|
>
|
||||||
|
<span class="font-medium text-slate-900"
|
||||||
|
>经度 {{ formatCoordinate(pickedLng) }}</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="relative overflow-hidden border border-slate-200 bg-slate-100">
|
||||||
|
<div ref="mapEl" class="h-[420px] w-full"></div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="loading"
|
||||||
|
class="absolute inset-0 flex items-center justify-center bg-white/80 text-sm font-medium text-slate-600"
|
||||||
|
>
|
||||||
|
正在加载地图...
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="errorMsg"
|
||||||
|
class="absolute inset-0 flex items-center justify-center bg-white/90 px-6 text-center text-sm text-red-600"
|
||||||
|
>
|
||||||
|
{{ errorMsg }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center justify-between border-t border-slate-200 px-6 py-4">
|
||||||
|
<p class="text-sm text-slate-500">{{ footerText }}</p>
|
||||||
|
<div class="flex gap-3">
|
||||||
|
<NButton
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
type="default"
|
||||||
|
class="oc-panel-button oc-panel-button--neutral"
|
||||||
|
@click="close"
|
||||||
|
>取消</NButton
|
||||||
|
>
|
||||||
|
<NButton
|
||||||
|
type="default"
|
||||||
|
secondary
|
||||||
|
strong
|
||||||
|
class="oc-panel-button oc-panel-button--sky"
|
||||||
|
:disabled="pickedLat === null || pickedLng === null"
|
||||||
|
@click="confirm"
|
||||||
|
>
|
||||||
|
使用这个位置
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
||||||
|
import { loadAMap } from '@/shared/map/amap'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
latitude: number | null
|
||||||
|
longitude: number | null
|
||||||
|
locationName?: string | null
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const mapEl = ref<HTMLDivElement | null>(null)
|
||||||
|
const loading = ref(false)
|
||||||
|
const errorMsg = ref('')
|
||||||
|
|
||||||
|
let amapLib: typeof AMap | null = null
|
||||||
|
let mapInstance: AMap.Map | null = null
|
||||||
|
let marker: AMap.Marker | null = null
|
||||||
|
|
||||||
|
const hasCoordinates = computed(() => {
|
||||||
|
return Number.isFinite(props.latitude) && Number.isFinite(props.longitude)
|
||||||
|
})
|
||||||
|
|
||||||
|
const center = computed<[number, number] | null>(() => {
|
||||||
|
if (!hasCoordinates.value) return null
|
||||||
|
return [props.longitude as number, props.latitude as number]
|
||||||
|
})
|
||||||
|
|
||||||
|
function destroyMap() {
|
||||||
|
marker?.setMap(null)
|
||||||
|
marker = null
|
||||||
|
mapInstance?.destroy()
|
||||||
|
mapInstance = null
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initializeMap() {
|
||||||
|
if (!center.value) {
|
||||||
|
destroyMap()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
errorMsg.value = ''
|
||||||
|
|
||||||
|
await nextTick()
|
||||||
|
destroyMap()
|
||||||
|
|
||||||
|
if (!mapEl.value) {
|
||||||
|
loading.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
amapLib = await loadAMap()
|
||||||
|
if ('getConfig' in amapLib) {
|
||||||
|
amapLib.getConfig().appname = 'amap-jsapi-skill'
|
||||||
|
}
|
||||||
|
|
||||||
|
mapInstance = new amapLib.Map(mapEl.value, {
|
||||||
|
viewMode: '2D',
|
||||||
|
zoom: 11,
|
||||||
|
center: center.value,
|
||||||
|
mapStyle: 'amap://styles/normal',
|
||||||
|
features: ['bg', 'road', 'building', 'point'],
|
||||||
|
resizeEnable: true,
|
||||||
|
dragEnable: true,
|
||||||
|
zoomEnable: true,
|
||||||
|
keyboardEnable: false,
|
||||||
|
doubleClickZoom: true,
|
||||||
|
scrollWheel: true,
|
||||||
|
} as AMap.MapOptions)
|
||||||
|
|
||||||
|
mapInstance.addControl(
|
||||||
|
new amapLib.ToolBar({
|
||||||
|
position: 'RT',
|
||||||
|
offset: [8, 8],
|
||||||
|
} as Record<string, unknown>),
|
||||||
|
)
|
||||||
|
|
||||||
|
marker = new amapLib.Marker({
|
||||||
|
position: center.value,
|
||||||
|
title: props.locationName || '拍摄位置',
|
||||||
|
content:
|
||||||
|
'<div class="h-4 w-4 rounded-full border-2 border-white bg-teal-500 shadow-[0_0_0_4px_rgba(52,116,93,0.24)]"></div>',
|
||||||
|
offset: new amapLib.Pixel(-8, -8),
|
||||||
|
} as AMap.MarkerOptions)
|
||||||
|
marker.setMap(mapInstance)
|
||||||
|
} catch (error) {
|
||||||
|
errorMsg.value = error instanceof Error ? error.message : '地图加载失败'
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
center,
|
||||||
|
() => {
|
||||||
|
initializeMap()
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
destroyMap()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div v-if="hasCoordinates" class="mt-5 overflow-hidden border border-slate-200 bg-white">
|
||||||
|
<div class="flex items-center justify-between border-b border-slate-200 px-4 py-3">
|
||||||
|
<div>
|
||||||
|
<p class="oc-section-label">位置地图</p>
|
||||||
|
<p class="mt-1 text-sm font-medium text-slate-900">
|
||||||
|
{{ locationName || '拍摄位置' }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<p class="text-right text-[11px] leading-5 text-slate-500">
|
||||||
|
{{ latitude?.toFixed(4) }}<br />
|
||||||
|
{{ longitude?.toFixed(4) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="relative h-40 bg-sky-50">
|
||||||
|
<div ref="mapEl" class="h-full w-full"></div>
|
||||||
|
<div
|
||||||
|
v-if="loading"
|
||||||
|
class="absolute inset-0 flex items-center justify-center bg-white/70 text-sm text-slate-500"
|
||||||
|
>
|
||||||
|
地图加载中...
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-else-if="errorMsg"
|
||||||
|
class="absolute inset-0 flex items-center justify-center bg-white/85 px-4 text-center text-sm text-slate-500"
|
||||||
|
>
|
||||||
|
{{ errorMsg }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
Vendored
+126
@@ -0,0 +1,126 @@
|
|||||||
|
declare namespace AMap {
|
||||||
|
class Map {
|
||||||
|
constructor(container: string | HTMLElement, opts?: MapOptions)
|
||||||
|
addControl(control: unknown): void
|
||||||
|
add(layer: unknown): void
|
||||||
|
remove(layer: unknown): void
|
||||||
|
destroy(): void
|
||||||
|
setCenter(center: [number, number]): void
|
||||||
|
setZoom(zoom: number, immediately?: boolean, duration?: number): void
|
||||||
|
setPitch(pitch: number): void
|
||||||
|
getPitch(): number
|
||||||
|
setRotation(rotation: number): void
|
||||||
|
getRotation(): number
|
||||||
|
on(event: string, callback: (...args: unknown[]) => void): void
|
||||||
|
off(event: string, callback: (...args: unknown[]) => void): void
|
||||||
|
getCenter(): { lng: number; lat: number }
|
||||||
|
getZoom(digits?: number): number
|
||||||
|
getAllOverlays(type?: string): unknown[]
|
||||||
|
addOverlay(overlay: unknown): void
|
||||||
|
removeOverlay(overlay: unknown): void
|
||||||
|
clearMap(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MapOptions {
|
||||||
|
viewMode?: '2D' | '3D'
|
||||||
|
pitch?: number
|
||||||
|
rotation?: number
|
||||||
|
zoom?: number
|
||||||
|
zooms?: [number, number]
|
||||||
|
center?: [number, number]
|
||||||
|
mapStyle?: string
|
||||||
|
features?: string[]
|
||||||
|
layers?: unknown[]
|
||||||
|
skyColor?: string
|
||||||
|
maxPitch?: number
|
||||||
|
resizeEnable?: boolean
|
||||||
|
dragEnable?: boolean
|
||||||
|
zoomEnable?: boolean
|
||||||
|
keyboardEnable?: boolean
|
||||||
|
doubleClickZoom?: boolean
|
||||||
|
scrollWheel?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
class Marker {
|
||||||
|
constructor(opts?: MarkerOptions)
|
||||||
|
on(event: string, callback: (...args: unknown[]) => void): void
|
||||||
|
setPosition(position: [number, number]): void
|
||||||
|
getPosition(): { lng: number; lat: number }
|
||||||
|
setContent(content: string): void
|
||||||
|
setOpacity(opacity: number): void
|
||||||
|
setMap(map: Map | null): void
|
||||||
|
remove(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MarkerOptions {
|
||||||
|
position?: [number, number]
|
||||||
|
content?: string | HTMLElement
|
||||||
|
offset?: Pixel
|
||||||
|
zIndex?: number
|
||||||
|
opacity?: number
|
||||||
|
title?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
class InfoWindow {
|
||||||
|
constructor(opts?: InfoWindowOptions)
|
||||||
|
open(map: Map, position?: [number, number]): void
|
||||||
|
close(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InfoWindowOptions {
|
||||||
|
content?: string | HTMLElement
|
||||||
|
offset?: Pixel
|
||||||
|
size?: Size
|
||||||
|
isCustom?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
class Scale {}
|
||||||
|
class ToolBar {
|
||||||
|
constructor(opts?: Record<string, unknown>)
|
||||||
|
}
|
||||||
|
class ControlBar {
|
||||||
|
constructor(opts?: Record<string, unknown>)
|
||||||
|
}
|
||||||
|
class Geolocation {
|
||||||
|
constructor(opts?: Record<string, unknown>)
|
||||||
|
getCurrentPosition(
|
||||||
|
onSuccess: (data: { position: { lng: number; lat: number } }) => void,
|
||||||
|
onError?: (error: unknown) => void,
|
||||||
|
): void
|
||||||
|
}
|
||||||
|
|
||||||
|
class TileLayer {
|
||||||
|
static Satellite: new () => TileLayer
|
||||||
|
static RoadNet: new () => TileLayer
|
||||||
|
setOpacity(opacity: number): void
|
||||||
|
}
|
||||||
|
|
||||||
|
class Pixel {
|
||||||
|
constructor(x: number, y: number)
|
||||||
|
}
|
||||||
|
|
||||||
|
class Size {
|
||||||
|
constructor(width: number, height: number)
|
||||||
|
}
|
||||||
|
|
||||||
|
class MarkerCluster {
|
||||||
|
constructor(map: Map, markers: Marker[], opts?: Record<string, unknown>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function AMapLoader_load(opts: {
|
||||||
|
key: string
|
||||||
|
version: string
|
||||||
|
plugins?: string[]
|
||||||
|
}): Promise<typeof AMap>
|
||||||
|
|
||||||
|
declare namespace AMap {
|
||||||
|
function getConfig(): { appname?: string }
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@amap/amap-jsapi-loader' {
|
||||||
|
const AMapLoader: {
|
||||||
|
load: typeof AMapLoader_load
|
||||||
|
}
|
||||||
|
export default AMapLoader
|
||||||
|
}
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
import { computed, ref } from 'vue'
|
|
||||||
import { defineStore } from 'pinia'
|
|
||||||
import {
|
|
||||||
AUTH_EXPIRED_EVENT,
|
|
||||||
AUTH_UPDATED_EVENT,
|
|
||||||
apiRequest,
|
|
||||||
clearAccessToken,
|
|
||||||
refreshSession,
|
|
||||||
setAccessToken,
|
|
||||||
} from '@/lib/api'
|
|
||||||
import type { AuthResponse, AuthUser } from '@/types/api'
|
|
||||||
import type { Profile } from '@/types/database'
|
|
||||||
|
|
||||||
export const useAuthStore = defineStore('auth', () => {
|
|
||||||
const user = ref<AuthUser | null>(null)
|
|
||||||
const profile = ref<Profile | null>(null)
|
|
||||||
const loading = ref(true)
|
|
||||||
let listenersAttached = false
|
|
||||||
|
|
||||||
const isLoggedIn = computed(() => !!user.value)
|
|
||||||
const isAdmin = computed(() => profile.value?.role === 'admin')
|
|
||||||
|
|
||||||
function applyAuth(auth: AuthResponse) {
|
|
||||||
setAccessToken(auth.access_token)
|
|
||||||
user.value = auth.user
|
|
||||||
profile.value = auth.profile
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearAuth() {
|
|
||||||
clearAccessToken()
|
|
||||||
user.value = null
|
|
||||||
profile.value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
async function login(email: string, password: string) {
|
|
||||||
const auth = await apiRequest<AuthResponse>('/auth/login', {
|
|
||||||
method: 'POST',
|
|
||||||
auth: false,
|
|
||||||
body: { email, password },
|
|
||||||
})
|
|
||||||
applyAuth(auth)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function register(email: string, password: string, username: string) {
|
|
||||||
await apiRequest('/auth/register', {
|
|
||||||
method: 'POST',
|
|
||||||
auth: false,
|
|
||||||
body: { email, password, username },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function logout() {
|
|
||||||
try {
|
|
||||||
await apiRequest('/auth/logout', { method: 'POST', retry: false })
|
|
||||||
} finally {
|
|
||||||
clearAuth()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updateUsername(username: string) {
|
|
||||||
const updatedProfile = await apiRequest<Profile>('/profiles/me', {
|
|
||||||
method: 'PATCH',
|
|
||||||
body: { username },
|
|
||||||
})
|
|
||||||
profile.value = updatedProfile
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updatePassword(password: string) {
|
|
||||||
const auth = await apiRequest<AuthResponse>('/auth/password', {
|
|
||||||
method: 'PATCH',
|
|
||||||
body: { password },
|
|
||||||
})
|
|
||||||
applyAuth(auth)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function sendPasswordReset(email: string) {
|
|
||||||
await apiRequest('/auth/forgot-password', {
|
|
||||||
method: 'POST',
|
|
||||||
auth: false,
|
|
||||||
body: { email },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initialize() {
|
|
||||||
if (!listenersAttached) {
|
|
||||||
window.addEventListener(AUTH_UPDATED_EVENT, event => {
|
|
||||||
applyAuth((event as CustomEvent<AuthResponse>).detail)
|
|
||||||
})
|
|
||||||
window.addEventListener(AUTH_EXPIRED_EVENT, clearAuth)
|
|
||||||
listenersAttached = true
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
applyAuth(await refreshSession())
|
|
||||||
} catch {
|
|
||||||
clearAuth()
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
user,
|
|
||||||
profile,
|
|
||||||
loading,
|
|
||||||
isLoggedIn,
|
|
||||||
isAdmin,
|
|
||||||
login,
|
|
||||||
register,
|
|
||||||
logout,
|
|
||||||
updateUsername,
|
|
||||||
updatePassword,
|
|
||||||
sendPasswordReset,
|
|
||||||
initialize,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { ref } from 'vue'
|
|
||||||
import { defineStore } from 'pinia'
|
|
||||||
import { apiRequest } from '@/lib/api'
|
|
||||||
import type { CloudType } from '@/types/database'
|
|
||||||
|
|
||||||
export const useCloudsStore = defineStore('clouds', () => {
|
|
||||||
const cloudTypes = ref<CloudType[]>([])
|
|
||||||
const loading = ref(false)
|
|
||||||
|
|
||||||
async function fetchCloudTypes() {
|
|
||||||
if (cloudTypes.value.length > 0) return
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
cloudTypes.value = await apiRequest<CloudType[]>('/cloud-types', { auth: false })
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { cloudTypes, loading, fetchCloudTypes }
|
|
||||||
})
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
import { computed, ref } from 'vue'
|
|
||||||
import { defineStore } from 'pinia'
|
|
||||||
import { apiRequest } from '@/lib/api'
|
|
||||||
import { useAuthStore } from '@/stores/auth'
|
|
||||||
import type { ApiCollection } from '@/types/api'
|
|
||||||
import type { CloudType, UserCollection } from '@/types/database'
|
|
||||||
|
|
||||||
export interface CollectionPreviewCloud {
|
|
||||||
id: string
|
|
||||||
image_url: string
|
|
||||||
thumbnail_url: string | null
|
|
||||||
captured_at: string | null
|
|
||||||
created_at: string
|
|
||||||
location_name: string | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CollectionEntry extends UserCollection {
|
|
||||||
firstCloud: CollectionPreviewCloud | null
|
|
||||||
}
|
|
||||||
|
|
||||||
function getErrorMessage(error: unknown) {
|
|
||||||
return error instanceof Error ? error.message : '图鉴收藏加载失败'
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useEncyclopediaStore = defineStore('encyclopedia', () => {
|
|
||||||
const authStore = useAuthStore()
|
|
||||||
|
|
||||||
const cloudTypes = ref<CloudType[]>([])
|
|
||||||
const myCollection = ref<CollectionEntry[]>([])
|
|
||||||
const loadingCloudTypes = ref(false)
|
|
||||||
const loadingCollection = ref(false)
|
|
||||||
const cloudTypesLoaded = ref(false)
|
|
||||||
const collectionLoadedForUserId = ref<string | null>(null)
|
|
||||||
const collectionError = ref('')
|
|
||||||
|
|
||||||
const collectionMap = computed(() => new Map(myCollection.value.map(item => [item.cloud_type_id, item])))
|
|
||||||
const unlockedCount = computed(() => myCollection.value.length)
|
|
||||||
const unlockProgress = computed(() => `${unlockedCount.value}/${cloudTypes.value.length || 10}`)
|
|
||||||
const unlockPercent = computed(() => cloudTypes.value.length
|
|
||||||
? Math.round(unlockedCount.value / cloudTypes.value.length * 100)
|
|
||||||
: 0)
|
|
||||||
|
|
||||||
async function fetchCloudTypes(force = false) {
|
|
||||||
if (cloudTypesLoaded.value && !force) return
|
|
||||||
loadingCloudTypes.value = true
|
|
||||||
try {
|
|
||||||
cloudTypes.value = await apiRequest<CloudType[]>('/cloud-types', { auth: false })
|
|
||||||
cloudTypesLoaded.value = true
|
|
||||||
} finally {
|
|
||||||
loadingCloudTypes.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchMyCollection(force = false) {
|
|
||||||
const userId = authStore.user?.id ?? null
|
|
||||||
if (!userId) {
|
|
||||||
myCollection.value = []
|
|
||||||
collectionLoadedForUserId.value = null
|
|
||||||
collectionError.value = ''
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!force && collectionLoadedForUserId.value === userId) return
|
|
||||||
|
|
||||||
loadingCollection.value = true
|
|
||||||
collectionError.value = ''
|
|
||||||
try {
|
|
||||||
const rows = await apiRequest<ApiCollection[]>('/collections/me')
|
|
||||||
myCollection.value = rows.map(({ first_cloud, cloud_type: _cloudType, ...collection }) => ({
|
|
||||||
...collection,
|
|
||||||
firstCloud: first_cloud,
|
|
||||||
}))
|
|
||||||
collectionLoadedForUserId.value = userId
|
|
||||||
} catch (error) {
|
|
||||||
myCollection.value = []
|
|
||||||
collectionLoadedForUserId.value = userId
|
|
||||||
collectionError.value = getErrorMessage(error)
|
|
||||||
} finally {
|
|
||||||
loadingCollection.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isUnlocked(cloudTypeId: number) {
|
|
||||||
return collectionMap.value.has(cloudTypeId)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCollectionEntry(cloudTypeId: number) {
|
|
||||||
return collectionMap.value.get(cloudTypeId) ?? null
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
cloudTypes,
|
|
||||||
myCollection,
|
|
||||||
loadingCloudTypes,
|
|
||||||
loadingCollection,
|
|
||||||
collectionError,
|
|
||||||
unlockedCount,
|
|
||||||
unlockProgress,
|
|
||||||
unlockPercent,
|
|
||||||
fetchCloudTypes,
|
|
||||||
fetchMyCollection,
|
|
||||||
isUnlocked,
|
|
||||||
getCollectionEntry,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
import { ref } from 'vue'
|
|
||||||
import { defineStore } from 'pinia'
|
|
||||||
import { apiRequest } from '@/lib/api'
|
|
||||||
import { useAuthStore } from '@/stores/auth'
|
|
||||||
import type { ApiCloud, ApiPage, PublicProfile } from '@/types/api'
|
|
||||||
import type { CloudType, Profile } from '@/types/database'
|
|
||||||
|
|
||||||
export interface ProfileCloudItem {
|
|
||||||
id: string
|
|
||||||
cloud_type_id: number | null
|
|
||||||
custom_cloud_type: string | null
|
|
||||||
image_url: string
|
|
||||||
thumbnail_url: string | null
|
|
||||||
latitude: number | null
|
|
||||||
longitude: number | null
|
|
||||||
location_name: string | null
|
|
||||||
description: string | null
|
|
||||||
captured_at: string | null
|
|
||||||
created_at: string
|
|
||||||
status: 'pending' | 'approved' | 'rejected'
|
|
||||||
is_hidden: boolean
|
|
||||||
cloudTypeName: string
|
|
||||||
cloudTypeRarity: CloudType['rarity']
|
|
||||||
}
|
|
||||||
|
|
||||||
function toProfileCloud(row: ApiCloud): ProfileCloudItem {
|
|
||||||
return {
|
|
||||||
id: row.id,
|
|
||||||
cloud_type_id: row.cloud_type_id,
|
|
||||||
custom_cloud_type: row.custom_cloud_type,
|
|
||||||
image_url: row.image_url,
|
|
||||||
thumbnail_url: row.thumbnail_url,
|
|
||||||
latitude: row.latitude,
|
|
||||||
longitude: row.longitude,
|
|
||||||
location_name: row.location_name,
|
|
||||||
description: row.description,
|
|
||||||
captured_at: row.captured_at,
|
|
||||||
created_at: row.created_at,
|
|
||||||
status: row.status,
|
|
||||||
is_hidden: row.is_hidden,
|
|
||||||
cloudTypeName: row.cloud_type_name || row.custom_cloud_type || '未知',
|
|
||||||
cloudTypeRarity: row.cloud_type_rarity || 'common',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function toProfile(profile: PublicProfile): Profile {
|
|
||||||
return {
|
|
||||||
...profile,
|
|
||||||
role: 'user',
|
|
||||||
is_disabled: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useProfileStore = defineStore('profile-page', () => {
|
|
||||||
const authStore = useAuthStore()
|
|
||||||
const profilesById = ref<Record<string, Profile>>({})
|
|
||||||
const cloudsByKey = ref<Record<string, ProfileCloudItem[]>>({})
|
|
||||||
const loadingKeys = ref<Record<string, boolean>>({})
|
|
||||||
const errorByKey = ref<Record<string, string>>({})
|
|
||||||
|
|
||||||
const makeKey = (userId: string, isOwnProfile: boolean) => `${userId}:${isOwnProfile ? 'own' : 'public'}`
|
|
||||||
|
|
||||||
function getProfile(userId: string | null) {
|
|
||||||
return userId ? profilesById.value[userId] ?? null : null
|
|
||||||
}
|
|
||||||
|
|
||||||
function getClouds(userId: string | null, isOwnProfile: boolean) {
|
|
||||||
return userId ? cloudsByKey.value[makeKey(userId, isOwnProfile)] ?? [] : []
|
|
||||||
}
|
|
||||||
|
|
||||||
function getError(userId: string | null, isOwnProfile: boolean) {
|
|
||||||
return userId ? errorByKey.value[makeKey(userId, isOwnProfile)] ?? '' : ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function isLoaded(userId: string | null, isOwnProfile: boolean) {
|
|
||||||
return !!userId && makeKey(userId, isOwnProfile) in cloudsByKey.value
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchAllClouds(userId: string, isOwnProfile: boolean) {
|
|
||||||
const requestOptions = { auth: isOwnProfile }
|
|
||||||
const first = await apiRequest<ApiPage<ApiCloud>>(`/profiles/${userId}/clouds?page=1&page_size=100`, requestOptions)
|
|
||||||
if (first.total_pages <= 1) return first.items
|
|
||||||
|
|
||||||
const remaining = await Promise.all(
|
|
||||||
Array.from({ length: first.total_pages - 1 }, (_, index) =>
|
|
||||||
apiRequest<ApiPage<ApiCloud>>(`/profiles/${userId}/clouds?page=${index + 2}&page_size=100`, requestOptions),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
return [first, ...remaining].flatMap(page => page.items)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchProfilePage(userId: string, isOwnProfile: boolean, force = false) {
|
|
||||||
const key = makeKey(userId, isOwnProfile)
|
|
||||||
if (!force && key in cloudsByKey.value && profilesById.value[userId]) return
|
|
||||||
|
|
||||||
loadingKeys.value[key] = true
|
|
||||||
errorByKey.value[key] = ''
|
|
||||||
try {
|
|
||||||
const profilePromise = isOwnProfile && authStore.profile?.id === userId
|
|
||||||
? Promise.resolve(authStore.profile)
|
|
||||||
: apiRequest<PublicProfile>(`/profiles/${userId}`, { auth: false }).then(toProfile)
|
|
||||||
const [profile, cloudRows] = await Promise.all([profilePromise, fetchAllClouds(userId, isOwnProfile)])
|
|
||||||
profilesById.value[userId] = profile
|
|
||||||
cloudsByKey.value[key] = cloudRows.map(toProfileCloud)
|
|
||||||
} catch (error) {
|
|
||||||
errorByKey.value[key] = error instanceof Error ? error.message : '个人主页加载失败'
|
|
||||||
cloudsByKey.value[key] = []
|
|
||||||
} finally {
|
|
||||||
loadingKeys.value[key] = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isLoading(userId: string | null, isOwnProfile: boolean) {
|
|
||||||
return !!userId && !!loadingKeys.value[makeKey(userId, isOwnProfile)]
|
|
||||||
}
|
|
||||||
|
|
||||||
function patchCachedCloud(userId: string, cloudId: string, patch: Partial<ProfileCloudItem>) {
|
|
||||||
for (const isOwnProfile of [true, false]) {
|
|
||||||
const key = makeKey(userId, isOwnProfile)
|
|
||||||
const current = cloudsByKey.value[key]
|
|
||||||
if (!current) continue
|
|
||||||
cloudsByKey.value[key] = current
|
|
||||||
.map(item => item.id === cloudId ? { ...item, ...patch } : item)
|
|
||||||
.filter(item => isOwnProfile || (item.status === 'approved' && !item.is_hidden))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeCachedClouds(userId: string, cloudIds: string[]) {
|
|
||||||
const idSet = new Set(cloudIds)
|
|
||||||
for (const isOwnProfile of [true, false]) {
|
|
||||||
const key = makeKey(userId, isOwnProfile)
|
|
||||||
const current = cloudsByKey.value[key]
|
|
||||||
if (current) cloudsByKey.value[key] = current.filter(item => !idSet.has(item.id))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function invalidateUser(userId: string) {
|
|
||||||
delete cloudsByKey.value[makeKey(userId, true)]
|
|
||||||
delete cloudsByKey.value[makeKey(userId, false)]
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updateCloud(userId: string, cloudId: string, patch: {
|
|
||||||
cloud_type_id: number | null
|
|
||||||
custom_cloud_type: string | null
|
|
||||||
latitude: number | null
|
|
||||||
longitude: number | null
|
|
||||||
location_name: string | null
|
|
||||||
description: string | null
|
|
||||||
captured_at: string | null
|
|
||||||
is_hidden: boolean
|
|
||||||
}) {
|
|
||||||
const updated = toProfileCloud(await apiRequest<ApiCloud>(`/clouds/${cloudId}`, {
|
|
||||||
method: 'PATCH',
|
|
||||||
body: patch,
|
|
||||||
}))
|
|
||||||
patchCachedCloud(userId, cloudId, updated)
|
|
||||||
return updated
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updateCloudVisibility(userId: string, cloudId: string, isHidden: boolean) {
|
|
||||||
await apiRequest<ApiCloud>(`/clouds/${cloudId}`, {
|
|
||||||
method: 'PATCH',
|
|
||||||
body: { is_hidden: isHidden },
|
|
||||||
})
|
|
||||||
patchCachedCloud(userId, cloudId, { is_hidden: isHidden })
|
|
||||||
}
|
|
||||||
|
|
||||||
async function deleteClouds(userId: string, cloudIds: string[]) {
|
|
||||||
if (!cloudIds.length) return 0
|
|
||||||
|
|
||||||
if (cloudIds.length === 1) {
|
|
||||||
await apiRequest(`/clouds/${cloudIds[0]}`, { method: 'DELETE' })
|
|
||||||
} else {
|
|
||||||
for (let offset = 0; offset < cloudIds.length; offset += 100) {
|
|
||||||
await apiRequest('/clouds/batch-delete', {
|
|
||||||
method: 'POST',
|
|
||||||
body: { ids: cloudIds.slice(offset, offset + 100) },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
removeCachedClouds(userId, cloudIds)
|
|
||||||
return cloudIds.length
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
getProfile,
|
|
||||||
getClouds,
|
|
||||||
getError,
|
|
||||||
isLoaded,
|
|
||||||
isLoading,
|
|
||||||
fetchProfilePage,
|
|
||||||
invalidateUser,
|
|
||||||
updateCloud,
|
|
||||||
updateCloudVisibility,
|
|
||||||
deleteClouds,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
+19
-20
@@ -1,27 +1,26 @@
|
|||||||
@layer base {
|
@layer base {
|
||||||
html,
|
html,
|
||||||
body,
|
body,
|
||||||
#app {
|
#app {
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
color: var(--oc-color-text);
|
color: var(--oc-color-text);
|
||||||
background:
|
background:
|
||||||
linear-gradient(180deg, rgb(15 23 42 / 2%), rgb(15 23 42 / 0%)),
|
linear-gradient(180deg, rgb(15 23 42 / 2%), rgb(15 23 42 / 0%)), var(--oc-color-canvas);
|
||||||
var(--oc-color-canvas);
|
font-family: var(--oc-font-sans);
|
||||||
font-family: var(--oc-font-sans);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
::selection {
|
::selection {
|
||||||
background: var(--oc-color-selection);
|
background: var(--oc-color-selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@layer utilities {
|
@layer utilities {
|
||||||
/* The atlas language is square by default. Documented exceptions may opt out. */
|
/* The atlas language is square by default. Documented exceptions may opt out. */
|
||||||
[class~='rounded'],
|
[class~='rounded'],
|
||||||
[class*='rounded-'] {
|
[class*='rounded-'] {
|
||||||
border-radius: 0 !important;
|
border-radius: 0 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+594
-263
@@ -1,314 +1,645 @@
|
|||||||
@layer components {
|
@layer components {
|
||||||
/* Application and page structure */
|
/* Application and page structure */
|
||||||
.oc-app-shell {
|
.oc-app-shell {
|
||||||
@apply flex min-h-screen flex-col;
|
@apply flex min-h-screen flex-col;
|
||||||
background: var(--oc-gradient-canvas);
|
background: var(--oc-gradient-canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-app-grid {
|
.oc-app-grid {
|
||||||
@apply pointer-events-none absolute inset-0 opacity-35;
|
@apply pointer-events-none absolute inset-0 opacity-35;
|
||||||
background-image: var(--oc-gradient-grid);
|
background-image: var(--oc-gradient-grid);
|
||||||
background-size: 32px 32px;
|
background-size: 32px 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-page-hero {
|
.oc-page-hero {
|
||||||
@apply border-b border-sky-100;
|
@apply border-b border-sky-100;
|
||||||
background: var(--oc-gradient-page);
|
background: var(--oc-gradient-page);
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-page-hero--soft {
|
.oc-page-hero--soft {
|
||||||
background: var(--oc-gradient-page-soft);
|
background: var(--oc-gradient-page-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-container {
|
.oc-container {
|
||||||
@apply mx-auto w-full px-4 sm:px-6 lg:px-8;
|
@apply mx-auto w-full px-4 sm:px-6 lg:px-8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-container--narrow {
|
.oc-container--narrow {
|
||||||
@apply max-w-4xl;
|
@apply max-w-4xl;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-container--content {
|
.oc-container--content {
|
||||||
@apply max-w-6xl;
|
@apply max-w-6xl;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-container--wide {
|
.oc-container--wide {
|
||||||
@apply max-w-7xl;
|
@apply max-w-7xl;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-page-hero__inner {
|
.oc-page-hero__inner {
|
||||||
@apply py-10;
|
@apply py-10;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-page-content {
|
.oc-page-hero__split {
|
||||||
@apply py-8;
|
@apply grid gap-6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-page-eyebrow {
|
@media (min-width: 900px) {
|
||||||
@apply text-sm font-medium uppercase tracking-[0.24em] text-sky-700;
|
.oc-page-hero__split {
|
||||||
}
|
grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.9fr);
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
.oc-page-title {
|
.oc-page-hero__split--stretch {
|
||||||
@apply mt-3 text-4xl font-bold text-slate-900;
|
align-items: stretch;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.oc-page-description {
|
.oc-page-content {
|
||||||
@apply mt-4 max-w-2xl text-sm leading-7 text-slate-600;
|
@apply py-8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reusable text hierarchy */
|
.oc-page-eyebrow {
|
||||||
.oc-section-label {
|
@apply text-sm font-medium uppercase tracking-[0.24em] text-sky-700;
|
||||||
@apply text-xs uppercase tracking-[0.18em] text-slate-500;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.oc-stat-label {
|
.oc-page-title {
|
||||||
@apply text-xs uppercase tracking-[0.2em] text-slate-500;
|
@apply mt-3 text-4xl font-bold text-slate-900;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-stat-value {
|
.oc-page-description {
|
||||||
@apply mt-2 text-2xl font-bold text-slate-900;
|
@apply mt-4 max-w-2xl text-sm leading-7 text-slate-600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-meta {
|
.oc-brand-mark {
|
||||||
@apply text-sm text-slate-500;
|
@apply flex h-10 w-10 items-center justify-center border border-sky-200 bg-sky-100;
|
||||||
}
|
box-shadow: var(--oc-shadow-sm);
|
||||||
|
}
|
||||||
|
|
||||||
.oc-field-label {
|
/* Reusable text hierarchy */
|
||||||
@apply mb-1 block text-sm font-medium text-slate-700;
|
.oc-section-label {
|
||||||
}
|
@apply text-xs uppercase tracking-[0.18em] text-slate-500;
|
||||||
|
}
|
||||||
|
|
||||||
.oc-field-required {
|
.oc-stat-label {
|
||||||
@apply text-rose-500;
|
@apply text-xs uppercase tracking-[0.2em] text-slate-500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-field-control {
|
.oc-stat-value {
|
||||||
@apply w-full border border-slate-300 bg-white px-3 py-2.5 text-sm text-slate-800 outline-none transition-colors;
|
@apply mt-2 text-2xl font-bold text-slate-900;
|
||||||
@apply focus:border-sky-500 focus:ring-2 focus:ring-sky-100;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.oc-field-error {
|
.oc-meta {
|
||||||
@apply mt-1 text-sm text-rose-600;
|
@apply text-sm text-slate-500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-field-help {
|
.oc-field-label {
|
||||||
@apply mt-1 text-sm text-slate-500;
|
@apply mb-1 block text-sm font-medium text-slate-700;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Surfaces */
|
.oc-field-required {
|
||||||
.oc-panel-card {
|
@apply text-rose-500;
|
||||||
box-shadow: var(--oc-shadow-md) !important;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.oc-panel-card-soft {
|
.oc-field-control {
|
||||||
box-shadow: 6px 6px 0 0 rgb(15 23 42 / 4%) !important;
|
@apply w-full border border-slate-300 bg-white px-3 py-2.5 text-sm text-slate-800 outline-none transition-colors;
|
||||||
}
|
@apply focus:border-sky-500 focus:ring-2 focus:ring-sky-100;
|
||||||
|
}
|
||||||
|
|
||||||
.oc-empty-card {
|
.oc-field-error {
|
||||||
box-shadow: 6px 6px 0 0 rgb(15 23 42 / 4%);
|
@apply mt-1 text-sm text-rose-600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-surface {
|
.oc-field-help {
|
||||||
@apply border border-slate-200 bg-white;
|
@apply mt-1 text-sm text-slate-500;
|
||||||
box-shadow: var(--oc-shadow-md);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.oc-inset-panel {
|
/* Surfaces */
|
||||||
@apply border border-slate-200 bg-slate-50 p-4;
|
.oc-panel-card {
|
||||||
}
|
box-shadow: var(--oc-shadow-md) !important;
|
||||||
|
}
|
||||||
|
|
||||||
.oc-map-button {
|
.oc-panel-card-xl {
|
||||||
@apply flex h-10 w-10 items-center justify-center bg-white shadow-md transition-colors hover:bg-slate-50;
|
box-shadow: var(--oc-shadow-xl) !important;
|
||||||
border-radius: 0.5rem !important;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.oc-system-page {
|
.oc-floating-panel {
|
||||||
@apply flex min-h-[calc(100vh-4rem)] items-center justify-center px-4 py-10;
|
box-shadow: var(--oc-shadow-lg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-system-card {
|
.oc-panel-card-soft {
|
||||||
@apply w-full max-w-2xl border border-slate-200 bg-white px-8 py-14 text-center;
|
box-shadow: 6px 6px 0 0 rgb(15 23 42 / 4%) !important;
|
||||||
box-shadow: var(--oc-shadow-xl);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Naive UI button contract */
|
.oc-empty-card {
|
||||||
.oc-primary-button.n-button,
|
box-shadow: 6px 6px 0 0 rgb(15 23 42 / 4%);
|
||||||
.oc-panel-button.n-button {
|
}
|
||||||
transition:
|
|
||||||
background-color var(--oc-duration-fast) var(--oc-ease-standard),
|
|
||||||
color var(--oc-duration-fast) var(--oc-ease-standard),
|
|
||||||
border-color var(--oc-duration-fast) var(--oc-ease-standard),
|
|
||||||
box-shadow var(--oc-duration-fast) var(--oc-ease-standard),
|
|
||||||
transform var(--oc-duration-fast) var(--oc-ease-standard);
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-primary-button.n-button .n-button__content,
|
.oc-surface {
|
||||||
.oc-panel-button.n-button .n-button__content {
|
@apply border border-slate-200 bg-white;
|
||||||
font-weight: 500;
|
box-shadow: var(--oc-shadow-md);
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-primary-button.n-button .n-button__content {
|
.oc-modal-shell {
|
||||||
letter-spacing: 0.12em;
|
@apply border border-slate-200 bg-white;
|
||||||
}
|
box-shadow: var(--oc-shadow-xl);
|
||||||
|
}
|
||||||
|
|
||||||
.oc-primary-button.n-button:not(.n-button--disabled):hover,
|
.oc-inset-panel {
|
||||||
.oc-panel-button.n-button:not(.n-button--disabled):hover,
|
@apply border border-slate-200 bg-slate-50 p-4;
|
||||||
.oc-panel-button.n-button:focus-visible {
|
}
|
||||||
transform: translate(-1px, -1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-primary-button--teal.n-button {
|
.oc-map-button {
|
||||||
border-color: rgb(153 246 228) !important;
|
@apply flex h-10 w-10 items-center justify-center border border-slate-200 bg-white text-slate-600;
|
||||||
background: rgb(255 255 255) !important;
|
box-shadow: var(--oc-shadow-xs);
|
||||||
color: rgb(17 94 89) !important;
|
}
|
||||||
box-shadow: var(--oc-shadow-teal) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-primary-button--teal.n-button:hover,
|
/* Shared interactive contracts */
|
||||||
.oc-primary-button--teal.n-button:focus-visible {
|
.oc-panel-button:not(.n-button),
|
||||||
border-color: rgb(94 234 212) !important;
|
.oc-header-button,
|
||||||
background: rgb(234 250 245) !important;
|
.oc-icon-button,
|
||||||
color: rgb(19 78 74) !important;
|
.oc-map-button,
|
||||||
}
|
.oc-choice-button,
|
||||||
|
.oc-text-button,
|
||||||
|
.oc-menu-item,
|
||||||
|
.oc-nav-link,
|
||||||
|
.oc-interactive-card {
|
||||||
|
transition:
|
||||||
|
background-color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
border-color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
box-shadow var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
transform var(--oc-duration-fast) var(--oc-ease-standard);
|
||||||
|
}
|
||||||
|
|
||||||
.oc-primary-button--teal.n-button:not(.n-button--disabled):hover {
|
.oc-panel-button:not(.n-button) {
|
||||||
box-shadow: 5px 5px 0 0 rgb(20 184 166 / 14%) !important;
|
@apply inline-flex min-h-9 items-center justify-center border px-3 py-2 text-sm font-medium;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oc-primary-button--sky.n-button {
|
.oc-panel-button:not(.n-button):not(:disabled):hover,
|
||||||
border-color: rgb(186 230 253) !important;
|
.oc-header-button:not(:disabled):hover,
|
||||||
background: rgb(255 255 255) !important;
|
.oc-icon-button:not(:disabled):hover,
|
||||||
color: rgb(7 89 133) !important;
|
.oc-map-button:not(:disabled):hover,
|
||||||
box-shadow: var(--oc-shadow-sky) !important;
|
.oc-choice-button:not(:disabled):hover {
|
||||||
}
|
transform: translate(-1px, -1px);
|
||||||
|
}
|
||||||
|
|
||||||
.oc-primary-button--sky.n-button:hover,
|
.oc-panel-button--neutral:not(.n-button) {
|
||||||
.oc-primary-button--sky.n-button:focus-visible {
|
@apply border-slate-200 bg-white text-slate-600;
|
||||||
border-color: rgb(125 211 252) !important;
|
box-shadow: var(--oc-shadow-xs);
|
||||||
background: rgb(240 249 255) !important;
|
}
|
||||||
color: rgb(12 74 110) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-primary-button--sky.n-button:not(.n-button--disabled):hover {
|
.oc-panel-button--neutral:not(.n-button):hover,
|
||||||
box-shadow: 5px 5px 0 0 rgb(14 165 233 / 18%) !important;
|
.oc-panel-button--neutral:not(.n-button):focus-visible {
|
||||||
}
|
@apply border-teal-200 bg-teal-50 text-teal-800;
|
||||||
|
box-shadow: var(--oc-shadow-primary);
|
||||||
|
}
|
||||||
|
|
||||||
.oc-panel-button.n-button {
|
.oc-panel-button--sky:not(.n-button) {
|
||||||
--n-color: rgb(255 255 255) !important;
|
@apply border-sky-200 bg-sky-100 text-sky-800;
|
||||||
--n-color-hover: rgb(240 253 250) !important;
|
box-shadow: var(--oc-shadow-sky);
|
||||||
--n-color-pressed: rgb(236 253 245) !important;
|
}
|
||||||
--n-border: 1px solid rgb(226 232 240) !important;
|
|
||||||
--n-border-hover: 1px solid rgb(153 246 228) !important;
|
|
||||||
--n-border-pressed: 1px solid rgb(94 234 212) !important;
|
|
||||||
--n-text-color: rgb(71 85 105) !important;
|
|
||||||
--n-text-color-hover: rgb(19 78 74) !important;
|
|
||||||
--n-text-color-pressed: rgb(17 94 89) !important;
|
|
||||||
border-color: rgb(226 232 240) !important;
|
|
||||||
background: rgb(255 255 255) !important;
|
|
||||||
color: rgb(71 85 105) !important;
|
|
||||||
box-shadow: var(--oc-shadow-xs) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-panel-button--neutral.n-button:hover,
|
.oc-panel-button--sky:not(.n-button):hover,
|
||||||
.oc-panel-button--neutral.n-button:focus-visible {
|
.oc-panel-button--sky:not(.n-button):focus-visible {
|
||||||
border-color: rgb(153 246 228) !important;
|
@apply border-sky-300 bg-sky-50 text-sky-900;
|
||||||
background: rgb(240 253 250) !important;
|
box-shadow: 5px 5px 0 0 rgb(14 165 233 / 18%);
|
||||||
color: rgb(19 78 74) !important;
|
}
|
||||||
box-shadow: 4px 4px 0 0 rgb(20 184 166 / 10%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-panel-button--sky.n-button {
|
.oc-panel-button--teal:not(.n-button) {
|
||||||
--n-color: rgb(224 242 254) !important;
|
@apply border-teal-200 bg-teal-50 text-teal-800;
|
||||||
--n-color-hover: rgb(240 249 255) !important;
|
box-shadow: var(--oc-shadow-teal);
|
||||||
--n-color-pressed: rgb(224 242 254) !important;
|
}
|
||||||
--n-border: 1px solid rgb(186 230 253) !important;
|
|
||||||
--n-border-hover: 1px solid rgb(125 211 252) !important;
|
|
||||||
--n-border-pressed: 1px solid rgb(56 189 248) !important;
|
|
||||||
--n-text-color: rgb(7 89 133) !important;
|
|
||||||
--n-text-color-hover: rgb(12 74 110) !important;
|
|
||||||
--n-text-color-pressed: rgb(12 74 110) !important;
|
|
||||||
border-color: rgb(186 230 253) !important;
|
|
||||||
background: rgb(224 242 254) !important;
|
|
||||||
color: rgb(7 89 133) !important;
|
|
||||||
box-shadow: var(--oc-shadow-sky) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-panel-button--sky.n-button:hover,
|
.oc-panel-button--teal:not(.n-button):hover,
|
||||||
.oc-panel-button--sky.n-button:focus-visible {
|
.oc-panel-button--teal:not(.n-button):focus-visible {
|
||||||
border-color: rgb(125 211 252) !important;
|
@apply border-teal-300 bg-teal-100 text-teal-900;
|
||||||
background: rgb(240 249 255) !important;
|
box-shadow: var(--oc-shadow-primary-hover);
|
||||||
color: rgb(12 74 110) !important;
|
}
|
||||||
box-shadow: 5px 5px 0 0 rgb(14 165 233 / 18%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-panel-button--teal.n-button {
|
.oc-panel-button--danger:not(.n-button) {
|
||||||
--n-color: rgb(242 250 247) !important;
|
@apply border-rose-200 bg-rose-50 text-rose-700;
|
||||||
--n-color-hover: rgb(234 250 245) !important;
|
box-shadow: 4px 4px 0 0 rgb(244 63 94 / 10%);
|
||||||
--n-color-pressed: rgb(220 252 231) !important;
|
}
|
||||||
--n-border: 1px solid rgb(153 246 228) !important;
|
|
||||||
--n-border-hover: 1px solid rgb(94 234 212) !important;
|
|
||||||
--n-border-pressed: 1px solid rgb(45 212 191) !important;
|
|
||||||
--n-text-color: rgb(17 94 89) !important;
|
|
||||||
--n-text-color-hover: rgb(19 78 74) !important;
|
|
||||||
--n-text-color-pressed: rgb(19 78 74) !important;
|
|
||||||
border-color: rgb(153 246 228) !important;
|
|
||||||
background: rgb(242 250 247) !important;
|
|
||||||
color: rgb(17 94 89) !important;
|
|
||||||
box-shadow: var(--oc-shadow-teal) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-panel-button--teal.n-button:hover,
|
.oc-panel-button--danger:not(.n-button):hover,
|
||||||
.oc-panel-button--teal.n-button:focus-visible {
|
.oc-panel-button--danger:not(.n-button):focus-visible {
|
||||||
border-color: rgb(94 234 212) !important;
|
@apply border-rose-300 bg-rose-100 text-rose-800;
|
||||||
background: rgb(234 250 245) !important;
|
box-shadow: 5px 5px 0 0 rgb(244 63 94 / 14%);
|
||||||
color: rgb(19 78 74) !important;
|
}
|
||||||
box-shadow: 5px 5px 0 0 rgb(20 184 166 / 14%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-panel-button--danger.n-button {
|
.oc-panel-button--amber:not(.n-button) {
|
||||||
--n-color: rgb(255 241 242) !important;
|
@apply border-amber-200 bg-amber-50 text-amber-800;
|
||||||
--n-color-hover: rgb(255 228 230) !important;
|
box-shadow: 4px 4px 0 0 rgb(245 158 11 / 10%);
|
||||||
--n-color-pressed: rgb(255 228 230) !important;
|
}
|
||||||
--n-border: 1px solid rgb(254 205 211) !important;
|
|
||||||
--n-border-hover: 1px solid rgb(253 164 175) !important;
|
|
||||||
--n-border-pressed: 1px solid rgb(251 113 133) !important;
|
|
||||||
--n-text-color: rgb(190 24 93) !important;
|
|
||||||
--n-text-color-hover: rgb(159 18 57) !important;
|
|
||||||
--n-text-color-pressed: rgb(159 18 57) !important;
|
|
||||||
border-color: rgb(254 205 211) !important;
|
|
||||||
background: rgb(255 241 242) !important;
|
|
||||||
color: rgb(190 24 93) !important;
|
|
||||||
box-shadow: 4px 4px 0 0 rgb(244 63 94 / 10%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-panel-button--danger.n-button:hover,
|
.oc-panel-button--amber:not(.n-button):hover,
|
||||||
.oc-panel-button--danger.n-button:focus-visible {
|
.oc-panel-button--amber:not(.n-button):focus-visible {
|
||||||
border-color: rgb(253 164 175) !important;
|
@apply border-amber-300 bg-amber-100 text-amber-900;
|
||||||
background: rgb(255 228 230) !important;
|
box-shadow: 5px 5px 0 0 rgb(245 158 11 / 14%);
|
||||||
color: rgb(159 18 57) !important;
|
}
|
||||||
box-shadow: 5px 5px 0 0 rgb(244 63 94 / 14%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-panel-button--amber.n-button {
|
.oc-icon-button {
|
||||||
--n-color: rgb(255 251 235) !important;
|
@apply flex h-10 w-10 shrink-0 items-center justify-center border border-slate-200 bg-white text-slate-600;
|
||||||
--n-color-hover: rgb(254 243 199) !important;
|
box-shadow: var(--oc-shadow-xs);
|
||||||
--n-color-pressed: rgb(253 230 138) !important;
|
}
|
||||||
--n-border: 1px solid rgb(253 230 138) !important;
|
|
||||||
--n-border-hover: 1px solid rgb(252 211 77) !important;
|
|
||||||
--n-border-pressed: 1px solid rgb(245 158 11) !important;
|
|
||||||
--n-text-color: rgb(146 64 14) !important;
|
|
||||||
--n-text-color-hover: rgb(120 53 15) !important;
|
|
||||||
--n-text-color-pressed: rgb(120 53 15) !important;
|
|
||||||
border-color: rgb(253 230 138) !important;
|
|
||||||
background: rgb(255 251 235) !important;
|
|
||||||
color: rgb(146 64 14) !important;
|
|
||||||
box-shadow: 4px 4px 0 0 rgb(245 158 11 / 10%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oc-panel-button--amber.n-button:hover,
|
.oc-icon-button:hover,
|
||||||
.oc-panel-button--amber.n-button:focus-visible {
|
.oc-icon-button:focus-visible,
|
||||||
border-color: rgb(252 211 77) !important;
|
.oc-map-button:hover,
|
||||||
background: rgb(254 243 199) !important;
|
.oc-map-button:focus-visible {
|
||||||
color: rgb(120 53 15) !important;
|
@apply border-teal-200 bg-teal-50 text-teal-800;
|
||||||
box-shadow: 5px 5px 0 0 rgb(245 158 11 / 14%) !important;
|
box-shadow: var(--oc-shadow-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.oc-icon-button--small {
|
||||||
|
@apply h-8 w-8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-icon-button--tiny {
|
||||||
|
@apply h-6 w-6 text-xs;
|
||||||
|
box-shadow: 2px 2px 0 0 rgb(15 23 42 / 8%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-icon-button--sky {
|
||||||
|
@apply border-sky-200 bg-sky-50 text-sky-700;
|
||||||
|
box-shadow: 3px 3px 0 0 rgb(14 165 233 / 12%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-icon-button--sky:hover,
|
||||||
|
.oc-icon-button--sky:focus-visible {
|
||||||
|
@apply border-sky-300 bg-sky-100 text-sky-900;
|
||||||
|
box-shadow: 4px 4px 0 0 rgb(14 165 233 / 16%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-icon-button--danger {
|
||||||
|
@apply border-rose-300 bg-rose-500 text-white;
|
||||||
|
box-shadow: 3px 3px 0 0 rgb(159 18 57 / 18%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-icon-button--danger:hover,
|
||||||
|
.oc-icon-button--danger:focus-visible {
|
||||||
|
@apply border-rose-400 bg-rose-600 text-white;
|
||||||
|
box-shadow: 4px 4px 0 0 rgb(159 18 57 / 22%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-overlay-button {
|
||||||
|
@apply flex shrink-0 items-center justify-center text-white/75 hover:bg-white/10 hover:text-white;
|
||||||
|
transition:
|
||||||
|
background-color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
transform var(--oc-duration-fast) var(--oc-ease-standard);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-text-button {
|
||||||
|
@apply inline-flex items-center font-medium text-sky-700 underline-offset-4 hover:text-sky-900 hover:underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-text-button--muted {
|
||||||
|
@apply text-slate-500 hover:text-slate-800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-text-button--danger {
|
||||||
|
@apply text-rose-600 hover:text-rose-800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-choice-button {
|
||||||
|
@apply inline-flex min-h-9 items-center justify-center border px-3 py-2 text-sm font-medium;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-choice-button--inactive {
|
||||||
|
@apply border-slate-200 bg-white text-slate-600 hover:border-teal-200 hover:bg-teal-50 hover:text-teal-800;
|
||||||
|
box-shadow: var(--oc-shadow-xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-choice-button--active {
|
||||||
|
@apply border-teal-200 bg-teal-50 text-teal-800;
|
||||||
|
box-shadow: var(--oc-shadow-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-menu-item {
|
||||||
|
@apply flex w-full items-center gap-3 px-4 py-2.5 text-left text-sm font-medium text-slate-700 hover:bg-teal-50 hover:text-teal-800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-menu-item--danger {
|
||||||
|
@apply text-rose-600 hover:bg-rose-50 hover:text-rose-700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-menu-item--amber {
|
||||||
|
@apply hover:bg-amber-50 hover:text-amber-700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-nav-link {
|
||||||
|
@apply px-3 py-2 text-sm font-medium uppercase tracking-[0.12em];
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-header-button {
|
||||||
|
@apply inline-flex h-8 items-center justify-center border px-3 text-sm font-medium md:h-10 md:px-4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-header-button--neutral {
|
||||||
|
@apply border-slate-200 bg-white/80 text-slate-700 hover:border-teal-200 hover:bg-teal-50 hover:text-teal-800;
|
||||||
|
box-shadow: var(--oc-shadow-xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-header-button--sky {
|
||||||
|
@apply border-sky-200 bg-sky-100 text-sky-800 hover:border-sky-300 hover:bg-sky-50 hover:text-sky-900;
|
||||||
|
box-shadow: var(--oc-shadow-sky);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-header-button--teal {
|
||||||
|
@apply border-teal-100 bg-white/80 text-teal-700 hover:border-teal-200 hover:bg-teal-50 hover:text-teal-800;
|
||||||
|
box-shadow: var(--oc-shadow-teal);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-header-button:hover {
|
||||||
|
box-shadow: 5px 5px 0 0 rgb(15 23 42 / 8%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-interactive-card:focus-visible {
|
||||||
|
@apply outline-none ring-2 ring-sky-600 ring-offset-2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-interactive-card {
|
||||||
|
box-shadow: var(--oc-shadow-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-interactive-card:hover {
|
||||||
|
box-shadow: var(--oc-shadow-lg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-interactive-card--selected {
|
||||||
|
@apply border-sky-500;
|
||||||
|
box-shadow: var(--oc-shadow-sky) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-interactive-row {
|
||||||
|
transition:
|
||||||
|
background-color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
box-shadow var(--oc-duration-fast) var(--oc-ease-standard);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-interactive-row:hover {
|
||||||
|
@apply bg-sky-50/60;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-interactive-row:focus-visible,
|
||||||
|
.oc-heatmap-cell:focus-visible {
|
||||||
|
@apply outline-none ring-2 ring-sky-600 ring-offset-2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-heatmap-cell {
|
||||||
|
transition:
|
||||||
|
border-color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
box-shadow var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
transform var(--oc-duration-fast) var(--oc-ease-standard);
|
||||||
|
}
|
||||||
|
|
||||||
|
:is(
|
||||||
|
.oc-primary-button,
|
||||||
|
.oc-panel-button,
|
||||||
|
.oc-header-button,
|
||||||
|
.oc-icon-button,
|
||||||
|
.oc-overlay-button,
|
||||||
|
.oc-map-button,
|
||||||
|
.oc-choice-button,
|
||||||
|
.oc-text-button,
|
||||||
|
.oc-menu-item,
|
||||||
|
.oc-nav-link
|
||||||
|
):focus-visible {
|
||||||
|
outline: 2px solid rgb(2 132 199);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-overlay-button:focus-visible {
|
||||||
|
outline-color: rgb(125 211 252);
|
||||||
|
}
|
||||||
|
|
||||||
|
:is(
|
||||||
|
.oc-panel-button,
|
||||||
|
.oc-header-button,
|
||||||
|
.oc-icon-button,
|
||||||
|
.oc-map-button,
|
||||||
|
.oc-choice-button
|
||||||
|
):disabled {
|
||||||
|
@apply cursor-not-allowed border-slate-200 bg-slate-100 text-slate-400 shadow-none;
|
||||||
|
transform: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-map-button:disabled {
|
||||||
|
box-shadow: var(--oc-shadow-xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
:is(
|
||||||
|
.oc-panel-button,
|
||||||
|
.oc-primary-button,
|
||||||
|
.oc-header-button,
|
||||||
|
.oc-icon-button,
|
||||||
|
.oc-map-button,
|
||||||
|
.oc-choice-button
|
||||||
|
):not(:disabled):active {
|
||||||
|
transform: translate(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-system-page {
|
||||||
|
@apply flex min-h-[calc(100vh-4rem)] items-center justify-center px-4 py-10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-system-card {
|
||||||
|
@apply w-full max-w-2xl border border-slate-200 bg-white px-8 py-14 text-center;
|
||||||
|
box-shadow: var(--oc-shadow-xl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Naive UI button contract */
|
||||||
|
.oc-primary-button.n-button,
|
||||||
|
.oc-panel-button.n-button {
|
||||||
|
transition:
|
||||||
|
background-color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
border-color var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
box-shadow var(--oc-duration-fast) var(--oc-ease-standard),
|
||||||
|
transform var(--oc-duration-fast) var(--oc-ease-standard);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-primary-button.n-button.n-button--disabled,
|
||||||
|
.oc-panel-button.n-button.n-button--disabled {
|
||||||
|
border-color: rgb(226 232 240) !important;
|
||||||
|
background: rgb(241 245 249) !important;
|
||||||
|
color: var(--oc-color-text-disabled) !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
opacity: 0.72;
|
||||||
|
transform: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-primary-button.n-button .n-button__content,
|
||||||
|
.oc-panel-button.n-button .n-button__content {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-primary-button.n-button .n-button__content {
|
||||||
|
letter-spacing: 0.12em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-primary-button.n-button:not(.n-button--disabled):hover,
|
||||||
|
.oc-panel-button.n-button:not(.n-button--disabled):hover,
|
||||||
|
.oc-panel-button.n-button:focus-visible {
|
||||||
|
transform: translate(-1px, -1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-primary-button--teal.n-button {
|
||||||
|
border-color: var(--color-teal-200) !important;
|
||||||
|
background: white !important;
|
||||||
|
color: var(--color-teal-700) !important;
|
||||||
|
box-shadow: var(--oc-shadow-teal) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-primary-button--teal.n-button:hover,
|
||||||
|
.oc-primary-button--teal.n-button:focus-visible {
|
||||||
|
border-color: var(--color-teal-300) !important;
|
||||||
|
background: var(--color-teal-50) !important;
|
||||||
|
color: var(--color-teal-800) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-primary-button--teal.n-button:not(.n-button--disabled):hover {
|
||||||
|
box-shadow: var(--oc-shadow-primary-hover) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-primary-button--sky.n-button {
|
||||||
|
border-color: rgb(186 230 253) !important;
|
||||||
|
background: rgb(255 255 255) !important;
|
||||||
|
color: rgb(7 89 133) !important;
|
||||||
|
box-shadow: var(--oc-shadow-sky) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-primary-button--sky.n-button:hover,
|
||||||
|
.oc-primary-button--sky.n-button:focus-visible {
|
||||||
|
border-color: rgb(125 211 252) !important;
|
||||||
|
background: rgb(240 249 255) !important;
|
||||||
|
color: rgb(12 74 110) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-primary-button--sky.n-button:not(.n-button--disabled):hover {
|
||||||
|
box-shadow: 5px 5px 0 0 rgb(14 165 233 / 18%) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-panel-button.n-button {
|
||||||
|
--n-color: white !important;
|
||||||
|
--n-color-hover: var(--color-teal-50) !important;
|
||||||
|
--n-color-pressed: var(--color-teal-100) !important;
|
||||||
|
--n-border: 1px solid rgb(226 232 240) !important;
|
||||||
|
--n-border-hover: 1px solid var(--color-teal-200) !important;
|
||||||
|
--n-border-pressed: 1px solid var(--color-teal-300) !important;
|
||||||
|
--n-text-color: rgb(71 85 105) !important;
|
||||||
|
--n-text-color-hover: var(--color-teal-800) !important;
|
||||||
|
--n-text-color-pressed: var(--color-teal-700) !important;
|
||||||
|
border-color: rgb(226 232 240) !important;
|
||||||
|
background: white !important;
|
||||||
|
color: rgb(71 85 105) !important;
|
||||||
|
box-shadow: var(--oc-shadow-xs) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-panel-button--neutral.n-button:hover,
|
||||||
|
.oc-panel-button--neutral.n-button:focus-visible {
|
||||||
|
border-color: var(--color-teal-200) !important;
|
||||||
|
background: var(--color-teal-50) !important;
|
||||||
|
color: var(--color-teal-800) !important;
|
||||||
|
box-shadow: var(--oc-shadow-primary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-panel-button--sky.n-button {
|
||||||
|
--n-color: rgb(224 242 254) !important;
|
||||||
|
--n-color-hover: rgb(240 249 255) !important;
|
||||||
|
--n-color-pressed: rgb(224 242 254) !important;
|
||||||
|
--n-border: 1px solid rgb(186 230 253) !important;
|
||||||
|
--n-border-hover: 1px solid rgb(125 211 252) !important;
|
||||||
|
--n-border-pressed: 1px solid rgb(56 189 248) !important;
|
||||||
|
--n-text-color: rgb(7 89 133) !important;
|
||||||
|
--n-text-color-hover: rgb(12 74 110) !important;
|
||||||
|
--n-text-color-pressed: rgb(12 74 110) !important;
|
||||||
|
border-color: rgb(186 230 253) !important;
|
||||||
|
background: rgb(224 242 254) !important;
|
||||||
|
color: rgb(7 89 133) !important;
|
||||||
|
box-shadow: var(--oc-shadow-sky) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-panel-button--sky.n-button:hover,
|
||||||
|
.oc-panel-button--sky.n-button:focus-visible {
|
||||||
|
border-color: rgb(125 211 252) !important;
|
||||||
|
background: rgb(240 249 255) !important;
|
||||||
|
color: rgb(12 74 110) !important;
|
||||||
|
box-shadow: 5px 5px 0 0 rgb(14 165 233 / 18%) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-panel-button--teal.n-button {
|
||||||
|
--n-color: var(--color-teal-50) !important;
|
||||||
|
--n-color-hover: var(--color-teal-100) !important;
|
||||||
|
--n-color-pressed: var(--color-teal-200) !important;
|
||||||
|
--n-border: 1px solid var(--color-teal-200) !important;
|
||||||
|
--n-border-hover: 1px solid var(--color-teal-300) !important;
|
||||||
|
--n-border-pressed: 1px solid var(--color-teal-400) !important;
|
||||||
|
--n-text-color: var(--color-teal-700) !important;
|
||||||
|
--n-text-color-hover: var(--color-teal-800) !important;
|
||||||
|
--n-text-color-pressed: var(--color-teal-800) !important;
|
||||||
|
border-color: var(--color-teal-200) !important;
|
||||||
|
background: var(--color-teal-50) !important;
|
||||||
|
color: var(--color-teal-700) !important;
|
||||||
|
box-shadow: var(--oc-shadow-teal) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-panel-button--teal.n-button:hover,
|
||||||
|
.oc-panel-button--teal.n-button:focus-visible {
|
||||||
|
border-color: var(--color-teal-300) !important;
|
||||||
|
background: var(--color-teal-100) !important;
|
||||||
|
color: var(--color-teal-800) !important;
|
||||||
|
box-shadow: var(--oc-shadow-primary-hover) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-panel-button--danger.n-button {
|
||||||
|
--n-color: rgb(255 241 242) !important;
|
||||||
|
--n-color-hover: rgb(255 228 230) !important;
|
||||||
|
--n-color-pressed: rgb(255 228 230) !important;
|
||||||
|
--n-border: 1px solid rgb(254 205 211) !important;
|
||||||
|
--n-border-hover: 1px solid rgb(253 164 175) !important;
|
||||||
|
--n-border-pressed: 1px solid rgb(251 113 133) !important;
|
||||||
|
--n-text-color: rgb(190 24 93) !important;
|
||||||
|
--n-text-color-hover: rgb(159 18 57) !important;
|
||||||
|
--n-text-color-pressed: rgb(159 18 57) !important;
|
||||||
|
border-color: rgb(254 205 211) !important;
|
||||||
|
background: rgb(255 241 242) !important;
|
||||||
|
color: rgb(190 24 93) !important;
|
||||||
|
box-shadow: 4px 4px 0 0 rgb(244 63 94 / 10%) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-panel-button--danger.n-button:hover,
|
||||||
|
.oc-panel-button--danger.n-button:focus-visible {
|
||||||
|
border-color: rgb(253 164 175) !important;
|
||||||
|
background: rgb(255 228 230) !important;
|
||||||
|
color: rgb(159 18 57) !important;
|
||||||
|
box-shadow: 5px 5px 0 0 rgb(244 63 94 / 14%) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-panel-button--amber.n-button {
|
||||||
|
--n-color: rgb(255 251 235) !important;
|
||||||
|
--n-color-hover: rgb(254 243 199) !important;
|
||||||
|
--n-color-pressed: rgb(253 230 138) !important;
|
||||||
|
--n-border: 1px solid rgb(253 230 138) !important;
|
||||||
|
--n-border-hover: 1px solid rgb(252 211 77) !important;
|
||||||
|
--n-border-pressed: 1px solid rgb(245 158 11) !important;
|
||||||
|
--n-text-color: rgb(146 64 14) !important;
|
||||||
|
--n-text-color-hover: rgb(120 53 15) !important;
|
||||||
|
--n-text-color-pressed: rgb(120 53 15) !important;
|
||||||
|
border-color: rgb(253 230 138) !important;
|
||||||
|
background: rgb(255 251 235) !important;
|
||||||
|
color: rgb(146 64 14) !important;
|
||||||
|
box-shadow: 4px 4px 0 0 rgb(245 158 11 / 10%) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-panel-button--amber.n-button:hover,
|
||||||
|
.oc-panel-button--amber.n-button:focus-visible {
|
||||||
|
border-color: rgb(252 211 77) !important;
|
||||||
|
background: rgb(254 243 199) !important;
|
||||||
|
color: rgb(120 53 15) !important;
|
||||||
|
box-shadow: 5px 5px 0 0 rgb(245 158 11 / 14%) !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+78
-35
@@ -5,44 +5,87 @@
|
|||||||
* values live here so the Vue and Naive UI layers share one visual contract.
|
* values live here so the Vue and Naive UI layers share one visual contract.
|
||||||
*/
|
*/
|
||||||
:root {
|
:root {
|
||||||
color-scheme: light;
|
color-scheme: light;
|
||||||
|
|
||||||
--oc-font-sans: 'IBM Plex Sans', 'Noto Sans SC', 'PingFang SC', sans-serif;
|
/*
|
||||||
--oc-font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;
|
* Tailwind compatibility palettes.
|
||||||
|
* Existing teal/emerald utilities intentionally resolve to OpenCloud's
|
||||||
|
* fresh eucalyptus and leaf colors instead of Tailwind's vivid defaults.
|
||||||
|
*/
|
||||||
|
--color-teal-50: #f2faf6;
|
||||||
|
--color-teal-100: #ddf2e6;
|
||||||
|
--color-teal-200: #bce4cf;
|
||||||
|
--color-teal-300: #8fceb0;
|
||||||
|
--color-teal-400: #60b18d;
|
||||||
|
--color-teal-500: #438f71;
|
||||||
|
--color-teal-600: #34745d;
|
||||||
|
--color-teal-700: #2d5f4e;
|
||||||
|
--color-teal-800: #274c40;
|
||||||
|
--color-teal-900: #213e35;
|
||||||
|
|
||||||
--oc-color-canvas: #eef4f8;
|
--color-emerald-50: #f4faef;
|
||||||
--oc-color-surface: #ffffff;
|
--color-emerald-100: #e5f3d9;
|
||||||
--oc-color-surface-muted: #f8fafc;
|
--color-emerald-200: #cce7b7;
|
||||||
--oc-color-text: #0f172a;
|
--color-emerald-300: #a8d58d;
|
||||||
--oc-color-text-secondary: #334155;
|
--color-emerald-400: #7fbc63;
|
||||||
--oc-color-text-muted: #64748b;
|
--color-emerald-500: #609d48;
|
||||||
--oc-color-border: #d9e3ee;
|
--color-emerald-600: #4d7f3b;
|
||||||
--oc-color-primary: #0f766e;
|
--color-emerald-700: #3f6633;
|
||||||
--oc-color-primary-hover: #115e59;
|
--color-emerald-800: #35522c;
|
||||||
--oc-color-primary-pressed: #134e4a;
|
--color-emerald-900: #2d4427;
|
||||||
--oc-color-info: #0369a1;
|
|
||||||
--oc-color-success: #0f766e;
|
|
||||||
--oc-color-warning: #d97706;
|
|
||||||
--oc-color-danger: #dc2626;
|
|
||||||
--oc-color-selection: rgb(15 118 110 / 18%);
|
|
||||||
|
|
||||||
--oc-gradient-canvas:
|
--oc-font-sans: 'IBM Plex Sans', 'Noto Sans SC', 'PingFang SC', sans-serif;
|
||||||
radial-gradient(circle at top left, rgb(12 148 136 / 12%), transparent 28%),
|
--oc-font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;
|
||||||
linear-gradient(180deg, #f8fbfd 0%, #eef4f8 100%);
|
|
||||||
--oc-gradient-page: linear-gradient(180deg, #e0f2fe 0%, #f8fafc 100%);
|
|
||||||
--oc-gradient-page-soft: linear-gradient(180deg, #f0fdfa 0%, #f8fafc 100%);
|
|
||||||
--oc-gradient-grid:
|
|
||||||
linear-gradient(rgb(15 23 42 / 3%) 1px, transparent 1px),
|
|
||||||
linear-gradient(90deg, rgb(15 23 42 / 3%) 1px, transparent 1px);
|
|
||||||
|
|
||||||
--oc-shadow-xs: 3px 3px 0 0 rgb(15 23 42 / 6%);
|
--oc-color-canvas: #eef4f8;
|
||||||
--oc-shadow-sm: 4px 4px 0 0 rgb(15 23 42 / 6%);
|
--oc-color-surface: #ffffff;
|
||||||
--oc-shadow-md: 6px 6px 0 0 rgb(15 23 42 / 5%);
|
--oc-color-surface-muted: #f8fafc;
|
||||||
--oc-shadow-lg: 8px 8px 0 0 rgb(15 23 42 / 8%);
|
--oc-color-text: #0f172a;
|
||||||
--oc-shadow-xl: 12px 12px 0 0 rgb(15 23 42 / 8%);
|
--oc-color-text-secondary: #334155;
|
||||||
--oc-shadow-sky: 4px 4px 0 0 rgb(14 165 233 / 14%);
|
--oc-color-text-muted: #64748b;
|
||||||
--oc-shadow-teal: 4px 4px 0 0 rgb(20 184 166 / 10%);
|
--oc-color-text-disabled: #94a3b8;
|
||||||
|
--oc-color-border: #d9e3ee;
|
||||||
|
--oc-color-primary: #34745d;
|
||||||
|
--oc-color-primary-hover: #2d5f4e;
|
||||||
|
--oc-color-primary-pressed: #274c40;
|
||||||
|
--oc-color-info: #0369a1;
|
||||||
|
--oc-color-success: #4d7f3b;
|
||||||
|
--oc-color-warning: #d97706;
|
||||||
|
--oc-color-danger: #dc2626;
|
||||||
|
--oc-color-selection: rgb(52 116 93 / 20%);
|
||||||
|
|
||||||
--oc-duration-fast: 160ms;
|
/* Contribution heatmap: no activity + GitHub-style contribution quartiles. */
|
||||||
--oc-ease-standard: ease;
|
--oc-heatmap-empty: #f1f5f9;
|
||||||
|
--oc-heatmap-empty-border: #d9e3ee;
|
||||||
|
--oc-heatmap-level-1: #ddf2e6;
|
||||||
|
--oc-heatmap-level-1-border: #bce4cf;
|
||||||
|
--oc-heatmap-level-2: #8fceb0;
|
||||||
|
--oc-heatmap-level-2-border: #60b18d;
|
||||||
|
--oc-heatmap-level-3: #438f71;
|
||||||
|
--oc-heatmap-level-3-border: #34745d;
|
||||||
|
--oc-heatmap-level-4: #274c40;
|
||||||
|
--oc-heatmap-level-4-border: #213e35;
|
||||||
|
|
||||||
|
--oc-gradient-canvas:
|
||||||
|
radial-gradient(circle at top left, rgb(52 116 93 / 11%), transparent 28%),
|
||||||
|
linear-gradient(180deg, #f8fbfd 0%, #eef4f8 100%);
|
||||||
|
--oc-gradient-page: linear-gradient(180deg, #e0f2fe 0%, #f8fafc 100%);
|
||||||
|
--oc-gradient-page-soft: linear-gradient(180deg, #f2faf6 0%, #f8fafc 100%);
|
||||||
|
--oc-gradient-grid:
|
||||||
|
linear-gradient(rgb(15 23 42 / 3%) 1px, transparent 1px),
|
||||||
|
linear-gradient(90deg, rgb(15 23 42 / 3%) 1px, transparent 1px);
|
||||||
|
|
||||||
|
--oc-shadow-xs: 3px 3px 0 0 rgb(15 23 42 / 6%);
|
||||||
|
--oc-shadow-sm: 4px 4px 0 0 rgb(15 23 42 / 6%);
|
||||||
|
--oc-shadow-md: 6px 6px 0 0 rgb(15 23 42 / 5%);
|
||||||
|
--oc-shadow-lg: 8px 8px 0 0 rgb(15 23 42 / 8%);
|
||||||
|
--oc-shadow-xl: 12px 12px 0 0 rgb(15 23 42 / 8%);
|
||||||
|
--oc-shadow-sky: 4px 4px 0 0 rgb(14 165 233 / 14%);
|
||||||
|
--oc-shadow-primary: 4px 4px 0 0 rgb(52 116 93 / 14%);
|
||||||
|
--oc-shadow-primary-hover: 5px 5px 0 0 rgb(52 116 93 / 20%);
|
||||||
|
--oc-shadow-amber: 5px 5px 0 0 rgb(245 158 11 / 12%);
|
||||||
|
--oc-shadow-teal: var(--oc-shadow-primary);
|
||||||
|
|
||||||
|
--oc-duration-fast: 160ms;
|
||||||
|
--oc-ease-standard: ease;
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-126
@@ -1,126 +0,0 @@
|
|||||||
declare namespace AMap {
|
|
||||||
class Map {
|
|
||||||
constructor(container: string | HTMLElement, opts?: MapOptions)
|
|
||||||
addControl(control: unknown): void
|
|
||||||
add(layer: unknown): void
|
|
||||||
remove(layer: unknown): void
|
|
||||||
destroy(): void
|
|
||||||
setCenter(center: [number, number]): void
|
|
||||||
setZoom(zoom: number): void
|
|
||||||
setPitch(pitch: number): void
|
|
||||||
getPitch(): number
|
|
||||||
setRotation(rotation: number): void
|
|
||||||
getRotation(): number
|
|
||||||
on(event: string, callback: (...args: unknown[]) => void): void
|
|
||||||
off(event: string, callback: (...args: unknown[]) => void): void
|
|
||||||
getCenter(): { lng: number; lat: number }
|
|
||||||
getZoom(): number
|
|
||||||
getAllOverlays(type?: string): unknown[]
|
|
||||||
addOverlay(overlay: unknown): void
|
|
||||||
removeOverlay(overlay: unknown): void
|
|
||||||
clearMap(): void
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MapOptions {
|
|
||||||
viewMode?: '2D' | '3D'
|
|
||||||
pitch?: number
|
|
||||||
rotation?: number
|
|
||||||
zoom?: number
|
|
||||||
zooms?: [number, number]
|
|
||||||
center?: [number, number]
|
|
||||||
mapStyle?: string
|
|
||||||
features?: string[]
|
|
||||||
layers?: unknown[]
|
|
||||||
skyColor?: string
|
|
||||||
maxPitch?: number
|
|
||||||
resizeEnable?: boolean
|
|
||||||
dragEnable?: boolean
|
|
||||||
zoomEnable?: boolean
|
|
||||||
keyboardEnable?: boolean
|
|
||||||
doubleClickZoom?: boolean
|
|
||||||
scrollWheel?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
class Marker {
|
|
||||||
constructor(opts?: MarkerOptions)
|
|
||||||
on(event: string, callback: (...args: unknown[]) => void): void
|
|
||||||
setPosition(position: [number, number]): void
|
|
||||||
getPosition(): { lng: number; lat: number }
|
|
||||||
setContent(content: string): void
|
|
||||||
setOpacity(opacity: number): void
|
|
||||||
setMap(map: Map | null): void
|
|
||||||
remove(): void
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MarkerOptions {
|
|
||||||
position?: [number, number]
|
|
||||||
content?: string | HTMLElement
|
|
||||||
offset?: Pixel
|
|
||||||
zIndex?: number
|
|
||||||
opacity?: number
|
|
||||||
title?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
class InfoWindow {
|
|
||||||
constructor(opts?: InfoWindowOptions)
|
|
||||||
open(map: Map, position?: [number, number]): void
|
|
||||||
close(): void
|
|
||||||
}
|
|
||||||
|
|
||||||
interface InfoWindowOptions {
|
|
||||||
content?: string | HTMLElement
|
|
||||||
offset?: Pixel
|
|
||||||
size?: Size
|
|
||||||
isCustom?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
class Scale {}
|
|
||||||
class ToolBar {
|
|
||||||
constructor(opts?: Record<string, unknown>)
|
|
||||||
}
|
|
||||||
class ControlBar {
|
|
||||||
constructor(opts?: Record<string, unknown>)
|
|
||||||
}
|
|
||||||
class Geolocation {
|
|
||||||
constructor(opts?: Record<string, unknown>)
|
|
||||||
getCurrentPosition(
|
|
||||||
onSuccess: (data: { position: { lng: number; lat: number } }) => void,
|
|
||||||
onError?: (error: unknown) => void,
|
|
||||||
): void
|
|
||||||
}
|
|
||||||
|
|
||||||
class TileLayer {
|
|
||||||
static Satellite: new () => TileLayer
|
|
||||||
static RoadNet: new () => TileLayer
|
|
||||||
setOpacity(opacity: number): void
|
|
||||||
}
|
|
||||||
|
|
||||||
class Pixel {
|
|
||||||
constructor(x: number, y: number)
|
|
||||||
}
|
|
||||||
|
|
||||||
class Size {
|
|
||||||
constructor(width: number, height: number)
|
|
||||||
}
|
|
||||||
|
|
||||||
class MarkerCluster {
|
|
||||||
constructor(map: Map, markers: Marker[], opts?: Record<string, unknown>)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
declare function AMapLoader_load(opts: {
|
|
||||||
key: string
|
|
||||||
version: string
|
|
||||||
plugins?: string[]
|
|
||||||
}): Promise<typeof AMap>
|
|
||||||
|
|
||||||
declare namespace AMap {
|
|
||||||
function getConfig(): { appname?: string }
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module '@amap/amap-jsapi-loader' {
|
|
||||||
const AMapLoader: {
|
|
||||||
load: typeof AMapLoader_load
|
|
||||||
}
|
|
||||||
export default AMapLoader
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
// Generated from hono-api/src/schemas. Do not edit manually.
|
||||||
|
export type AdminCloudListQuery = {
|
||||||
|
page?: number
|
||||||
|
page_size?: number
|
||||||
|
review_status?: 'pending' | 'approved' | 'rejected'
|
||||||
|
}
|
||||||
|
export type CloudCreateResponse = { message: string; cloud_id: string }
|
||||||
|
export type CloudIdParams = { cloud_id: string }
|
||||||
|
export type CloudIdsBody = { cloud_ids: Array<string> }
|
||||||
|
export type CloudImageParams = {
|
||||||
|
cloud_id: string
|
||||||
|
variant: 'original' | 'preview'
|
||||||
|
}
|
||||||
|
export type CloudListResponse = Array<{
|
||||||
|
id: string
|
||||||
|
owner: { id: string; username: string }
|
||||||
|
cloud_type: {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
genus: string | null
|
||||||
|
icon_id: string | null
|
||||||
|
rarity: number
|
||||||
|
description: string
|
||||||
|
}
|
||||||
|
latitude: number
|
||||||
|
longitude: number
|
||||||
|
description: string | null
|
||||||
|
captured_at: string | null
|
||||||
|
uploaded_at: string
|
||||||
|
updated_at: string
|
||||||
|
received_like_count: number
|
||||||
|
review_status: 'pending' | 'approved' | 'rejected'
|
||||||
|
is_hidden: boolean
|
||||||
|
}>
|
||||||
|
export type CloudMapQuery = {
|
||||||
|
start: string
|
||||||
|
end: string
|
||||||
|
time_field?: 'captured_at' | 'uploaded_at'
|
||||||
|
limit?: number
|
||||||
|
}
|
||||||
|
export type CloudPageResponse = {
|
||||||
|
items: Array<{
|
||||||
|
id: string
|
||||||
|
owner: { id: string; username: string }
|
||||||
|
cloud_type: {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
genus: string | null
|
||||||
|
icon_id: string | null
|
||||||
|
rarity: number
|
||||||
|
description: string
|
||||||
|
}
|
||||||
|
latitude: number
|
||||||
|
longitude: number
|
||||||
|
description: string | null
|
||||||
|
captured_at: string | null
|
||||||
|
uploaded_at: string
|
||||||
|
updated_at: string
|
||||||
|
received_like_count: number
|
||||||
|
review_status: 'pending' | 'approved' | 'rejected'
|
||||||
|
is_hidden: boolean
|
||||||
|
}>
|
||||||
|
page: number
|
||||||
|
page_size: number
|
||||||
|
has_more: boolean
|
||||||
|
}
|
||||||
|
export type CloudResponse = {
|
||||||
|
id: string
|
||||||
|
owner: { id: string; username: string }
|
||||||
|
cloud_type: {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
genus: string | null
|
||||||
|
icon_id: string | null
|
||||||
|
rarity: number
|
||||||
|
description: string
|
||||||
|
}
|
||||||
|
latitude: number
|
||||||
|
longitude: number
|
||||||
|
description: string | null
|
||||||
|
captured_at: string | null
|
||||||
|
uploaded_at: string
|
||||||
|
updated_at: string
|
||||||
|
received_like_count: number
|
||||||
|
review_status: 'pending' | 'approved' | 'rejected'
|
||||||
|
is_hidden: boolean
|
||||||
|
}
|
||||||
|
export type CloudTypeCreateResponse = {
|
||||||
|
message: string
|
||||||
|
cloud_type_id: number
|
||||||
|
}
|
||||||
|
export type CloudTypeIdParams = { cloud_type_id: number }
|
||||||
|
export type CloudTypeResponse = {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
genus: string | null
|
||||||
|
icon_id: string | null
|
||||||
|
rarity: number
|
||||||
|
description: string
|
||||||
|
created_at: string
|
||||||
|
}
|
||||||
|
export type CloudTypeSummary = {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
genus: string | null
|
||||||
|
icon_id: string | null
|
||||||
|
rarity: number
|
||||||
|
description: string
|
||||||
|
}
|
||||||
|
export type CreateCloudTypeBody = {
|
||||||
|
name: string
|
||||||
|
genus?: string | null
|
||||||
|
icon_id?: string | null
|
||||||
|
rarity: number
|
||||||
|
description: string
|
||||||
|
}
|
||||||
|
export type CreateUserBody = {
|
||||||
|
username: string
|
||||||
|
email: string
|
||||||
|
password: string
|
||||||
|
role: 'user' | 'admin'
|
||||||
|
}
|
||||||
|
export type ErrorResponse = {
|
||||||
|
issues?: Array<{ path: string; message: string }>
|
||||||
|
message: string
|
||||||
|
}
|
||||||
|
export type MessageResponse = { message: string }
|
||||||
|
export type PaginationQuery = { page?: number; page_size?: number }
|
||||||
|
export type PublicCloudListQuery = {
|
||||||
|
page?: number
|
||||||
|
page_size?: number
|
||||||
|
filter?: 'type' | 'owner'
|
||||||
|
value?: string
|
||||||
|
}
|
||||||
|
export type ReviewCloudsBody = {
|
||||||
|
cloud_ids: Array<string>
|
||||||
|
review_status: 'approved' | 'rejected'
|
||||||
|
}
|
||||||
|
export type ReviewStatus = 'pending' | 'approved' | 'rejected'
|
||||||
|
export type SetUserPasswordBody = { new_password: string }
|
||||||
|
export type SetUserRoleBody = { role: 'user' | 'admin' }
|
||||||
|
export type UpdateCloudBody = {
|
||||||
|
latitude?: number
|
||||||
|
longitude?: number
|
||||||
|
cloud_type_id?: number
|
||||||
|
description?: string
|
||||||
|
captured_at?: string
|
||||||
|
is_hidden?: boolean
|
||||||
|
}
|
||||||
|
export type UpdateCloudTypeBody = {
|
||||||
|
name?: string
|
||||||
|
genus?: string | null
|
||||||
|
icon_id?: string | null
|
||||||
|
rarity?: number
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
export type UpdateUsernameBody = { username: string }
|
||||||
|
export type UploadCloudForm = {
|
||||||
|
image: File
|
||||||
|
cloud_type_id: number
|
||||||
|
latitude: number
|
||||||
|
longitude: number
|
||||||
|
description?: string
|
||||||
|
captured_at?: string
|
||||||
|
is_hidden: boolean | '0' | '1' | 'true' | 'false'
|
||||||
|
}
|
||||||
|
export type UserIdParams = { user_id: string }
|
||||||
|
export type UserListResponse = Array<{
|
||||||
|
id: string
|
||||||
|
username: string
|
||||||
|
email: string
|
||||||
|
image: string | null
|
||||||
|
cloud_count: number
|
||||||
|
received_like_count: number
|
||||||
|
last_online: string | null
|
||||||
|
role: 'user' | 'admin'
|
||||||
|
is_disabled: boolean
|
||||||
|
created_at: string
|
||||||
|
}>
|
||||||
|
export type UserProfileResponse = {
|
||||||
|
id: string
|
||||||
|
username: string
|
||||||
|
email: string
|
||||||
|
image: string | null
|
||||||
|
cloud_count: number
|
||||||
|
received_like_count: number
|
||||||
|
last_online: string | null
|
||||||
|
role: 'user' | 'admin'
|
||||||
|
is_disabled: boolean
|
||||||
|
created_at: string
|
||||||
|
}
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
import type { Cloud, CloudType, Profile, UserCollection } from '@/types/database'
|
|
||||||
|
|
||||||
export interface AuthUser {
|
|
||||||
id: string
|
|
||||||
email: string
|
|
||||||
email_verified: boolean
|
|
||||||
created_at: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AuthResponse {
|
|
||||||
access_token: string
|
|
||||||
token_type: 'bearer'
|
|
||||||
expires_in: number
|
|
||||||
user: AuthUser
|
|
||||||
profile: Profile
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MeResponse {
|
|
||||||
user: AuthUser
|
|
||||||
profile: Profile
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PublicProfile {
|
|
||||||
id: string
|
|
||||||
username: string
|
|
||||||
avatar_url: string | null
|
|
||||||
created_at: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApiPage<T> {
|
|
||||||
items: T[]
|
|
||||||
page: number
|
|
||||||
page_size: number
|
|
||||||
total: number
|
|
||||||
total_pages: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApiCloudTypeSummary {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
name_en: string
|
|
||||||
rarity: CloudType['rarity']
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApiCloudOwner {
|
|
||||||
id: string
|
|
||||||
username: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApiCloud extends Cloud {
|
|
||||||
updated_at: string
|
|
||||||
cloud_type: ApiCloudTypeSummary | null
|
|
||||||
owner: ApiCloudOwner | null
|
|
||||||
cloud_type_name: string | null
|
|
||||||
cloud_type_rarity: CloudType['rarity'] | null
|
|
||||||
username: string | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApiCollection extends UserCollection {
|
|
||||||
cloud_type: ApiCloudTypeSummary
|
|
||||||
first_cloud: Pick<
|
|
||||||
ApiCloud,
|
|
||||||
'id' | 'image_url' | 'thumbnail_url' | 'captured_at' | 'created_at' | 'location_name'
|
|
||||||
> | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UnlockedBadge {
|
|
||||||
cloud_type_id: number
|
|
||||||
cloud_name: string
|
|
||||||
cloud_name_en: string
|
|
||||||
rarity: CloudType['rarity']
|
|
||||||
unlocked_at: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CloudCreateResponse {
|
|
||||||
cloud: ApiCloud
|
|
||||||
unlocked_badge: UnlockedBadge | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminStats {
|
|
||||||
users: number
|
|
||||||
images: number
|
|
||||||
today_uploads: number
|
|
||||||
pending: number
|
|
||||||
approved: number
|
|
||||||
rejected: number
|
|
||||||
hidden: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminUserItem {
|
|
||||||
user: AuthUser
|
|
||||||
profile: Profile
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
export interface CloudType {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
name_en: string
|
|
||||||
genus: string
|
|
||||||
rarity: 'common' | 'uncommon' | 'rare'
|
|
||||||
description: string | null
|
|
||||||
icon_url: string | null
|
|
||||||
created_at: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Cloud {
|
|
||||||
id: string
|
|
||||||
user_id: string
|
|
||||||
cloud_type_id: number | null
|
|
||||||
custom_cloud_type: string | null
|
|
||||||
image_url: string
|
|
||||||
thumbnail_url: string | null
|
|
||||||
latitude: number | null
|
|
||||||
longitude: number | null
|
|
||||||
location_name: string | null
|
|
||||||
description: string | null
|
|
||||||
captured_at: string | null
|
|
||||||
status: 'pending' | 'approved' | 'rejected'
|
|
||||||
is_hidden: boolean
|
|
||||||
created_at: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Profile {
|
|
||||||
id: string
|
|
||||||
username: string
|
|
||||||
avatar_url: string | null
|
|
||||||
role: 'user' | 'admin'
|
|
||||||
is_disabled: boolean
|
|
||||||
created_at: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UserCollection {
|
|
||||||
id: string
|
|
||||||
user_id: string
|
|
||||||
cloud_type_id: number
|
|
||||||
first_cloud_id: string | null
|
|
||||||
unlocked_at: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Reaction {
|
|
||||||
id: string
|
|
||||||
user_id: string
|
|
||||||
cloud_id: string
|
|
||||||
emoji: string
|
|
||||||
created_at: string
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
export interface CloudType {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
genus: string
|
||||||
|
icon_id: string | null
|
||||||
|
rarity: number
|
||||||
|
description: string | null
|
||||||
|
created_at: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Cloud {
|
||||||
|
id: string
|
||||||
|
user_id: string
|
||||||
|
cloud_type_id: number | null
|
||||||
|
image_url: string
|
||||||
|
thumbnail_url: string | null
|
||||||
|
latitude: number | null
|
||||||
|
longitude: number | null
|
||||||
|
description: string | null
|
||||||
|
captured_at: string | null
|
||||||
|
status: 'pending' | 'approved' | 'rejected'
|
||||||
|
is_hidden: boolean
|
||||||
|
created_at: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Profile {
|
||||||
|
id: string
|
||||||
|
username: string
|
||||||
|
image: string | null
|
||||||
|
role: 'user' | 'admin'
|
||||||
|
is_disabled: boolean
|
||||||
|
created_at: string
|
||||||
|
}
|
||||||
Vendored
+8
-8
@@ -1,12 +1,12 @@
|
|||||||
import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
||||||
|
|
||||||
declare module 'vue-router' {
|
declare module 'vue-router' {
|
||||||
interface RouteMeta {
|
interface RouteMeta {
|
||||||
title?: string | ((route: RouteLocationNormalizedLoaded) => string)
|
title?: string | ((route: RouteLocationNormalizedLoaded) => string)
|
||||||
description?: string | ((route: RouteLocationNormalizedLoaded) => string)
|
description?: string | ((route: RouteLocationNormalizedLoaded) => string)
|
||||||
canonicalPath?: string
|
canonicalPath?: string
|
||||||
noindex?: boolean
|
noindex?: boolean
|
||||||
requiresAuth?: boolean
|
requiresAuth?: boolean
|
||||||
requiresAdmin?: boolean
|
requiresAdmin?: boolean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user