mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
自动生成js资源json文件
This commit is contained in:
parent
506b78551e
commit
b4e5494b45
118
ShadowEditor.Web/assets/js/opentype.min.js
vendored
118
ShadowEditor.Web/assets/js/opentype.min.js
vendored
File diff suppressed because one or more lines are too long
2414
ShadowEditor.Web/assets/js_assets.json
Normal file
2414
ShadowEditor.Web/assets/js_assets.json
Normal file
File diff suppressed because it is too large
Load Diff
47
test/update_javascript_assets.py
Normal file
47
test/update_javascript_assets.py
Normal file
@ -0,0 +1,47 @@
|
||||
import os
|
||||
import json
|
||||
|
||||
# 自动生成js资源json文件:`\ShadowEditor.Web\assets\js_assets.json`
|
||||
|
||||
root_path = os.getcwd()
|
||||
js_assets_path = '%s\\ShadowEditor.Web\\assets\\js' % root_path
|
||||
json_path = '%s\\ShadowEditor.Web\\assets\\js_assets.json' % root_path
|
||||
|
||||
list = []
|
||||
name_list = []
|
||||
|
||||
|
||||
def handle(path):
|
||||
parts = path.split('\\')
|
||||
names = parts[len(parts) - 1].split('.')
|
||||
|
||||
if names[len(names) - 1] != 'js':
|
||||
return
|
||||
|
||||
name = ''.join(names[:-1])
|
||||
|
||||
if name in name_list:
|
||||
print('%s is already existed!' % name)
|
||||
|
||||
name_list.append(name)
|
||||
|
||||
list.append({
|
||||
'name': name,
|
||||
'assets': [
|
||||
path
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
for root, dirs, files in os.walk(js_assets_path):
|
||||
for i in files:
|
||||
file = '%s\\%s' % (root, i)
|
||||
handle(file)
|
||||
|
||||
data = json.dumps(list, ensure_ascii=False)
|
||||
|
||||
file = open(json_path, 'wb')
|
||||
file.write(data.encode('utf-8'))
|
||||
file.close()
|
||||
|
||||
print('Completed!')
|
||||
Loading…
x
Reference in New Issue
Block a user