diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index a92fa17..6c0797b 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -15,3 +15,4 @@ #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} +def enableProguardInReleaseBuilds = true diff --git a/project/config.js b/project/config.js index 3a06143..25e188b 100644 --- a/project/config.js +++ b/project/config.js @@ -48,6 +48,7 @@ requestCameraPermission(); const Config = { "download_path": RNFS.ExternalDirectoryPath, + "conf_file_path": `${RNFS.ExternalDirectoryPath}/.GetAnything.Conf`, "host": "http://23ss464660.iok.la", "default_host":"http://23ss464660.iok.la", "server_download_path": "/GetVideoUrl", @@ -58,11 +59,12 @@ const Config = { }; function reloadConf(){ - RNFS.readFile(`${RNFS.ExternalDirectoryPath}/GetAnything.Conf`).then((data) =>{ + RNFS.readFile(Config.conf_file_path).then((data) =>{ Config.host = data }).catch((err) => { // 创建文件 - RNFS.writeFile(`${RNFS.ExternalDirectoryPath}/GetAnything.Conf`, Config.host) + console.error(err); + RNFS.writeFile(Config.conf_file_path, Config.host) }); } reloadConf(); diff --git a/project/pages/setting.js b/project/pages/setting.js index 6b412cd..bcdea51 100644 --- a/project/pages/setting.js +++ b/project/pages/setting.js @@ -39,7 +39,7 @@ export default class SettingScreen extends React.Component { super(props); this.state = { Value:"", - reload:"", + reload: false, }; } @@ -56,7 +56,7 @@ export default class SettingScreen extends React.Component { } console.warn(this.state.Value); if (this.state.Value.match("http") == null || this.state.Value.substring(0, 4) != "http"){ - Alert.alert("修改配置出错", "输入Host非法,应该以http或https开头,示例:http://23ss464660.iok.la") + Alert.alert("修改配置出错", "输入Host非法,应该以http或https开头,示例:http://23ss464660.iok.la"); return } // 连接服务器测试是否可用 @@ -65,9 +65,13 @@ export default class SettingScreen extends React.Component { }).then(response => response.text()).then(data => { console.warn(data); if (data == "ok"){ - RNFS.writeFile(`${RNFS.ExternalDirectoryPath}/GetAnything.Conf`, Config.host); - Config.host = this.state.Value; - this.refs.toast.show(`已修改服务器Host:${Config.host}`, 3000); + RNFS.writeFile(Config.conf_file_path, this.state.Value) + .then(_ => { + Alert.alert("修改配置成功", `已修改服务器HOST: ${Config.host}`); + this.setState({reload: !this.state.reload}); + Config.host = this.state.Value; + }); + }else{ Alert.alert("修改配置失败", `${this.state.Value}服务器未能响应,请检查服务是否启动。`) }