@@ -185,47 +186,9 @@ import { onMounted, ref, onUnmounted, computed } from "vue";
import { useI18n } from "vue-i18n";
import { useStockQuote } from "@/store/stock-quote/index.js";
const { getStockQuate, stockQuote, formatted } = useStockQuote();
-
getStockQuate();
-
-const formatCustomDate = (dateString, timeZone = "EDT") => {
- // 尝试解析日期
- const date = new Date(dateString);
-
- // 验证日期有效性
- if (isNaN(date.getTime())) {
- return "Invalid Date";
- }
-
- // 从原始字符串提取 AM/PM
- const periodMatch = dateString.match(/(AM|PM)/i);
- const period = periodMatch ? periodMatch[0] : "AM"; // 默认 AM(如果没有匹配到)
-
- // 提取小时和分钟(基于 Date 对象,避免时区影响)
- let hours = date.getHours();
- const minutes = date.getMinutes().toString().padStart(2, "0");
-
- // 转换为 12 小时制
- let displayHours = hours % 12;
- displayHours = displayHours || 12; // 0 显示为 12
-
- // 时间部分(如 2:44AM)
- const timePart = `${displayHours}:${minutes}${period}`;
-
- // 日期部分(如 EDT 26/05/25)
- const day = date.getDate().toString().padStart(2, "0");
- const month = (date.getMonth() + 1).toString().padStart(2, "0");
- const year = date.getFullYear().toString(); // 取后两位
-
- const datePart = `${timeZone} ${day}/${month}/${year}`;
-
- // 组合最终结果
- return `As of ${timePart} ${datePart}`;
-};
-
// 示例数据
const sampleDate = ref(formatted);
-const formattedDate = computed(() => formatCustomDate(sampleDate.value));
const { t: $t } = useI18n();
const contentRef = ref(null);
diff --git a/src/views/myHome/size375/index.vue b/src/views/myHome/size375/index.vue
index 574a707..cc421dd 100644
--- a/src/views/myHome/size375/index.vue
+++ b/src/views/myHome/size375/index.vue
@@ -99,7 +99,7 @@
Time
{{
- formattedDate
+ formatted
}}
@@ -114,8 +114,9 @@
{{
$t("HOME.CONTAINY.STOCK_INFO.CHANGE")
}}
- {{ stockQuote.change[0] }}{{ stockQuote.change[1] }}{{ stockQuote.change?.[0] || "--" }}
+ {{ stockQuote.change?.[1] || "--" }}
@@ -196,48 +197,7 @@ import { onMounted, ref, onUnmounted, computed } from "vue";
import { useI18n } from "vue-i18n";
import { useStockQuote } from "@/store/stock-quote/index.js";
const { getStockQuate, stockQuote, formatted } = useStockQuote();
-
getStockQuate();
-
-const formatCustomDate = (dateString, timeZone = "EDT") => {
- // 尝试解析日期
- const date = new Date(dateString);
-
- // 验证日期有效性
- if (isNaN(date.getTime())) {
- return "Invalid Date";
- }
-
- // 从原始字符串提取 AM/PM
- const periodMatch = dateString.match(/(AM|PM)/i);
- const period = periodMatch ? periodMatch[0] : "AM"; // 默认 AM(如果没有匹配到)
-
- // 提取小时和分钟(基于 Date 对象,避免时区影响)
- let hours = date.getHours();
- const minutes = date.getMinutes().toString().padStart(2, "0");
-
- // 转换为 12 小时制
- let displayHours = hours % 12;
- displayHours = displayHours || 12; // 0 显示为 12
-
- // 时间部分(如 2:44AM)
- const timePart = `${displayHours}:${minutes}${period}`;
-
- // 日期部分(如 EDT 26/05/25)
- const day = date.getDate().toString().padStart(2, "0");
- const month = (date.getMonth() + 1).toString().padStart(2, "0");
- const year = date.getFullYear().toString(); // 取后两位
-
- const datePart = `${timeZone} ${day}/${month}/${year}`;
-
- // 组合最终结果
- return `As of ${timePart} ${datePart}`;
-};
-
-// 示例数据
-const sampleDate = ref(formatted);
-const formattedDate = computed(() => formatCustomDate(sampleDate.value));
-
const { t: $t } = useI18n();
const contentRef = ref(null);
const isInView = ref(false);
diff --git a/src/views/myHome/size768/index.vue b/src/views/myHome/size768/index.vue
index 574a707..3130ead 100644
--- a/src/views/myHome/size768/index.vue
+++ b/src/views/myHome/size768/index.vue
@@ -99,7 +99,7 @@
Time
{{
- formattedDate
+ formatted
}}
@@ -114,8 +114,9 @@
{{
$t("HOME.CONTAINY.STOCK_INFO.CHANGE")
}}
- {{ stockQuote.change[0] }}{{ stockQuote.change[1] }}{{ stockQuote.change?.[0] || "--" }}
+ {{ stockQuote.change?.[1] || "--" }}
@@ -199,45 +200,6 @@ const { getStockQuate, stockQuote, formatted } = useStockQuote();
getStockQuate();
-const formatCustomDate = (dateString, timeZone = "EDT") => {
- // 尝试解析日期
- const date = new Date(dateString);
-
- // 验证日期有效性
- if (isNaN(date.getTime())) {
- return "Invalid Date";
- }
-
- // 从原始字符串提取 AM/PM
- const periodMatch = dateString.match(/(AM|PM)/i);
- const period = periodMatch ? periodMatch[0] : "AM"; // 默认 AM(如果没有匹配到)
-
- // 提取小时和分钟(基于 Date 对象,避免时区影响)
- let hours = date.getHours();
- const minutes = date.getMinutes().toString().padStart(2, "0");
-
- // 转换为 12 小时制
- let displayHours = hours % 12;
- displayHours = displayHours || 12; // 0 显示为 12
-
- // 时间部分(如 2:44AM)
- const timePart = `${displayHours}:${minutes}${period}`;
-
- // 日期部分(如 EDT 26/05/25)
- const day = date.getDate().toString().padStart(2, "0");
- const month = (date.getMonth() + 1).toString().padStart(2, "0");
- const year = date.getFullYear().toString(); // 取后两位
-
- const datePart = `${timeZone} ${day}/${month}/${year}`;
-
- // 组合最终结果
- return `As of ${timePart} ${datePart}`;
-};
-
-// 示例数据
-const sampleDate = ref(formatted);
-const formattedDate = computed(() => formatCustomDate(sampleDate.value));
-
const { t: $t } = useI18n();
const contentRef = ref(null);
const isInView = ref(false);