This commit is contained in:
oneao committed 2026-03-08 22:17:01 +08:00
1 parent 26ff2381b7
commit 00a1cce5ac
22 files changed
+335 -215

No files matched your search

Binary file not shown.
+26 -30
View File
@@ -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
}
@@ -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
+41
View File
@@ -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()
);
Whitespace-only changes.
+2 -2
View File
@@ -1,7 +1,7 @@
{
"expo": {
"name": "app",
"slug": "app",
"name": "AllApp",
"slug": "AllApp",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 81 KiB

+1
View File
@@ -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",
+19
View File
@@ -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':
@@ -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 (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<AButton onPress={() => {
setShowDissolve(true)
}}
>
{spaceStore.currentSpace?.space_id}
</AButton>
<AModal
title="提示"
body="确认解散该空间么?"
isOpen={showDissolve}
onClose={() => {
setShowDissolve(false)
}}
onCancel={() => {
setShowDissolve(false)
}}
onConfirm={() => {
setShowDissolve(false)
}}
/>
</View>
)
}
@@ -28,7 +28,7 @@ export default function Index() {
<AButton
className="w-full"
onPress={() => {
navStore.navigateTo('finance/index')
navStore.navigateTo('finance')
}}
>
开始使用
@@ -25,7 +25,7 @@ export default function User() {
</View>
<View className="mt-8 flex flex-col">
<ListItem icon="Earth" text="共享空间" href="/system/share" />
{/* <ListItem icon="Earth" text="共享空间" href="/system/share" /> */}
<ListItem icon="Settings" text="设置"href="/system/settings" />
</View>
</SafeAreaView>
+138 -139
View File
@@ -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() {
</View>
<View className="flex flex-col gap-4">
{/* <AButton
<AButton
leftIcon={
<IconWeixin color="#fff" />
}
@@ -235,20 +235,19 @@ export default function Auth() {
onPress={onQQLogin}
>
QQ
</AButton> */}
<AButton
variant="outline"
leftIcon={
<IconQq />
}
loading={loading}
onPress={testLogin}
>
模拟登录
</AButton>
</View>
{/* <AButton
variant="outline"
leftIcon={
<IconQq />
}
onPress={testLogin}
>
QQ
</AButton> */}
<View className="mt-10 items-center flex flex-row justify-center">
<ACheckbox
checked={isAgree}
@@ -0,0 +1,80 @@
import React, { useState } from 'react'
import { Pressable, Text, View } from 'react-native'
import { KeyboardAvoidingView } from 'react-native-keyboard-controller'
import { AInput, LucideIcon } from '@/components/common/ao'
import CustomHeader from '@/components/custom/Header'
export default function TestScreen() {
const [value, setValue] = useState('')
const [height, setHeight] = useState(40)
const handleContentSizeChange = (event: any) => {
const newHeight = Math.min(100, Math.max(40, event.nativeEvent.contentSize.height))
setHeight(newHeight)
}
return (
<View className="flex-1 bg-white ">
<CustomHeader showHeader={false} />
<KeyboardAvoidingView
behavior="padding"
className="flex-1"
>
<View className="flex-row items-center justify-between h-14 px-3 border-b border-gray-100">
{/* 左侧 */}
<View className="flex-row items-center gap-2">
<Pressable className="w-10 h-10 items-center justify-center rounded-full">
<LucideIcon icon="ChevronLeft" size={28} color="#111827" />
</Pressable>
<Text className="text-base font-semibold text-gray-900">
聊天室
</Text>
</View>
{/* 右侧 */}
<View className="flex-row items-center gap-3">
<Pressable className="w-9 h-9 items-center justify-center rounded-full bg-[#f9f9f9]">
<LucideIcon icon="TvMinimalPlay" size={18} color="#374151" />
</Pressable>
<Pressable className="w-9 h-9 items-center justify-center rounded-full bg-[#f9f9f9]">
<LucideIcon icon="Phone" size={18} color="#374151" />
</Pressable>
<Pressable className="w-9 h-9 items-center justify-center rounded-full bg-[#f9f9f9]">
<LucideIcon icon="Ellipsis" size={18} color="#374151" />
</Pressable>
</View>
</View>
<View className="flex-1">
</View>
<View
className="m-4 flex-row px-3 items-center bg-[#f6f6f7] rounded-full"
>
<LucideIcon icon="Mic" size={24} />
<AInput
placeholder="请输入消息"
className="flex-1 py-2"
style={{
borderWidth: 0,
height,
}}
multiline={true}
onContentSizeChange={handleContentSizeChange}
/>
<LucideIcon icon="Smile" size={24} />
<LucideIcon icon="CirclePlus" size={24} className="ml-3" />
</View>
</KeyboardAvoidingView>
</View>
)
}
@@ -17,6 +17,8 @@ export interface AInputProps extends Omit<TextInputProps, 'onChange'> {
leftIcon?: ComponentType
className?: string
style?: StyleProp<ViewStyle>
inputClassName?: string
inputStyle?: StyleProp<ViewStyle>
}
const AInput = forwardRef<React.ComponentRef<typeof InputField>, AInputProps>(
@@ -32,6 +34,8 @@ const AInput = forwardRef<React.ComponentRef<typeof InputField>, AInputProps>(
leftIcon,
className,
style,
inputClassName,
inputStyle,
...rest
}, ref) => {
const [showPassword, setShowPassword] = useState(false)
@@ -56,6 +60,8 @@ const AInput = forwardRef<React.ComponentRef<typeof InputField>, AInputProps>(
<InputField
ref={ref}
className={inputClassName}
style={inputStyle}
type={isPassword ? (showPassword ? 'text' : 'password') : 'text'}
{...rest}
/>
+1 -1
View File
@@ -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,
@@ -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' },
]