mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-11-10 07:28:24 +08:00
Merge pull request #184 from timi137137/feat/timi137137
chore: 将模板代码向TS对齐
This commit is contained in:
commit
5be1b14b07
45
.eslintrc
45
.eslintrc
|
@ -44,7 +44,24 @@
|
||||||
"import/first": "off", // https://github.com/vuejs/vue-eslint-parser/issues/58
|
"import/first": "off", // https://github.com/vuejs/vue-eslint-parser/issues/58
|
||||||
"@typescript-eslint/no-explicit-any": "off",
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||||
"vue/first-attribute-linebreak": 0
|
"vue/first-attribute-linebreak": 0,
|
||||||
|
|
||||||
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"argsIgnorePattern": "^_",
|
||||||
|
"varsIgnorePattern": "^_"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"argsIgnorePattern": "^_",
|
||||||
|
"varsIgnorePattern": "^_"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@typescript-eslint/ban-ts-comment": "off",
|
||||||
|
"@typescript-eslint/ban-types": "off"
|
||||||
},
|
},
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
{
|
||||||
|
@ -57,6 +74,32 @@
|
||||||
"vue/no-v-html": 0,
|
"vue/no-v-html": 0,
|
||||||
"vue-scoped-css/enforce-style-type": ["error", { "allows": ["scoped"] }]
|
"vue-scoped-css/enforce-style-type": ["error", { "allows": ["scoped"] }]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.ts", "*.tsx"], // https://github.com/typescript-eslint eslint-recommended
|
||||||
|
"rules": {
|
||||||
|
"constructor-super": "off", // ts(2335) & ts(2377)
|
||||||
|
"getter-return": "off", // ts(2378)
|
||||||
|
"no-const-assign": "off", // ts(2588)
|
||||||
|
"no-dupe-args": "off", // ts(2300)
|
||||||
|
"no-dupe-class-members": "off", // ts(2393) & ts(2300)
|
||||||
|
"no-dupe-keys": "off", // ts(1117)
|
||||||
|
"no-func-assign": "off", // ts(2539)
|
||||||
|
"no-import-assign": "off", // ts(2539) & ts(2540)
|
||||||
|
"no-new-symbol": "off", // ts(2588)
|
||||||
|
"no-obj-calls": "off", // ts(2349)
|
||||||
|
"no-redeclare": "off", // ts(2451)
|
||||||
|
"no-setter-return": "off", // ts(2408)
|
||||||
|
"no-this-before-super": "off", // ts(2376)
|
||||||
|
"no-undef": "off", // ts(2304)
|
||||||
|
"no-unreachable": "off", // ts(7027)
|
||||||
|
"no-unsafe-negation": "off", // ts(2365) & ts(2360) & ts(2358)
|
||||||
|
"no-var": "error", // ts transpiles let/const to var, so no need for vars any more
|
||||||
|
"prefer-const": "error", // ts provides better types with const
|
||||||
|
"prefer-rest-params": "error", // ts provides better types with rest args over arguments
|
||||||
|
"prefer-spread": "error", // ts transpiles spread to apply, so no need for manual apply
|
||||||
|
"valid-typeof": "off" // ts(2367)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
[[ "$(uname -a)" = *"MINGW64"* ]] && exit 0
|
||||||
|
[ -n "$CI" ] && exit 0
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
exec < /dev/tty && npx git-cz --hook || true
|
exec < /dev/tty && npx git-cz --hook || true
|
|
@ -70,7 +70,7 @@ import { useSettingStore } from '@/store';
|
||||||
import { getActive } from '@/router';
|
import { getActive } from '@/router';
|
||||||
import { prefix } from '@/config/global';
|
import { prefix } from '@/config/global';
|
||||||
import LogoFull from '@/assets/assets-logo-full.svg?component';
|
import LogoFull from '@/assets/assets-logo-full.svg?component';
|
||||||
import { MenuRoute } from '@/interface';
|
import { MenuRoute } from '@/types/interface';
|
||||||
|
|
||||||
import Notice from './Notice.vue';
|
import Notice from './Notice.vue';
|
||||||
import Search from './Search.vue';
|
import Search from './Search.vue';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { defineComponent, PropType, computed, h } from 'vue';
|
import { defineComponent, PropType, computed, h } from 'vue';
|
||||||
import { prefix } from '@/config/global';
|
import { prefix } from '@/config/global';
|
||||||
import { MenuRoute } from '@/interface';
|
import { MenuRoute } from '@/types/interface';
|
||||||
import { getActive } from '@/router';
|
import { getActive } from '@/router';
|
||||||
|
|
||||||
const getMenuList = (list: MenuRoute[], basePath?: string): MenuRoute[] => {
|
const getMenuList = (list: MenuRoute[], basePath?: string): MenuRoute[] => {
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useNotificationStore } from '@/store';
|
import { useNotificationStore } from '@/store';
|
||||||
import { NotificationItem } from '@/interface';
|
import { NotificationItem } from '@/types/interface';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const store = useNotificationStore();
|
const store = useNotificationStore();
|
||||||
|
|
|
@ -11,7 +11,7 @@ import LayoutContent from './components/Content.vue';
|
||||||
import Setting from './setting.vue';
|
import Setting from './setting.vue';
|
||||||
|
|
||||||
import { prefix } from '@/config/global';
|
import { prefix } from '@/config/global';
|
||||||
import { TRouterInfo } from '@/interface';
|
import { TRouterInfo } from '@/types/interface';
|
||||||
|
|
||||||
import '@/style/layout.less';
|
import '@/style/layout.less';
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ import { ref, onMounted } from 'vue';
|
||||||
import { prefix } from '@/config/global';
|
import { prefix } from '@/config/global';
|
||||||
import { BASE_INFO_DATA, TABLE_COLUMNS_DATA as columns, PRODUCT_LIST } from './constants';
|
import { BASE_INFO_DATA, TABLE_COLUMNS_DATA as columns, PRODUCT_LIST } from './constants';
|
||||||
import request from '@/utils/request';
|
import request from '@/utils/request';
|
||||||
import { ResDataType } from '@/interface';
|
import { ResDataType } from '@/types/interface';
|
||||||
|
|
||||||
import Product from './components/Product.vue';
|
import Product from './components/Product.vue';
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ import { BASE_INFO_DATA, TABLE_COLUMNS as columns } from './constants';
|
||||||
import { changeChartsTheme } from '@/utils/color';
|
import { changeChartsTheme } from '@/utils/color';
|
||||||
|
|
||||||
import { prefix } from '@/config/global';
|
import { prefix } from '@/config/global';
|
||||||
import { ResDataType } from '@/interface';
|
import { ResDataType } from '@/types/interface';
|
||||||
import request from '@/utils/request';
|
import request from '@/utils/request';
|
||||||
|
|
||||||
echarts.use([
|
echarts.use([
|
||||||
|
|
|
@ -60,7 +60,7 @@ export default {
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { NOTIFICATION_TYPES } from '@/constants';
|
import { NOTIFICATION_TYPES } from '@/constants';
|
||||||
import { NotificationItem } from '@/interface';
|
import { NotificationItem } from '@/types/interface';
|
||||||
import EmptyIcon from '@/assets/assets-empty.svg?component';
|
import EmptyIcon from '@/assets/assets-empty.svg?component';
|
||||||
import { useNotificationStore } from '@/store';
|
import { useNotificationStore } from '@/store';
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ import { MessagePlugin } from 'tdesign-vue-next';
|
||||||
|
|
||||||
import { CONTRACT_STATUS, CONTRACT_TYPES, CONTRACT_PAYMENT_TYPES } from '@/constants';
|
import { CONTRACT_STATUS, CONTRACT_TYPES, CONTRACT_PAYMENT_TYPES } from '@/constants';
|
||||||
import Trend from '@/components/trend/index.vue';
|
import Trend from '@/components/trend/index.vue';
|
||||||
import { ResDataType } from '@/interface';
|
import { ResDataType } from '@/types/interface';
|
||||||
import request from '@/utils/request';
|
import request from '@/utils/request';
|
||||||
import { useSettingStore } from '@/store';
|
import { useSettingStore } from '@/store';
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ import { MessagePlugin } from 'tdesign-vue-next';
|
||||||
import ProductCard from '@/components/product-card/index.vue';
|
import ProductCard from '@/components/product-card/index.vue';
|
||||||
import DialogForm from './components/DialogForm.vue';
|
import DialogForm from './components/DialogForm.vue';
|
||||||
import request from '@/utils/request';
|
import request from '@/utils/request';
|
||||||
import { ResDataType } from '@/interface';
|
import { ResDataType } from '@/types/interface';
|
||||||
|
|
||||||
const INITIAL_DATA = {
|
const INITIAL_DATA = {
|
||||||
name: '',
|
name: '',
|
||||||
|
|
|
@ -118,7 +118,7 @@ import { ref, computed, onMounted } from 'vue';
|
||||||
import { MessagePlugin } from 'tdesign-vue-next';
|
import { MessagePlugin } from 'tdesign-vue-next';
|
||||||
import Trend from '@/components/trend/index.vue';
|
import Trend from '@/components/trend/index.vue';
|
||||||
import request from '@/utils/request';
|
import request from '@/utils/request';
|
||||||
import { ResDataType } from '@/interface';
|
import { ResDataType } from '@/types/interface';
|
||||||
import { useSettingStore } from '@/store';
|
import { useSettingStore } from '@/store';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
6
src/shims-vue.d.ts
vendored
6
src/shims-vue.d.ts
vendored
|
@ -1,6 +0,0 @@
|
||||||
declare module '*.vue' {
|
|
||||||
import { DefineComponent } from 'vue';
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
|
|
||||||
const component: DefineComponent<{}, {}, any>;
|
|
||||||
export default component;
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { NotificationItem } from '@/interface';
|
import { NotificationItem } from '@/types/interface';
|
||||||
|
|
||||||
const msgData = [
|
const msgData = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { TRouterInfo, TTabRouterType } from '@/interface';
|
import { TRouterInfo, TTabRouterType } from '@/types/interface';
|
||||||
import { store } from '@/store';
|
import { store } from '@/store';
|
||||||
|
|
||||||
const homeRoute: Array<TRouterInfo> = [
|
const homeRoute: Array<TRouterInfo> = [
|
||||||
|
|
10
globals.d.ts → src/types/globals.d.ts
vendored
10
globals.d.ts → src/types/globals.d.ts
vendored
|
@ -1,11 +1,19 @@
|
||||||
// 通用声明
|
// 通用声明
|
||||||
|
|
||||||
|
// Vue
|
||||||
|
declare module '*.vue' {
|
||||||
|
import { DefineComponent } from 'vue';
|
||||||
|
|
||||||
|
const component: DefineComponent<{}, {}, any>;
|
||||||
|
export default component;
|
||||||
|
}
|
||||||
|
|
||||||
declare type ClassName = { [className: string]: any } | ClassName[] | string;
|
declare type ClassName = { [className: string]: any } | ClassName[] | string;
|
||||||
|
|
||||||
declare interface ImportMeta {
|
declare interface ImportMeta {
|
||||||
env: {
|
env: {
|
||||||
MODE: 'mock' | 'development' | 'test' | 'release';
|
MODE: 'mock' | 'development' | 'test' | 'release';
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
glob: (url: string) => { url };
|
glob: (url: string) => { url };
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ export function getDateArray(dateTime: string[] = [], divideNum = 10): string[]
|
||||||
*
|
*
|
||||||
* @memberOf DashboardBase
|
* @memberOf DashboardBase
|
||||||
*/
|
*/
|
||||||
export function getRandomArray(num = 100) {
|
export function getRandomArray(num = 100): number {
|
||||||
let resultNum = Number((Math.random() * num).toFixed(0));
|
let resultNum = Number((Math.random() * num).toFixed(0));
|
||||||
|
|
||||||
if (resultNum <= 1) {
|
if (resultNum <= 1) {
|
||||||
|
|
|
@ -10,11 +10,11 @@ import { getSettingStore } from '@/store';
|
||||||
* @param {string} theme
|
* @param {string} theme
|
||||||
* @returns {}
|
* @returns {}
|
||||||
*/
|
*/
|
||||||
export function getColorFromTheme(theme: string) {
|
export function getColorFromTheme(theme: string): Array<string> {
|
||||||
const settingStore = getSettingStore();
|
const settingStore = getSettingStore();
|
||||||
const { colorList, mode } = settingStore;
|
const { colorList, mode } = settingStore;
|
||||||
const isDarkMode = mode === 'dark';
|
const isDarkMode = mode === 'dark';
|
||||||
let themeColorList = [];
|
let themeColorList;
|
||||||
const themeColor = getBrandColor(theme, colorList);
|
const themeColor = getBrandColor(theme, colorList);
|
||||||
|
|
||||||
if (!/^#[A-F\d]{6}$/i.test(theme)) {
|
if (!/^#[A-F\d]{6}$/i.test(theme)) {
|
||||||
|
@ -52,7 +52,7 @@ export function getChartListColor(): Array<string> {
|
||||||
* @param {Array<string>} chartsList
|
* @param {Array<string>} chartsList
|
||||||
* @param {string} theme
|
* @param {string} theme
|
||||||
*/
|
*/
|
||||||
export function changeChartsTheme(chartsList: echarts.EChartsType[]) {
|
export function changeChartsTheme(chartsList: echarts.EChartsType[]): void {
|
||||||
if (chartsList && chartsList.length) {
|
if (chartsList && chartsList.length) {
|
||||||
const chartChangeColor = getChartListColor();
|
const chartChangeColor = getChartListColor();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import axios from 'axios';
|
import axios, { AxiosInstance } from 'axios';
|
||||||
import proxy from '../config/proxy';
|
import proxy from '../config/proxy';
|
||||||
|
|
||||||
const env = import.meta.env.MODE || 'development';
|
const env = import.meta.env.MODE || 'development';
|
||||||
|
@ -8,19 +8,15 @@ const host = env === 'mock' ? '/' : proxy[env].host; // 如果是mock模式 就
|
||||||
const CODE = {
|
const CODE = {
|
||||||
LOGIN_TIMEOUT: 1000,
|
LOGIN_TIMEOUT: 1000,
|
||||||
REQUEST_SUCCESS: 0,
|
REQUEST_SUCCESS: 0,
|
||||||
REQUEST_FOBID: 1001,
|
REQUEST_FAILED: 1001,
|
||||||
};
|
};
|
||||||
|
|
||||||
const instance = axios.create({
|
const instance: AxiosInstance = axios.create({
|
||||||
baseURL: host,
|
baseURL: host,
|
||||||
timeout: 1000,
|
timeout: 5000,
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.interceptors.request.use((config) => config);
|
|
||||||
|
|
||||||
instance.defaults.timeout = 5000;
|
|
||||||
|
|
||||||
instance.interceptors.response.use(
|
instance.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
"@/*": ["src/*"]
|
"@/*": ["src/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts", "src/**/*.d.ts", "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
|
"include": ["**/*.ts", "src/**/*.d.ts",
|
||||||
|
"src/types/**/*.d.ts", "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
|
||||||
"compileOnSave": false
|
"compileOnSave": false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user