Skip to content

Commit

Permalink
Merge pull request #71 from he3-app/yeming/fix/add-toast
Browse files Browse the repository at this point in the history
fix: add toast
  • Loading branch information
Mashirowww authored Oct 23, 2023
2 parents 7b756d5 + 76365ff commit 0e6ca13
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 207 deletions.
2 changes: 1 addition & 1 deletion exchange-rate-calculator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "Exchange Rate Calculator",
"id": "exchange-rate-calculator",
"icon": "block-outlined",
"version": "1.2.3",
"version": "1.2.4",
"description": "The Exchange Rate Calculator is a tool used to calculate currency exchange rates. It can convert the amount of one currency into the amounts of multiple other currencies and display them in the tool's output area.\n\nFeatures:\n\n1. Enter the currency amount and type to be converted in the tool.\n\n2. Select the other currency types to convert the currency into.\n\n3. Click the \"Add Currency\" button to add more currency types to convert into.\n\n4. Click the \"Convert\" button, and the tool will calculate and display the conversion amounts for each currency type.\n\nUse cases:\n\n1. Travel: When traveling, people need to convert one currency into another. Using the Exchange Rate Calculator tool, they can easily calculate the exchange rates between different currencies and understand their travel budget.\n\n2. Trade: In international trade, people need to convert currencies into other currencies. Using this tool, they can quickly calculate the exchange rates between different currencies and understand their trading costs.\n\n3. Financial investment: In financial investment, people need to understand the exchange rates between different currencies. Using the Exchange Rate Calculator tool, they can easily calculate the exchange rates between different currencies and understand their investment return rates.",
"relatedToolId": [],
"isPublic": true,
Expand Down
11 changes: 9 additions & 2 deletions exchange-rate-calculator/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function addToCurrency() {
async function convertCurrency() {
try {
loading.value = true
loading.value = true;
result.value = {};
for (const item of toCurrencies.value) {
if (fromCurrency.value === item) {
Expand All @@ -109,6 +109,13 @@ async function convertCurrency() {
const response = await fetch(
`https://api.frankfurter.app/latest?amount=${amount.value}&from=${fromCurrency.value}&to=${item}`
);
if (!response.ok) {
$he3.message.error(t("requestErr"));
loading.value = false;
result.value = {};
return;
}
const output = await response.json();
const key = `${Object.keys(output["rates"])[0]}`;
const keyName = `${t(currencies[Object.keys(output["rates"])[0]])} / ${
Expand All @@ -120,7 +127,7 @@ async function convertCurrency() {
};
}
}
loading.value = false
loading.value = false;
} catch (error) {
console.error("Error fetching exchange rates:", error);
}
Expand Down
Loading

0 comments on commit 0e6ca13

Please sign in to comment.