Skip to content

Commit

Permalink
chore: fix hooks, styles, directives deps
Browse files Browse the repository at this point in the history
  • Loading branch information
kirklin committed Jul 3, 2024
1 parent fa41b70 commit 34cf4d6
Show file tree
Hide file tree
Showing 41 changed files with 206 additions and 82 deletions.
3 changes: 0 additions & 3 deletions apps/admin/autoResolver/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ declare global {
const useKeyModifier: typeof import('@vueuse/core')['useKeyModifier']
const useLastChanged: typeof import('@vueuse/core')['useLastChanged']
const useLink: typeof import('vue-router')['useLink']
const useLoading: typeof import('@celeris/hooks')['useLoading']
const useLoadingBar: typeof import('@celeris/ca-components')['useLoadingBar']
const useLocalStorage: typeof import('@vueuse/core')['useLocalStorage']
const useMagicKeys: typeof import('@vueuse/core')['useMagicKeys']
Expand Down Expand Up @@ -510,7 +509,6 @@ declare module 'vue' {
readonly useKeyModifier: UnwrapRef<typeof import('@vueuse/core')['useKeyModifier']>
readonly useLastChanged: UnwrapRef<typeof import('@vueuse/core')['useLastChanged']>
readonly useLink: UnwrapRef<typeof import('vue-router')['useLink']>
readonly useLoading: UnwrapRef<typeof import('@celeris/hooks')['useLoading']>
readonly useLoadingBar: UnwrapRef<typeof import('@celeris/ca-components')['useLoadingBar']>
readonly useLocalStorage: UnwrapRef<typeof import('@vueuse/core')['useLocalStorage']>
readonly useMagicKeys: UnwrapRef<typeof import('@vueuse/core')['useMagicKeys']>
Expand Down Expand Up @@ -816,7 +814,6 @@ declare module '@vue/runtime-core' {
readonly useKeyModifier: UnwrapRef<typeof import('@vueuse/core')['useKeyModifier']>
readonly useLastChanged: UnwrapRef<typeof import('@vueuse/core')['useLastChanged']>
readonly useLink: UnwrapRef<typeof import('vue-router')['useLink']>
readonly useLoading: UnwrapRef<typeof import('@celeris/hooks')['useLoading']>
readonly useLoadingBar: UnwrapRef<typeof import('@celeris/ca-components')['useLoadingBar']>
readonly useLocalStorage: UnwrapRef<typeof import('@vueuse/core')['useLocalStorage']>
readonly useMagicKeys: UnwrapRef<typeof import('@vueuse/core')['useMagicKeys']>
Expand Down
8 changes: 4 additions & 4 deletions apps/admin/src/pages/dashboard/components/DataOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function generateSeries(name: string, lineColor: string, itemBorderColor: string
},
};
}
const { loading, setLoading } = useLoading(true);
const loading = ref<boolean>(true);
const { getDarkMode } = useThemeSetting();
const renderData = computed(() => [
{
Expand Down Expand Up @@ -222,7 +222,7 @@ const { chartOption } = useChartOption((isDark: boolean) => {
};
});
async function fetchData() {
setLoading(true);
loading.value = true;
try {
const data = await queryDataOverview();
xAxis.value = data.xAxis;
Expand All @@ -237,9 +237,9 @@ async function fetchData() {
likedResponsesData.value = el.value;
});
} catch (err) {
setLoading(false);
loading.value = false;
} finally {
setLoading(false);
loading.value = false;
}
}
fetchData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const props = defineProps({
},
});
const { loading, setLoading } = useLoading(true);
const loading = ref<boolean>(true);
const count = ref();
const growth = ref(100);
const chartData = ref<any>([]);
Expand Down Expand Up @@ -83,6 +83,7 @@ const { chartOption } = useChartOption(() => {
};
});
async function fetchData(params: { quota: string }) {
loading.value = true;
try {
const data = await queryUserAnalysisData(params);
const { chartData: resChartData } = data;
Expand All @@ -102,8 +103,9 @@ async function fetchData(params: { quota: string }) {
});
} catch (err) {
// you can report use errorHandler or other
loading.value = false;
} finally {
setLoading(false);
loading.value = false;
}
}
fetchData({ quota: props.quota });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { ForgotPasswordFromType } from "~/pages/login/types";
const { t } = useI18n();
const formRef = ref<FormInst | null>(null);
const message = useMessage();
const { loading, setLoading } = useLoading(false);
const loading = ref<boolean>(true);
const model = ref<ForgotPasswordFromType>({
phoneNumber: "",
});
Expand All @@ -37,9 +37,9 @@ const rules: FormRules = {
function forgotPassword(e: Event) {
e.preventDefault();
setLoading(true);
loading.value = true;
formRef.value?.validate((errors: Array<FormValidationError> | undefined) => {
setLoading(false);
loading.value = false;
if (!errors) {
message.success(t("page.login.form.resetLinkSentMessage"));
}
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/store/modules/design/themeUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ButtonColorScene, ColorAction, ColorType, ColorTypeCase, ThemeColor, ThemeConfig } from "@celeris/types";
import { deepMerge, generateColorPalettes } from "@celeris/utils";
import { type GlobalThemeOverrides, commonDark, commonLight } from "naive-ui";
import type { ButtonColorScene, ColorAction, ColorType, ColorTypeCase, ThemeColor, ThemeConfig } from "./types";

/**
* 将字符串的第一个字符大写
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion packages/shared/vite/src/plugins/unpluginAutoImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export function createAutoImportPluginConfig(): PluginOption {
{
"@celeris/hooks": [
"useComponentRef",
"useLoading",
"useMergeState",
"useScreen",
"useState",
Expand Down
21 changes: 17 additions & 4 deletions packages/web/CAComponents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@
"author": "Kirk Lin (https://github.com/kirklin)",
"license": "MIT",
"homepage": "https://github.com/kirklin/celeris-web",
"main": "index.ts",
"module": "index.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./index.ts",
"module": "./index.ts",
"types": "./dist/index.d.ts",
"scripts": {
"clean": "pnpm rimraf node_modules && pnpm rimraf dist"
"build": "tsup",
"dev": "tsup --stub",
"clean": "pnpm rimraf node_modules && pnpm rimraf dist",
"prepublishOnly": "npm run build",
"postinstall": "npm run build"
},
"peerDependencies": {
"vue": "^3.3.4"
"naive-ui": ">=2.38.2",
"vue": ">=3.3.4"
},
"dependencies": {},
"devDependencies": {
Expand Down
23 changes: 23 additions & 0 deletions packages/web/CAComponents/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "@celeris/tsconfig/tsconfig.base.json",
"compilerOptions": {
"target": "esnext",
"lib": [
"esnext",
"dom"
],
"baseUrl": ".",
"module": "esnext",
"moduleResolution": "Node",
"strict": true,
"sourceMap": false,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": [
"index.ts"
],
"exclude": [
"node_modules"
]
}
10 changes: 10 additions & 0 deletions packages/web/CAComponents/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["./index.ts"],
clean: true,
format: ["esm", "cjs"],
external: ["vue"],
dts: true,
minify: true,
});
4 changes: 1 addition & 3 deletions packages/web/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export * from "./Application";
export * from "./Icon";
export * from "./Charts";
export * from "./src";
4 changes: 2 additions & 2 deletions packages/web/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"author": "Kirk Lin (https://github.com/kirklin)",
"license": "MIT",
"homepage": "https://github.com/kirklin/celeris-web",
"main": "index.ts",
"module": "index.ts",
"main": "./index.ts",
"module": "./index.ts",
"scripts": {
"clean": "pnpm rimraf node_modules && pnpm rimraf dist"
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/web/components/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./Application";
export * from "./Icon";
export * from "./Charts";
18 changes: 15 additions & 3 deletions packages/web/constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@
"author": "Kirk Lin (https://github.com/kirklin)",
"license": "MIT",
"homepage": "https://github.com/kirklin/celeris-web",
"main": "index.ts",
"module": "index.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./index.ts",
"module": "./index.ts",
"types": "./dist/index.d.ts",
"scripts": {
"clean": "pnpm rimraf node_modules && pnpm rimraf dist"
"build": "tsup",
"dev": "tsup --stub",
"clean": "pnpm rimraf node_modules && pnpm rimraf dist",
"prepublishOnly": "npm run build",
"postinstall": "npm run build"
},
"dependencies": {
"lodash.pick": "4.4.0"
Expand Down
3 changes: 2 additions & 1 deletion packages/web/constants/src/utils/defineConstants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pick from "lodash/pick";
// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires
const pick = require("lodash/pick.js");

/**
* Utility function to determine the raw type of a value.
Expand Down
22 changes: 22 additions & 0 deletions packages/web/constants/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "@celeris/tsconfig/tsconfig.base.json",
"compilerOptions": {
"target": "esnext",
"lib": [
"esnext",
"dom"
],
"baseUrl": ".",
"module": "esnext",
"strict": true,
"sourceMap": false,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
9 changes: 9 additions & 0 deletions packages/web/constants/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["./index.ts"],
clean: true,
format: ["esm", "cjs"],
dts: true,
minify: true,
});
2 changes: 1 addition & 1 deletion packages/web/directives/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "tsup";
export default defineConfig({
entry: ["./index.ts"],
clean: true,
format: ["esm", "cjs", "iife"],
format: ["esm", "cjs"],
external: ["vue"],
dts: true,
minify: true,
Expand Down
1 change: 0 additions & 1 deletion packages/web/hooks/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from "./useComponentRef";
export * from "./useLoading";
export * from "./useMergeState";
export * from "./useScreen";
export * from "./useState";
2 changes: 2 additions & 0 deletions packages/web/hooks/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type BasicStateAction<S> = ((state: S) => S) | S;
export type Dispatch<A> = (action: A) => void;
13 changes: 0 additions & 13 deletions packages/web/hooks/src/useLoading.ts

This file was deleted.

26 changes: 21 additions & 5 deletions packages/web/hooks/src/useState.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import type { Ref } from "vue";
import { ref } from "vue";
import { isFunction } from "@celeris/utils";
import type { BasicStateAction, Dispatch } from "./types";

export function useState<T>(defaultValue?: T): [Ref<T>, (newValue: T) => void] {
const value = ref(defaultValue) as Ref<T>;
const setValue = (newValue: T) => {
value.value = newValue;
export function useState<S>(
initialState?: (() => S) | S,
): [Ref<S>, Dispatch<BasicStateAction<S>>] {
// "vue useState is use customRef to simulation.;

let state = initialState;
if (isFunction(initialState)) {
state = initialState();
}

const reactiveState = ref(state) as Ref<S>;

const dispatchAction = (actionOrState: ((prevState: S) => S) | S) => {
if (isFunction(actionOrState)) {
reactiveState.value = actionOrState(reactiveState.value);
} else {
reactiveState.value = actionOrState;
}
};

return [value, setValue];
return [reactiveState, dispatchAction];
}
2 changes: 1 addition & 1 deletion packages/web/hooks/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "tsup";
export default defineConfig({
entry: ["./index.ts"],
clean: true,
format: ["esm", "cjs", "iife"],
format: ["esm", "cjs"],
external: ["vue"],
dts: true,
minify: true,
Expand Down
15 changes: 13 additions & 2 deletions packages/web/locale/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,26 @@
"author": "Kirk Lin (https://github.com/kirklin)",
"license": "MIT",
"homepage": "https://github.com/kirklin/celeris-web",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./index.ts",
"module": "./index.ts",
"types": "./dist/index.d.ts",
"scripts": {
"clean": "pnpm rimraf node_modules && pnpm rimraf dist"
"build": "tsup",
"dev": "tsup --stub",
"clean": "pnpm rimraf node_modules && pnpm rimraf dist",
"prepublishOnly": "npm run build",
"postinstall": "npm run build"
},
"dependencies": {
"@celeris/constants": "workspace:*",
"@celeris/hooks": "workspace:*",
"@celeris/types": "workspace:*",
"@celeris/utils": "workspace:*",
"iso-639-1": "^3.1.2",
"vue": "^3.4.30",
Expand Down
23 changes: 23 additions & 0 deletions packages/web/locale/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "@celeris/tsconfig/tsconfig.base.json",
"compilerOptions": {
"target": "esnext",
"lib": [
"esnext",
"dom"
],
"baseUrl": ".",
"module": "esnext",
"moduleResolution": "Node",
"strict": true,
"sourceMap": false,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
Loading

0 comments on commit 34cf4d6

Please sign in to comment.