diff --git a/code/allapp/allapp-go/cmd/allapp-go b/code/allapp/allapp-go/cmd/allapp-go new file mode 100644 index 00000000..30dc17a1 Binary files /dev/null and b/code/allapp/allapp-go/cmd/allapp-go differ diff --git a/code/allapp/allapp-go/config/index.go b/code/allapp/allapp-go/config/index.go index 7cbbacca..3fedaa25 100644 --- a/code/allapp/allapp-go/config/index.go +++ b/code/allapp/allapp-go/config/index.go @@ -3,9 +3,10 @@ package config import ( "allapp/db" "allapp/utils/redisx" + "bytes" + _ "embed" "fmt" "os" - "path/filepath" "strings" "time" @@ -83,50 +84,45 @@ func defaultConfig() *Config { } } +//go:embed resources/application.yaml +var defaultYaml []byte + +//go:embed resources/application-dev.yaml +var devYaml []byte + +//go:embed resources/application-build.yaml +var buildYaml []byte + func readConfigFile() error { - // 配置文件的目录 - prefix := "resources" - env := GetEnv() // 获取当前环境 + conf = defaultConfig() + env := GetEnv() - // 设置默认值 - conf = defaultConfig() // 先给默认结构体 - - // 默认配置文件 - confFileRelPath := filepath.Join(prefix, "application.yaml") - - // 创建 viper 实例 v := viper.New() - - // 首先加载默认的 application.yaml - v.SetConfigFile(confFileRelPath) v.SetConfigType("yaml") - // 读取默认配置文件 - if err := v.ReadInConfig(); err != nil { - panic(err) + // 读取默认配置 + if err := v.ReadConfig(bytes.NewReader(defaultYaml)); err != nil { + return fmt.Errorf("read default config failed: %w", err) } - // 根据环境加载不同的配置文件 + // 根据环境合并 switch env { - case "dev": - v.SetConfigFile(filepath.Join(prefix, "application-dev.yaml")) case "build": - v.SetConfigFile(filepath.Join(prefix, "application-build.yaml")) + if err := v.MergeConfig(bytes.NewReader(buildYaml)); err != nil { + return fmt.Errorf("merge build config failed: %w", err) + } + default: // dev 或其他值都使用 dev + if err := v.MergeConfig(bytes.NewReader(devYaml)); err != nil { + return fmt.Errorf("merge dev config failed: %w", err) + } } - // 如果需要,合并环境特定的配置文件 - if err := v.MergeInConfig(); err != nil { - return fmt.Errorf("merge env config failed: %w", err) - } - - if err := v.Unmarshal(conf); err != nil { + if err := v.Unmarshal(&conf); err != nil { return fmt.Errorf("unmarshal config failed: %w", err) } - fmt.Println("✅️ 加载配置成功") - // 设置环境变量 conf.Env = env - + fmt.Println("✅ 加载配置成功, 环境:", env) return nil } diff --git a/code/allapp/allapp-go/config/resources/application-build.yaml b/code/allapp/allapp-go/config/resources/application-build.yaml new file mode 100644 index 00000000..a4b3df02 --- /dev/null +++ b/code/allapp/allapp-go/config/resources/application-build.yaml @@ -0,0 +1,17 @@ +postgres: + host: 127.0.0.1 + port: 5432 + user: postgres + password: zhang520.. + dbname: app_online + timezone: Asia/Shanghai + max_open_conns: 10 + max_idle_conns: 5 + conn_max_lifetime: 30m + sll_mode: false + +redis: + host: 127.0.0.1 + port: 6379 + password: zhang520.. + db: 0 \ No newline at end of file diff --git a/code/allapp/allapp-go/resources/application-dev.yaml b/code/allapp/allapp-go/config/resources/application-dev.yaml similarity index 100% rename from code/allapp/allapp-go/resources/application-dev.yaml rename to code/allapp/allapp-go/config/resources/application-dev.yaml diff --git a/code/allapp/allapp-go/resources/application.yaml b/code/allapp/allapp-go/config/resources/application.yaml similarity index 100% rename from code/allapp/allapp-go/resources/application.yaml rename to code/allapp/allapp-go/config/resources/application.yaml diff --git a/code/allapp/allapp-go/db/schema.sql b/code/allapp/allapp-go/db/schema.sql index 5b010a47..9832c824 100644 --- a/code/allapp/allapp-go/db/schema.sql +++ b/code/allapp/allapp-go/db/schema.sql @@ -110,3 +110,44 @@ create table finance_record update_by bigint not null, update_time timestamp with time zone default now() ); + + +-- session +CREATE TABLE session ( + id bigint not null primary key, + space_id bigint not null, + type smallint not null, + name varchar(255), + avatar varchar(255), + description text, + status smallint default 0, + create_time timestamp with time zone default now(), + update_time timestamp with time zone default now() +) + +-- session_member +create table session_member +( + id bigint not null + primary key, + session_id bigint not null, + user_id bigint not null, + remark varchar(255), + is_top smallint default 0 not null, + unread_count integer default 0, + last_msg_id bigint, + status integer default 0, + create_time timestamp with time zone default now(), + update_time timestamp with time zone default now() +); + +create table session_message +( + id bigint not null + primary key, + session_id bigint not null, + sender_id bigint not null, + content text not null, + content_type smallint default 0 not null, + create_time timestamp with time zone default now() +); diff --git a/code/allapp/allapp-go/resources/application-build.yaml b/code/allapp/allapp-go/resources/application-build.yaml deleted file mode 100644 index e69de29b..00000000 diff --git a/code/allapp/allapp-rn/app.json b/code/allapp/allapp-rn/app.json index 1b126b3e..2b7da1eb 100644 --- a/code/allapp/allapp-rn/app.json +++ b/code/allapp/allapp-rn/app.json @@ -1,7 +1,7 @@ { "expo": { - "name": "app", - "slug": "app", + "name": "AllApp", + "slug": "AllApp", "version": "1.0.0", "orientation": "portrait", "icon": "./assets/icon.png", diff --git a/code/allapp/allapp-rn/assets/adaptive-icon.png b/code/allapp/allapp-rn/assets/adaptive-icon.png index 03d6f6b6..0fd90bc0 100644 Binary files a/code/allapp/allapp-rn/assets/adaptive-icon.png and b/code/allapp/allapp-rn/assets/adaptive-icon.png differ diff --git a/code/allapp/allapp-rn/assets/favicon.png b/code/allapp/allapp-rn/assets/favicon.png index e75f697b..0fd90bc0 100644 Binary files a/code/allapp/allapp-rn/assets/favicon.png and b/code/allapp/allapp-rn/assets/favicon.png differ diff --git a/code/allapp/allapp-rn/assets/icon.png b/code/allapp/allapp-rn/assets/icon.png index a0b1526f..173c4e27 100644 Binary files a/code/allapp/allapp-rn/assets/icon.png and b/code/allapp/allapp-rn/assets/icon.png differ diff --git a/code/allapp/allapp-rn/assets/splash-icon.png b/code/allapp/allapp-rn/assets/splash-icon.png index 03d6f6b6..0fd90bc0 100644 Binary files a/code/allapp/allapp-rn/assets/splash-icon.png and b/code/allapp/allapp-rn/assets/splash-icon.png differ diff --git a/code/allapp/allapp-rn/package.json b/code/allapp/allapp-rn/package.json index c6ca2b2e..b35cd104 100644 --- a/code/allapp/allapp-rn/package.json +++ b/code/allapp/allapp-rn/package.json @@ -15,6 +15,7 @@ "@gluestack-ui/core": "^3.0.12", "@gluestack-ui/utils": "^3.0.11", "@gluestack/ui-next-adapter": "^3.0.3", + "@hiraku-ai/react-native-emoji-picker": "^1.2.4", "@legendapp/list": "^2.0.19", "@legendapp/motion": "2.4.0", "@react-native-async-storage/async-storage": "2.2.0", diff --git a/code/allapp/allapp-rn/pnpm-lock.yaml b/code/allapp/allapp-rn/pnpm-lock.yaml index 7aee9cb6..541342de 100644 --- a/code/allapp/allapp-rn/pnpm-lock.yaml +++ b/code/allapp/allapp-rn/pnpm-lock.yaml @@ -23,6 +23,9 @@ importers: '@gluestack/ui-next-adapter': specifier: ^3.0.3 version: 3.0.3 + '@hiraku-ai/react-native-emoji-picker': + specifier: ^1.2.4 + version: 1.2.4(@react-native-async-storage/async-storage@2.2.0(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0)))(react-native-svg@15.12.1(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0) '@legendapp/list': specifier: ^2.0.19 version: 2.0.19(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0) @@ -1065,6 +1068,15 @@ packages: resolution: {integrity: sha512-KqddPNq5YsTa9f4GQL4DcSEwbbfBWMahR1blj37Z7oJYLwPHF6aAVn00ZaOHI75lE4eh9KjIWMbyJAJ2h0x5/A==} engines: {node: '>=16'} + '@hiraku-ai/react-native-emoji-picker@1.2.4': + resolution: {integrity: sha512-JuTJKhQA4y19m0zRDL0gmK9/mz8xGtDVYVwE7LktCG8lgHH/Gs1Mu6CM1JeBp39sPgiEHimUx6EF7Cgfp9iYVw==} + engines: {node: '>=12.0.0'} + peerDependencies: + '@react-native-async-storage/async-storage': '>=1.0.0' + react: '>=16.0.0' + react-native: '>=0.60.0' + react-native-svg: '>=12.0.0' + '@humanfs/core@0.19.1': resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} engines: {node: '>=18.18.0'} @@ -7352,6 +7364,13 @@ snapshots: find-yarn-workspace-root: 2.0.0 fs-extra: 11.3.2 + '@hiraku-ai/react-native-emoji-picker@1.2.4(@react-native-async-storage/async-storage@2.2.0(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0)))(react-native-svg@15.12.1(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)': + dependencies: + '@react-native-async-storage/async-storage': 2.2.0(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0)) + react: 19.1.0 + react-native: 0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0) + react-native-svg: 15.12.1(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0) + '@humanfs/core@0.19.1': {} '@humanfs/node@0.16.7': diff --git a/code/allapp/allapp-rn/src/app/(tabs)/chat.tsx b/code/allapp/allapp-rn/src/app/(tabs)/chat.tsx deleted file mode 100644 index 914bfbbb..00000000 --- a/code/allapp/allapp-rn/src/app/(tabs)/chat.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { useNavigation } from 'expo-router' -import React, { useState } from 'react' -import { Text, View } from 'react-native' -import { AButton, AModal } from '@/components/common/ao' -import AnimatedSwitch from '@/components/common/ao/Switch' -import { useSpaceStore } from '@/store/space' - -export default function TestScreen() { - const [showDissolve, setShowDissolve] = useState(false) - const spaceStore = useSpaceStore() - const navigation = useNavigation() - - console.log(navigation.getState()?.routeNames) - - return ( - - { - setShowDissolve(true) - }} - > - {spaceStore.currentSpace?.space_id} - - { - setShowDissolve(false) - }} - onCancel={() => { - setShowDissolve(false) - }} - onConfirm={() => { - setShowDissolve(false) - }} - /> - - ) -} diff --git a/code/allapp/allapp-rn/src/app/(tabs)/index.tsx b/code/allapp/allapp-rn/src/app/(tabs)/index.tsx index 66a905bf..ab2e27d4 100644 --- a/code/allapp/allapp-rn/src/app/(tabs)/index.tsx +++ b/code/allapp/allapp-rn/src/app/(tabs)/index.tsx @@ -28,7 +28,7 @@ export default function Index() { { - navStore.navigateTo('finance/index') + navStore.navigateTo('finance') }} > 开始使用 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 85f1ca83..4070a0f1 100644 --- a/code/allapp/allapp-rn/src/app/(tabs)/user/index.tsx +++ b/code/allapp/allapp-rn/src/app/(tabs)/user/index.tsx @@ -25,7 +25,7 @@ export default function User() { - + {/* */} diff --git a/code/allapp/allapp-rn/src/app/auth/index.tsx b/code/allapp/allapp-rn/src/app/auth/index.tsx index 30978b41..dedc9f6e 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 { useNavigation, 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 { toast } from 'sonner-native' @@ -28,153 +28,153 @@ export default function Auth() { const router = useRouter() const userStore = useUserStore() - // 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 onQQLogin() { + setLoading(true) + setForm(val => ({ + ...val, + type: 1, + })) + await ExpoQQ.login(['get_user_info']) + } - // async function onWeChatLogin() { - // setLoading(true) + async function onWeChatLogin() { + setLoading(true) - // // 检查微信是否安装 - // const isInstalled = await ExpoWeChat.isWXAppInstalled() - // if (!isInstalled) { - // toast.warning(onLoginFinished?.errorMessage || '请先安装微信') - // setLoading(false) - // return - // } + // 检查微信是否安装 + const isInstalled = await ExpoWeChat.isWXAppInstalled() + if (!isInstalled) { + toast.warning(onLoginFinished?.errorMessage || '请先安装微信') + setLoading(false) + return + } - // setForm(val => ({ - // ...val, - // type: 0, - // })) + setForm(val => ({ + ...val, + type: 0, + })) - // ExpoWeChat.sendAuthRequest('snsapi_userinfo', 'state123') - // } + ExpoWeChat.sendAuthRequest('snsapi_userinfo', 'state123') + } - // useEffect(() => { - // ExpoQQ.init('102826474', '') - // ExpoWeChat.registerApp('wxdab3e21a1f7e392f', '') - // }, []) + useEffect(() => { + ExpoQQ.init('102826474', '') + ExpoWeChat.registerApp('wxdab3e21a1f7e392f', '') + }, []) - // useEffect(() => { - // if (!onLoginFinished) { - // return - // } + useEffect(() => { + if (!onLoginFinished) { + return + } - // if (!onLoginFinished.success) { - // toast.warning(onLoginFinished?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权') - // setLoading(false) - // return - // } + if (!onLoginFinished.success) { + toast.warning(onLoginFinished?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权') + setLoading(false) + return + } - // const fetchUserInfo = async () => { - // try { - // const tokenInfo = await ExpoQQ.getLoginTokenInfo() - // if (!tokenInfo.openId) { - // toast.warning(tokenInfo?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权') - // setLoading(false) - // return - // } + const fetchUserInfo = async () => { + try { + const tokenInfo = await ExpoQQ.getLoginTokenInfo() + if (!tokenInfo.openId) { + toast.warning(tokenInfo?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权') + setLoading(false) + return + } - // setForm(val => ({ - // ...val, - // openid: String(tokenInfo.openId), - // })) + setForm(val => ({ + ...val, + openid: String(tokenInfo.openId), + })) - // await ExpoQQ.sendGetUserInfoReq() - // } - // catch (e) { - // console.error('QQ 登录未完成', e) - // setLoading(false) - // } - // } + await ExpoQQ.sendGetUserInfoReq() + } + catch (e) { + console.error('QQ 登录未完成', e) + setLoading(false) + } + } - // fetchUserInfo() - // }, [onLoginFinished]) + fetchUserInfo() + }, [onLoginFinished]) - // // QQ登录 - // useEffect(() => { - // const handleLogin = async () => { - // if (!onGetUserInfo) - // return + // 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, - // }) + try { + const loginRes = await loginQqApi({ + openid: form.openid, + nickname: onGetUserInfo.nickname || '', + avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2, + }) - // console.log(loginRes) + console.log(loginRes) - // if (loginRes.isSuccess) { - // userStore.setUserInfo({ - // token: loginRes.data.token, - // id: loginRes.data.userId, - // nickname: loginRes.data.nickname, - // avatar: loginRes.data.avatar, - // }) - // await appStore.init() - // } - // } - // catch (err) { - // console.error('登录接口出错', err) - // } - // finally { - // setLoading(false) - // } - // } + if (loginRes.isSuccess) { + userStore.setUserInfo({ + token: loginRes.data.token, + id: loginRes.data.userId, + nickname: loginRes.data.nickname, + avatar: loginRes.data.avatar, + }) + await appStore.init() + } + } + catch (err) { + console.error('登录接口出错', err) + } + finally { + setLoading(false) + } + } - // handleLogin() - // }, [onGetUserInfo]) + handleLogin() + }, [onGetUserInfo]) - // // 微信登录 - // useEffect(() => { - // if (!authResult) - // return + // 微信登录 + useEffect(() => { + if (!authResult) + return - // const handleLogin = async () => { - // if (authResult.errorCode === 0) { - // try { - // const loginRes = await loginWxApi({ - // code: authResult.code, - // }) + 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, - // }) + if (loginRes.isSuccess) { + userStore.setUserInfo({ + token: loginRes.data.token, + id: loginRes.data.userId, + nickname: loginRes.data.nickname, + avatar: loginRes.data.avatar, + }) - // await appStore.init() - // } - // } - // catch (err) { - // console.error('登录接口出错', err) - // } - // finally { - // setLoading(false) - // } - // } - // else { - // console.log('授权失败:', authResult.errorMessage) - // setLoading(false) - // } - // } + await appStore.init() + } + } + catch (err) { + console.error('登录接口出错', err) + } + finally { + setLoading(false) + } + } + else { + console.log('授权失败:', authResult.errorMessage) + setLoading(false) + } + } - // handleLogin() - // }, [authResult]) + handleLogin() + }, [authResult]) async function testLogin() { // eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NjY3ODU5ODIxNjUwNjEsImlhdCI6MTc2OTM0ODI0Nn0.17ZNaHD3HSLM8dVn_JQK-gvsG9MKj47IRYV9D4xZkzs @@ -216,7 +216,7 @@ export default function Auth() { - {/* } @@ -235,20 +235,19 @@ export default function Auth() { onPress={onQQLogin} > QQ - */} - - - } - loading={loading} - onPress={testLogin} - > - 模拟登录 + {/* + } + onPress={testLogin} + > + QQ + */} + { + const newHeight = Math.min(100, Math.max(40, event.nativeEvent.contentSize.height)) + setHeight(newHeight) + } + + return ( + + + + + + {/* 左侧 */} + + + + + + + 聊天室 + + + + {/* 右侧 */} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) +} diff --git a/code/allapp/allapp-rn/src/components/common/ao/Input.tsx b/code/allapp/allapp-rn/src/components/common/ao/Input.tsx index afa22600..27e10d9d 100644 --- a/code/allapp/allapp-rn/src/components/common/ao/Input.tsx +++ b/code/allapp/allapp-rn/src/components/common/ao/Input.tsx @@ -17,6 +17,8 @@ export interface AInputProps extends Omit { leftIcon?: ComponentType className?: string style?: StyleProp + inputClassName?: string + inputStyle?: StyleProp } const AInput = forwardRef, AInputProps>( @@ -32,6 +34,8 @@ const AInput = forwardRef, AInputProps>( leftIcon, className, style, + inputClassName, + inputStyle, ...rest }, ref) => { const [showPassword, setShowPassword] = useState(false) @@ -56,6 +60,8 @@ const AInput = forwardRef, AInputProps>( diff --git a/code/allapp/allapp-rn/src/request/index.ts b/code/allapp/allapp-rn/src/request/index.ts index e1b1517e..ea7322df 100644 --- a/code/allapp/allapp-rn/src/request/index.ts +++ b/code/allapp/allapp-rn/src/request/index.ts @@ -31,7 +31,7 @@ function isWhiteListed(url: string) { } const alovaInstance = createAlova({ - baseURL: 'http://192.168.5.6:8086/app', + baseURL: 'https://www.oneao.cn/app', // baseURL: 'http://192.168.1.137:8086/app', requestAdapter: axiosRequestAdapter(), timeout: 5000, diff --git a/code/allapp/allapp-rn/src/store/navigation.ts b/code/allapp/allapp-rn/src/store/navigation.ts index eda481fc..bd6310ef 100644 --- a/code/allapp/allapp-rn/src/store/navigation.ts +++ b/code/allapp/allapp-rn/src/store/navigation.ts @@ -20,8 +20,8 @@ interface NavState { const DEFAULT_NAV_MENUS: NavItem[] = [ { label: '记账', path: '/finance', icon: 'CircleDollarSign' }, - { label: '恋爱记', path: '/love', icon: 'Heart' }, - { label: '聊天', path: '/chat', icon: 'MessageCircle' }, + // { label: '恋爱记', path: '/love', icon: 'Heart' }, + // { label: '聊天', path: '/chat', icon: 'MessageCircle' }, { label: '个人中心', path: '/user', icon: 'CircleUserRound' }, { label: '空间管理', path: '/space', icon: 'Earth' }, ]