Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
smart_hotel_app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张宏
smart_hotel_app
Commits
9db068bb
Commit
9db068bb
authored
Jun 12, 2026
by
张宏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
14c26670
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
80 additions
and
92 deletions
+80
-92
README.md
README.md
+12
-19
build.gradle
android/app/build.gradle
+34
-0
build.gradle.kts
android/app/build.gradle.kts
+0
-44
AndroidManifest.xml
android/app/src/main/AndroidManifest.xml
+1
-1
strings.xml
android/app/src/main/res/values/strings.xml
+4
-0
build.gradle.kts
android/build.gradle.kts
+0
-24
problems-report.html
android/build/reports/problems/problems-report.html
+0
-0
auth_bloc.dart
lib/blocs/auth/auth_bloc.dart
+3
-0
constants.dart
lib/utils/constants.dart
+16
-3
dio_request.dart
lib/utils/http/dio_request.dart
+10
-1
No files found.
README.md
View file @
9db068bb
...
@@ -9,26 +9,19 @@
...
@@ -9,26 +9,19 @@
dart run build_runner build
dart run build_runner build
dart run build_runner watch
dart run build_runner watch
## 打包
### ✅ dev
flutter build apk --dart-define=APP_ENV=dev --flavor dev
### ✅ staging(不要写 test)
flutter build apk --dart-define=APP_ENV=staging --flavor staging
### ✅ prod
flutter build apk --dart-define=APP_ENV=prod --flavor prod
---
---
### gitlab
git config --global user.name "xxx"
git config --global user.email "xxx"
Create a new repository
git clone http://git.ruanyiit.com/zhanghong/smart_hotel_app.git
cd smart_hotel_app
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin http://git.ruanyiit.com/zhanghong/smart_hotel_app.git
git add .
git commit -m "Initial commit"
git push -u origin master
### 版本处理
### 版本处理
版本对齐后,必须清除旧缓存,否则 Gradle 会继续读取损坏的元数据
版本对齐后,必须清除旧缓存,否则 Gradle 会继续读取损坏的元数据
...
...
android/app/build.gradle
View file @
9db068bb
...
@@ -51,6 +51,29 @@ android {
...
@@ -51,6 +51,29 @@ android {
versionName
flutterVersionName
versionName
flutterVersionName
}
}
flavorDimensions
"environment"
productFlavors
{
dev
{
dimension
"environment"
applicationIdSuffix
".dev"
versionNameSuffix
"-dev"
resValue
"string"
,
"app_name"
,
"智能酒店-dev"
}
staging
{
dimension
"environment"
applicationIdSuffix
".staging"
versionNameSuffix
"-staging"
resValue
"string"
,
"app_name"
,
"智能酒店-staging"
}
prod
{
dimension
"environment"
applicationIdSuffix
""
versionNameSuffix
""
resValue
"string"
,
"app_name"
,
"智能酒店"
}
}
buildTypes
{
buildTypes
{
release
{
release
{
// TODO: Add your own signing config for the release build.
// TODO: Add your own signing config for the release build.
...
@@ -58,6 +81,17 @@ android {
...
@@ -58,6 +81,17 @@ android {
signingConfig
signingConfigs
.
debug
signingConfig
signingConfigs
.
debug
}
}
}
}
// 自定义 APK 输出文件名
applicationVariants
.
all
{
variant
->
variant
.
outputs
.
all
{
if
(
variant
.
flavorName
==
"dev"
||
variant
.
flavorName
==
"staging"
)
{
outputFileName
=
"app-${variant.flavorName}.apk"
}
else
{
outputFileName
=
"app-${variant.flavorName}-${variant.buildType.name}.apk"
}
}
}
}
}
flutter
{
flutter
{
...
...
android/app/build.gradle.kts
deleted
100644 → 0
View file @
14c26670
plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
android {
namespace = "com.example.smart_hotel_app"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.smart_hotel_app"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
}
}
}
flutter {
source = "../.."
}
android/app/src/main/AndroidManifest.xml
View file @
9db068bb
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<application
<application
android:label=
"
智能酒店
"
android:label=
"
@string/app_name
"
android:name=
"${applicationName}"
android:name=
"${applicationName}"
android:icon=
"@mipmap/ic_launcher"
>
android:icon=
"@mipmap/ic_launcher"
>
<activity
<activity
...
...
android/app/src/main/res/values/strings.xml
0 → 100644
View file @
9db068bb
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name=
"app_name"
>
智能酒店
</string>
</resources>
android/build.gradle.kts
deleted
100644 → 0
View file @
14c26670
allprojects {
repositories {
google()
mavenCentral()
}
}
val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)
subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
android/build/reports/problems/problems-report.html
0 → 100644
View file @
9db068bb
This source diff could not be displayed because it is too large. You can
view the blob
instead.
lib/blocs/auth/auth_bloc.dart
View file @
9db068bb
...
@@ -41,6 +41,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
...
@@ -41,6 +41,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
AuthTokenExpiredEvent
event
,
AuthTokenExpiredEvent
event
,
Emitter
<
AuthState
>
emit
,
Emitter
<
AuthState
>
emit
,
)
async
{
)
async
{
// 防止重复处理:如果已经在过期或登出状态,直接跳过
if
(
state
is
AuthTokenExpired
||
state
is
AuthLoggedOut
)
return
;
await
_storageService
.
deleteToken
();
await
_storageService
.
deleteToken
();
await
_storageService
.
deleteUserInfo
();
await
_storageService
.
deleteUserInfo
();
await
_storageService
.
deleteClientId
();
await
_storageService
.
deleteClientId
();
...
...
lib/utils/constants.dart
View file @
9db068bb
class
Constants
{
class
Constants
{
// ==================== 环境配置 ====================
// ==================== 环境配置 ====================
static
const
String
baseUrl
=
'http://121.41.57.178:9090'
;
/// 当前环境:dev / staging / prod,通过 --dart-define=APP_ENV=xxx 注入
// static const String baseUrl = 'http://192.168.0.168:9090';
static
const
String
env
=
String
.
fromEnvironment
(
'APP_ENV'
,
defaultValue:
'dev'
);
// static const String baseUrl = 'http://192.168.1.7:9090';
/// 根据环境返回对应的 API 地址
static
String
get
baseUrl
{
switch
(
env
)
{
case
'dev'
:
return
'http://121.41.57.178:9090'
;
case
'staging'
:
return
'http://121.41.57.178:9090'
;
case
'prod'
:
return
'http://121.41.57.178:9090'
;
default
:
return
'http://121.41.57.178:9090'
;
}
}
...
...
lib/utils/http/dio_request.dart
View file @
9db068bb
import
'package:dio/dio.dart'
;
import
'package:dio/dio.dart'
;
import
'../constants.dart'
;
import
'../constants.dart'
;
import
'../event_bus.dart'
;
import
'exceptions/app_exception.dart'
;
import
'exceptions/app_exception.dart'
;
import
'interceptors/error_interceptor.dart'
;
import
'interceptors/error_interceptor.dart'
;
import
'interceptors/request_interceptor.dart'
;
import
'interceptors/request_interceptor.dart'
;
...
@@ -338,11 +339,19 @@ class DioRequest {
...
@@ -338,11 +339,19 @@ class DioRequest {
};
};
}
}
return
ResponseModel
<
T
>.
fromJson
(
final
result
=
ResponseModel
<
T
>.
fromJson
(
jsonData
,
jsonData
,
uuid:
uuid
,
uuid:
uuid
,
fromJsonT:
fromJsonT
,
fromJsonT:
fromJsonT
,
);
);
// 当后端返回 HTTP 200 但 body 中 code 为 401 时,
// 表示 token 已在后端失效,触发 token 过期事件
if
(
result
.
code
==
401
)
{
eventBus
.
emit
(
TokenExpiredEvent
());
}
return
result
;
}
catch
(
e
)
{
}
catch
(
e
)
{
return
_handleError
<
T
>(
e
,
uuid
);
return
_handleError
<
T
>(
e
,
uuid
);
}
finally
{
}
finally
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment