Commit 3979605c authored by 范雪寒's avatar 范雪寒

fix: 图片路径问题

parent 81445ff1
This diff is collapsed.
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef} from '@angular/core'; import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef } from '@angular/core';
import { defaultData } from '../../assets/default/formData/defaultData.js' import { defaultData } from '../../assets/default/formData/defaultData.js'
@Component({ @Component({
...@@ -13,7 +13,16 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -13,7 +13,16 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
dataArray: Array<Object> = []; dataArray: Array<Object> = [];
hotZoneItemArr: Array<Object> = []; hotZoneItemArr: Array<Object> = [];
bgItem: Object; bgItem: Object;
bgImages: Object = {leftTop:"", middleTop:"", rightTop:"", leftMiddle:"", rightMiddle:"", leftBottom:"", middleBottom:"", rightBottom:""}; bgImages: Object = {
leftTop: "",
middleTop: "",
rightTop: "",
leftMiddle: "",
rightMiddle: "",
leftBottom: "",
middleBottom: "",
rightBottom: ""
};
KEY = 'DataKey_YM4-11'; KEY = 'DataKey_YM4-11';
set item(item) { set item(item) {
...@@ -32,18 +41,24 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -32,18 +41,24 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit() { ngOnInit() {
this.item = {}; this.item = {};
this.item.contentObj = {}; this.item.contentObj = {};
const getData = (<any> window).courseware.getData; const getData = (<any>window).courseware.getData;
getData((data) => { getData((data) => {
// console.log("读取数据", data) // console.log("读取数据", data)
if (data) {
if (data.data) {
this.item = data.data;
} else if (data) {
this.item = data; this.item = data;
} else { } else {
this.item = {}; this.item = {};
} }
if ( !this.item.contentObj ) { if (!this.item.contentObj) {
this.item.contentObj = {}; this.item.contentObj = {};
} }
console.log('this.item:: ', this.item);
this.init(); this.init();
this.refresh(); this.refresh();
}, this.KEY); }, this.KEY);
} }
...@@ -54,7 +69,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -54,7 +69,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnDestroy() { ngOnDestroy() {
} }
saveData(e){ saveData(e) {
this.bgItem = e.bgItem; this.bgItem = e.bgItem;
// this.bgImages = e.bgImages // this.bgImages = e.bgImages
this.hotZoneItemArr.length = 0; this.hotZoneItemArr.length = 0;
...@@ -65,7 +80,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -65,7 +80,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
init() { init() {
if(typeof(this.item.contentObj.hotZoneItemArr) == undefined || typeof(this.item.contentObj.bgItem) == undefined || typeof(this.item.contentObj.bgImages) == undefined || this.item.contentObj.version != defaultData.version) { if (typeof (this.item.contentObj.hotZoneItemArr) == undefined
|| typeof (this.item.contentObj.bgItem) == undefined
|| typeof (this.item.contentObj.bgImages) == undefined
|| this.item.contentObj.version != defaultData.version) {
console.log("Init defalue data") console.log("Init defalue data")
this.item.contentObj = defaultData this.item.contentObj = defaultData
this.hotZoneItemArr = defaultData.hotZoneItemArr this.hotZoneItemArr = defaultData.hotZoneItemArr
...@@ -80,7 +99,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -80,7 +99,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
cardItemData(){ cardItemData() {
return { return {
audio_url: "", audio_url: "",
image_url: "", image_url: "",
...@@ -88,7 +107,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -88,7 +107,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}; };
} }
cardChoiceData(){ cardChoiceData() {
return { isText: true, text: "", image_url: "" } return { isText: true, text: "", image_url: "" }
} }
...@@ -147,7 +166,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -147,7 +166,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
save() { save() {
(<any> window).courseware.setData(this.item, null, this.KEY); (<any>window).courseware.setData(this.item, null, this.KEY);
this.refresh(); this.refresh();
// console.log("保存", this.item) // console.log("保存", this.item)
} }
......
This diff is collapsed.
import os
import json
def file_name(file_dir):
fileList =["bg_kuang", "bg_kuang2", "bg_light"]
f = open('filename.txt', 'w');
blank = False
for root, dirs, files in os.walk(file_dir):
for fileName in files:
if root.split("\\")[-1]=="frame" or root.split("\\")[-1]=="sound" or root.split("\\")[-1]=="play" or (root.split("\\")[-1] in fileList):
blank = True
if root.split("\\")[-1] != "play":
f.write("'" + fileName.split(".")[0] + "': 'assets/play/" + root.split("\\")[-1] + "/" + fileName + "',\n")
else:
f.write("'" + fileName.split(".")[0] + "': 'assets/" + root.split("\\")[-1] + "/" + fileName + "',\n")
if blank:
f.write("\n")
blank = False
f.close()
fileList = file_name(os.path.abspath('.'))
'bg_70_40': 'assets/play/bg_70_40.png',
'creatJsonProfile': 'assets/play/creatJsonProfile.py',
'filename': 'assets/play/filename.txt',
'line': 'assets/play/line.png',
'num-1': 'assets/play/num-1.png',
'num-2': 'assets/play/num-2.png',
'num-3': 'assets/play/num-3.png',
'num-4': 'assets/play/num-4.png',
'num-5': 'assets/play/num-5.png',
'num-6': 'assets/play/num-6.png',
'num-7': 'assets/play/num-7.png',
'num-8': 'assets/play/num-8.png',
'oval-copy': 'assets/play/oval-copy.png',
'question-bg': 'assets/play/question-bg.png',
'resizeImg': 'assets/play/resizeImg.py',
'1': 'assets/play/sound/1.mp3',
'2': 'assets/play/sound/2.mp3',
'3': 'assets/play/sound/3.mp3',
'check': 'assets/play/sound/check.mp3',
'fanye': 'assets/play/sound/fanye.mp3',
'jifen': 'assets/play/sound/jifen.mp3',
'kulian': 'assets/play/sound/kulian.mp3',
'putong': 'assets/play/sound/putong.mp3',
'start': 'assets/play/sound/start.mp3',
'xianshi': 'assets/play/sound/xianshi.mp3',
'xiaolian': 'assets/play/sound/xiaolian.mp3',
'xingxing': 'assets/play/sound/xingxing.mp3',
import os
import json
def file_name(file_dir):
fileList =["bg_kuang", "bg_kuang2", "bg_light"]
f = open('filename.txt', 'w');
blank = False
for root, dirs, files in os.walk(file_dir):
for fileName in files:
print(root.split("\\")[-1])
f.write("'" + fileName.split(".")[0] + "': 'assets/hotZooCard/" + root.split("\\")[-1] + "/" + fileName + "',\n")
f.close()
fileList = file_name(os.path.abspath('.'))
'bg_70_40_1': 'assets/hotZooCard/hotZooCard/bg_70_40_1.png',
'bg_70_40_10': 'assets/hotZooCard/hotZooCard/bg_70_40_10.png',
'bg_70_40_11': 'assets/hotZooCard/hotZooCard/bg_70_40_11.png',
'bg_70_40_12': 'assets/hotZooCard/hotZooCard/bg_70_40_12.png',
'bg_70_40_13': 'assets/hotZooCard/hotZooCard/bg_70_40_13.png',
'bg_70_40_14': 'assets/hotZooCard/hotZooCard/bg_70_40_14.png',
'bg_70_40_15': 'assets/hotZooCard/hotZooCard/bg_70_40_15.png',
'bg_70_40_16': 'assets/hotZooCard/hotZooCard/bg_70_40_16.png',
'bg_70_40_17': 'assets/hotZooCard/hotZooCard/bg_70_40_17.png',
'bg_70_40_18': 'assets/hotZooCard/hotZooCard/bg_70_40_18.png',
'bg_70_40_19': 'assets/hotZooCard/hotZooCard/bg_70_40_19.png',
'bg_70_40_2': 'assets/hotZooCard/hotZooCard/bg_70_40_2.png',
'bg_70_40_20': 'assets/hotZooCard/hotZooCard/bg_70_40_20.png',
'bg_70_40_21': 'assets/hotZooCard/hotZooCard/bg_70_40_21.png',
'bg_70_40_22': 'assets/hotZooCard/hotZooCard/bg_70_40_22.png',
'bg_70_40_23': 'assets/hotZooCard/hotZooCard/bg_70_40_23.png',
'bg_70_40_24': 'assets/hotZooCard/hotZooCard/bg_70_40_24.png',
'bg_70_40_25': 'assets/hotZooCard/hotZooCard/bg_70_40_25.png',
'bg_70_40_3': 'assets/hotZooCard/hotZooCard/bg_70_40_3.png',
'bg_70_40_4': 'assets/hotZooCard/hotZooCard/bg_70_40_4.png',
'bg_70_40_5': 'assets/hotZooCard/hotZooCard/bg_70_40_5.png',
'bg_70_40_6': 'assets/hotZooCard/hotZooCard/bg_70_40_6.png',
'bg_70_40_7': 'assets/hotZooCard/hotZooCard/bg_70_40_7.png',
'bg_70_40_8': 'assets/hotZooCard/hotZooCard/bg_70_40_8.png',
'bg_70_40_9': 'assets/hotZooCard/hotZooCard/bg_70_40_9.png',
'creatJsonProfile': 'assets/hotZooCard/hotZooCard/creatJsonProfile.py',
'filename': 'assets/hotZooCard/hotZooCard/filename.txt',
import os
import shutil
from PIL import Image
fileName = os.listdir('./')
withBorder = False
border_left = ""
border_right = ""
imageName = input("图片名:")
if input("是否包含边框? (y/n):")=="y":
withBorder = True
if withBorder:
border_left = input("左边框文件名:")
border_right = input("右边框文件名:")
number = int(input("数量:"))
if os.path.exists('./' + imageName + '/'):
shutil.rmtree('./' + imageName + '/')
os.mkdir('./' + imageName + '/')
pic = Image.open('./' + imageName + '.PNG')
width = pic.width
height = pic.height
f = open('./' + imageName + '/' + imageName + '_map.txt', 'w')
if withBorder:
borderImg_left, borderImg_right = Image.open('./' + border_left + '.PNG'), Image.open('./' + border_right + '.PNG')
for index in range(1, number):
newpic = pic.resize((width*index, height),Image.ANTIALIAS)
loc1, loc2, loc3 = (0, 0), (borderImg_left.width, 0), (borderImg_left.width +newpic.width, 0)
join_pic = Image.new('RGBA', (borderImg_left.width + newpic.width + borderImg_right.width, newpic.height))
join_pic.paste(borderImg_left, loc1)
join_pic.paste(newpic, loc2)
join_pic.paste(borderImg_right, loc3)
join_pic.save('./' + imageName + '/' + imageName + '_' + str(index) + 'x.PNG')
f.write('"' + str(width*index) + '": "' + imageName + '_' + str(index) + 'x",\n')
f.close()
else:
for index in range(1, number):
newpic = pic.resize((width*index, height),Image.ANTIALIAS)
newpic.save('./' + imageName + '/' + imageName + '_' + str(index) + 'x.PNG')
f.write('"' + str(width*index) + '": "' + imageName + '_' + str(index) + 'x",\n')
f.close()
\ No newline at end of file
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh"> <html lang="zh">
<head>
<head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>NgOne</title> <title>NgOne</title>
<base href="/" /> <base href="/" />
<style> <style>
html, body{ html,
body {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
</style> </style>
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" /> <link rel="icon" type="image/x-icon" href="favicon.ico" />
<!-- <script type="text/javascript" src="http://teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js" ></script> --> <!-- <script type="text/javascript" src="http://teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js" ></script> -->
<script type="text/javascript" src="https://staging-teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air_online.js"></script> <script type="text/javascript"
</head> src="https://staging-teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"></script>
<body> </head>
<body>
<app-root></app-root> <app-root></app-root>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment