Skip to content

Commit

Permalink
Merge pull request #1112 from aiselp/setup-v7
Browse files Browse the repository at this point in the history
一些更新
  • Loading branch information
kkevsekk1 authored Aug 14, 2024
2 parents cf57487 + e5c9192 commit f2bfc05
Show file tree
Hide file tree
Showing 71 changed files with 1,642 additions and 333 deletions.
2 changes: 0 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@
android:name="org.autojs.autojs.ui.error.IssueReporterActivity"
android:theme="@style/IssueReporterTheme" />

<service android:name="org.autojs.autojs.external.foreground.ForegroundService" />

<activity android:name="org.autojs.autojs.external.tasker.TaskPrefEditActivity_" />

<activity-alias
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/assets/sample/v7/java交互/创建java对象.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { loadClass, java } from 'java'

const File = loadClass('java.io.File')

const a = new File('/sdcard')
const b = new java.io.File('/sdcard')

console.log(a.isFile());
console.log(b.isFile());
12 changes: 12 additions & 0 deletions app/src/main/assets/sample/v7/对话框/Alert.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { showAlertDialog } from 'dialogs'

await showAlertDialog("AlertDialog", {
content: "对话框内容"
})


await showAlertDialog("提示", {
content: "不可通过点击返回键和点击外部取消的对话框",
dismissOnBackPress: false,
dismissOnClickOutside: false,
})
8 changes: 8 additions & 0 deletions app/src/main/assets/sample/v7/对话框/Confirm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { showConfirmDialog } from 'dialogs'
import { showToast } from 'toast'

const cilik = await showConfirmDialog("提示", {
content: "对话框内容"
})

showToast('你点击了:' + (cilik ? '确认' : '取消'))
6 changes: 6 additions & 0 deletions app/src/main/assets/sample/v7/对话框/InputDialog.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { showInputDialog } from 'dialogs'
import { showToast } from 'toast'

const input = await showInputDialog("请输入一些内容")

showToast('你输入了:' + input)
7 changes: 7 additions & 0 deletions app/src/main/assets/sample/v7/对话框/MultiChoiceDialog.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { showMultiChoiceDialog } from 'dialogs'
import { showToast } from 'toast'


const select = await showMultiChoiceDialog("标题", ['item1', 'item2', 'item3'])

showToast('你选择了:' + select)
7 changes: 7 additions & 0 deletions app/src/main/assets/sample/v7/对话框/SelectDialog.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { showSelectDialog } from 'dialogs'
import { showToast } from 'toast'


const select = await showSelectDialog("标题", ['item1', 'item2', 'item3'])

showToast('你选择了:' + select)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { showSingleChoiceDialog } from 'dialogs'
import { showToast } from 'toast'


const select = await showSingleChoiceDialog("标题", ['item1', 'item2', 'item3'])

showToast('你选择了:' + select)
36 changes: 36 additions & 0 deletions app/src/main/assets/sample/v7/对话框/ui中使用对话框.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { showAlertDialog, DialogFactory } from 'dialogs'
import {
createApp, xml, startActivity, Icons, defineComponent, ModifierExtension
} from "vue-ui";
import { showToast } from 'toast'

/**
* 如果有ui界面,建议使用以下方法创建对话框,拥有更好的交互效果
*/
const factory = new DialogFactory()

function alert() {
factory.showAlertDialog('提示', {
content: '这是ui中的对话框'
})
}

async function confirm() {
const b = await factory.showConfirmDialog('提示', {
content: '这是一个确认框'
})
showToast(b)
}
const app = createApp({
render() {
return xml`
<column>
<Button onClick=${alert}>弹出提示</Button>
<Button onClick=${confirm}>弹出确认框</Button>
<${factory.Dialog/**对话框的挂载点 */} />
</column>
`
}
})

startActivity(app)
10 changes: 5 additions & 5 deletions app/src/main/assets/sample/v7/用户界面ui/AppBar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const TopAppBar = defineComponent({
<TopAppBar title=${"TopAppBar"} >
<template #navigationIcon>
<IconButton>
<Icon src=${Menu()} />
<Icon src=${Menu} />
</IconButton>
</template>
<template #actions>
Expand All @@ -31,17 +31,17 @@ const BottomAppBar = defineComponent({
<column verticalArrangement=end modifier=${[fillMaxSize()]}>
<BottomAppBar>
<template #floatingActionButton>
<FloatingActionButton size="small" icon=${Add()} />
<FloatingActionButton size="small" icon=${Add} />
</template>
<template #actions>
<IconButton>
<Icon src=${Menu()} />
<Icon src=${Menu} />
</IconButton>
<IconButton>
<Icon src=${Search()} />
<Icon src=${Search} />
</IconButton>
<IconButton>
<Icon src=${Star()} />
<Icon src=${Star} />
</IconButton>
</template>
</BottomAppBar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const BottomSheetScaffold = defineComponent({
<template #topBar>
<TopAppBar title=${"TopAppBar"} >
<template #navigationIcon>
<IconButton><Icon src=${Menu()} /></IconButton>
<IconButton><Icon src=${Menu} /></IconButton>
</template>
</TopAppBar>
</template>
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/assets/sample/v7/用户界面ui/Chip.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ const app = createApp({
render() {
return xml`
<column>
<Chip type="assist" onClick=${onClick} leadingIcon=${Settings()} label="Assist" />
<Chip type="assist" onClick=${onClick} leadingIcon=${Settings} label="Assist" />
<Chip type="filter" onClick=${onClick} selected=${selected.value}
leadingIcon=${selected.value ? Done() : null} label="Filter" />
leadingIcon=${selected.value ? Done : null} label="Filter" />
<Chip type="input" onClick=${onClick} selected=${selected.value}
avatar=${Person()} label="Input" />
avatar=${Person} label="Input" />
<Chip type="suggestion" onClick=${onClick} label="Suggestion" />
<Chip type="assist" style="elevated" leadingIcon=${Settings()}
<Chip type="assist" style="elevated" leadingIcon=${Settings}
onClick=${onClick} label="Assist" />
<Chip type="filter" style="elevated" selected=${selected.value}
leadingIcon=${selected.value ? Done() : null}
leadingIcon=${selected.value ? Done : null}
onClick=${onClick} label="Filter" />
<Chip type="suggestion" style="elevated" onClick=${onClick} label="Suggestion" />
<Chip type="input" onClick=${onClick} selected=${selected.value}>
<template #label>
<text color=#cc99c9 >Input</text>
</template>
<template #avatar>
<Icon src=${Person()} tint=#c419c1 />
<Icon src=${Person} tint=#c419c1 />
</template>
<template #leadingIcon>
<Icon src=${Done()} tint=#c45cc1 />
<Icon src=${Done} tint=#c45cc1 />
</template>
<template #trailingIcon>
<Icon src=${Close()} tint=#557799 />
<Icon src=${Close} tint=#557799 />
</template>
</Chip>
</column>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/assets/sample/v7/用户界面ui/Tabs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const { Person, Star, Home, Close, Settings } = Icons.Default
const modifier = [padding(0, 5)]
const tabs = [{
text: "Settings",
icon: Settings(),
icon: Settings,
enabled: true,
}, {
text: "Home",
icon: Home(),
icon: Home,
enabled: false
}, {
text: "Star",
icon: Star(),
icon: Star,
enabled: true,
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const app = createApp({
return xml`
<column modifier=${modifier}>
Icon
<Icon modifier=${ImgModifier} src=${Home()} />
<Icon modifier=${ImgModifier} src=${Home} />
带颜色的Icon
<Icon modifier=${ImgModifier} src=${Add()} tint=${0xffcc4433n} />
<Icon modifier=${ImgModifier} src=${Add} tint=${0xffcc4433n} />
支持@drawer/ 中的资源
<Icon modifier=${ImgModifier} src="@drawable/ic_ali_close" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const M2 = defineComponent({
readOnly=${true}
singleLine=${true} >
<template #trailingIcon>
<Icon modifier=${[rotate(this.rotate)]} src=${ArrowDropDown()} />
<Icon modifier=${[rotate(this.rotate)]} src=${ArrowDropDown} />
</template>
</OutlinedTextField>
<template #menu>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/sample/v7/用户界面ui/按钮.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const app = createApp({
<Button type="elevated">elevated按钮</Button>
<Button type="outlined">outlined按钮</Button>
<Button type="tonal">tonal按钮</Button>
<IconButton><Icon src=${Home()} /></IconButton>
<IconButton><Icon src=${Home} /></IconButton>
切换按钮
<${G}/>
</column>
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/assets/sample/v7/用户界面ui/浮动按钮.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ const app = createApp({
return xml`
<column verticalArrangement="space_between" modifier=${[fillMaxSize()]}>
<row modifier=${[fillMaxWidth()]} horizontalArrangement="space_between" >
<FloatingActionButton size="small" icon=${Add()} />
<FloatingActionButton size="small" icon=${Add} />
<FloatingActionButton >
<Icon src=${Home()} tint=${0xffcc7459n} />
<Icon src=${Home} tint=${0xffcc7459n} />
</FloatingActionButton>
<FloatingActionButton size="large" icon=${Menu()} />
<FloatingActionButton size="large" icon=${Menu} />
</row>
<row modifier=${[fillMaxWidth()]} horizontalArrangement="space_between" >
<ExtendedFloatingActionButton text="Extended Fab" icon=${Home()} />
<ExtendedFloatingActionButton text="Extended Fab" icon=${Home()}>
<ExtendedFloatingActionButton text="Extended Fab" icon=${Home} />
<ExtendedFloatingActionButton text="Extended Fab" icon=${Home}>
<template #icon>
<Icon src=${Add()} tint=${0xffcc4433n} />
<Icon src=${Add} tint=${0xffcc4433n} />
</template>
<template #text>
<text color=#cc99c1 >Extended Fab2</text>
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/assets/sample/v7/用户界面ui/界面模板.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const TopAppBar = defineComponent({
<TopAppBar title=${"界面模板"} >
<template #navigationIcon>
<IconButton onClick=${() => { drawer.open() }}>
<Icon src=${Menu()} />
<Icon src=${Menu} />
</IconButton>
</template>
<template #actions>
Expand Down Expand Up @@ -106,9 +106,9 @@ let app = createApp({
<text text="第 ${cu.value} 内容:" />
</box>
<NavigationBar>
<item selected=${cu.value == 0} onClick=${() => cu.value = 0} icon=${Home()}>主页</item>
<item selected=${cu.value == 1} onClick=${() => cu.value = 1} icon=${Home()}>管理</item>
<item enabled=${false} icon=${Home()}>文档</item>
<item selected=${cu.value == 0} onClick=${() => cu.value = 0} icon=${Home}>主页</item>
<item selected=${cu.value == 1} onClick=${() => cu.value = 1} icon=${Home}>管理</item>
<item enabled=${false} icon=${Home}>文档</item>
</NavigationBar>
</column>
</ModalNavigationDrawer>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/assets/sample/v7/用户界面ui/输入框.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const app = createApp({
<TextField prefix="https://" suffix=".com" value=${input.value} onValueChange=${updateInput} />
只读和图标
<TextField readOnly=${true} value=${input.value} onValueChange=${updateInput} >
<template #leadingIcon><Icon src=${Home()} /> </template>
<template #trailingIcon><Icon src=${Add()} /> </template>
<template #leadingIcon><Icon src=${Home} /> </template>
<template #trailingIcon><Icon src=${Add} /> </template>
</TextField>
</column>
`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getRunningEngines } from 'engines'

getRunningEngines().forEach(engine => {
engine.emit('test', 789012)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

engines.all().forEach(e => {
e.emit('test', 123456)
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
events.on('test', (data) => {
toast(`收到test事件, data:${data}`)
})

//保持脚本运行
setInterval(() => { }, 1000)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { selfEngine } from 'engines'
import { showToast } from 'toast'

// console.log(myEngine());

selfEngine.on('test', (data) => {
showToast(`收到test事件, data:${data}`)
})

//保持脚本运行
setInterval(() => { }, 1000)
26 changes: 26 additions & 0 deletions app/src/main/assets/sample/v7/脚本引擎/运行脚本.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { execScriptFile, stopAll } from 'engines'
import { writeFile, rm } from 'fs/promises'
import { showToast } from 'toast'


const file = process.cwd() + '/test.js'
await writeFile(file, `
setTimeout(() => { }, 2000)
`, "utf8")
console.log(process.cwd());

execScriptFile(file, {
onStart() {
showToast('开始执行')
},
onSuccess() {
showToast('执行成功')
rm(file, { force: true })
},
onException() {
showToast('执行出错')
rm(file, { force: true })
}
})

setTimeout(() => { }, 5000)
Loading

0 comments on commit f2bfc05

Please sign in to comment.