Skip to content

Commit

Permalink
Support receive external search paramerters, selecting recipe by its id.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tnze committed Oct 5, 2024
1 parent 2c6fcae commit 3405140
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/components/recipe-manager/RecipePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,23 @@ async function triggerSearch() {
}

// 页面载入后更新
onMounted(() => {
triggerSearch()
craftTypeRemoteMethod()
})
onMounted(async () => {
triggerSearch();
craftTypeRemoteMethod();

// 接受跳转参数
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('recipeId')) {
const recipeId = searchParams.get('recipeId');
const source = await settingStore.getDataSource;
if (source.recipeInfo == undefined) {
ElMessage.error($t("datasource-unsupport-recipe-info"));
return;
}
const recipeInfo = await source.recipeInfo(recipeId);
await selectRecipeRow(recipeInfo);
}
});

// 数据源切换时更新
watch(() => settingStore.getDataSource, (source) => {
Expand All @@ -155,12 +168,13 @@ const isNormalRecipe = computed(() => {
return selectedRecipe.value?.[0].conditions_flag === 15
})
let confirmDialogCallback: ((mode: 'designer' | 'simulator') => void) | null = null
const selectRecipeRow = async (row: RecipeInfo) => {
async function selectRecipeRow(row: RecipeInfo) {
try {
isRecipeTableLoading.value = true
const source = await settingStore.getDataSource;
var [recipeLevel, info] = await Promise.all([
(await settingStore.getDataSource).recipeLevelTable(row.rlv),
(await settingStore.getDataSource).itemInfo(row.item_id)
source.recipeLevelTable(row.rlv),
source.itemInfo(row.item_id)
])
} catch (e: any) {
ElMessage.error(String(e))
Expand Down Expand Up @@ -294,6 +308,7 @@ const selectRecipeRow = async (row: RecipeInfo) => {
</style>

<fluent locale="zh-CN">
datasource-unsupport-recipe-info = 当前数据源不支持从外部选择配方
confirm-select = 开始制作“{ $itemName }”吗?
confirm-select2 = 这是一个高难度配方,请选择模式。
please-confirm = 请确认
Expand All @@ -317,6 +332,7 @@ required-control = 最低{ control }
</fluent>

<fluent locale="en-US">
datasource-unsupport-recipe-info = Current data-source doesn't support choice recipe from external pages
confirm-select = Start crafting "{ $itemName }"?
confirm-select2 = This is a 高难度配方. Please make a choice.
please-confirm = Please confirm
Expand Down

0 comments on commit 3405140

Please sign in to comment.