add
This commit is contained in:
2
MyApplication2/entry/.gitignore
vendored
Normal file
2
MyApplication2/entry/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/build
|
||||
/node_modules
|
37
MyApplication2/entry/build.gradle
Normal file
37
MyApplication2/entry/build.gradle
Normal file
@@ -0,0 +1,37 @@
|
||||
apply plugin: 'com.huawei.ohos.hap'
|
||||
apply plugin: 'com.huawei.ohos.decctest'
|
||||
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
|
||||
ohos {
|
||||
signingConfigs {
|
||||
debug {
|
||||
storeFile file('C:\\Users\\honor\\.ohos\\config\\auto_debug_myapplication_56657123.p12')
|
||||
storePassword '00000018ABED8099CAAA6EC570D4E456ABF55BBB47D8D1BE27C2F7E7A55EB2A5D81A3ECD28278B1C'
|
||||
keyAlias = 'debugKey'
|
||||
keyPassword '000000182BFA80CB83594170D6A068FA249C80099F9B45A3650D15571AC7AA6789CBEA5CAAEEDF58'
|
||||
signAlg = 'SHA256withECDSA'
|
||||
profile file('C:\\Users\\honor\\.ohos\\config\\auto_debug_myapplication_56657123.p7b')
|
||||
certpath file('C:\\Users\\honor\\.ohos\\config\\auto_debug_myapplication_56657123.cer')
|
||||
}
|
||||
}
|
||||
compileSdkVersion 5
|
||||
defaultConfig {
|
||||
compatibleSdkVersion 4
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
proguardOpt {
|
||||
proguardEnabled false
|
||||
rulesFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200'
|
||||
}
|
||||
decc {
|
||||
supportType = ['html', 'xml']
|
||||
}
|
1
MyApplication2/entry/package.json
Normal file
1
MyApplication2/entry/package.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
1
MyApplication2/entry/proguard-rules.pro
vendored
Normal file
1
MyApplication2/entry/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1 @@
|
||||
# config module specific ProGuard rules here.
|
65
MyApplication2/entry/src/main/config.json
Normal file
65
MyApplication2/entry/src/main/config.json
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.xcl20481.myapplication",
|
||||
"vendor": "xcl20481",
|
||||
"version": {
|
||||
"code": 1000000,
|
||||
"name": "1.0.1"
|
||||
}
|
||||
},
|
||||
"deviceConfig": {
|
||||
"default": {
|
||||
"keepAlive": true
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"package": "com.xcl20481.myapplication",
|
||||
"name": ".MyApplication",
|
||||
"mainAbility": "com.xcl20481.myapplication.MainAbility",
|
||||
"deviceType": [
|
||||
"phone",
|
||||
"tablet",
|
||||
"tv",
|
||||
"wearable"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "entry",
|
||||
"moduleType": "entry",
|
||||
"installationFree": false
|
||||
},
|
||||
"abilities": [
|
||||
{
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
],
|
||||
"visible": true,
|
||||
"name": "com.xcl20481.myapplication.MainAbility",
|
||||
"icon": "$media:icon2",
|
||||
"description": "$string:mainability_description",
|
||||
"label": "$string:xcl2048",
|
||||
"type": "page",
|
||||
"launchType": "standard"
|
||||
}
|
||||
],
|
||||
"js": [
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index"
|
||||
],
|
||||
"name": "default",
|
||||
"window": {
|
||||
"designWidth": 720,
|
||||
"autoDesignWidth": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.xcl20481.myapplication;
|
||||
|
||||
import ohos.ace.ability.AceAbility;
|
||||
import ohos.aafwk.content.Intent;
|
||||
|
||||
public class MainAbility extends AceAbility {
|
||||
@Override
|
||||
public void onStart(Intent intent) {
|
||||
super.onStart(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package com.xcl20481.myapplication;
|
||||
|
||||
import ohos.aafwk.ability.AbilityPackage;
|
||||
|
||||
public class MyApplication extends AbilityPackage {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
super.onInitialize();
|
||||
}
|
||||
}
|
8
MyApplication2/entry/src/main/js/default/app.js
Normal file
8
MyApplication2/entry/src/main/js/default/app.js
Normal file
@@ -0,0 +1,8 @@
|
||||
export default {
|
||||
onCreate() {
|
||||
console.info('AceApplication onCreate');
|
||||
},
|
||||
onDestroy() {
|
||||
console.info('AceApplication onDestroy');
|
||||
}
|
||||
};
|
Binary file not shown.
After Width: | Height: | Size: 152 KiB |
BIN
MyApplication2/entry/src/main/js/default/common/images/bg-tv.jpg
Normal file
BIN
MyApplication2/entry/src/main/js/default/common/images/bg-tv.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 210 KiB |
6
MyApplication2/entry/src/main/js/default/i18n/en-US.json
Normal file
6
MyApplication2/entry/src/main/js/default/i18n/en-US.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"strings": {
|
||||
"hello": "Hello",
|
||||
"world": "World"
|
||||
}
|
||||
}
|
6
MyApplication2/entry/src/main/js/default/i18n/zh-CN.json
Normal file
6
MyApplication2/entry/src/main/js/default/i18n/zh-CN.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"strings": {
|
||||
"hello": "您好",
|
||||
"world": "世界"
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
.container{
|
||||
width: 227px;
|
||||
height: 227px;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.score{
|
||||
text-align: center;
|
||||
width: 70px;
|
||||
height: 17px;
|
||||
letter-spacing: 0px;
|
||||
font-size: 11px;
|
||||
margin-top: 1.8px;
|
||||
margin-bottom:3px;
|
||||
}
|
||||
.best{
|
||||
text-align: center;
|
||||
width: 60px;
|
||||
height: 17px;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0px;
|
||||
margin-top: 8.5px;
|
||||
}
|
||||
.tile-wrap{
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
flex-wrap: wrap;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
.tile{
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
margin-top: 2px;
|
||||
margin-left: 2px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.btn{
|
||||
width: 61.5px;
|
||||
height: 20.5px;
|
||||
background-color: #155ddc;
|
||||
margin-top: 5px;
|
||||
font-size: 13px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.text{
|
||||
font-size: 13px;
|
||||
color: #000000;
|
||||
}
|
||||
.stack{
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
}
|
||||
.subcontainer{
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: transparent;
|
||||
}
|
||||
.gameover{
|
||||
font-size: 20px;
|
||||
color: #FF7500;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
<div class="container">
|
||||
<text class="best">
|
||||
Best:{{best}}
|
||||
</text>
|
||||
<text class="score">
|
||||
Score:{{score}}
|
||||
</text>
|
||||
<stack class="stack">
|
||||
<div class="tile-wrap" onswipe="onSwipe">
|
||||
<div class="tile" for="{{tiles}}" style="background-color:#000000">
|
||||
<text class="text" style="color:#FFFFFF">
|
||||
{{$item.text}}
|
||||
</text>
|
||||
</div>
|
||||
</div>
|
||||
<div class="subcontainer" show="{{isShow}}">
|
||||
<text class="gameover">
|
||||
Gameover!
|
||||
</text>
|
||||
</div>
|
||||
</stack>
|
||||
<input class="btn" type="button" value="Restart!" onclick="onInit" ></input>
|
||||
</div>
|
127
MyApplication2/entry/src/main/js/default/pages/index/index.js
Normal file
127
MyApplication2/entry/src/main/js/default/pages/index/index.js
Normal file
@@ -0,0 +1,127 @@
|
||||
import brightness from '@system.brightness';
|
||||
let numbers,newNumbers;
|
||||
export default{
|
||||
data:{
|
||||
score:0,
|
||||
best:0,
|
||||
tiles:[],
|
||||
isShow:false,
|
||||
},
|
||||
onInit() {
|
||||
this.isShow=false;
|
||||
this.score=0;
|
||||
this.tiles=[{text:""},{text:""},{text:""},{text:""},{text:""},{text:""},{text:""},{text:""},{text:""},{text:""},{text:""},{text:""},{text:""},{text:""},{text:""},{text:""}];
|
||||
numbers=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
||||
newNumbers=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
||||
this.supplyNumber();
|
||||
this.supplyNumber();
|
||||
this.updateView();
|
||||
brightness.setKeepScreenOn({keepScreenOn: true,});
|
||||
brightness.setMode({mode: 1,});
|
||||
},
|
||||
supplyNumber(){
|
||||
let positions=[];
|
||||
for(let i=0;i<=15;i++){
|
||||
if(!newNumbers[i]) positions.push(i);
|
||||
}
|
||||
let h=Math.floor(Math.random()*positions.length);
|
||||
if (Math.random()<=0.8){
|
||||
newNumbers[positions[h]]=2;
|
||||
}else{
|
||||
newNumbers[positions[h]]=4;
|
||||
}
|
||||
},
|
||||
onSwipe(e) {
|
||||
newNumbers=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
||||
let start=0,differ=0,step=0;
|
||||
switch(e.direction){
|
||||
case 'left':
|
||||
start=0;
|
||||
differ=1;
|
||||
step=4;
|
||||
break;
|
||||
case 'right':
|
||||
start=3;
|
||||
differ=-1;
|
||||
step=4;
|
||||
break;
|
||||
case 'up':
|
||||
start=0;
|
||||
differ=4;
|
||||
step=1;
|
||||
break;
|
||||
case 'down':
|
||||
start=12;
|
||||
differ=-4;
|
||||
step=1;
|
||||
break;
|
||||
}
|
||||
let ids;
|
||||
for (let j=0;j<=3;j++){
|
||||
ids=this.getIds(start, differ);
|
||||
let before=null;
|
||||
let noZeros=0;
|
||||
for(let k=0;k<=3;k++){
|
||||
let id=ids[k];
|
||||
let number=numbers[id];
|
||||
if (number!=0){
|
||||
if(number==before){
|
||||
this.score+=number*2;
|
||||
newNumbers[ids[noZeros-1]]*=2;
|
||||
before=null;
|
||||
}else{
|
||||
newNumbers[ids[noZeros]]=number;
|
||||
before=number;
|
||||
noZeros+=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
start+=step;
|
||||
}
|
||||
if(this.best>=this.score){
|
||||
this.best=this.best;
|
||||
}else{
|
||||
this.best=this.score;}
|
||||
if(numbers.toString()!=newNumbers.toString()){
|
||||
this.supplyNumber();
|
||||
this.updateView();
|
||||
newNumbers=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
||||
if(this.isGameOver()==true){this.isShow=true;}
|
||||
}
|
||||
},
|
||||
getIds(start, differ){
|
||||
let ids=[];
|
||||
for (let z=4;z>=1;z--){
|
||||
ids.push(start);
|
||||
start+=differ;
|
||||
}
|
||||
return ids;
|
||||
},
|
||||
updateView() {
|
||||
for (let x=0;x<=15;x++) {
|
||||
if (newNumbers[x]!=0){
|
||||
this.tiles[x].text=newNumbers[x].toString();
|
||||
}else{
|
||||
this.tiles[x].text="";
|
||||
}
|
||||
}
|
||||
numbers=newNumbers;
|
||||
},
|
||||
isGameOver(){
|
||||
if(this.isGridsFull()==true && this.isGridsNotMergeable()==true) return true;
|
||||
},
|
||||
isGridsFull(){
|
||||
if(numbers.indexOf(0)==-1){return true;}
|
||||
},
|
||||
isGridsNotMergeable(){
|
||||
for(let l=0;l<=15;l++){
|
||||
if(l<=14){
|
||||
if(numbers[l]==numbers[l+1]&&(l+1)%4!=0) return false;
|
||||
}
|
||||
if(l<=11){
|
||||
if(numbers[l]==numbers[l+4]) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "xcl2048",
|
||||
"value": "xcl2048"
|
||||
},
|
||||
{
|
||||
"name": "mainability_description",
|
||||
"value": "JS_Empty Ability"
|
||||
}
|
||||
]
|
||||
}
|
BIN
MyApplication2/entry/src/main/resources/base/media/icon.png
Normal file
BIN
MyApplication2/entry/src/main/resources/base/media/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
BIN
MyApplication2/entry/src/main/resources/base/media/icon2.jpg
Normal file
BIN
MyApplication2/entry/src/main/resources/base/media/icon2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
@@ -0,0 +1,14 @@
|
||||
package com.xcl20481.myapplication;
|
||||
|
||||
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ExampleOhosTest {
|
||||
@Test
|
||||
public void testBundleName() {
|
||||
final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
|
||||
assertEquals("com.xcl20481.myapplication", actualBundleName);
|
||||
}
|
||||
}
|
8
MyApplication2/entry/src/ohosTest/js/default/app.js
Normal file
8
MyApplication2/entry/src/ohosTest/js/default/app.js
Normal file
@@ -0,0 +1,8 @@
|
||||
export default {
|
||||
onCreate() {
|
||||
console.info('TestApplication onCreate');
|
||||
},
|
||||
onDestroy() {
|
||||
console.info('TestApplication onDestroy');
|
||||
}
|
||||
};
|
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"strings": {
|
||||
"hello": "Hello",
|
||||
"world": "World"
|
||||
},
|
||||
"Files": {
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"strings": {
|
||||
"hello": "您好",
|
||||
"world": "世界"
|
||||
},
|
||||
"Files": {
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
.container {
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 100px;
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
<div class="container">
|
||||
<text class="title">
|
||||
{{ $t('strings.hello') }} {{ title }}
|
||||
</text>
|
||||
</div>
|
@@ -0,0 +1,41 @@
|
||||
import file from '@system.file'
|
||||
import app from '@system.app'
|
||||
import device from '@system.device'
|
||||
import router from '@system.router'
|
||||
import {Core, Constant, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index'
|
||||
|
||||
export default {
|
||||
data: {
|
||||
title: ""
|
||||
},
|
||||
onInit() {
|
||||
this.title = this.$t('strings.world');
|
||||
},
|
||||
onShow() {
|
||||
console.info('onShow finish')
|
||||
const core = Core.getInstance()
|
||||
const expectExtend = new ExpectExtend({
|
||||
'id': 'extend'
|
||||
})
|
||||
const reportExtend = new ReportExtend(file)
|
||||
const instrumentLog = new InstrumentLog({
|
||||
'id': 'report',
|
||||
'version': '1.0.3'
|
||||
})
|
||||
core.addService('expect', expectExtend)
|
||||
core.addService('report', reportExtend)
|
||||
core.addService('report', instrumentLog)
|
||||
core.init()
|
||||
core.subscribeEvent('spec', instrumentLog)
|
||||
core.subscribeEvent('suite', instrumentLog)
|
||||
core.subscribeEvent('task', instrumentLog)
|
||||
|
||||
const configService = core.getDefaultService('config')
|
||||
configService.setConfig(this)
|
||||
|
||||
require('../../../test/List.test')
|
||||
core.execute()
|
||||
},
|
||||
onReady() {
|
||||
},
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
import app from '@system.app'
|
||||
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
|
||||
|
||||
describe('appInfoTest', function () {
|
||||
it('app_info_test_001', 0, function () {
|
||||
var info = app.getInfo()
|
||||
expect(info.versionName).assertEqual('1.0')
|
||||
expect(info.versionCode).assertEqual('3')
|
||||
})
|
||||
})
|
1
MyApplication2/entry/src/ohosTest/js/test/List.test.js
Normal file
1
MyApplication2/entry/src/ohosTest/js/test/List.test.js
Normal file
@@ -0,0 +1 @@
|
||||
require('./ExampleJsunit.test.js')
|
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "MyApplication"
|
||||
},
|
||||
{
|
||||
"name": "mainability_description",
|
||||
"value": "hap sample empty page"
|
||||
}
|
||||
]
|
||||
}
|
BIN
MyApplication2/entry/src/ohosTest/resources/base/media/icon.png
Normal file
BIN
MyApplication2/entry/src/ohosTest/resources/base/media/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
Reference in New Issue
Block a user