Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
scanqrwhitecopy
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
scanqrwhitecopy
Commits
010a5e62
Commit
010a5e62
authored
Jan 16, 2025
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
855fcbdb
Pipeline
#1461
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
2 deletions
+26
-2
GetInfo.py
app/GetInfo.py
+26
-2
No files found.
app/GetInfo.py
View file @
010a5e62
...
@@ -100,6 +100,9 @@ def update_global_config(file_path, json_data):
...
@@ -100,6 +100,9 @@ def update_global_config(file_path, json_data):
print
(
f
"更新文件时发生错误: {e}"
)
print
(
f
"更新文件时发生错误: {e}"
)
import
os
import
json
def
update_google_services
(
json_data
):
def
update_google_services
(
json_data
):
"""更新 google-services.json 文件内容"""
"""更新 google-services.json 文件内容"""
try
:
try
:
...
@@ -108,8 +111,10 @@ def update_google_services(json_data):
...
@@ -108,8 +111,10 @@ def update_google_services(json_data):
if
os
.
path
.
exists
(
google_services_path
):
if
os
.
path
.
exists
(
google_services_path
):
print
(
f
"找到 google-services.json 文件: {google_services_path}"
)
print
(
f
"找到 google-services.json 文件: {google_services_path}"
)
# 从 applicationid.json 中读取
googleServices 的值
# 从 applicationid.json 中读取
数据
google_services_raw
=
json_data
.
get
(
"googleServices"
)
google_services_raw
=
json_data
.
get
(
"googleServices"
)
package_name
=
json_data
.
get
(
"PACKAGE_NAME"
)
if
google_services_raw
:
if
google_services_raw
:
try
:
try
:
# 反序列化 googleServices 的值
# 反序列化 googleServices 的值
...
@@ -127,12 +132,31 @@ def update_google_services(json_data):
...
@@ -127,12 +132,31 @@ def update_google_services(json_data):
except
json
.
JSONDecodeError
as
e
:
except
json
.
JSONDecodeError
as
e
:
print
(
f
"googleServices 值的反序列化失败: {e}"
)
print
(
f
"googleServices 值的反序列化失败: {e}"
)
else
:
else
:
print
(
"applicationid.json 中未找到 googleServices 的值。"
)
if
package_name
:
print
(
"googleServices 的值为空,尝试更新 package_name。"
)
with
open
(
google_services_path
,
"r"
,
encoding
=
"utf-8"
)
as
file
:
google_services_data
=
json
.
load
(
file
)
# 更新 package_name
if
"client"
in
google_services_data
:
for
client
in
google_services_data
[
"client"
]:
if
"client_info"
in
client
and
"android_client_info"
in
client
[
"client_info"
]:
client
[
"client_info"
][
"android_client_info"
][
"package_name"
]
=
package_name
print
(
f
"已将 package_name 更新为: {package_name}"
)
# 写入更新后的数据
with
open
(
google_services_path
,
"w"
,
encoding
=
"utf-8"
)
as
file
:
json
.
dump
(
google_services_data
,
file
,
ensure_ascii
=
False
,
indent
=
4
)
print
(
"
\n
google-services.json 文件已更新(更新 package_name)。"
)
else
:
print
(
"未找到 PACKAGE_NAME 值,无法更新 package_name。"
)
else
:
else
:
print
(
"未找到 google-services.json 文件。"
)
print
(
"未找到 google-services.json 文件。"
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"更新 google-services.json 文件时发生错误: {e}"
)
print
(
f
"更新 google-services.json 文件时发生错误: {e}"
)
def
update_build_gradle
(
json_data
):
def
update_build_gradle
(
json_data
):
"""更新 build.gradle 或 build.gradle.kts 文件中的 applicationId 值"""
"""更新 build.gradle 或 build.gradle.kts 文件中的 applicationId 值"""
try
:
try
:
...
...
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