diff --git a/code/allapp/allapp-go/api/handler/auth/index.go b/code/allapp/allapp-go/api/handler/auth/index.go
index 8e054841..ad775b09 100644
--- a/code/allapp/allapp-go/api/handler/auth/index.go
+++ b/code/allapp/allapp-go/api/handler/auth/index.go
@@ -12,11 +12,11 @@ import (
"allapp/utils/requestx"
"allapp/utils/responsex"
"allapp/utils/uniqueid"
- "errors"
"fmt"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/client"
+ "github.com/gofiber/fiber/v3/log"
)
// LoginQq qq登录
@@ -48,6 +48,11 @@ func LoginWechat(c fiber.Ctx) error {
openid, accessToken, err := getWechatAccess(dto.Code)
if err != nil {
+ log.Errorw("调用微信 access 接口失败",
+ "code", dto.Code, // 不打印原始 code
+ "error", err.Error(),
+ )
+ fmt.Println(err.Error())
return responsex.Error(c, "微信登录失败,请重试")
}
@@ -68,6 +73,10 @@ func LoginWechat(c fiber.Ctx) error {
// 新用户 → 拉用户信息
nickname, avatar, err := getWechatUserInfo(accessToken, openid)
if err != nil {
+ log.Errorw("调用微信用户信息接口失败",
+ "openid", openid,
+ "error", err,
+ )
return responsex.Error(c, "微信登录失败,请重试")
}
@@ -104,7 +113,7 @@ func getWechatAccess(code string) (openid string, accessToken string, err error)
openid, _ = accessMap["openid"].(string)
if accessToken == "" || openid == "" {
- return "", "", errors.New("获取微信登录凭证失败")
+ return "", "", fmt.Errorf("获取微信登录凭证失败: %s", bodyData)
}
return
diff --git a/code/allapp/allapp-go/api/router/middleware/logger.go b/code/allapp/allapp-go/api/router/middleware/logger.go
index e0b4a4cb..29547e63 100644
--- a/code/allapp/allapp-go/api/router/middleware/logger.go
+++ b/code/allapp/allapp-go/api/router/middleware/logger.go
@@ -20,7 +20,7 @@ func Logger() fiber.Handler {
duration := time.Since(start)
// 记录日志
- log.Infow("API Request",
+ log.WithContext(c.Context()).Infow("API Request",
"method", c.Method(),
"path", c.Path(),
"status", c.Response().StatusCode(),
diff --git a/code/allapp/allapp-go/api/router/middleware/space_guard.go b/code/allapp/allapp-go/api/router/middleware/space_guard.go
index fbf229e9..b05249ca 100644
--- a/code/allapp/allapp-go/api/router/middleware/space_guard.go
+++ b/code/allapp/allapp-go/api/router/middleware/space_guard.go
@@ -17,46 +17,60 @@ const CtxSpaceIDKey = "space_id"
func SpaceGuard() fiber.Handler {
return func(c fiber.Ctx) error {
userID, err := GetUserID(c)
-
if err != nil {
return err
}
spaceIDStr := strings.TrimSpace(c.Get("SPACE_ID"))
-
spaceID, err := strconv.ParseInt(spaceIDStr, 10, 64)
if err != nil || spaceID <= 0 {
return responsex.SpaceError(c, "请选择空间")
}
- // 校验
+ // 1 先查 Redis
inSpace, err := redisx.SpaceIsMember(spaceID, userID)
+ if err != nil {
+ return err
+ }
if inSpace {
+ c.Locals(CtxSpaceIDKey, spaceID)
return c.Next()
}
- // 检验空间是否存在
- space, err := db.Queries.GetSpaceById(c.Context(), spaceID)
-
+ // 2 Redis miss → 查数据库
+ role, err := db.Queries.GetUserSpaceRole(c.Context(), repo.GetUserSpaceRoleParams{
+ SpaceID: spaceID,
+ UserID: userID,
+ })
if err != nil {
if errorx.IsNotFound(err) {
- // 未找到
- return responsex.SpaceError(c, "空间已失效")
+ return responsex.SpaceError(c, "未加入空间")
}
return err
}
- // 空间有效,判断是否在该空间内
- role, err := db.Queries.GetUserSpaceRole(c.Context(), repo.GetUserSpaceRoleParams{
- SpaceID: spaceID,
- UserID: spaceID,
- })
- if err != nil {
- if errorx.IsNotFound(err) {
-
- }
- }
+ // 3 写回 Redis(重建缓存)
+ _ = redisx.SpaceAddOrUpdateMember(spaceID, userID, int(role))
+ c.Locals(CtxSpaceIDKey, spaceID)
+ // 4 放行
+ return c.Next()
}
}
+
+func GetSpaceID(c fiber.Ctx) (int64, error) {
+ v := c.Locals(CtxSpaceIDKey)
+
+ if v == nil {
+ return 0, responsex.SpaceError(c, "空间无效")
+ }
+
+ spaceID, ok := v.(int64)
+
+ if !ok {
+ return 0, responsex.SpaceError(c, "空间无效")
+ }
+
+ return spaceID, nil
+}
diff --git a/code/allapp/allapp-go/api/router/router.go b/code/allapp/allapp-go/api/router/router.go
index 9f098803..fbe86443 100644
--- a/code/allapp/allapp-go/api/router/router.go
+++ b/code/allapp/allapp-go/api/router/router.go
@@ -10,13 +10,22 @@ import (
func SetupRouters(app *fiber.App) {
api := app.Group(config.GetConf().Server.BaseUrl)
- public := api.Group("")
- //private := api.Group("", middleware.Auth())
+ // 1️⃣ 公开接口(无需登录)
+ publicGroup := api.Group("")
+ // 2️⃣ 需要登录
+ //authGroup := api.Group("", middleware.Auth())
+ //
+ //// 3️⃣ 需要登录 + 需要空间
+ //spaceGroup := api.Group("", middleware.Auth(), middleware.SpaceGuard())
+
+ // --------------------
// auth
- authRouter := public.Group("/auth")
+ authRouter := publicGroup.Group("/auth")
authRouter.Post("/login/qq", auth.LoginQq)
authRouter.Post("/login/wechat", auth.LoginWechat)
- // 其他的都带中间件
+ // 示例
+ // authGroup.Get("/user/profile", user.GetProfile)
+ // spaceGroup.Get("/space/info", space.GetInfo)
}
diff --git a/code/allapp/allapp-go/db/queries/user.sql b/code/allapp/allapp-go/db/queries/user.sql
index 4ff21180..1b37fd29 100644
--- a/code/allapp/allapp-go/db/queries/user.sql
+++ b/code/allapp/allapp-go/db/queries/user.sql
@@ -28,4 +28,4 @@ INSERT INTO "user" (
-- name: UpdateUserLastLoginTime :exec
UPDATE "user"
SET last_login_time = NOW()
-WHERE id = $1;
+WHERE id = $1;
\ No newline at end of file
diff --git a/code/allapp/allapp-go/go.mod b/code/allapp/allapp-go/go.mod
index 906cdf48..a1883517 100644
--- a/code/allapp/allapp-go/go.mod
+++ b/code/allapp/allapp-go/go.mod
@@ -3,9 +3,13 @@ module allapp
go 1.25.0
require (
+ github.com/go-playground/validator/v10 v10.30.1
github.com/gofiber/contrib/v3/zap v1.0.0
github.com/gofiber/fiber/v3 v3.1.0
github.com/golang-jwt/jwt/v5 v5.3.1
+ github.com/jackc/pgx/v5 v5.8.0
+ github.com/redis/go-redis/v9 v9.18.0
+ github.com/shopspring/decimal v1.4.0
github.com/spf13/viper v1.21.0
go.uber.org/zap v1.27.1
gopkg.in/natefinch/lumberjack.v2 v2.2.1
@@ -18,17 +22,15 @@ require (
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
- github.com/gabriel-vasile/mimetype v1.4.12 // indirect
+ github.com/gabriel-vasile/mimetype v1.4.13 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
- github.com/go-playground/validator/v10 v10.30.1 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/gofiber/schema v1.7.0 // indirect
github.com/gofiber/utils/v2 v2.0.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
- github.com/jackc/pgx/v5 v5.8.0 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/klauspost/compress v1.18.4 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
@@ -36,9 +38,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
- github.com/redis/go-redis/v9 v9.18.0 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
- github.com/shopspring/decimal v1.4.0 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
diff --git a/code/allapp/allapp-go/go.sum b/code/allapp/allapp-go/go.sum
index 6a22f891..b0e99b7e 100644
--- a/code/allapp/allapp-go/go.sum
+++ b/code/allapp/allapp-go/go.sum
@@ -15,6 +15,8 @@ github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sa
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
+github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
+github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
diff --git a/code/allapp/allapp-go/resources/application.yaml b/code/allapp/allapp-go/resources/application.yaml
index cf8f824b..9dc17fab 100644
--- a/code/allapp/allapp-go/resources/application.yaml
+++ b/code/allapp/allapp-go/resources/application.yaml
@@ -11,6 +11,10 @@ log:
max_age: 7
compress: true
+wechat:
+ app_id: wxdab3e21a1f7e392f
+ app_secret: 0895443c6fedfc21cb92c9cd60de2a26
+
jwt:
secret: 3Bde3BGEbYqtqyEUzW3ry8jKFcaPH17fRmTmqE7MDr05Lwj95uruRKrrkb44TJ4s
access_expiry: -1
\ No newline at end of file
diff --git a/code/allapp/allapp-go/utils/redisx/helper.go b/code/allapp/allapp-go/utils/redisx/helper.go
index 54d07c68..fb8b655e 100644
--- a/code/allapp/allapp-go/utils/redisx/helper.go
+++ b/code/allapp/allapp-go/utils/redisx/helper.go
@@ -68,22 +68,6 @@ func SpaceIsMember(spaceID int64, userID int64) (bool, error) {
return ok, err
}
-// SpaceInitMembers 初始化用户成员
-func SpaceInitMembers(spaceID int64, members map[int64]int) error {
- key := spaceMemberKey(spaceID)
-
- data := make(map[string]interface{})
- for userID, role := range members {
- data[strconv.FormatInt(userID, 10)] = role
- }
-
- return Client.HSet(
- context.Background(),
- key,
- data,
- ).Err()
-}
-
// SpaceDelete 删除空间
func SpaceDelete(spaceID int64) error {
key := spaceMemberKey(spaceID)
diff --git a/code/allapp/allapp-go/utils/responsex/index.go b/code/allapp/allapp-go/utils/responsex/index.go
index 4201d36c..80a0a5c3 100644
--- a/code/allapp/allapp-go/utils/responsex/index.go
+++ b/code/allapp/allapp-go/utils/responsex/index.go
@@ -7,7 +7,7 @@ type Result struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
- TrackId string `json:"trackId,omitempty"`
+ TrackId string `json:"track_id,omitempty"`
}
// 业务码
diff --git a/code/allapp/allapp-rn/src/app/(tabs)/index.tsx b/code/allapp/allapp-rn/src/app/(tabs)/index.tsx
index dc0f8167..140dd8c8 100644
--- a/code/allapp/allapp-rn/src/app/(tabs)/index.tsx
+++ b/code/allapp/allapp-rn/src/app/(tabs)/index.tsx
@@ -21,15 +21,31 @@ export default function Index() {
- 记录生活,记录情绪,也记录每一笔重要的支出
+ 记录生活,记录情绪
- router.replace('/money')}
>
开始使用
-
+ */}
+
+ router.replace('/money')}
+ >
+ 创建空间
+
+ router.replace('/money')}
+ >
+ 加入空间
+
+
+
)
diff --git a/code/allapp/allapp-rn/src/app/(tabs)/user/index.tsx b/code/allapp/allapp-rn/src/app/(tabs)/user/index.tsx
index d3f4bfcf..84cecaa6 100644
--- a/code/allapp/allapp-rn/src/app/(tabs)/user/index.tsx
+++ b/code/allapp/allapp-rn/src/app/(tabs)/user/index.tsx
@@ -10,7 +10,7 @@ import ListItem from './components/ListItem'
export default function User() {
const userStore = useUserStore()
-
+ console.log(userStore.userInfo)
return (
@@ -20,7 +20,7 @@ export default function User() {
source={{ uri: userStore.userInfo?.avatar }}
/>
- {userStore.userInfo?.username}
+ {userStore.userInfo?.nickname}
diff --git a/code/allapp/allapp-rn/src/app/auth/index.tsx b/code/allapp/allapp-rn/src/app/auth/index.tsx
index ca096122..c5ccdb11 100644
--- a/code/allapp/allapp-rn/src/app/auth/index.tsx
+++ b/code/allapp/allapp-rn/src/app/auth/index.tsx
@@ -1,7 +1,7 @@
import { useEvent } from 'expo'
-// import ExpoQQ from 'expo-qq'
+import ExpoQQ from 'expo-qq'
import { useRouter } from 'expo-router'
-// import ExpoWeChat from 'expo-wechat'
+import ExpoWeChat from 'expo-wechat'
import { useEffect, useState } from 'react'
import { Image, Text, View } from 'react-native'
import { AButton, ACheckbox } from '@/components/common/ao'
@@ -25,176 +25,174 @@ export default function Auth() {
const userStore = useUserStore()
const appStore = useAppStore()
- // const onLoginFinished = useEvent(ExpoQQ, 'onLoginFinished')
- // const onGetUserInfo = useEvent(ExpoQQ, 'onGetUserInfo')
- // const authResult = useEvent(ExpoWeChat, 'onAuthResult')
+ const onLoginFinished = useEvent(ExpoQQ, 'onLoginFinished')
+ const onGetUserInfo = useEvent(ExpoQQ, 'onGetUserInfo')
+ const authResult = useEvent(ExpoWeChat, 'onAuthResult')
- // async function onQQLogin() {
- // setLoading(true)
- // setForm(val => ({
- // ...val,
- // type: 1,
- // }))
- // await ExpoQQ.login(['get_user_info'])
- // }
-
- // async function onWeChatLogin() {
- // setLoading(true)
-
- // // 检查微信是否安装
- // const isInstalled = await ExpoWeChat.isWXAppInstalled()
- // if (!isInstalled) {
- // toast.show({
- // title: onLoginFinished?.errorMessage || '请先安装微信',
- // })
- // setLoading(false)
- // return
- // }
-
- // setForm(val => ({
- // ...val,
- // type: 0,
- // }))
-
- // ExpoWeChat.sendAuthRequest('snsapi_userinfo', 'state123')
- // }
-
- // useEffect(() => {
- // ExpoQQ.init('102826474', '')
- // ExpoWeChat.registerApp('wxdab3e21a1f7e392f', '')
- // }, [])
-
- // useEffect(() => {
- // if (!onLoginFinished) {
- // return
- // }
-
- // if (!onLoginFinished.success) {
- // toast.show({
- // title: onLoginFinished?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权',
- // })
- // setLoading(false)
- // return
- // }
-
- // const fetchUserInfo = async () => {
- // try {
- // const tokenInfo = await ExpoQQ.getLoginTokenInfo()
- // if (!tokenInfo.openId) {
- // toast.show({
- // title: tokenInfo?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权',
- // })
- // setLoading(false)
- // return
- // }
-
- // setForm(val => ({
- // ...val,
- // openid: String(tokenInfo.openId),
- // }))
-
- // await ExpoQQ.sendGetUserInfoReq()
- // }
- // catch (e) {
- // console.error('QQ 登录未完成', e)
- // setLoading(false)
- // }
- // }
-
- // fetchUserInfo()
- // }, [onLoginFinished])
-
- // // QQ登录
- // useEffect(() => {
- // const handleLogin = async () => {
- // if (!onGetUserInfo)
- // return
-
- // try {
- // const loginRes = await loginQqApi({
- // openid: form.openid,
- // username: onGetUserInfo.nickname || '',
- // avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2,
- // })
-
- // if (loginRes.isSuccess) {
- // userStore.setUserInfo({
- // token: loginRes.data.token,
- // id: loginRes.data.userId,
- // username: loginRes.data.username,
- // avatar: loginRes.data.avatar,
- // })
-
- // console.log(loginRes.data.token)
-
- // router.push('/')
- // }
- // }
- // catch (err) {
- // console.error('登录接口出错', err)
- // }
- // finally {
- // setLoading(false)
- // }
- // }
-
- // handleLogin()
- // }, [onGetUserInfo])
-
- // // 微信登录
- // useEffect(() => {
- // if (!authResult)
- // return
-
- // const handleLogin = async () => {
- // if (authResult.errorCode === 0) {
- // try {
- // const loginRes = await loginWxApi({
- // code: authResult.code,
- // })
-
- // if (loginRes.isSuccess) {
- // userStore.setUserInfo({
- // token: loginRes.data.token,
- // id: loginRes.data.userId,
- // username: loginRes.data.username,
- // avatar: loginRes.data.avatar,
- // })
-
- // router.push('/')
- // }
- // }
- // catch (err) {
- // console.error('登录接口出错', err)
- // }
- // finally {
- // setLoading(false)
- // }
- // }
- // else {
- // console.log('授权失败:', authResult.errorMessage)
- // setLoading(false)
- // }
- // }
-
- // handleLogin()
- // }, [authResult])
-
- function testLogin() {
- // eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NjY3ODU5ODIxNjUwNjEsImlhdCI6MTc2OTM0ODI0Nn0.17ZNaHD3HSLM8dVn_JQK-gvsG9MKj47IRYV9D4xZkzs
-
- userStore.setUserInfo({
- token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3Njc4NjM3NTU5MzE3MTcsImlhdCI6MTc2OTYwMzEzOX0.xfW-uyFBi799u4VJ-93A88c2CC8jwpYOPsALUuaIizg',
- id: 767863755931717,
- username: 'Zhang',
- avatar: 'http://thirdqq.qlogo.cn/ek_qqapp/AQHVialeUibE42oV8RvTTVZ4tyRlPYeJrUibWTwtCPfV68E4rSzn9cw00GkXQ3QDTiawwhjoqQb7/100',
- })
-
- appStore.init()
-
- router.push('/')
+ async function onQQLogin() {
+ setLoading(true)
+ setForm(val => ({
+ ...val,
+ type: 1,
+ }))
+ await ExpoQQ.login(['get_user_info'])
}
+ async function onWeChatLogin() {
+ setLoading(true)
+
+ // 检查微信是否安装
+ const isInstalled = await ExpoWeChat.isWXAppInstalled()
+ if (!isInstalled) {
+ toast.show({
+ title: onLoginFinished?.errorMessage || '请先安装微信',
+ })
+ setLoading(false)
+ return
+ }
+
+ setForm(val => ({
+ ...val,
+ type: 0,
+ }))
+
+ ExpoWeChat.sendAuthRequest('snsapi_userinfo', 'state123')
+ }
+
+ useEffect(() => {
+ ExpoQQ.init('102826474', '')
+ ExpoWeChat.registerApp('wxdab3e21a1f7e392f', '')
+ }, [])
+
+ useEffect(() => {
+ if (!onLoginFinished) {
+ return
+ }
+
+ if (!onLoginFinished.success) {
+ toast.show({
+ title: onLoginFinished?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权',
+ })
+ setLoading(false)
+ return
+ }
+
+ const fetchUserInfo = async () => {
+ try {
+ const tokenInfo = await ExpoQQ.getLoginTokenInfo()
+ if (!tokenInfo.openId) {
+ toast.show({
+ title: tokenInfo?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权',
+ })
+ setLoading(false)
+ return
+ }
+
+ setForm(val => ({
+ ...val,
+ openid: String(tokenInfo.openId),
+ }))
+
+ await ExpoQQ.sendGetUserInfoReq()
+ }
+ catch (e) {
+ console.error('QQ 登录未完成', e)
+ setLoading(false)
+ }
+ }
+
+ fetchUserInfo()
+ }, [onLoginFinished])
+
+ // QQ登录
+ useEffect(() => {
+ const handleLogin = async () => {
+ if (!onGetUserInfo)
+ return
+
+ try {
+ const loginRes = await loginQqApi({
+ openid: form.openid,
+ nickname: onGetUserInfo.nickname || '',
+ avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2,
+ })
+
+ if (loginRes.isSuccess) {
+ userStore.setUserInfo({
+ token: loginRes.data.token,
+ id: loginRes.data.userId,
+ nickname: loginRes.data.nickname,
+ avatar: loginRes.data.avatar,
+ })
+
+ router.push('/auth/space')
+ }
+ }
+ catch (err) {
+ console.error('登录接口出错', err)
+ }
+ finally {
+ setLoading(false)
+ }
+ }
+
+ handleLogin()
+ }, [onGetUserInfo])
+
+ // 微信登录
+ useEffect(() => {
+ if (!authResult)
+ return
+
+ const handleLogin = async () => {
+ if (authResult.errorCode === 0) {
+ try {
+ const loginRes = await loginWxApi({
+ code: authResult.code,
+ })
+
+ if (loginRes.isSuccess) {
+ userStore.setUserInfo({
+ token: loginRes.data.token,
+ id: loginRes.data.userId,
+ nickname: loginRes.data.nickname,
+ avatar: loginRes.data.avatar,
+ })
+
+ router.push('/')
+ }
+ }
+ catch (err) {
+ console.error('登录接口出错', err)
+ }
+ finally {
+ setLoading(false)
+ }
+ }
+ else {
+ console.log('授权失败:', authResult.errorMessage)
+ setLoading(false)
+ }
+ }
+
+ handleLogin()
+ }, [authResult])
+
+ // function testLogin() {
+ // // eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NjY3ODU5ODIxNjUwNjEsImlhdCI6MTc2OTM0ODI0Nn0.17ZNaHD3HSLM8dVn_JQK-gvsG9MKj47IRYV9D4xZkzs
+
+ // userStore.setUserInfo({
+ // token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NzgxMTUwMzIxMDA5MzMsImlhdCI6MTc3MjExMDQ5N30.Ab7_YNwftJigktnPt8f-FwwcLeS45CkrH0jT2jLjRtA',
+ // id: 778115032100933,
+ // nickname: 'Zhang',
+ // avatar: 'http://thirdqq.qlogo.cn/ek_qqapp/AQHVialeUibE42oV8RvTTVZ4tyRlPYeJrUibWTwtCPfV68E4rSzn9cw00GkXQ3QDTiawwhjoqQb7/100',
+ // })
+
+ // appStore.init()
+
+ // router.push('/')
+ // }
+
return (
- {/*
}
@@ -231,7 +229,7 @@ export default function Auth() {
onPress={onQQLogin}
>
QQ
- */}
+
}
loading={loading}
- onPress={testLogin}
+ // onPress={testLogin}
>
模拟登录
diff --git a/code/allapp/allapp-rn/src/app/auth/space.tsx b/code/allapp/allapp-rn/src/app/auth/space.tsx
new file mode 100644
index 00000000..786c9ad7
--- /dev/null
+++ b/code/allapp/allapp-rn/src/app/auth/space.tsx
@@ -0,0 +1,61 @@
+import { Text, View } from 'react-native'
+import { AButton, LucideIcon } from '@/components/common/ao'
+import EmptyState from '@/components/common/EmptyStatus'
+import CustomHeader from '@/components/custom/Header'
+
+// name renshu
+
+export default function AuthSpace() {
+ return (
+
+
+
+
+ 你的空间
+ 选择要进入的空间
+
+
+
+ {/*
+
+ */}
+
+
+
+
+
+
+
+
+
+
+ A 的空间
+
+ 张三 · 8 名成员
+
+
+
+
+
+
+
+
+
+
+
+ 创建新空间
+ 加入其他空间
+
+
+
+ )
+}
diff --git a/code/allapp/allapp-rn/src/components/common/EmptyStatus.tsx b/code/allapp/allapp-rn/src/components/common/EmptyStatus.tsx
index f7012074..68d4669c 100644
--- a/code/allapp/allapp-rn/src/components/common/EmptyStatus.tsx
+++ b/code/allapp/allapp-rn/src/components/common/EmptyStatus.tsx
@@ -39,7 +39,7 @@ export default function EmptyState({
{image ?? defaultImages[type]}
{title && (
- {title}
+ {title}
)}
{description && (
diff --git a/code/allapp/allapp-rn/src/components/common/ao/LucideIcon.tsx b/code/allapp/allapp-rn/src/components/common/ao/LucideIcon.tsx
index 48a95f1b..337466c8 100644
--- a/code/allapp/allapp-rn/src/components/common/ao/LucideIcon.tsx
+++ b/code/allapp/allapp-rn/src/components/common/ao/LucideIcon.tsx
@@ -12,6 +12,7 @@ export interface LucideIconProps {
style?: ViewStyle
clickable?: boolean
className?: string
+ fill?: string
}
export default function LucideIcon({
@@ -22,6 +23,7 @@ export default function LucideIcon({
onPress,
style,
clickable = true,
+ fill = 'none',
className,
}: LucideIconProps) {
const IconComponent = icons[icon]
@@ -30,12 +32,12 @@ export default function LucideIcon({
return null
if (!clickable) {
- return
+ return
}
return (
-
+
)
}
diff --git a/code/allapp/allapp-rn/src/request/api/auth.ts b/code/allapp/allapp-rn/src/request/api/auth.ts
index 4c29e034..e28348a8 100644
--- a/code/allapp/allapp-rn/src/request/api/auth.ts
+++ b/code/allapp/allapp-rn/src/request/api/auth.ts
@@ -8,5 +8,5 @@ export function loginQqApi(params: LoginQqParams) {
}
export function loginWxApi(params: LoginWxParams) {
- return alovaInstance.Post>(`${API_PREFIX}/login/wx`, params)
+ return alovaInstance.Post>(`${API_PREFIX}/login/wechat`, params)
}
diff --git a/code/allapp/allapp-rn/src/request/index.ts b/code/allapp/allapp-rn/src/request/index.ts
index 1288fff7..2d25f23a 100644
--- a/code/allapp/allapp-rn/src/request/index.ts
+++ b/code/allapp/allapp-rn/src/request/index.ts
@@ -7,7 +7,7 @@ import { useUserStore } from '@/store/user'
import { toast } from '@/utils/toast'
enum HttpCode {
- Success = 200,
+ Success = 1000,
Unauthorized = 401,
Fail = 500,
}
diff --git a/code/allapp/allapp-rn/src/store/navigation.ts b/code/allapp/allapp-rn/src/store/navigation.ts
index 20739a16..6f0b86ce 100644
--- a/code/allapp/allapp-rn/src/store/navigation.ts
+++ b/code/allapp/allapp-rn/src/store/navigation.ts
@@ -23,6 +23,7 @@ const DEFAULT_NAV_MENUS: NavItem[] = [
{ label: '恋爱记', path: '/love', icon: 'Heart' },
{ label: '聊天', path: '/chat', icon: 'MessageCircle' },
{ label: '个人中心', path: '/user', icon: 'CircleUserRound' },
+ { label: '我的空间', path: '/auth/space', icon: 'Earth' },
]
export const useNavStore = create()(
@@ -43,7 +44,7 @@ export const useNavStore = create()(
}),
{
name: 'nav-storage',
- storage: createJSONStorage(() => AsyncStorage),
+ // storage: createJSONStorage(() => AsyncStorage),
},
),
)
diff --git a/code/allapp/allapp-rn/src/types/auth.ts b/code/allapp/allapp-rn/src/types/auth.ts
index 18512d35..844731a9 100644
--- a/code/allapp/allapp-rn/src/types/auth.ts
+++ b/code/allapp/allapp-rn/src/types/auth.ts
@@ -1,6 +1,6 @@
export interface LoginQqParams {
openid: string
- username: string
+ nickname: string
avatar: string
}
@@ -11,6 +11,6 @@ export interface LoginWxParams {
export interface LoginResult {
token: string
userId: number
- username: string
+ nickname: string
avatar: string
}
diff --git a/code/allapp/allapp-rn/src/types/global.d.ts b/code/allapp/allapp-rn/src/types/global.d.ts
index c8cf6723..a4607141 100644
--- a/code/allapp/allapp-rn/src/types/global.d.ts
+++ b/code/allapp/allapp-rn/src/types/global.d.ts
@@ -2,7 +2,7 @@ export {}
declare global {
interface ResponseData {
- trackId: string
+ track_id: string
code: number
message: string
data: T
@@ -12,14 +12,13 @@ declare global {
interface UserInfo {
id: number
token: string
- username?: string
+ nickname?: string
avatar?: string
}
interface UserSpace {
id: number
name: string
- invite_code: string
role: number
}
}