Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
ChatGPT
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
关振斌
ChatGPT
Commits
2ed6da52
Commit
2ed6da52
authored
May 18, 2023
by
netyouli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加创作记录查询
parent
a5e04e48
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
177 additions
and
39 deletions
+177
-39
ios/Runner.xcodeproj/project.pbxproj
ios/Runner.xcodeproj/project.pbxproj
+18
-3
lib/common/db/db_tool.dart
lib/common/db/db_tool.dart
+9
-8
lib/common/routers/names.dart
lib/common/routers/names.dart
+1
-0
lib/common/routers/pages.dart
lib/common/routers/pages.dart
+6
-0
lib/pages/creation-detail/controller.dart
lib/pages/creation-detail/controller.dart
+9
-13
lib/pages/creation-detail/models/detail_model.dart
lib/pages/creation-detail/models/detail_model.dart
+8
-9
lib/pages/creation/history/bindings.dart
lib/pages/creation/history/bindings.dart
+11
-0
lib/pages/creation/history/controller.dart
lib/pages/creation/history/controller.dart
+20
-0
lib/pages/creation/history/index.dart
lib/pages/creation/history/index.dart
+5
-0
lib/pages/creation/history/state.dart
lib/pages/creation/history/state.dart
+8
-0
lib/pages/creation/history/view.dart
lib/pages/creation/history/view.dart
+67
-0
lib/pages/creation/view.dart
lib/pages/creation/view.dart
+15
-6
No files found.
ios/Runner.xcodeproj/project.pbxproj
View file @
2ed6da52
...
...
@@ -363,8 +363,11 @@
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
CLANG_ENABLE_MODULES
=
YES
;
CODE_SIGN_ENTITLEMENTS
=
Runner/RunnerProfile.entitlements
;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]"
=
"iPhone Distribution"
;
CODE_SIGN_STYLE
=
Manual
;
CURRENT_PROJECT_VERSION
=
2
;
DEVELOPMENT_TEAM
=
Z99J24WADU
;
DEVELOPMENT_TEAM
=
""
;
"DEVELOPMENT_TEAM[sdk=iphoneos*]"
=
Z99J24WADU
;
ENABLE_BITCODE
=
NO
;
FLUTTER_BUILD_NAME
=
1.0.3
;
INFOPLIST_FILE
=
Runner/Info.plist
;
...
...
@@ -376,6 +379,8 @@
MARKETING_VERSION
=
5
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.wudi.app
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
PROVISIONING_PROFILE_SPECIFIER
=
""
;
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]"
=
"iOS Team Store Provisioning Profile: com.wudi.app"
;
SWIFT_OBJC_BRIDGING_HEADER
=
"Runner/Runner-Bridging-Header.h"
;
SWIFT_VERSION
=
5.0
;
VERSIONING_SYSTEM
=
"apple-generic"
;
...
...
@@ -496,8 +501,11 @@
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
CLANG_ENABLE_MODULES
=
YES
;
CODE_SIGN_ENTITLEMENTS
=
Runner/RunnerDebug.entitlements
;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]"
=
"iPhone Distribution"
;
CODE_SIGN_STYLE
=
Manual
;
CURRENT_PROJECT_VERSION
=
2
;
DEVELOPMENT_TEAM
=
Z99J24WADU
;
DEVELOPMENT_TEAM
=
""
;
"DEVELOPMENT_TEAM[sdk=iphoneos*]"
=
Z99J24WADU
;
ENABLE_BITCODE
=
NO
;
FLUTTER_BUILD_NAME
=
1.0.3
;
INFOPLIST_FILE
=
Runner/Info.plist
;
...
...
@@ -509,6 +517,8 @@
MARKETING_VERSION
=
5
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.wudi.app
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
PROVISIONING_PROFILE_SPECIFIER
=
""
;
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]"
=
"iOS Team Store Provisioning Profile: com.wudi.app"
;
SWIFT_OBJC_BRIDGING_HEADER
=
"Runner/Runner-Bridging-Header.h"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Onone"
;
SWIFT_VERSION
=
5.0
;
...
...
@@ -523,8 +533,11 @@
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
CLANG_ENABLE_MODULES
=
YES
;
CODE_SIGN_ENTITLEMENTS
=
Runner/Runner.entitlements
;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]"
=
"iPhone Distribution"
;
CODE_SIGN_STYLE
=
Manual
;
CURRENT_PROJECT_VERSION
=
2
;
DEVELOPMENT_TEAM
=
Z99J24WADU
;
DEVELOPMENT_TEAM
=
""
;
"DEVELOPMENT_TEAM[sdk=iphoneos*]"
=
Z99J24WADU
;
ENABLE_BITCODE
=
NO
;
FLUTTER_BUILD_NAME
=
1.0.3
;
INFOPLIST_FILE
=
Runner/Info.plist
;
...
...
@@ -536,6 +549,8 @@
MARKETING_VERSION
=
5
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.wudi.app
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
PROVISIONING_PROFILE_SPECIFIER
=
""
;
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]"
=
"iOS Team Store Provisioning Profile: com.wudi.app"
;
SWIFT_OBJC_BRIDGING_HEADER
=
"Runner/Runner-Bridging-Header.h"
;
SWIFT_VERSION
=
5.0
;
VERSIONING_SYSTEM
=
"apple-generic"
;
...
...
lib/common/db/db_tool.dart
View file @
2ed6da52
...
...
@@ -21,21 +21,21 @@ class DBTool {
return
;
}
final
basePath
=
await
getDatabasesPath
();
final
path
=
'
$basePath$_dbName
.db'
;
final
path
=
'
$basePath
/
$_dbName
.db'
;
_db
=
await
openDatabase
(
path
,
version:
_version
);
}
static
Future
<
bool
>
_isExistTable
(
String
tableName
)
async
{
//内建表sqlite_master
var
sql
=
"SELECT * FROM sqlite_master WHERE TYPE = 'table' AND NAME = '
$tableName
'"
;
var
res
=
await
_db
?.
rawQuery
(
sql
);
var
isExist
=
res
!=
null
&&
res
.
isNotEmpty
;
final
sql
=
"SELECT * FROM sqlite_master WHERE TYPE = 'table' AND NAME = '
$tableName
'"
;
final
res
=
await
_db
?.
rawQuery
(
sql
);
final
isExist
=
res
!=
null
&&
res
.
isNotEmpty
;
return
isExist
;
}
static
Future
<
void
>
_createTable
(
DBModel
model
)
async
{
await
_initDB
(
model
);
var
isExist
=
await
_isExistTable
(
model
.
tableName
);
final
isExist
=
await
_isExistTable
(
model
.
tableName
);
if
(!
isExist
)
{
await
_db
?.
execute
(
model
.
createTableSql
);
}
...
...
@@ -49,7 +49,7 @@ class DBTool {
static
Future
<
int
>
update
(
DBModel
model
,
{
String
?
where
,
bool
?
isInsert
=
false
})
async
{
await
_createTable
(
model
);
if
(
isInsert
??
false
)
{
final
list
=
await
query
(
model
.
tableName
,
where:
where
);
final
list
=
await
query
(
model
,
where:
where
);
if
(
list
.
isEmpty
)
{
return
await
insert
(
model
);
}
...
...
@@ -57,8 +57,9 @@ class DBTool {
return
await
_db
?.
update
(
model
.
tableName
,
model
.
mapValues
,
where:
where
)
??
0
;
}
static
Future
<
List
<
Map
<
String
,
Object
?>>>
query
(
String
tableName
,
{
String
?
where
})
async
{
return
await
_db
?.
query
(
tableName
,
where:
where
)
??
[];
static
Future
<
List
<
Map
<
String
,
Object
?>>>
query
(
DBModel
model
,
{
String
?
where
})
async
{
await
_createTable
(
model
);
return
await
_db
?.
query
(
model
.
tableName
,
where:
where
)
??
[];
}
static
Future
<
int
>
delete
(
DBModel
model
,
{
String
?
where
})
async
{
...
...
lib/common/routers/names.dart
View file @
2ed6da52
...
...
@@ -18,6 +18,7 @@ class AppRoutes {
static
const
HOME_PAGE
=
'/home'
;
static
const
CREATION_PAGE
=
'/creation'
;
static
const
CREATION_HISTORY_PAGE
=
'/creation-history'
;
static
const
CREATION_PAGE_DETAIL
=
'/creation-detail'
;
static
const
ASSISTANT_PAGE
=
'/assistant'
;
static
const
MY_PAGE
=
'/my'
;
...
...
lib/common/routers/pages.dart
View file @
2ed6da52
...
...
@@ -2,6 +2,7 @@ import 'package:chart/pages/assistant-item/index.dart';
import
'package:chart/pages/assistant/index.dart'
;
import
'package:chart/pages/chat/view.dart'
;
import
'package:chart/pages/creation-detail/index.dart'
;
import
'package:chart/pages/creation/history/index.dart'
;
import
'package:chart/pages/creation/index.dart'
;
import
'package:chart/pages/eula/bindings.dart'
;
import
'package:chart/pages/eula/view.dart'
;
...
...
@@ -176,6 +177,11 @@ class AppPages {
page:
()
=>
CreationPage
(),
binding:
CreationBinding
(),
),
GetPage
(
name:
AppRoutes
.
CREATION_HISTORY_PAGE
,
page:
()
=>
CreateHistoryPage
(),
binding:
CreateHistoryBinding
(),
),
GetPage
(
name:
AppRoutes
.
ASSISTANT_PAGE
,
page:
()
=>
AssistantPage
(),
...
...
lib/pages/creation-detail/controller.dart
View file @
2ed6da52
...
...
@@ -27,7 +27,6 @@ class CreationDetailController extends GetxController {
'input2'
:
TextEditingController
(),
};
final
state
=
CreationDetailState
();
final
model
=
DetailModel
();
// final
...
...
@@ -47,13 +46,6 @@ class CreationDetailController extends GetxController {
state
.
title
=
title
;
state
.
id
=
id
;
// state.detailList.value = [];
final
list
=
await
DBTool
.
query
(
DetailModel
.
TableName
,
where:
"type = '
$title
'"
);
if
(
list
.
isNotEmpty
)
{
final
model
=
DetailModel
.
fromJson
(
list
[
0
]);
inputControllerMap
[
"input1"
]?.
text
=
model
.
object
;
inputControllerMap
[
"input2"
]?.
text
=
model
.
subject
;
// state.genText = model.content;
}
items
.
sort
((
a
,
b
)
=>
a
.
sort
!
-
b
.
sort
!);
// input1
state
.
detailList
.
addAll
(
items
);
...
...
@@ -121,6 +113,15 @@ class CreationDetailController extends GetxController {
// "content": state.messageList[0].text,
// });
_this
.
state
.
isLoading
=
false
;
// 保存到数据库
final
model
=
DetailModel
();
final
date
=
DateTime
.
now
();
model
.
type
=
state
.
title
;
model
.
object
=
inputControllerMap
[
"input1"
]?.
text
??
""
;
model
.
subject
=
inputControllerMap
[
"input2"
]?.
text
??
""
;
model
.
content
=
state
.
genText
;
model
.
date
=
"
${date.year}
-
${date.month < 10 ? "0${date.month}
"
:
date
.
month
}-
$
{
date
.
day
<
10
?
"0
${date.day}
"
:
date
.
day
}
$
{
date
.
hour
<
10
?
"0
${date.hour}
"
:
date
.
hour
}:
$
{
date
.
minute
<
10
?
"0
${date.minute}
"
:
date
.
minute
}:
$
{
date
.
second
<
10
?
"0
${date.second}
"
:
date
.
second
}
";
DBTool.insert(model);
return;
}
Map<String, dynamic> jsonMap = jsonDecode("
$
{
event
.
data
}
");
...
...
@@ -132,11 +133,6 @@ class CreationDetailController extends GetxController {
}
bool back() {
model
.
type
=
to
.
state
.
title
;
model
.
object
=
inputControllerMap
[
"input1"
]?.
text
??
""
;
model
.
subject
=
inputControllerMap
[
"input2"
]?.
text
??
""
;
model
.
content
=
state
.
genText
;
DBTool
.
update
(
model
,
isInsert:
true
,
where:
"type = '
${model.type}
'"
);
state.detailList.value = [];
inputControllerMap['input1']!.text = '';
inputControllerMap['input2']!.text = '';
...
...
lib/pages/creation-detail/models/detail_model.dart
View file @
2ed6da52
...
...
@@ -7,25 +7,24 @@ class DetailModel implements DBModel {
var
object
=
""
;
var
subject
=
""
;
var
content
=
""
;
var
date
=
""
;
@override
// TODO: implement tableName
String
get
tableName
=>
TableName
;
@override
// TODO: implement createTableSql
String
get
createTableSql
=>
"CREATE TABLE
$tableName
(id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, object TEXT, subject TEXT, content TEXT)"
;
String
get
createTableSql
=>
"CREATE TABLE
$tableName
(id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, object TEXT, subject TEXT, content TEXT, date TEXT)"
;
@override
// TODO: implement mapValues
Map
<
String
,
Object
>
get
mapValues
=>
{
"type"
:
type
,
"object"
:
object
,
"subject"
:
subject
,
"content"
:
content
};
Map
<
String
,
Object
>
get
mapValues
=>
{
"type"
:
type
,
"object"
:
object
,
"subject"
:
subject
,
"content"
:
content
,
"date"
:
date
};
static
DetailModel
fromJson
(
Map
<
String
,
Object
?>
jsonData
)
{
final
model
=
DetailModel
();
model
.
content
=
jsonData
[
"content"
]
as
String
;
model
.
type
=
jsonData
[
"type"
]
as
String
;
model
.
object
=
jsonData
[
"object"
]
as
String
;
model
.
subject
=
jsonData
[
"subject"
]
as
String
;
model
.
content
=
jsonData
[
"content"
]
as
String
?
??
""
;
model
.
type
=
jsonData
[
"type"
]
as
String
?
??
""
;
model
.
object
=
jsonData
[
"object"
]
as
String
?
??
""
;
model
.
subject
=
jsonData
[
"subject"
]
as
String
?
??
""
;
model
.
date
=
jsonData
[
"date"
]
as
String
?
??
""
;
return
model
;
}
...
...
lib/pages/creation/history/bindings.dart
0 → 100644
View file @
2ed6da52
import
'package:chart/pages/creation/history/controller.dart'
;
import
'package:get/get.dart'
;
class
CreateHistoryBinding
extends
Bindings
{
@override
void
dependencies
()
{
Get
.
lazyPut
<
CreateHistoryController
>(()
=>
CreateHistoryController
());
}
}
\ No newline at end of file
lib/pages/creation/history/controller.dart
0 → 100644
View file @
2ed6da52
import
'package:chart/pages/creation-detail/models/detail_model.dart'
;
import
'package:get/get.dart'
;
import
'./state.dart'
;
import
'../../../common/db/db_tool.dart'
;
class
CreateHistoryController
extends
GetxController
{
CreateHistoryController
();
static
CreateHistoryController
get
to
=>
Get
.
put
(
CreateHistoryController
());
final
state
=
CreateHistoryState
();
getHistoryMoels
()
{
DBTool
.
query
(
DetailModel
()).
then
((
value
)
{
final
list
=
value
.
map
((
e
)
=>
DetailModel
.
fromJson
(
e
)).
toList
();
state
.
models
.
value
=
list
;
});
}
}
\ No newline at end of file
lib/pages/creation/history/index.dart
0 → 100644
View file @
2ed6da52
library
creation_history
;
export
'./controller.dart'
;
export
'./view.dart'
;
export
'./bindings.dart'
;
\ No newline at end of file
lib/pages/creation/history/state.dart
0 → 100644
View file @
2ed6da52
import
'package:chart/pages/creation-detail/models/detail_model.dart'
;
import
'package:get/get.dart'
;
class
CreateHistoryState
{
var
models
=
<
DetailModel
>[].
obs
;
}
\ No newline at end of file
lib/pages/creation/history/view.dart
0 → 100644
View file @
2ed6da52
import
'package:chart/pages/creation/history/controller.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
class
CreateHistoryPage
extends
GetView
<
CreateHistoryController
>
{
const
CreateHistoryPage
({
Key
?
key
})
:
super
(
key:
key
);
Widget
_mainView
()
{
return
Obx
(()
=>
ListView
(
children:
controller
.
state
.
models
.
map
((
e
)
{
return
Container
(
padding:
const
EdgeInsets
.
all
(
15
),
width:
double
.
infinity
,
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
"类型:
${e.type}
\n
时间:
${e.date}
"
,
textAlign:
TextAlign
.
start
,),
const
SizedBox
(
height:
15
,),
Container
(
padding:
const
EdgeInsets
.
all
(
20
),
width:
Get
.
width
,
constraints:
const
BoxConstraints
(
minHeight:
300
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
4
),
gradient:
const
LinearGradient
(
colors:
[
Color
.
fromARGB
(
255
,
40
,
40
,
57
),
Color
.
fromARGB
(
255
,
40
,
40
,
57
),
],
begin:
Alignment
.
topCenter
,
end:
Alignment
.
bottomCenter
,
),
),
child:
Text
(
e
.
content
))
]),
);
}).
toList
()
));
}
@override
Widget
build
(
BuildContext
context
)
{
return
GetBuilder
<
CreateHistoryController
>(
id:
"create_history"
,
init:
CreateHistoryController
(),
builder:
(
_
)
{
return
Container
(
decoration:
BoxDecoration
(
image:
DecorationImage
(
image:
Image
.
asset
(
"assets/images/background.png"
).
image
,
fit:
BoxFit
.
cover
),
),
child:
Scaffold
(
backgroundColor:
Color
.
fromARGB
(
0
,
29
,
33
,
60
),
appBar:
AppBar
(
backgroundColor:
Color
.
fromARGB
(
255
,
29
,
33
,
60
),
title:
const
Text
(
"创作记录"
,
),
elevation:
0
),
body:
SafeArea
(
child:
_mainView
()),
)
);
});
}
}
\ No newline at end of file
lib/pages/creation/view.dart
View file @
2ed6da52
import
'package:chart/common/routers/routes.dart'
;
import
'package:chart/common/widgets/widgets.dart'
;
import
'./history/index.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
...
...
@@ -26,12 +29,18 @@ class CreationPage extends GetView<CreationController> {
builder:
(
_
)
{
return
Scaffold
(
backgroundColor:
Color
.
fromARGB
(
0
,
29
,
33
,
60
),
// appBar: AppBar(
// backgroundColor: Color.fromARGB(255, 29, 33, 60),
// // title: const Text(
// // "创作",
// // ),
// elevation: 0),
appBar:
AppBar
(
backgroundColor:
Color
.
fromARGB
(
255
,
29
,
33
,
60
),
title:
const
Text
(
"创作"
,
),
actions:
[
TextButton
(
onPressed:
()
{
CreateHistoryController
.
to
.
getHistoryMoels
();
Get
.
toNamed
(
AppRoutes
.
CREATION_HISTORY_PAGE
);
},
child:
const
Text
(
"历史记录"
,
style:
TextStyle
(
color:
Colors
.
white
),))
],
elevation:
0
),
body:
SafeArea
(
child:
_buildView
(),
),
...
...
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