feat: 登录改为 Casdoor 统一身份认证(SSO),重建用户体系
- 移除内置密码注册/登录/改密/删号/头像,统一走 Casdoor OIDC 授权码 - 服务端 casdoor-nodejs-sdk:code 换 token + 证书公钥验签 + get-account 补齐资料 - 用户表重建为 provider+provider_id(Casdoor sub 为准),邮箱不再唯一 - 管理员由 Casdoor token 的 isAdmin/IsAdmin 字段或 admin 角色判定,删除角色切换接口 - 前端登录弹窗改为申统认证跳转,注册去 Casdoor;后台用户列表只读角色 - 会话沿用 an_session httpOnly Cookie,requireUser/requireAdmin 守卫保留 - 配置注入 deploy.sh/.env.example;新增 casdoor 单测,删除 password 单测
This commit is contained in:
@@ -7,7 +7,7 @@ import { getDb } from '../../utils/db'
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const users = getDb()
|
||||
.prepare('SELECT id, username, email, phone, role, created_at AS createdAt FROM users ORDER BY id DESC')
|
||||
.prepare('SELECT id, provider, provider_id, username, email, role, created_at AS createdAt FROM users ORDER BY id DESC')
|
||||
.all()
|
||||
return { users }
|
||||
})
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import { readBody, createError, getRouterParam } from 'h3'
|
||||
import { requireAdmin } from '../../../utils/auth'
|
||||
import { getDb } from '../../../utils/db'
|
||||
import { writeAudit } from '../../../utils/audit'
|
||||
|
||||
/**
|
||||
* 后台更新用户(角色切换)
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const me = requireAdmin(event)
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
const body = await readBody(event)
|
||||
const db = getDb()
|
||||
|
||||
if (me.id === id) {
|
||||
throw createError({ statusCode: 400, message: '不能修改自己的角色', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
const target = db.prepare('SELECT id FROM users WHERE id = ?').get(id)
|
||||
if (!target) {
|
||||
throw createError({ statusCode: 404, message: '用户不存在', data: { code: 'NOT_FOUND' } })
|
||||
}
|
||||
if (body?.role !== undefined) {
|
||||
if (!['user', 'admin'].includes(body.role)) {
|
||||
throw createError({ statusCode: 400, message: '角色不合法', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
db.prepare('UPDATE users SET role = ? WHERE id = ?').run(body.role, id)
|
||||
}
|
||||
writeAudit(event, 'update', `user:${id}`)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -1,55 +0,0 @@
|
||||
import { readMultipartFormData, readBody, createError } from 'h3'
|
||||
import { requireUser, toPublicUser, type UserRow } from '../../utils/auth'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { saveImage, IMAGE_EXT_BY_TYPE, UploadError } from '../../utils/upload'
|
||||
|
||||
/**
|
||||
* 修改头像:
|
||||
* - multipart/form-data(字段 file)-> 上传图片到 OSS/本地,保存 URL
|
||||
* - JSON { clear: true } -> 清除头像(回退默认生成头像)
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = requireUser(event)
|
||||
const db = getDb()
|
||||
const contentType = event.headers.get('content-type') || ''
|
||||
|
||||
if (contentType.includes('multipart/form-data')) {
|
||||
const parts = await readMultipartFormData(event)
|
||||
const file = parts?.find((p) => p.name === 'file' && p.data?.length)
|
||||
if (!file?.data) {
|
||||
throw createError({ statusCode: 400, message: '缺少文件', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
const type = file.type || ''
|
||||
if (!IMAGE_EXT_BY_TYPE[type]) {
|
||||
throw createError({ statusCode: 400, message: '仅支持图片(png/jpg/gif/webp/svg/avif)', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
let url: string
|
||||
try {
|
||||
url = await saveImage(Buffer.from(file.data), type, 'avatars')
|
||||
} catch (err) {
|
||||
if (err instanceof UploadError) {
|
||||
throw createError({ statusCode: 400, message: err.message, data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
throw err
|
||||
}
|
||||
|
||||
db.prepare('UPDATE users SET avatar = ? WHERE id = ?').run(url, user.id)
|
||||
const updated = db
|
||||
.prepare('SELECT id, username, email, phone, avatar, role, created_at FROM users WHERE id = ?')
|
||||
.get(user.id) as UserRow
|
||||
return { ok: true, user: toPublicUser(updated) }
|
||||
}
|
||||
|
||||
// JSON:清除头像
|
||||
const body = await readBody(event).catch(() => ({}))
|
||||
if (body?.clear) {
|
||||
db.prepare('UPDATE users SET avatar = NULL WHERE id = ?').run(user.id)
|
||||
} else {
|
||||
throw createError({ statusCode: 400, message: '请上传图片或传入 clear', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
const updated = db
|
||||
.prepare('SELECT id, username, email, phone, avatar, role, created_at FROM users WHERE id = ?')
|
||||
.get(user.id) as UserRow
|
||||
return { ok: true, user: toPublicUser(updated) }
|
||||
})
|
||||
@@ -0,0 +1,36 @@
|
||||
import { getQuery, getCookie, deleteCookie, createError, sendRedirect } from 'h3'
|
||||
import { exchangeCodeForIdentity, getCasdoorState } from '../../utils/casdoor'
|
||||
import { upsertCasdoorUser, createSession, setSessionCookie } from '../../utils/auth'
|
||||
import { isCasdoorEnabled } from '../../utils/config'
|
||||
|
||||
/**
|
||||
* Casdoor OAuth 回调:
|
||||
* code -> 交换 access_token -> JWT 验签 -> upsert 本地用户 -> 建立会话 -> 回跳。
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
if (!isCasdoorEnabled()) {
|
||||
throw createError({ statusCode: 503, message: '未配置 Casdoor 统一认证', data: { code: 'CASDOOR_NOT_CONFIGURED' } })
|
||||
}
|
||||
|
||||
const query = getQuery(event)
|
||||
const code = String(query?.code ?? '')
|
||||
const state = String(query?.state ?? '')
|
||||
|
||||
// state 校验(SDK 以 appName 为 state;登录端点已写入同值 Cookie)
|
||||
const expectedState = getCasdoorState()
|
||||
if (expectedState && state && state !== expectedState) {
|
||||
throw createError({ statusCode: 400, message: 'state 校验失败', data: { code: 'OAUTH_STATE_MISMATCH' } })
|
||||
}
|
||||
|
||||
const identity = await exchangeCodeForIdentity(code)
|
||||
const user = upsertCasdoorUser(identity)
|
||||
const token = createSession(user.id)
|
||||
setSessionCookie(event, token)
|
||||
|
||||
const cookieNext = getCookie(event, 'an_oauth_next') || '/'
|
||||
const safeNext = cookieNext.startsWith('/') && !cookieNext.startsWith('//') ? cookieNext : '/'
|
||||
deleteCookie(event, 'an_oauth_state', { path: '/' })
|
||||
deleteCookie(event, 'an_oauth_next', { path: '/' })
|
||||
|
||||
return sendRedirect(event, safeNext)
|
||||
})
|
||||
@@ -0,0 +1,26 @@
|
||||
import { getQuery, setCookie, sendRedirect, createError } from 'h3'
|
||||
import { getCasdoorSignInUrl, getCasdoorState } from '../../utils/casdoor'
|
||||
import { isCasdoorEnabled } from '../../utils/config'
|
||||
|
||||
/**
|
||||
* 统一认证入口:跳转到 Casdoor 登录页。
|
||||
* - 记录期望 state 和回跳路径(短时效 Cookie,callback 消费)
|
||||
* - next 仅允许站内相对路径,防开放重定向
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
if (!isCasdoorEnabled()) {
|
||||
throw createError({ statusCode: 503, message: '未配置 Casdoor 统一认证', data: { code: 'CASDOOR_NOT_CONFIGURED' } })
|
||||
}
|
||||
|
||||
const query = getQuery(event)
|
||||
const next = String(query?.next ?? '/')
|
||||
const safeNext = next.startsWith('/') && !next.startsWith('//') ? next : '/'
|
||||
|
||||
setCookie(event, 'an_oauth_state', getCasdoorState(), {
|
||||
path: '/', httpOnly: true, sameSite: 'lax', maxAge: 600,
|
||||
})
|
||||
setCookie(event, 'an_oauth_next', safeNext, {
|
||||
path: '/', httpOnly: true, sameSite: 'lax', maxAge: 600,
|
||||
})
|
||||
return sendRedirect(event, getCasdoorSignInUrl())
|
||||
})
|
||||
@@ -1,30 +0,0 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { verifyPassword, createSession, setSessionCookie, toPublicUser, type UserRow } from '../../utils/auth'
|
||||
|
||||
/**
|
||||
* 登录:账号(用户名或邮箱)+ 密码 -> 校验 -> 建立会话
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event)
|
||||
const account = String(body?.account ?? '').trim()
|
||||
const password = String(body?.password ?? '')
|
||||
|
||||
if (!account || !password) {
|
||||
throw createError({ statusCode: 400, message: '请输入账号与密码', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
const db = getDb()
|
||||
const user = db
|
||||
.prepare('SELECT * FROM users WHERE username = ? OR email = ?')
|
||||
.get(account, account.toLowerCase()) as (UserRow & { password_hash: string }) | undefined
|
||||
|
||||
if (!user || !(await verifyPassword(password, user.password_hash))) {
|
||||
throw createError({ statusCode: 401, message: '账号或密码错误', data: { code: 'INVALID_CREDENTIALS' } })
|
||||
}
|
||||
|
||||
const token = createSession(user.id)
|
||||
setSessionCookie(event, token)
|
||||
|
||||
return { user: toPublicUser(user) }
|
||||
})
|
||||
@@ -1,23 +0,0 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { requireUser, verifyPassword, clearSessionCookie } from '../../utils/auth'
|
||||
|
||||
/**
|
||||
* 自助删除账号(需验证当前密码;删除后登出,级联清理会话/评论/收藏)
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = requireUser(event)
|
||||
const body = await readBody(event)
|
||||
const password = String(body?.password ?? '')
|
||||
|
||||
const row = getDb().prepare('SELECT password_hash FROM users WHERE id = ?').get(user.id) as
|
||||
| { password_hash: string }
|
||||
| undefined
|
||||
if (!row || !(await verifyPassword(password, row.password_hash))) {
|
||||
throw createError({ statusCode: 400, message: '密码不正确', data: { code: 'WRONG_PASSWORD' } })
|
||||
}
|
||||
|
||||
getDb().prepare('DELETE FROM users WHERE id = ?').run(user.id) // 外键级联:sessions/comments/favorites
|
||||
clearSessionCookie(event)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -1,10 +1,10 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { requireUser, toPublicUser, type UserRow } from '../../utils/auth'
|
||||
import { isValidUsername, isValidPhone } from '../../utils/validation'
|
||||
import { isValidUsername } from '../../utils/validation'
|
||||
|
||||
/**
|
||||
* 更新当前用户资料(用户名/手机号)
|
||||
* 更新当前用户资料(仅用户名;邮箱/头像/角色均由 Casdoor 管理)
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = requireUser(event)
|
||||
@@ -25,17 +25,9 @@ export default defineEventHandler(async (event) => {
|
||||
db.prepare('UPDATE users SET username = ? WHERE id = ?').run(username, user.id)
|
||||
}
|
||||
|
||||
if (body?.phone !== undefined) {
|
||||
const phone = String(body.phone).trim()
|
||||
if (!isValidPhone(phone)) {
|
||||
throw createError({ statusCode: 400, message: '手机号格式不正确', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
db.prepare('UPDATE users SET phone = ? WHERE id = ?').run(phone || null, user.id)
|
||||
}
|
||||
|
||||
const updated = db
|
||||
.prepare('SELECT id, username, email, phone, role, created_at FROM users WHERE id = ?')
|
||||
.prepare('SELECT id, provider, provider_id, username, email, avatar, role, created_at FROM users WHERE id = ?')
|
||||
.get(user.id) as UserRow
|
||||
|
||||
return { user: toPublicUser(updated) }
|
||||
})
|
||||
})
|
||||
@@ -1,28 +0,0 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { requireUser, verifyPassword, hashPassword } from '../../utils/auth'
|
||||
import { isValidPassword } from '../../utils/validation'
|
||||
|
||||
/**
|
||||
* 修改密码:校验当前密码 -> 新密码强度 -> 更新
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = requireUser(event)
|
||||
const body = await readBody(event)
|
||||
const currentPassword = String(body?.currentPassword ?? '')
|
||||
const newPassword = String(body?.newPassword ?? '')
|
||||
|
||||
const row = getDb().prepare('SELECT password_hash FROM users WHERE id = ?').get(user.id) as
|
||||
| { password_hash: string }
|
||||
| undefined
|
||||
if (!row || !(await verifyPassword(currentPassword, row.password_hash))) {
|
||||
throw createError({ statusCode: 400, message: '当前密码不正确', data: { code: 'WRONG_PASSWORD' } })
|
||||
}
|
||||
if (!isValidPassword(newPassword)) {
|
||||
throw createError({ statusCode: 400, message: '新密码至少需要 8 位', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
const passwordHash = await hashPassword(newPassword)
|
||||
getDb().prepare('UPDATE users SET password_hash = ? WHERE id = ?').run(passwordHash, user.id)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -1,57 +0,0 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { hashPassword, createSession, setSessionCookie, toPublicUser, type UserRow } from '../../utils/auth'
|
||||
import { isAdminEmail } from '../../utils/config'
|
||||
import { isValidUsername, isValidEmail, isValidPassword, isValidPhone } from '../../utils/validation'
|
||||
|
||||
/**
|
||||
* 注册:校验 -> scrypt 哈希 -> 落库 -> 建立会话
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event)
|
||||
const username = String(body?.username ?? '').trim()
|
||||
const email = String(body?.email ?? '').trim().toLowerCase()
|
||||
const phone = String(body?.phone ?? '').trim()
|
||||
const password = String(body?.password ?? '')
|
||||
|
||||
if (!isValidUsername(username)) {
|
||||
throw createError({ statusCode: 400, message: '用户名需为 2-20 位字符', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
if (!isValidEmail(email)) {
|
||||
throw createError({ statusCode: 400, message: '邮箱格式不正确', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
if (!isValidPassword(password)) {
|
||||
throw createError({ statusCode: 400, message: '密码至少需要 8 位', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
if (phone && !isValidPhone(phone)) {
|
||||
throw createError({ statusCode: 400, message: '手机号格式不正确', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
const db = getDb()
|
||||
const existing = db
|
||||
.prepare('SELECT username, email FROM users WHERE username = ? OR email = ?')
|
||||
.get(username, email) as { username: string; email: string } | undefined
|
||||
|
||||
if (existing) {
|
||||
if (existing.username === username) {
|
||||
throw createError({ statusCode: 400, message: '用户名已被使用', data: { code: 'USERNAME_TAKEN' } })
|
||||
}
|
||||
throw createError({ statusCode: 400, message: '该邮箱已被注册', data: { code: 'EMAIL_TAKEN' } })
|
||||
}
|
||||
|
||||
const passwordHash = await hashPassword(password)
|
||||
// 管理员邮箱白名单命中者自动授予 admin 角色(后续可后台切换)
|
||||
const role = isAdminEmail(email) ? 'admin' : 'user'
|
||||
const info = db
|
||||
.prepare('INSERT INTO users (username, email, phone, password_hash, role) VALUES (?, ?, ?, ?, ?)')
|
||||
.run(username, email, phone || null, passwordHash, role)
|
||||
|
||||
const user = db
|
||||
.prepare('SELECT id, username, email, phone, role, created_at FROM users WHERE id = ?')
|
||||
.get(info.lastInsertRowid) as UserRow
|
||||
|
||||
const token = createSession(user.id)
|
||||
setSessionCookie(event, token)
|
||||
|
||||
return { user: toPublicUser(user) }
|
||||
})
|
||||
+48
-10
@@ -2,15 +2,14 @@ import { randomBytes } from 'node:crypto'
|
||||
import { createError, getCookie, setCookie, deleteCookie } from 'h3'
|
||||
import type { H3Event } from 'h3'
|
||||
import { getDb } from './db'
|
||||
import { hashPassword, verifyPassword } from './password'
|
||||
|
||||
export { hashPassword, verifyPassword }
|
||||
import type { CasdoorIdentity } from './casdoor'
|
||||
|
||||
export interface UserRow {
|
||||
id: number
|
||||
provider: string
|
||||
provider_id: string
|
||||
username: string
|
||||
email: string
|
||||
phone: string | null
|
||||
avatar: string | null
|
||||
role: 'user' | 'admin'
|
||||
created_at: string
|
||||
@@ -34,12 +33,12 @@ export function destroySession(token: string): void {
|
||||
getDb().prepare('DELETE FROM sessions WHERE token = ?').run(token)
|
||||
}
|
||||
|
||||
/** 根据 token 返回有效用户(过期会话返回 null);role 以数据库存储为准(后台可切换) */
|
||||
/** 根据 token 返回有效用户(过期会话返回 null);role 为登录时由 Casdoor claim 快照 */
|
||||
export function getSessionUser(token: string | null): UserRow | null {
|
||||
if (!token) return null
|
||||
const row = getDb()
|
||||
.prepare(
|
||||
`SELECT u.id, u.username, u.email, u.phone, u.avatar, u.role, u.created_at
|
||||
`SELECT u.id, u.provider, u.provider_id, u.username, u.email, u.avatar, u.role, u.created_at
|
||||
FROM sessions s
|
||||
JOIN users u ON u.id = s.user_id
|
||||
WHERE s.token = ? AND s.expires_at > datetime('now')`,
|
||||
@@ -89,23 +88,62 @@ export function clearSessionCookie(event: H3Event): void {
|
||||
deleteCookie(event, SESSION_COOKIE, { path: '/' })
|
||||
}
|
||||
|
||||
/** 返回给前端的脱敏用户对象(含 admin 角色,供个人中心/后台展示) */
|
||||
// ---------- Casdoor 用户映射 ----------
|
||||
|
||||
/**
|
||||
* 按 Casdoor 唯一标识(provider + sub)upsert 本地用户。
|
||||
* - 已存在:刷新资料(姓名/邮箱/头像)与角色快照(角色只从 Casdoor claim 派生)
|
||||
* - 不存在:首次登录自动建号
|
||||
*/
|
||||
export function upsertCasdoorUser(identity: CasdoorIdentity): UserRow {
|
||||
const db = getDb()
|
||||
const role: 'user' | 'admin' = identity.isAdmin ? 'admin' : 'user'
|
||||
|
||||
const existing = db
|
||||
.prepare('SELECT id FROM users WHERE provider = ? AND provider_id = ?')
|
||||
.get(identity.provider, identity.providerId) as { id: number } | undefined
|
||||
|
||||
if (existing) {
|
||||
db.prepare('UPDATE users SET username = ?, email = ?, avatar = ?, role = ? WHERE id = ?').run(
|
||||
identity.username,
|
||||
identity.email,
|
||||
identity.avatar || null,
|
||||
role,
|
||||
existing.id,
|
||||
)
|
||||
} else {
|
||||
db.prepare('INSERT INTO users (provider, provider_id, username, email, avatar, role) VALUES (?, ?, ?, ?, ?, ?)').run(
|
||||
identity.provider,
|
||||
identity.providerId,
|
||||
identity.username,
|
||||
identity.email,
|
||||
identity.avatar || null,
|
||||
role,
|
||||
)
|
||||
}
|
||||
|
||||
return db
|
||||
.prepare('SELECT id, provider, provider_id, username, email, avatar, role, created_at FROM users WHERE provider = ? AND provider_id = ?')
|
||||
.get(identity.provider, identity.providerId) as UserRow
|
||||
}
|
||||
|
||||
/** 返回给前端的脱敏用户对象 */
|
||||
export function toPublicUser(user: UserRow): {
|
||||
id: number
|
||||
providerId: string
|
||||
username: string
|
||||
email: string
|
||||
phone: string | null
|
||||
avatar: string | null
|
||||
role: 'user' | 'admin'
|
||||
createdAt: string
|
||||
} {
|
||||
return {
|
||||
id: user.id,
|
||||
providerId: user.provider_id,
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
phone: user.phone,
|
||||
avatar: user.avatar,
|
||||
role: user.role,
|
||||
createdAt: user.created_at,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
import { SDK } from 'casdoor-nodejs-sdk'
|
||||
import { getConfig } from './config'
|
||||
|
||||
/**
|
||||
* Casdoor 统一认证封装(服务端)。
|
||||
*
|
||||
* - 登录 URL、code->token 交换、JWT 验签全部走官方 casdoor-nodejs-sdk
|
||||
* - 客户端 secret / 证书公钥只存在于服务端环境变量,绝不进入浏览器
|
||||
* - 登录成功后再通过 get-account 补齐邮箱/头像/角色等字段(拿不到也不阻塞登录)
|
||||
*/
|
||||
let _sdk: SDK | null = null
|
||||
let _sdkKey = ''
|
||||
|
||||
function getSDK(): SDK {
|
||||
const { casdoor } = getConfig()
|
||||
const key = [casdoor.serverUrl, casdoor.clientId, casdoor.clientSecret, casdoor.orgName, casdoor.appName, casdoor.certificate].join('|')
|
||||
if (!_sdk || _sdkKey !== key) {
|
||||
_sdk = new SDK({
|
||||
endpoint: casdoor.serverUrl,
|
||||
clientId: casdoor.clientId,
|
||||
clientSecret: casdoor.clientSecret,
|
||||
certificate: casdoor.certificate,
|
||||
orgName: casdoor.orgName,
|
||||
appName: casdoor.appName || undefined,
|
||||
})
|
||||
_sdkKey = key
|
||||
}
|
||||
return _sdk
|
||||
}
|
||||
|
||||
/** 构造 Casdoor 登录授权地址(redirect_uri = 本站回调) */
|
||||
export function getCasdoorSignInUrl(): string {
|
||||
const { casdoor } = getConfig()
|
||||
return getSDK().getSignInUrl(casdoor.redirectUri)
|
||||
}
|
||||
|
||||
/** 构造 Casdoor 注册页地址(在 Casdoor 侧完成注册) */
|
||||
export function getCasdoorSignUpUrl(): string {
|
||||
const { casdoor } = getConfig()
|
||||
return `${casdoor.serverUrl}/signup/${casdoor.appName}`
|
||||
}
|
||||
|
||||
/** 单点登出地址(访问后跳回 redirectUri;未配置则返回空串) */
|
||||
export function getCasdoorLogoutUrl(): string {
|
||||
const { casdoor } = getConfig()
|
||||
if (!casdoor.serverUrl || !casdoor.clientId) return ''
|
||||
return `${casdoor.serverUrl}/logout?client_id=${casdoor.clientId}&redirect_uri=${encodeURIComponent(casdoor.redirectUri)}`
|
||||
}
|
||||
|
||||
/** 登录回调校验的期望 state(casdoor SDK 以 appName 作为 state 返回) */
|
||||
export function getCasdoorState(): string {
|
||||
return getConfig().casdoor.appName
|
||||
}
|
||||
|
||||
export interface CasdoorIdentity {
|
||||
/** 唯一用户标识(Casdoor 用户 UUID,即 JWT 的 sub) */
|
||||
providerId: string
|
||||
provider: string
|
||||
username: string
|
||||
email: string
|
||||
avatar: string
|
||||
isAdmin: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* 交换授权码并验签,返回可落库的身份信息。
|
||||
* @throws 交换失败 / 验签失败 / 缺少 sub
|
||||
*/
|
||||
export async function exchangeCodeForIdentity(code: string): Promise<CasdoorIdentity> {
|
||||
if (!code) {
|
||||
throw new Error('缺少授权码')
|
||||
}
|
||||
const { access_token } = await getSDK().getAuthToken(code)
|
||||
if (!access_token) {
|
||||
throw new Error('Casdoor 未返回 access_token')
|
||||
}
|
||||
|
||||
const claims = getSDK().parseJwtToken(access_token)
|
||||
const account = await getAccountProfile(access_token).catch(() => null)
|
||||
|
||||
const providerId = String(account?.sub || (claims as any).sub || (claims as any).id || '')
|
||||
if (!providerId) {
|
||||
throw new Error('Casdoor token 缺少用户标识(sub)')
|
||||
}
|
||||
|
||||
const username =
|
||||
String(account?.name || (claims as any).name || (claims as any).preferred_username || 'user').trim() ||
|
||||
'user'
|
||||
const email = String(account?.email || (claims as any).email || '').trim().toLowerCase()
|
||||
const avatar = String(account?.avatar || (claims as any).avatar || (claims as any).picture || '').trim()
|
||||
|
||||
return {
|
||||
providerId,
|
||||
provider: 'casdoor',
|
||||
username,
|
||||
email,
|
||||
avatar,
|
||||
isAdmin: isAdminClaim(account) || isAdminClaim(claims),
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员判定:
|
||||
* - token 字段 `IsAdmin` / `isAdmin` 为 true
|
||||
* - roles(对象数组 {name} 或字符串数组)命中 NUXT_CASDOOR_ADMIN_ROLES
|
||||
*/
|
||||
export function isAdminClaim(claims: Record<string, unknown> | undefined | null): boolean {
|
||||
if (!claims) return false
|
||||
if ((claims as any).isAdmin === true || (claims as any).IsAdmin === true) return true
|
||||
|
||||
const { casdoor } = getConfig()
|
||||
const roles = (claims as any).roles
|
||||
if (!Array.isArray(roles) || roles.length === 0) return false
|
||||
const names = roles
|
||||
.map((r: any) => (typeof r === 'string' ? r : r?.name))
|
||||
.filter(Boolean)
|
||||
.map((n: string) => n.toLowerCase())
|
||||
return names.some((n: string) => casdoor.adminRoles.includes(n))
|
||||
}
|
||||
|
||||
/** 通过 get-account 接口补齐完整账号信息(含邮箱/头像/角色);失败不阻塞登录 */
|
||||
async function getAccountProfile(accessToken: string): Promise<Record<string, unknown> | null> {
|
||||
const { casdoor } = getConfig()
|
||||
const url = `${casdoor.serverUrl}/api/get-account?access_token=${encodeURIComponent(accessToken)}`
|
||||
const res = await fetch(url)
|
||||
if (!res.ok) return null
|
||||
const body = (await res.json()) as { status?: string; data?: Record<string, unknown> }
|
||||
if (body?.status !== 'ok') return null
|
||||
return body.data ?? null
|
||||
}
|
||||
+66
-12
@@ -26,9 +26,22 @@ export interface AppConfig {
|
||||
}
|
||||
contactTo: string
|
||||
adminEmails: string[]
|
||||
/** 首次初始化时预置 admin 账号的密码(NUXT_ADMIN_INITIAL_PASSWORD),未设则不预置 */
|
||||
adminInitialPassword: string
|
||||
/** OSS 文件存储(RustFS / S3 v4 兼容) */
|
||||
/** Casdoor 统一认证 */
|
||||
casdoor: {
|
||||
serverUrl: string
|
||||
clientId: string
|
||||
clientSecret: string
|
||||
orgName: string
|
||||
appName: string
|
||||
/** 应用证书公钥 PEM(用于验证 JWT 签名),由 certB64 解码得到 */
|
||||
certificate: string
|
||||
/** 命中任一角色名即管理员 */
|
||||
adminRoles: string[]
|
||||
callbackPath: string
|
||||
/** 完整回调地址(siteUrl + callbackPath),用于 OAuth redirect_uri */
|
||||
redirectUri: string
|
||||
}
|
||||
/** OSS 服务(RustFS / S3 v4 兼容) */
|
||||
oss: {
|
||||
endpoint: string
|
||||
accessKey: string
|
||||
@@ -42,6 +55,15 @@ export interface AppConfig {
|
||||
|
||||
export function getConfig(): AppConfig {
|
||||
const c = useRuntimeConfig()
|
||||
const cfg = _buildConfig(c)
|
||||
// 回调地址依赖 siteUrl,在对象组装完成后补算
|
||||
const siteUrl = String((c.public as { siteUrl?: string })?.siteUrl || '').replace(/\/$/, '')
|
||||
cfg.siteUrl = siteUrl
|
||||
cfg.casdoor.redirectUri = `${siteUrl}${cfg.casdoor.callbackPath}`
|
||||
return cfg
|
||||
}
|
||||
|
||||
function _buildConfig(c: any): AppConfig {
|
||||
return {
|
||||
dbPath: (c.dbPath as string) || '.data/arcticnewone.db',
|
||||
sessionSecret: (c.sessionSecret as string) || '',
|
||||
@@ -57,19 +79,51 @@ export function getConfig(): AppConfig {
|
||||
.split(',')
|
||||
.map((s) => s.trim().toLowerCase())
|
||||
.filter(Boolean),
|
||||
adminInitialPassword: String((c as any).adminInitialPassword || ''),
|
||||
oss: {
|
||||
endpoint: String((c as any).ossEndpoint || '').replace(/^https?:\/\//, '').replace(/\/$/, ''),
|
||||
accessKey: String((c as any).ossAccessKey || ''),
|
||||
secretKey: String((c as any).ossSecretKey || ''),
|
||||
bucket: String((c as any).ossBucket || ''),
|
||||
region: String((c as any).ossRegion || 'us-east-1'),
|
||||
publicBase: String((c as any).ossPublicBase || '').replace(/\/$/, ''),
|
||||
casdoor: {
|
||||
serverUrl: String((c.casdoorServerUrl as string) || '').replace(/\/$/, ''),
|
||||
clientId: String((c.casdoorClientId as string) || ''),
|
||||
clientSecret: String((c.casdoorClientSecret as string) || ''),
|
||||
orgName: String((c.casdoorOrgName as string) || ''),
|
||||
appName: String((c.casdoorAppName as string) || ''),
|
||||
certificate: decodeCert(String((c.casdoorCertB64 as string) || '')),
|
||||
adminRoles: String((c.casdoorAdminRoles as string) || 'admin')
|
||||
.split(',')
|
||||
.map((s) => s.trim().toLowerCase())
|
||||
.filter(Boolean),
|
||||
callbackPath: String((c.casdoorCallbackPath as string) || '/api/auth/callback'),
|
||||
redirectUri: '',
|
||||
},
|
||||
siteUrl: String((c.public as { siteUrl?: string })?.siteUrl || '').replace(/\/$/, ''),
|
||||
oss: {
|
||||
endpoint: String((c.ossEndpoint as string) || '').replace(/^https?:\/\//, '').replace(/\/$/, ''),
|
||||
accessKey: String((c.ossAccessKey as string) || ''),
|
||||
secretKey: String((c.ossSecretKey as string) || ''),
|
||||
bucket: String((c.ossBucket as string) || ''),
|
||||
region: String((c.ossRegion as string) || 'us-east-1'),
|
||||
publicBase: String((c.ossPublicBase as string) || '').replace(/\/$/, ''),
|
||||
},
|
||||
siteUrl: '',
|
||||
}
|
||||
}
|
||||
|
||||
/** 将证书 PEM 以 base64(或原文)传入,统一还原为 PEM 字符串 */
|
||||
function decodeCert(input: string): string {
|
||||
const v = (input || '').trim()
|
||||
if (!v) return ''
|
||||
if (v.includes('BEGIN CERTIFICATE')) return v
|
||||
try {
|
||||
const pem = Buffer.from(v, 'base64').toString('utf-8')
|
||||
return pem.includes('BEGIN CERTIFICATE') ? pem : v
|
||||
} catch {
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
/** Casdoor 配置已就绪(有了 clientId + 服务端地址即可启用统一登录) */
|
||||
export function isCasdoorEnabled(): boolean {
|
||||
const { casdoor } = getConfig()
|
||||
return Boolean(casdoor.serverUrl && casdoor.clientId)
|
||||
}
|
||||
|
||||
/** 判断某邮箱是否在管理员白名单中 */
|
||||
export function isAdminEmail(email: string): boolean {
|
||||
return getConfig().adminEmails.includes(email.toLowerCase())
|
||||
|
||||
+28
-25
@@ -1,7 +1,6 @@
|
||||
import Database from 'better-sqlite3'
|
||||
import { mkdirSync } from 'node:fs'
|
||||
import { dirname } from 'node:path'
|
||||
import { scryptSync, randomBytes } from 'node:crypto'
|
||||
import { getConfig } from './config'
|
||||
import { articlesSeed, worksSeed } from './seed'
|
||||
|
||||
@@ -43,18 +42,34 @@ export function getDb(): Database.Database {
|
||||
}
|
||||
|
||||
function migrate(db: Database.Database): void {
|
||||
// ---- 老库升级:内置密码认证已废弃,改由 Casdoor 统一认证 ----
|
||||
// 旧 users 表含 password_hash(自研密码认证)。检测到即清空用户相关数据并重建:
|
||||
// 账号唯一标识改为 provider + provider_id(Casdoor 的 sub),邮箱仅作资料展示不再唯一。
|
||||
const userCols = db.prepare('PRAGMA table_info(users)').all() as Array<{ name: string }>
|
||||
if (userCols.some((c) => c.name === 'password_hash')) {
|
||||
db.exec(`
|
||||
DROP TABLE IF EXISTS comments;
|
||||
DROP TABLE IF EXISTS favorites;
|
||||
DROP TABLE IF EXISTS sessions;
|
||||
DROP TABLE IF EXISTS users;
|
||||
`)
|
||||
console.log('[db] 检测到旧版内置认证用户表,已重置用户数据(会话/收藏/评论一并清空)')
|
||||
}
|
||||
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
username TEXT NOT NULL UNIQUE,
|
||||
email TEXT NOT NULL UNIQUE,
|
||||
phone TEXT,
|
||||
avatar TEXT,
|
||||
password_hash TEXT NOT NULL,
|
||||
role TEXT NOT NULL DEFAULT 'user',
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
provider TEXT NOT NULL DEFAULT 'casdoor',
|
||||
provider_id TEXT NOT NULL UNIQUE,
|
||||
username TEXT NOT NULL,
|
||||
email TEXT NOT NULL,
|
||||
avatar TEXT,
|
||||
role TEXT NOT NULL DEFAULT 'user',
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_users_provider ON users(provider_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sessions (
|
||||
token TEXT PRIMARY KEY,
|
||||
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
@@ -179,7 +194,6 @@ function migrate(db: Database.Database): void {
|
||||
// 老库迁移:为已存在的表补充新增列(SQLite 不支持 ADD COLUMN IF NOT EXISTS)
|
||||
ensureColumn(db, 'contacts', 'read', 'INTEGER NOT NULL DEFAULT 0')
|
||||
ensureColumn(db, 'subscribers', 'token', 'TEXT')
|
||||
ensureColumn(db, 'users', 'avatar', 'TEXT')
|
||||
}
|
||||
|
||||
/** 若表中缺少某列则补上(用于老库升级) */
|
||||
@@ -191,11 +205,10 @@ function ensureColumn(db: Database.Database, table: string, column: string, ddl:
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化种子数据:内容表为空时灌入 articles/works 种子;
|
||||
* users 为空且配置了 adminInitialPassword 时创建预置管理员。
|
||||
* 初始化种子数据:内容表为空时灌入 articles/works 种子。
|
||||
* 用户账号由 Casdoor 统一认证管理,首次登录时自动建号。
|
||||
*/
|
||||
function seedIfEmpty(db: Database.Database): void {
|
||||
const { adminInitialPassword, adminEmails } = getConfig()
|
||||
|
||||
const articleCount = (db.prepare('SELECT COUNT(*) AS c FROM articles').get() as { c: number }).c
|
||||
if (articleCount === 0) {
|
||||
@@ -233,18 +246,8 @@ function seedIfEmpty(db: Database.Database): void {
|
||||
tx()
|
||||
}
|
||||
|
||||
// 预置管理员(仅当首次初始化且配置了初始密码)
|
||||
const userCount = (db.prepare('SELECT COUNT(*) AS c FROM users').get() as { c: number }).c
|
||||
if (userCount === 0 && adminInitialPassword && adminEmails.length > 0) {
|
||||
const email = adminEmails[0]
|
||||
const username = 'admin'
|
||||
// 与 auth.ts 相同的 salt:hash 存储格式(scrypt)
|
||||
const salt = randomBytes(16).toString('hex')
|
||||
const hash = scryptSync(adminInitialPassword, salt, 64).toString('hex')
|
||||
db.prepare('INSERT INTO users (username, email, password_hash, role) VALUES (?, ?, ?, ?)')
|
||||
.run(username, email, `${salt}:${hash}`, 'admin')
|
||||
console.log('[seed] 已创建预置管理员账号: admin(邮箱 ' + email + ')')
|
||||
}
|
||||
// 注:用户账号已完全交由 Casdoor 统一认证管理,此处不再预置本地 admin。
|
||||
// 用户角色(role)在每次 Casdoor 登录时由 claim 快照。
|
||||
}
|
||||
|
||||
/** 供服务端任意位置安全关闭数据库(测试/热更新用) */
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import { randomBytes, scrypt, timingSafeEqual } from 'node:crypto'
|
||||
import { promisify } from 'node:util'
|
||||
|
||||
/**
|
||||
* 密码哈希/校验(scrypt,盐 + 哈希以冒号分隔存储)。
|
||||
* 独立于 Nuxt/Nitro 依赖,便于单元测试。
|
||||
*/
|
||||
const scryptAsync = promisify(scrypt) as (
|
||||
password: string,
|
||||
salt: string,
|
||||
keylen: number,
|
||||
) => Promise<Buffer>
|
||||
|
||||
export async function hashPassword(password: string): Promise<string> {
|
||||
const salt = randomBytes(16).toString('hex')
|
||||
const key = await scryptAsync(password, salt, 64)
|
||||
return `${salt}:${key.toString('hex')}`
|
||||
}
|
||||
|
||||
export async function verifyPassword(password: string, stored: string): Promise<boolean> {
|
||||
const [salt, hash] = stored.split(':')
|
||||
if (!salt || !hash) return false
|
||||
const key = await scryptAsync(password, salt, 64)
|
||||
const expected = Buffer.from(hash, 'hex')
|
||||
return key.length === expected.length && timingSafeEqual(key, expected)
|
||||
}
|
||||
+26
-56
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* 种子数据(由 scripts/generate-seed.mjs 生成,勿手改)。
|
||||
* 站点初始内容:6 篇动态 + 6 个作品(中英双语)。
|
||||
* 种子数据(站点初始内容,手维护)。
|
||||
* 6 篇动态 + 6 个作品(中英双语);图片留空,由后台 CMS 上传配置。
|
||||
* DB 初始化(migrate)时若对应表为空则自动灌入。
|
||||
*/
|
||||
import type { ArticleBlock } from './db'
|
||||
@@ -91,7 +91,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"contentEn": [
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "In 2026, the design industry is undergoing a profound transformation. From the return of minimalism to the rise of bold typography, from the普及 of 3D elements to the maturity of AI-assisted design, these trends are redefining the boundaries of digital experiences."
|
||||
"text": "In 2026, the design industry is undergoing a profound transformation. From the return of minimalism to the rise of bold typography, from the proliferation of 3D elements to the maturity of AI-assisted design, these trends are redefining the boundaries of digital experiences."
|
||||
},
|
||||
{
|
||||
"type": "heading",
|
||||
@@ -99,7 +99,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
},
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "In an age of information overload, users increasingly渴望 clean, clear interfaces. 2026's minimalism isn't just 'less is more' — it's about delivering more value in limited space through careful information architecture and visual hierarchy."
|
||||
"text": "In an age of information overload, users increasingly crave clean, clear interfaces. 2026's minimalism isn't just 'less is more' — it's about delivering more value in limited space through careful information architecture and visual hierarchy."
|
||||
},
|
||||
{
|
||||
"type": "quote",
|
||||
@@ -122,7 +122,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"text": "AI tools are shifting from 'replacing designers' to 'empowering designers.' Smart layout suggestions, automated color schemes, and real-time design feedback let designers focus on creativity and strategy rather than repetitive execution."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/1/800/500",
|
||||
"image": null,
|
||||
"date": "2026-05-28",
|
||||
"readTime": 5,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -200,10 +200,10 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
},
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "After launch, user停留 time increased by 60%, bounce rate decreased by 35%, and conversion rate improved by 45%."
|
||||
"text": "After launch, user engagement time increased by 60%, bounce rate decreased by 35%, and conversion rate improved by 45%."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/201/800/500",
|
||||
"image": null,
|
||||
"date": "2026-05-15",
|
||||
"readTime": 3,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -284,7 +284,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"text": "We plan to complete 50+ projects and serve 30+ new clients in the coming year while continuing to explore new possibilities."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/164/800/500",
|
||||
"image": null,
|
||||
"date": "2026-05-10",
|
||||
"readTime": 2,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -365,7 +365,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"text": "AI tools help us analyze user feedback more efficiently. Sentiment analysis, topic clustering, and trend prediction help extract valuable insights from massive data."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/180/800/500",
|
||||
"image": null,
|
||||
"date": "2026-04-28",
|
||||
"readTime": 7,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -415,7 +415,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"contentEn": [
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "Bold Moves is an interactive website showcasing innovative architectural designs. This article provides an in-depth look at the design思路, technical implementation, and final results."
|
||||
"text": "Bold Moves is an interactive website showcasing innovative architectural designs. This article provides an in-depth look at the design approach, technical implementation, and final results."
|
||||
},
|
||||
{
|
||||
"type": "heading",
|
||||
@@ -443,10 +443,10 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
},
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "The project received widespread acclaim and won multiple design awards. Average user停留 time exceeded 5 minutes, well above industry average."
|
||||
"text": "The project received widespread acclaim and won multiple design awards. Average user engagement time exceeded 5 minutes, well above industry average."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/119/800/500",
|
||||
"image": null,
|
||||
"date": "2026-04-20",
|
||||
"readTime": 6,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -504,7 +504,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
},
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "We've引入 the latest design collaboration platform supporting real-time multi-person editing, version management, and design system integration."
|
||||
"text": "We've introduced the latest design collaboration platform supporting real-time multi-person editing, version management, and design system integration."
|
||||
},
|
||||
{
|
||||
"type": "quote",
|
||||
@@ -527,7 +527,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"text": "We upgraded our project management platform with new Kanban views, time tracking, and resource allocation features for better project oversight."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/326/800/500",
|
||||
"image": null,
|
||||
"date": "2026-04-12",
|
||||
"readTime": 4,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -559,13 +559,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"E-commerce",
|
||||
"React"
|
||||
],
|
||||
"image": "https://picsum.photos/id/201/1200/800",
|
||||
"gallery": [
|
||||
"https://picsum.photos/id/201/800/600",
|
||||
"https://picsum.photos/id/202/800/600",
|
||||
"https://picsum.photos/id/203/800/600",
|
||||
"https://picsum.photos/id/204/800/600"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
},
|
||||
@@ -592,13 +587,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"Marketing",
|
||||
"UI/UX"
|
||||
],
|
||||
"image": "https://picsum.photos/id/180/1200/800",
|
||||
"gallery": [
|
||||
"https://picsum.photos/id/180/800/600",
|
||||
"https://picsum.photos/id/181/800/600",
|
||||
"https://picsum.photos/id/182/800/600",
|
||||
"https://picsum.photos/id/183/800/600"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
},
|
||||
@@ -625,13 +615,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"Vue.js",
|
||||
"Node.js"
|
||||
],
|
||||
"image": "https://picsum.photos/id/119/1200/800",
|
||||
"gallery": [
|
||||
"https://picsum.photos/id/119/800/600",
|
||||
"https://picsum.photos/id/120/800/600",
|
||||
"https://picsum.photos/id/121/800/600",
|
||||
"https://picsum.photos/id/122/800/600"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
},
|
||||
@@ -658,13 +643,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"3D",
|
||||
"Three.js"
|
||||
],
|
||||
"image": "https://picsum.photos/id/164/1200/800",
|
||||
"gallery": [
|
||||
"https://picsum.photos/id/164/800/600",
|
||||
"https://picsum.photos/id/165/800/600",
|
||||
"https://picsum.photos/id/166/800/600",
|
||||
"https://picsum.photos/id/167/800/600"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
},
|
||||
@@ -691,13 +671,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"Visual Identity",
|
||||
"Corporate"
|
||||
],
|
||||
"image": "https://picsum.photos/id/101/1200/800",
|
||||
"gallery": [
|
||||
"https://picsum.photos/id/101/800/600",
|
||||
"https://picsum.photos/id/102/800/600",
|
||||
"https://picsum.photos/id/103/800/600",
|
||||
"https://picsum.photos/id/104/800/600"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
},
|
||||
@@ -724,13 +699,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"API",
|
||||
"Python"
|
||||
],
|
||||
"image": "https://picsum.photos/id/326/1200/800",
|
||||
"gallery": [
|
||||
"https://picsum.photos/id/326/800/600",
|
||||
"https://picsum.photos/id/327/800/600",
|
||||
"https://picsum.photos/id/328/800/600",
|
||||
"https://picsum.photos/id/329/800/600"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user