Skip to content

Commit

Permalink
增加活力值签到逻辑,可视化配置中支持仅当前页配置重置为默认值
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyJiangWJ committed Jun 13, 2023
1 parent fa14dd2 commit cd056ef
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 34 deletions.
4 changes: 2 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: TonyJiangWJ
* @Date: 2019-12-09 20:42:08
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2023-05-05 19:59:15
* @Last Modified time: 2023-06-13 20:53:53
* @Description:
*/
require('./lib/Runtimes.js')(global)
Expand Down Expand Up @@ -275,7 +275,7 @@ let default_config = {
random_gesture_safe_range_top: '',
random_gesture_safe_range_bottom: '',
// 代码版本
code_version: 'v1.3.7.9',
code_version: 'v1.3.8',
}
// 文件更新后直接生效,不使用缓存的值
let no_cache_configs = ['release_access_token', 'code_version']
Expand Down
4 changes: 2 additions & 2 deletions core/Ant_forest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: NickHopps
* @Date: 2019-01-31 22:58:00
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2023-05-05 18:46:17
* @Last Modified time: 2023-06-12 18:34:27
* @Description:
*/
let { config: _config, storage_name: _storage_name } = require('../config.js')(runtime, global)
Expand Down Expand Up @@ -649,7 +649,7 @@ function Ant_forest () {
if (collect) {
automator.click(collect.centerX(), collect.centerY())
sleep(1000)
let getRewards = _widgetUtils.widgetGetAll('立即领取')
let getRewards = _widgetUtils.widgetGetAll('^(立即领取|领取)$')
if (getRewards && getRewards.length > 0) {
debugInfo(['找到可领取的奖励数量:{}', getRewards.length])
getRewards.forEach(getReward => {
Expand Down
9 changes: 4 additions & 5 deletions lib/BaseCommonFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,11 @@ function CommonFunctions () {
if (_config.auto_set_bang_offset) {
let offset = this.getStatusBarHeightCompat()
_logUtils.debugInfo(['自动设置刘海偏移量为:{}', offset])
let configStorage = storages.create(_storage_name)
// 设为负值
_config.bang_offset = -offset
configStorage.put('bang_offset', _config.bang_offset)
configStorage.put('auto_set_bang_offset', false)
_config.overwrite('bang_offset', -offset)
_config.overwrite('auto_set_bang_offset', false)
}
_logUtils.debugInfo(['当前刘海偏移量:{}', _config.bang_offset])
}

/**
Expand Down Expand Up @@ -670,7 +669,7 @@ function CommonFunctions () {
if (getCurrentPkgName !== package) {
return false
}
if (backOrColse) {
if (backOrColse && automator.checkCenterClickable(backOrColse)) {
automator.clickCenter(backOrColse)
} else {
back()
Expand Down
53 changes: 44 additions & 9 deletions lib/BridgeHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = (postMessageToWebView) => {
}
}
changedConfig[key] = newVal
storageConfig.put(key, newVal)
config.overwrite(key, newVal)
}
})
changed && sendConfigChangedBroadcast(changedConfig)
Expand Down Expand Up @@ -86,11 +86,33 @@ module.exports = (postMessageToWebView) => {
if (ok) {
Object.keys(default_config).forEach(key => {
let defaultValue = default_config[key]
config[key] = defaultValue
storageConfig.put(key, defaultValue)
config.overwrite(key, defaultValue)
})
toastLog('重置默认值')
sendConfigChangedBroadcast(config)
postMessageToWebView({ callbackId: callbackId, data: { success: true } })
}
})
})
},
resetPageConfigs: (data, callbackId) => {
ui.run(function () {
confirm('确定重置当前页配置为默认值吗?').then(ok => {
if (ok) {
let prepend = data.prepend
let current_default = default_config
if (prepend) {
current_default = default_config[prepend + '_config']
}
data.resetFields.forEach(key => {
let defaultValue = current_default[key]
if (typeof defaultValue != 'undefined') {
config.overwrite(prepend ? prepend + '.' + key : key, defaultValue)
}
})
toastLog('重置默认值')
sendConfigChangedBroadcast(config)
postMessageToWebView({ callbackId: callbackId, data: { success: true } })
}
})
})
Expand All @@ -101,7 +123,7 @@ module.exports = (postMessageToWebView) => {
if (ok) {
doAsyncOperationWithDialog('导出', () => {
Object.keys(default_config).forEach(key => {
console.verbose(key + ': ' + config[key])
console.verbose(key + ': ' + JSON.stringify(config[key]))
})
let configString = AesUtil.encrypt(JSON.stringify(config), aesKey)
files.write(local_config_path, configString)
Expand Down Expand Up @@ -145,12 +167,25 @@ module.exports = (postMessageToWebView) => {
function refillConfigs (configStr) {
let local_config = JSON.parse(configStr)
Object.keys(default_config).forEach(key => {
let defaultValue = local_config[key]
if (typeof defaultValue === 'undefined') {
defaultValue = default_config[key]
let currentValue = local_config[key]
if (key.endsWith('_config')) {
let prepend = key.replace('_config', '')
let defaultExtendConfig = default_config[key]
if (defaultExtendConfig) {
Object.keys(defaultExtendConfig).forEach(extKey => {
let extendValue = currentValue[extKey]
if (typeof extendValue === 'undefined') {
extendValue = defaultExtendConfig[extKey]
}
config.overwrite(prepend + '.' + extKey, extendValue)
})
}
return
}
if (typeof currentValue !== 'undefined') {
currentValue = default_config[key]
}
config[key] = defaultValue
storageConfig.put(key, defaultValue)
config.overwrite(key, currentValue)
})
// 触发页面重载
toastLog('重新导入配置成功')
Expand Down
5 changes: 3 additions & 2 deletions lib/Unlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: TonyJiangWJ
* @Date: 2019-11-05 09:12:00
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2023-04-13 16:26:52
* @Last Modified time: 2023-06-13 15:45:01
* @Description:
*/
let { config: _config, storageName: _storageName } = require('../config.js')(runtime, global)
Expand Down Expand Up @@ -363,9 +363,10 @@ module.exports = {
if (!_unlocker.relock) {
let executeArguments = engines.myEngine().execArgv
// 定时任务启动 启用佛系模式
if (_config.buddha_like_mode && executeArguments.intent && !executeArguments.executeByDispatcher) {
if (_config.buddha_like_mode && executeArguments.intent && (!executeArguments.executeByDispatcher || executeArguments.buddha)) {
infoLog('已启用佛系模式,且未锁定屏幕,等待5分钟后再试')
_config.forceStop = true
_config._buddha = true
_commonFunctions.setUpAutoStart(5)
_runningQueueDispatcher.removeRunningTask()
exit()
Expand Down
4 changes: 2 additions & 2 deletions lib/prototype/RunningQueueDispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let STORAGE_KEY = "autojs_dispatch_queue_storage"
let RUNNING_KEY = "qunningTask"
let WAITING_QUEUE_KEY = "waitingQueue"
let WRITE_LOCK_KEY = "writeLock"
let { storage_name } = require('../../config.js')(runtime, global)
let { config, storage_name } = require('../../config.js')(runtime, global)
let singletonRequire = require('../SingletonRequirer.js')(runtime, global)
let lockableStorages = singletonRequire('LockableStorage')
let Timers = singletonRequire('Timers')
Expand Down Expand Up @@ -66,7 +66,7 @@ function RunningQueueDispatcher () {
this.executeTargetScript = function (source) {
_logUtils.logInfo(['启动目标脚本:{}', source])
ui.run(function () {
engines.execScriptFile(source, { path: source.substring(0, source.lastIndexOf('/')), arguments: { executeByDispatcher: true } })
engines.execScriptFile(source, { path: source.substring(0, source.lastIndexOf('/')), arguments: { executeByDispatcher: true, buddha: config._buddha } })
})
sleep(1000)
}
Expand Down
5 changes: 3 additions & 2 deletions unit/神奇海洋收集.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ function findTrashs (delay) {
let ball = findBalls[0]
floatyInstance.setFloatyInfo({ x: ball.x, y: ball.y }, '找到了垃圾')
sleep(500)
floatyInstance.setFloatyInfo({ x: ball.x - ball.radius * 2, y: ball.y + ball.radius * 2 }, '点击位置')
let clickPos = { x: ball.x - ball.radius * 1.5, y: ball.y + ball.radius * 1.5 }
floatyInstance.setFloatyInfo(clickPos, '点击位置')
sleep(2000)
automator.click(ball.x - ball.radius * 2, ball.y + ball.radius * 2)
automator.click(clickPos.x, clickPos.y)
sleep(1000)
let collect = widgetUtils.widgetGetOne('.*(清理|收下|(欢迎|迎回)伙伴).*')
if (collect) {
Expand Down
4 changes: 2 additions & 2 deletions vue_configs/error.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@
加载失败
<div class="white"></div>
</div>
<div class="text-tip" data-word="可能某个网络资源加载异常,请重新打开,开发者正在尝试修复此问题">
可能某个网络资源加载异常,请重新打开,开发者正在尝试修复此问题
<div class="text-tip" data-word="可能某个网络资源加载异常,请给予联网权限并多重试几次">
可能某个网络资源加载异常,请给予联网权限并多重试几次
<div class="white"></div>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions vue_configs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<van-col @click="resetDefaultConfigs">重置所有配置为默认值
</van-col>
</van-row>
<van-row type="flex" justify="center" class="van-cell">
<van-col @click="resetPageConfigs">重置当前页配置为默认值</van-col>
</van-row>
<van-divider :style="{ margin: '0' }"></van-divider>
<van-row type="flex" justify="center" class="van-cell">
<van-col @click="exportConfigs">导出配置到备份文件
Expand Down
14 changes: 12 additions & 2 deletions vue_configs/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: TonyJiangWJ
* @Date: 2020-11-29 13:24:38
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2022-09-07 13:56:05
* @Last Modified time: 2023-06-13 16:51:41
* @Description:
*/

Expand Down Expand Up @@ -41,7 +41,17 @@ let app = new Vue({
this.$router.back()
},
resetDefaultConfigs: function () {
$app.invoke('resetConfigs')
$nativeApi.request('resetConfigs').then(resp => {
this.$store.commit('configChanged')
})
},
resetPageConfigs: function () {
let currentFields = this.$store.getters.getCurrentFields
if (currentFields && currentFields.length > 0) {
$nativeApi.request('resetPageConfigs', { resetFields: currentFields, prepend: this.$store.getters.getExtendPrepend }).then(resp => {
this.$store.commit('configChanged')
})
}
},
exportConfigs: function () {
$app.invoke('exportConfigs')
Expand Down
12 changes: 11 additions & 1 deletion vue_configs/js/components/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: TonyJiangWJ
* @Date: 2020-11-29 13:16:53
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2023-04-23 22:54:33
* @Last Modified time: 2023-06-13 16:48:18
* @Description: 组件代码,传统方式,方便在手机上进行修改
*/

Expand Down Expand Up @@ -112,10 +112,18 @@ let mixin_common = {
saveConfigs: function () {
this.doSaveConfigs()
},
persistCurrentFields: function () {
this.$store.commit('setCurrentFields', Object.keys(this.configs))
let _this = this
this.$store.commit('setConfigChangedCallback', () => _this.loadConfigs())
},
loadConfigs: function () {
$app.invoke('loadConfigs', {}, config => {
Object.keys(this.configs).forEach(key => {
// console.log('load config key:[' + key + '] value: [' + config[key] + ']')
if (!config.hasOwnProperty(key)) {
console.error('config.js中未配置', key, '请检查代码')
}
this.$set(this.configs, key, config[key])
})
this.device.width = config.device_width
Expand Down Expand Up @@ -171,10 +179,12 @@ let mixin_common = {
},
mounted () {
this.loadConfigs()
this.persistCurrentFields()
},
destroyed () {
console.log('保存当前界面配置')
this.saveConfigs()
this.$store.commit('clearConfig')
}
}

Expand Down
10 changes: 6 additions & 4 deletions vue_configs/js/components/configuration/CommonConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ const LockConfig = {
<number-field v-model="configs.timeout_unlock" label="解锁超时时间" placeholder="请输入解锁超时时间">
<template #right-icon><span>毫秒</span></template>
</number-field>
<tip-block>仅限在支付宝账号管理-登录设置-开启可信设备自动登录后才有效,否则需要密码登录,无法使用此功能自动登录</tip-block>
<switch-cell title="多设备自动登录" v-model="configs.multi_device_login" />
<switch-cell title="支付宝是否锁定" v-model="configs.is_alipay_locked" />
<van-field v-if="configs.is_alipay_locked" v-model="configs.alipay_lock_password" label="手势密码" placeholder="请输入手势密码对应的九宫格数字" type="password" input-align="right" />
<template v-if="typeof config.is_alipay_locked != 'undefined'">
<tip-block>仅限在支付宝账号管理-登录设置-开启可信设备自动登录后才有效,否则需要密码登录,无法使用此功能自动登录</tip-block>
<switch-cell title="多设备自动登录" v-model="configs.multi_device_login" />
<switch-cell title="支付宝是否锁定" v-model="configs.is_alipay_locked" />
<van-field v-if="configs.is_alipay_locked" v-model="configs.alipay_lock_password" label="手势密码" placeholder="请输入手势密码对应的九宫格数字" type="password" input-align="right" />
</template>
<switch-cell title="锁屏启动设置最低亮度" v-model="configs.auto_set_brightness" />
<tip-block>启用佛系模式之后,如果屏幕未锁定,则认定手机正在使用中,自动延迟五分钟,等待下次运行时状态为已锁屏才继续运行。由其他脚本触发的不受此模式限制</tip-block>
<switch-cell title="启用佛系模式" v-model="configs.buddha_like_mode" />
Expand Down
1 change: 1 addition & 0 deletions vue_configs/js/components/configuration/ImageConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const ImageConfig = {
Object.keys(this.configs).forEach(key => {
this.$set(this.configs, key, imageConfig[key])
})
this.$store.commit('setExtendPrepend', 'image')
},
doSaveConfigs () {
let newConfigs = this.filterErrorFields(this.configs)
Expand Down
30 changes: 29 additions & 1 deletion vue_configs/js/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ const store = new Vuex.Store({
configSaveCallbacks: [],
currentIndex: 0,
currentTitle: '配置管理',
titleMap: {}
titleMap: {},
currentFields: [],
extendPrepend: '',
configChangedCallback: null
},
getters: {
getSaveCallbacks: state => {
Expand All @@ -14,6 +17,12 @@ const store = new Vuex.Store({
},
getTitleByPath: state => {
return (path) => state.titleMap[path]
},
getCurrentFields: state => {
return state.currentFields
},
getExtendPrepend: state => {
return state.extendPrepend
}
},
mutations: {
Expand All @@ -29,5 +38,24 @@ const store = new Vuex.Store({
state.currentTitle = payload.title
state.titleMap[payload.path] = payload.title
},
setCurrentFields: (state, currentFields) => {
state.currentFields = currentFields
},
setExtendPrepend: (state, prepend) => {
state.extendPrepend = prepend
},
setConfigChangedCallback: (state, callback) => {
state.configChangedCallback = callback
},
configChanged: (state) => {
if (state.configChangedCallback) {
state.configChangedCallback()
}
},
clearConfig: (state) => {
state.currentFields = []
state.extendPrepend = ''
state.configChangedCallback = null
}
}
})

0 comments on commit cd056ef

Please sign in to comment.