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'
@Component({
......@@ -10,10 +10,19 @@ import { defaultData } from '../../assets/default/formData/defaultData.js'
export class FormComponent implements OnInit, OnChanges, OnDestroy {
_item: any;
dataArray: Array<Object> = [];
dataArray: Array<Object> = [];
hotZoneItemArr: Array<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';
set item(item) {
......@@ -32,18 +41,24 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit() {
this.item = {};
this.item.contentObj = {};
const getData = (<any> window).courseware.getData;
const getData = (<any>window).courseware.getData;
getData((data) => {
// console.log("读取数据", data)
if (data) {
if (data.data) {
this.item = data.data;
} else if (data) {
this.item = data;
} else {
this.item = {};
}
if ( !this.item.contentObj ) {
if (!this.item.contentObj) {
this.item.contentObj = {};
}
console.log('this.item:: ', this.item);
this.init();
this.refresh();
}, this.KEY);
}
......@@ -54,7 +69,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnDestroy() {
}
saveData(e){
saveData(e) {
this.bgItem = e.bgItem;
// this.bgImages = e.bgImages
this.hotZoneItemArr.length = 0;
......@@ -65,7 +80,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
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")
this.item.contentObj = defaultData
this.hotZoneItemArr = defaultData.hotZoneItemArr
......@@ -77,10 +96,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.bgItem = this.item.contentObj.bgItem;
this.bgImages = this.item.contentObj.bgImages;
}
}
cardItemData(){
cardItemData() {
return {
audio_url: "",
image_url: "",
......@@ -88,12 +107,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
};
}
cardChoiceData(){
cardChoiceData() {
return { isText: true, text: "", image_url: "" }
}
getDefaultPicArr() {
let arr = [];
let arr = [];
return arr;
}
......@@ -102,7 +121,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
addChoice(questionIndex) {
addChoice(questionIndex) {
// let item = this.cardChoiceData();
// this.dataArray[questionIndex].choice.incorrect.push(item);
// this.saveItem();
......@@ -110,21 +129,21 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
onImageUploadSuccessByItem(e, item) {
item.image_url = e.url
this.save();
this.save();
}
onAudioUploadSuccessByItem(e, item) {
item.audio_url = e.url;
onAudioUploadSuccessByItem(e, item) {
item.audio_url = e.url;
this.save();
}
onTitleAudioUploadSuccess(e) {
onTitleAudioUploadSuccess(e) {
this.item.contentObj.titleAudio_url = e.url;
this.save();
}
addItem() {
let item = this.cardItemData();
addItem() {
let item = this.cardItemData();
this.dataArray.push(item);
this.saveItem();
}
......@@ -147,7 +166,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
save() {
(<any> window).courseware.setData(this.item, null, this.KEY);
(<any>window).courseware.setData(this.item, null, this.KEY);
this.refresh();
// 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>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>NgOne</title>
<base href="/" />
<style>
html, body{
width: 100%;
height: 100%;
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<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="https://staging-teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air_online.js"></script>
</head>
<body>
<app-root></app-root>
</body>
</html>
<head>
<meta charset="utf-8" />
<title>NgOne</title>
<base href="/" />
<style>
html,
body {
width: 100%;
height: 100%;
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<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="https://staging-teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"></script>
</head>
<body>
<app-root></app-root>
</body>
</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