Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 75b573e5
authored
2025-12-05 15:58:11 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
H5的实际打包版本,调整为从package.json中读取和解析
1 parent
78b40772
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
lib/services/local_server_service.dart
lib/services/local_server_service.dart
View file @
75b573e
import
'dart:convert'
;
import
'dart:io'
;
import
'dart:io'
;
import
'package:appframe/config/constant.dart'
;
import
'package:appframe/config/constant.dart'
;
...
@@ -162,9 +163,12 @@ class LocalServerService {
...
@@ -162,9 +163,12 @@ class LocalServerService {
var
version
=
getIt
.
get
<
SharedPreferences
>().
getString
(
Constant
.
h5VersionKey
)
??
Constant
.
h5Version
;
var
version
=
getIt
.
get
<
SharedPreferences
>().
getString
(
Constant
.
h5VersionKey
)
??
Constant
.
h5Version
;
var
dir
=
await
getApplicationSupportDirectory
();
var
dir
=
await
getApplicationSupportDirectory
();
var
distFilePath
=
'
${dir.path}
/
${Constant.h5DistDir}
/
$version
.zip'
;
var
distFilePath
=
'
${dir.path}
/
${Constant.h5DistDir}
/
$version
.zip'
;
if
(!
File
(
distFilePath
).
existsSync
())
{
if
(!
await
File
(
distFilePath
).
exists
())
{
distFilePath
=
'assets/
$version
.zip'
;
if
(!
await
File
(
distFilePath
).
exists
())
{
distFilePath
=
'assets/dist.zip'
;
distFilePath
=
'assets/dist.zip'
;
}
}
}
// 解压
// 解压
await
ZipUtil
.
extractZipFile
(
distFilePath
,
outputDirectory
);
await
ZipUtil
.
extractZipFile
(
distFilePath
,
outputDirectory
);
// 用于显示的版本号
// 用于显示的版本号
...
@@ -173,10 +177,11 @@ class LocalServerService {
...
@@ -173,10 +177,11 @@ class LocalServerService {
// 读取和设置用于显示的版本号
// 读取和设置用于显示的版本号
Future
<
void
>
_getAndSetShowVersion
(
String
outputDirectory
)
async
{
Future
<
void
>
_getAndSetShowVersion
(
String
outputDirectory
)
async
{
var
versionFile
=
File
(
'
$outputDirectory
/
version.txt
'
);
var
versionFile
=
File
(
'
$outputDirectory
/
package.json
'
);
if
(
await
versionFile
.
exists
())
{
if
(
await
versionFile
.
exists
())
{
var
content
=
(
await
versionFile
.
readAsString
()).
trim
();
var
content
=
(
await
versionFile
.
readAsString
()).
trim
();
getIt
.
get
<
SharedPreferences
>().
setString
(
Constant
.
h5ShowVersionKey
,
content
);
var
json
=
jsonDecode
(
content
);
getIt
.
get
<
SharedPreferences
>().
setString
(
Constant
.
h5ShowVersionKey
,
json
[
'version'
]
??
'undefined'
);
}
else
{
}
else
{
getIt
.
get
<
SharedPreferences
>().
setString
(
Constant
.
h5ShowVersionKey
,
'undefined'
);
getIt
.
get
<
SharedPreferences
>().
setString
(
Constant
.
h5ShowVersionKey
,
'undefined'
);
}
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment