Skip to content

Commit

Permalink
fix #280
Browse files Browse the repository at this point in the history
  • Loading branch information
baiy committed Sep 1, 2023
1 parent 8d999e7 commit 1d051ab
Show file tree
Hide file tree
Showing 9 changed files with 503 additions and 333 deletions.
2 changes: 1 addition & 1 deletion packages/ctool-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"a-color-picker": "^1.2.1",
"ajv": "^8.12.0",
"ajv-i18n": "^4.2.0",
"axios": "^0.27.2",
"axios": "^1.5.0",
"bcryptjs": "^2.4.3",
"bignumber.js": "^9.1.1",
"chardet": "^1.5.1",
Expand Down
28 changes: 15 additions & 13 deletions packages/ctool-core/src/helper/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import {proxy} from "ctool-config";
import _axios from "axios";
import platform from "@/helper/platform"
import { proxy } from "ctool-config";
import _axios, { AxiosHeaders } from "axios";
import platform from "@/helper/platform";
import qs from "qs";
import useSetting from "@/store/setting";

// 对外请求代理方法
export const axios = () => {
const storeSetting = useSetting()
const instance = _axios.create()
const storeSetting = useSetting();
const instance = _axios.create();
instance.interceptors.request.use(config => {
// 判断是否需要使用代理
if (platform.runtime.webSecurity() && (config.url && proxy.is(config.url))) {
if (platform.runtime.webSecurity() && config.url && proxy.is(config.url)) {
if (!storeSetting.items.proxy_enable || !storeSetting.items.proxy_url) {
throw new Error($t('main_network_request_proxy_prompt'))
throw new Error($t("main_network_request_proxy_prompt"));
}
config.headers = !config.headers ? {} : config.headers
const connector = config.url.includes("?") ? "&" : "?"
config.headers["Ctool-Proxy-Url"] = `${config.url}${config.params ? `${connector}${qs.stringify(config.params)}` : ""}`;
config.headers = !config.headers ? new AxiosHeaders() : config.headers;
const connector = config.url.includes("?") ? "&" : "?";
config.headers["Ctool-Proxy-Url"] = `${config.url}${
config.params ? `${connector}${qs.stringify(config.params)}` : ""
}`;
config.params = undefined;
config.url = storeSetting.items.proxy_url
config.url = storeSetting.items.proxy_url;
}
return config;
});
return instance
}
return instance;
};
20 changes: 8 additions & 12 deletions packages/ctool-core/src/tools/time/Timestamp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:center="false"
:label="$t('time_timezone')"
v-model="action.current.timezone"
:options="timezoneLists"
:options="timezoneOptions"
@change="value => (action.current.timezone = value)"
/>
<Display position="right-center">
Expand Down Expand Up @@ -98,10 +98,8 @@ import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";
import { onUnmounted, watch } from "vue";
import zhTimezone from "./timezone/zh_CN.json";
import enTimezone from "./timezone/en_US.json";
import { SelectOption } from "@/types";
import { Format, transform, InputType } from "./util/timestamp";
import { timezoneOptions } from "./util/timezone";
dayjs.extend(utc);
dayjs.extend(timezone);
Expand Down Expand Up @@ -144,14 +142,6 @@ watch(
{ immediate: true, deep: true },
);
const timezoneLists: SelectOption = $computed(() => {
return (
Object.entries($t("main_locale") === "zh_CN" ? zhTimezone : enTimezone).map(([key, value]) => {
return { value: key, label: `${value}` };
}) || []
);
});
let current = $ref(dayjs().valueOf());
const currentTimer = setInterval(() => {
current = dayjs().valueOf();
Expand All @@ -169,4 +159,10 @@ const example = $computed(() => {
{ format: $t("time_unix_millisecond"), value: day.valueOf().toString() },
];
});
console.log(dayjs.tz(dayjs("2013-12-01"), "Europe/Dublin").format("YYYY-MM-DD HH:mm:ss"));
console.log(dayjs.tz(dayjs("2013-06-01"), "Europe/Dublin").format("YYYY-MM-DD HH:mm:ss"));
console.log(dayjs.tz(dayjs(), "Europe/Dublin").format("Z"));
console.log(dayjs.tz(dayjs("2023-01-01 07:09:50"), "Europe/Dublin").format("Z"));
console.log(timezoneOptions);
</script>
16 changes: 4 additions & 12 deletions packages/ctool-core/src/tools/time/Timezone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Align>
<Select
v-model="action.current.timezone[i]"
:options="timezoneLists"
:options="timezoneOptions"
:size="'small'"
:disabled="isValid && action.current.timezone[i] === action.current.type"
/>
Expand All @@ -33,7 +33,7 @@
<ExtendPage v-model="isMore">
<Align direction="vertical">
<Display
v-for="item in timezoneLists"
v-for="item in timezoneOptions"
position="right-center"
:text="item['label']"
:type="item['value'] === action.current.type ? `danger` : `general`"
Expand All @@ -49,12 +49,11 @@
import { initialize, useAction } from "@/store/action";
import { range } from "lodash";
import { watch, computed } from "vue";
import { SelectOption, ComponentSizeType } from "@/types";
import { ComponentSizeType } from "@/types";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";
import zhTimezone from "./timezone/zh_CN.json";
import enTimezone from "./timezone/en_US.json";
import { timezoneOptions } from "./util/timezone";
dayjs.extend(utc);
dayjs.extend(timezone);
Expand All @@ -69,13 +68,6 @@ const defaultTimezoneLists = [
"Africa/Cairo",
"Asia/Calcutta",
];
const timezoneLists: SelectOption = $computed(() => {
return (
Object.entries($t("main_locale") === "zh_CN" ? zhTimezone : enTimezone).map(([key, value]) => {
return { value: key, label: `${value}` };
}) || []
);
});
const check = (value: string) => {
return (
Expand Down
2 changes: 0 additions & 2 deletions packages/ctool-core/src/tools/time/timezone/README.md

This file was deleted.

140 changes: 0 additions & 140 deletions packages/ctool-core/src/tools/time/timezone/en_US.json

This file was deleted.

Loading

0 comments on commit 1d051ab

Please sign in to comment.