mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
Compare commits
3 Commits
fafec01fe3
...
v1.7.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97454de75e | ||
|
|
f61f4eed51 | ||
|
|
99b45ddf52 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cultivation",
|
||||
"version": "1.7.0",
|
||||
"version": "1.7.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^1.0.0-rc.5",
|
||||
|
||||
@@ -40,22 +40,22 @@ pub fn config_path(profile: String) -> PathBuf {
|
||||
if profile.as_str() == "default" {
|
||||
path.push("configuration.json");
|
||||
} else {
|
||||
path.push("profile");
|
||||
path.push(profile);
|
||||
path.push("profiles");
|
||||
path.push(profile + ".json");
|
||||
}
|
||||
|
||||
path
|
||||
}
|
||||
|
||||
pub fn get_config(profile_name: String) -> Configuration {
|
||||
let path = config_path(profile_name);
|
||||
let path = config_path(profile_name.clone());
|
||||
let config = std::fs::read_to_string(path).unwrap_or("{}".to_string());
|
||||
let config: Configuration = serde_json::from_str(&config).unwrap_or_default();
|
||||
|
||||
let default = String::from("default");
|
||||
let prof = config.profile.as_ref().unwrap_or(&default);
|
||||
if *prof != String::from("default") {
|
||||
get_config(prof.clone());
|
||||
//let default = String::from("default");
|
||||
let prof = config.profile.clone().unwrap_or_default();
|
||||
if prof != String::from("default") && prof != profile_name.clone() {
|
||||
return get_config(prof.clone());
|
||||
}
|
||||
|
||||
config
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "Cultivation",
|
||||
"version": "1.7.0"
|
||||
"version": "1.7.1"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
||||
@@ -143,7 +143,7 @@ export default class NewsSection extends React.Component<IProps, IState> {
|
||||
<tr>
|
||||
<td>
|
||||
Work in progress area! These numbers may be outdated, so please do not use them as reference. Latest
|
||||
version: Grasscutter 1.7.4 (4.0) / Forks (6.1) - Cultivation 1.7.0
|
||||
version: Grasscutter 1.7.4 (4.0) / Forks (6.1) - Cultivation 1.7.1
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
|
||||
@@ -177,6 +177,19 @@ async function readConfigFile() {
|
||||
configFilePath = local + 'cultivation/configuration.json'
|
||||
}
|
||||
|
||||
const dataFiles = await fs.readDir(local + 'cultivation')
|
||||
|
||||
// Ensure config exists
|
||||
if (!dataFiles.find((fileOrDir) => fileOrDir?.name === 'configuration.json')) {
|
||||
// Create config file
|
||||
const file: fs.FsTextFileOption = {
|
||||
path: configFilePath,
|
||||
contents: JSON.stringify(defaultConfig),
|
||||
}
|
||||
|
||||
await fs.writeFile(file)
|
||||
}
|
||||
|
||||
// Read existing config to get profile name
|
||||
const raw = await fs.readTextFile(configFilePath)
|
||||
const cfg = <Configuration>JSON.parse(raw)
|
||||
@@ -206,19 +219,6 @@ async function readConfigFile() {
|
||||
await fs.createDir(local + 'cultivation/grasscutter').catch((e) => console.log(e))
|
||||
}
|
||||
|
||||
const dataFiles = await fs.readDir(local + 'cultivation')
|
||||
|
||||
// Ensure config exists
|
||||
if (!dataFiles.find((fileOrDir) => fileOrDir?.name === 'configuration.json')) {
|
||||
// Create config file
|
||||
const file: fs.FsTextFileOption = {
|
||||
path: configFilePath,
|
||||
contents: JSON.stringify(defaultConfig),
|
||||
}
|
||||
|
||||
await fs.writeFile(file)
|
||||
}
|
||||
|
||||
// Finally, read the file
|
||||
return await fs.readTextFile(configFilePath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user