Skip to content

Commit

Permalink
fix: Artifact config
Browse files Browse the repository at this point in the history
  • Loading branch information
wormtql committed Sep 1, 2024
1 parent 740141a commit 169d862
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "genshin_artifacts",
"version": "5.26.0",
"version": "5.26.1",
"private": true,
"scripts": {
"serve": "cross-env ENV_FILE=.env.development.yaml vue-cli-service serve",
Expand Down
8 changes: 6 additions & 2 deletions src/pages/NewArtifactPlanPage/NewArtifactPlanPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@

<script setup lang="ts">
import {convertArtifact} from "@util/converter"
import {newDefaultArtifactConfigForWasm} from "@util/artifacts"
import {mergeArtifactConfig, newDefaultArtifactConfigForWasm} from "@util/artifacts"
import {deepCopy} from "@/utils/common"
import {wasmSingleOptimize} from "@/wasm/single_optimize"
import {createComputeResult} from "@/api/misc"
Expand Down Expand Up @@ -1113,7 +1113,11 @@ function usePreset(name: string) {
artifactEffectMode.value = item.artifactEffectMode ?? "auto"
// use artifact config
artifactConfig.value = item.artifactConfig ?? newDefaultArtifactConfigForWasm()
if (item.artifactConfig) {
artifactConfig.value = mergeArtifactConfig(item.artifactConfig)
} else {
artifactConfig.value = newDefaultArtifactConfigForWasm()
}
miscCurrentPresetName.value = name
}
Expand Down
18 changes: 18 additions & 0 deletions src/utils/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,24 @@ export function getArtifactAllConfigs(item: any): any {
return config2.concat(config4)
}

/// Get artifacts configs (config2/config4) for current artifact name
export function getArtifactAllConfigsByName(name: ArtifactSetName): any {
return getArtifactAllConfigs(artifactsData[name])
}

/// merge configs into a legit config
/// note: there may be circumstances where a merging config is not complete (e.g. lacking some config2 fields)
export function mergeArtifactConfig(config: any): any {
const defaultConfig = newDefaultArtifactConfigForWasm()
for (const key in config) {
if (key in defaultConfig) {
for (const configKey in config[key]) {
if (configKey in defaultConfig[key]) {
defaultConfig[key][configKey] = deepCopy(config[key][configKey])
}
}
}
}
console.log(defaultConfig)
return defaultConfig
}

0 comments on commit 169d862

Please sign in to comment.