Skip to content

Commit

Permalink
Merge pull request #25 from powerAn2020/dev
Browse files Browse the repository at this point in the history
BUG修复
  • Loading branch information
powerAn2020 authored Oct 5, 2024
2 parents b9e387b + 9a5ae34 commit 156d235
Show file tree
Hide file tree
Showing 21 changed files with 864 additions and 352 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ Options:
<api_type> local/central
local
status -- Show Node Status
service -- Manage Zerotier-One Service Status
action value:[ start | stop ]
network -- When the action is "list", "networkid" and "bodydata" are optional. When the action is "leave", "bodydata" is optional. When the action is "join", "networkid" and "bodydata" are required.
action value:[ list | leave | join ]
networkid value:[ networkid ](optional)
Expand Down Expand Up @@ -135,6 +137,8 @@ Example:

local
sh api.sh local status
sh api.sh local service start
sh api.sh local service stop
sh api.sh local peer
sh api.sh local firewall A
sh api.sh local firewall D
Expand Down
22 changes: 20 additions & 2 deletions api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
### <api_type> local/central
### local
### status -- Show Node Status
### service -- Manage Zerotier-One Service Status
### action value:[ start | stop ]
### network -- When the action is "list", "networkid" and "bodydata" are optional. When the action is "leave", "bodydata" is optional. When the action is "join", "networkid" and "bodydata" are required.
### action value:[ list | leave | join ]
### networkid value:[ networkid ](optional)
Expand Down Expand Up @@ -44,6 +46,8 @@
###
### local
### sh api.sh local status
### sh api.sh local service start
### sh api.sh local service stop
### sh api.sh local peer
### sh api.sh local firewall A
### sh api.sh local firewall D
Expand Down Expand Up @@ -92,7 +96,7 @@ ZEROTIERD=$MODDIR/zerotier-one
SECRETFILE=$ZTPATH/authtoken.secret
TOKENAUTH=$ZTPATH/TOKENAUTH
TOKEN=$(cat ${SECRETFILE})
apiToken=$(cat ${TOKENAUTH})
apiToken=$(grep '[^[:space:]]' $TOKENAUTH)
CurlBIN="${MODDIR}/bin/curl -s -A 'ZerotierForKSU' --connect-timeout 5"
localAPIBase='http://localhost:9993'
remoteAPIBase='https://api.zerotier.com/api/v1'
Expand Down Expand Up @@ -152,6 +156,16 @@ local_router() {
fi
fi
}
local_service() {
if [ "$1" = "start" ]; then
if [ ! -f "${ZTPATH}/state/disable" ];then
touch ${ZTPATH}/state/disable
fi
rm ${ZTPATH}/state/disable
else
touch ${ZTPATH}/state/disable
fi
}
# =========================== Central API ===========================
api_networks() {
# $1 operation GET/POST/DELETE
Expand Down Expand Up @@ -179,7 +193,7 @@ remote_status() {
$CurlBIN -X GET -H "Authorization: token $apiToken" ${remoteAPIBase}/status
}
check_apiToken() {
if [ ! -f ${TOKENAUTH} -a -z $apiToken ]; then
if [ ! -f ${TOKENAUTH} -o -z "$apiToken" ]; then
# 重定向提示内容给webui
{
echo "The api token was not found. Use 'api.sh update xxxx' to add it." 1>&2
Expand All @@ -198,6 +212,10 @@ local)
status)
local_status
;;
service)
shift
local_service $1
;;
network)
shift
action=$1
Expand Down
2 changes: 1 addition & 1 deletion changelog_dev.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
update
修复国际化
2 changes: 2 additions & 0 deletions customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ui_print "- Installing Zerotier for KSU"

if [ ! -d "/data/adb/zerotier" ]; then
mkdir -p /data/adb/zerotier/state
touch /data/adb/zerotier/TOKENAUTH
set_perm /data/adb/zerotier 0 0 0755
set_perm /data/adb/zerotier/state 0 0 0755
fi
Expand All @@ -48,6 +49,7 @@ set_perm $MODPATH/zerotier-idtool 0 0 0755
set_perm $MODPATH/zerotier-cli 0 0 0755
set_perm $MODPATH/zerotier.sh 0 0 0755
set_perm $MODPATH/zerotier.inotify 0 0 0755
set_perm $MODPATH/build.inotify 0 0 0755
set_perm $MODPATH/api.sh 0 0 0755
set_perm $MODPATH/uninstall.sh 0 0 0755
set_perm $MODPATH/bin/curl 0 0 0755
Expand Down
6 changes: 5 additions & 1 deletion ui-src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"postinstall": "patch-package"
"postinstall": "patch-package",
"devbuild": "vite build",
"predevbuild": "if exist %cd%\\dist.zip del %cd%\\dist.zip",
"postdevbuild": "7z u dist.zip ./dist/* & adb -s 192.168.10.237:46713 push %cd%\\dist.zip /sdcard/Download/dist/"
},
"dependencies": {
"buffer": "^6.0.3",
"kernelsu": "^1.0.6",
"pinia": "^2.2.2",
"vant": "^4.9.7",
"vue": "^3.5.10",
"vue-i18n": "^9.14.1",
"vue-router": "^4.4.5",
"vue3-json-viewer": "^2.2.2"
},
Expand Down
144 changes: 104 additions & 40 deletions ui-src/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
<van-config-provider :theme="theme ? 'light' : 'dark'">
<van-nav-bar title="Zerotier For KSU" safe-area-inset-top fixed>
<template #left>
<van-icon size="1.2rem" @click="switchTheme" :name="iconName"
style="background-color: #1989fa;border-radius: 50%;" />
<van-space>
<van-icon size="1.2rem" @click="switchTheme" :name="iconName" />
<van-icon size="1.2rem" :name="lang" @click="localeShow = true" />
</van-space>
</template>
<template #right>
<!-- <el-icon><icon-ep-sunny /></el-icon>
<el-icon><icon-ep-moon /></el-icon> -->
<!-- <v-icon name="bi-music-player" /> -->
<van-icon v-if="router.currentRoute.value.fullPath !== '/setting'" name="add" size="1.2rem"
<van-icon v-if="router.currentRoute.value.fullPath !== '/setting'" :name="add" size="1.2rem"
@click="newAdd(undefined)" />
</template>
</van-nav-bar>
Expand All @@ -20,8 +22,8 @@
</router-view>
<div style="height: 0.1rem;"></div>
<van-tabbar route safe-area-inset-bottom>
<van-tabbar-item replace to="/" icon="home-o">首页</van-tabbar-item>
<van-tabbar-item replace to="/peers" icon="friends-o">成员</van-tabbar-item>
<van-tabbar-item replace to="/" icon="home-o">{{t('common.dash')}}</van-tabbar-item>
<van-tabbar-item replace to="/peers" icon="friends-o">{{t('common.peers')}}</van-tabbar-item>
<van-tabbar-item replace to="/center">
<template #icon>
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 36 36">
Expand All @@ -34,71 +36,133 @@
</svg>

</template>
管理
{{t('common.network')}}
</van-tabbar-item>
<van-tabbar-item replace to="/setting" icon="setting-o">设置</van-tabbar-item>
<van-tabbar-item replace to="/setting" icon="setting-o">{{t('common.setting')}}</van-tabbar-item>
</van-tabbar>
<van-action-sheet v-model:show="localeShow" :actions="language" @select="switchLocale" close-on-click-action/>

</van-config-provider>
<!-- <van-floating-bubble icon="replay" axis="xy" magnetic="x" @click="onClick" /> -->

</template>

<script setup>
import { ref, watch } from 'vue';
import { useRouter } from 'vue-router';
// import { ref, watch } from 'vue';
// import { useRouter } from 'vue-router';
import { execCmd } from './tools'
import { vantLocales, useI18n , i18n} from './locales'; // 导入所有翻译信息
const { t, locale } = useI18n();
const router = useRouter()
const theme = ref();
const localeShow = ref(false);
const routerViewRef = ref()
const night = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxZW0iIGhlaWdodD0iMWVtIiB2aWV3Qm94PSIwIDAgMjQgMjQiPjxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2Utd2lkdGg9IjIiIGQ9Ik05Ljg3NCA1LjAwOGMyLjcyOC0xLjY4IDYuNjA0LTEuMDE0IDguMjUuMTk3Yy0yLjk1NS44NC01LjExIDMuMjY3LTUuMjQyIDYuNDE1Yy0uMTggNC4yOCAzLjAwNiA2LjU4OCA1LjI0IDcuMTUyYy0xLjk2NCAxLjM0My00LjM2IDEuMjkzLTUuMjM1IDEuMTcyYy0zLjU2OC0uNDkyLTYuOTAyLTMuNDMzLTcuMDA3LTcuNzExYy0uMTA2LTQuMjc4IDIuNTczLTYuMzUgMy45OTQtNy4yMjV6Ii8+PC9zdmc+";
const light = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3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MDY2NjcgOTUwLjYxMzMzMyA0MjEuNTQ2NjY3IDg1Ni43NDY2NjcgNTI5LjkyTTQxMC44OCA4MDcuNjggNTI5LjA2NjY2NyA4NTYuNzQ2NjY3IDQyMS4xMiA5NTAuMTg2NjY3IDQxMC44OCA4MDcuNjhaIiBwLWlkPSI0NjAyIiBmaWxsPSIjMTk4OWZhIj48L3BhdGg+PC9zdmc+';
const add = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxZW0iIGhlaWdodD0iMWVtIiB2aWV3Qm94PSIwIDAgMjQgMjQiPjxnIGZpbGw9IiMxOTg5ZmEiIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNMiAxMkMyIDYuNDc3IDYuNDc3IDIgMTIgMnMxMCA0LjQ3NyAxMCAxMHMtNC40NzcgMTAtMTAgMTBTMiAxNy41MjMgMiAxMm0xMC04YTggOCAwIDEgMCAwIDE2YTggOCAwIDAgMCAwLTE2Ii8+PHBhdGggZD0iTTEzIDdhMSAxIDAgMSAwLTIgMHY0SDdhMSAxIDAgMSAwIDAgMmg0djRhMSAxIDAgMSAwIDIgMHYtNGg0YTEgMSAwIDEgMCAwLTJoLTR6Ii8+PC9nPjwvc3ZnPg==';
// const onClick = () => {
// window.location.reload();
// }
execCmd('settings get secure ui_night_mode').then(v => {
// 0 表示跟随系统设置?即当前模式与系统设置的主题模式相匹配.
// 1 表示开启了 Dark Mode(夜间模式).
// 2 表示关闭了 Dark Mode(白天模式).
if (v == '1') {
theme.value = true;
} else if (v == '2') {
theme.value = false;
const language = [
{ name: "中文(简体)", value: "zh" },
{ name: "English(US)", value: "en" }
]
// 切换语言
const switchLocale = (language) => {
debugger
// Vant basic
vantLocales(language)
// Business component
// locale.value = language;
locale.value = language.value
// Cookie
localStorage.setItem('ZerotierForKSU.locale', language.value)
localeShow.value = false;
}
const initTheme = () => {
execCmd('settings get secure ui_night_mode').then(v => {
// 0 表示跟随系统设置?即当前模式与系统设置的主题模式相匹配.
// 1 表示开启了 Dark Mode(夜间模式).
// 2 表示关闭了 Dark Mode(白天模式).
if (v == '1') {
theme.value = true;
} else if (v == '2') {
theme.value = false;
}
// 返回值竟然有null
if (v == null) {
theme.value = false;
}
localStorage.setItem('ZerotierForKSU.theme', theme.value)
});
const cacheTheme = localStorage.getItem('ZerotierForKSU.theme');
if (typeof cacheTheme != "undefined" && cacheTheme != null) {
theme.value = JSON.parse(cacheTheme);
} else {
localStorage.setItem('ZerotierForKSU.theme', false)
}
}
const initI18n = () => {
debugger
const cacheLocale = localStorage.getItem('ZerotierForKSU.locale')
if (typeof cacheLocale != "undefined" && cacheLocale != null) {
i18n.global.locale = cacheLocale
return
}
// 返回值竟然有null
if (v == null) {
theme.value = false;
let locale
switch (navigator.language) {
case 'en':
locale = 'en-US'
break
case 'zh-CN':
locale = 'zh-CN'
break
default:
locale = 'zh-CN'
}
localStorage.setItem('theme', theme.value)
});
const cacheTheme = localStorage.getItem('theme');
if (typeof cacheTheme != "undefined" && cacheTheme != null) {
theme.value = JSON.parse(cacheTheme);
} else {
localStorage.setItem('theme', false)
i18n.global.locale = locale
localStorage.setItem('ZerotierForKSU.locale', locale)
}
const switchTheme = () => {
theme.value = !theme.value;
localStorage.setItem('theme', theme.value)
localStorage.setItem('ZerotierForKSU.theme', theme.value)
};
const newAdd = (index) => {
routerViewRef.value.newAdd(index);
}
watch(theme, (theme, prevtheme) => {
if (JSON.parse(theme)) {
iconName.value = night;
} else {
iconName.value = light;
}
}, {
immediate: true
})
// watch(theme, (theme, prevtheme) => {
// if (JSON.parse(theme)) {
// iconName.value = night;
// } else {
// iconName.value = light;
// }
// }, {
// immediate: true
// })
initTheme()
initI18n()
</script>

<style>
.van-theme-dark body {
color: #f5f5f5;
background-color: black;
}
.van-theme-light body {
/* color: #f7f8fa; */
background-color: #f7f8fa;
--van-dialog-background: #f7f8fa;
}
* {
-webkit-touch-callout:none; /*系统默认菜单被禁用*/
-webkit-user-select:none; /*webkit浏览器*/
-moz-user-select:none;/*火狐*/
-ms-user-select:none; /*IE10*/
user-select:none;
}
</style>
16 changes: 11 additions & 5 deletions ui-src/src/Center.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
<template>
<div style="height: 0.1rem;"></div>
<router-view />
<van-empty :description="t('network.api-not-found')" v-if="show"/>
<div style="height: 2.8rem;"></div>
</template>

<script setup>
import { useRoute, useRouter } from 'vue-router'
// import { ref } from 'vue';
// import { useRoute, useRouter } from 'vue-router'
import { MODDIR, execCmdWithCallback, execCmdWithErrno } from './tools'
import { useI18n } from './locales'; // 导入所有翻译信息
const { t } = useI18n();
const router = useRouter()
const route = useRoute()
const show=ref(false);
const init = () => {
execCmdWithErrno(`sh ${MODDIR}/api.sh apiToken show`).then(v => {
console.info(`v:${v}`)
if (v == 0) {
router.push('/center/network')
} else {
showDialog({ message: '未配置apiToken,先去设置页添加一个吧' });
show.value=true;
// showDialog({ message: '未配置apiToken,先去设置页添加一个吧' });
}
})
Expand All @@ -27,9 +33,9 @@ const beforeClose = (action) => {
setTimeout(() => {
execCmdWithCallback({
cmd: `sh ${MODDIR}/api.sh central network add`, onSuccess: (data) => {
showToast('添加成功');
showToast(t('network.operation_success'));
}, onError: (data) => {
showToast('添加失败.' + data);
showToast(t('network.operation_fail') + data);
}
})
resolve(true);
Expand All @@ -39,7 +45,7 @@ const beforeClose = (action) => {
const newAdd = (index) => {
showConfirmDialog({
message:
'添加一个新网络?',
t('network.ask_new_network'),
beforeClose
})
}
Expand Down
Loading

0 comments on commit 156d235

Please sign in to comment.