소스 검색

目录分类:拆分TS和其他引用目录

xia 3 년 전
부모
커밋
c4fdc8bcc0

+ 1 - 1
src/api/config.ts

@@ -4,7 +4,7 @@ import store from "@/store";
 import router from "@/router";
 
 import { HTTP } from "@/helper/enum";
-import { IResponse } from "@/types/api";
+import { IResponse } from "#/api";
 import { MutationType } from "@/store/modules/app/_type";
 
 const instance: AxiosInstance = axios.create({

+ 1 - 1
src/api/index.ts

@@ -26,7 +26,7 @@ import {
   IGZHItem,
   IDomainItem,
   IPBookItem,
-} from "@/types/api";
+} from "#/api";
 
 /**
  * 登录

+ 72 - 1
src/components/Tinymce/src/Editor.vue

@@ -132,7 +132,7 @@ export default defineComponent({
       bindModelHandlers(editor);
       bindHandlers(e, attrs, unref(editorRef));
     }
-    function setValue(editor: Recordable, val: string, prevVal?: string) {
+    function setValue(editor: any, val: string, prevVal?: string) {
       if (
         editor &&
         typeof val === "string" &&
@@ -142,6 +142,77 @@ export default defineComponent({
         editor.setContent(val);
       }
     }
+
+    function bindModelHandlers(editor: any) {
+      const modelEvents = attrs.modelEvents ? attrs.modelEvents : null;
+      const normalizedEvents = Array.isArray(modelEvents)
+        ? modelEvents.join(" ")
+        : modelEvents;
+
+      watch(
+        () => props.modelValue,
+        (val: string, prevVal: string) => {
+          setValue(editor, val, prevVal);
+        }
+      );
+
+      watch(
+        () => props.value,
+        (val: any, prevVal: any) => {
+          setValue(editor, val, prevVal);
+        },
+        {
+          immediate: true,
+        }
+      );
+
+      editor.on(
+        normalizedEvents ? normalizedEvents : "change keyup undo redo",
+        () => {
+          const content = editor.getContent({ format: attrs.outputFormat });
+          emit("update:modelValue", content);
+          emit("change", content);
+        }
+      );
+    }
+    function handleDone(name: string, url: string) {
+      const editor = unref(editorRef);
+      if (!editor) return;
+
+      const content = editor?.getContent() ?? "";
+      const val =
+        content?.replace(getImgName(name), `<img src="${url}"/>`) ?? "";
+      setValue(editor, val);
+    }
+
+    function getImgName(name: string) {
+      return `[uploading:${name}]`;
+    }
+
+    return {
+      containerWidth,
+      initOptions,
+      tinymceContent,
+      tinymceScriptSrc,
+      elRef,
+      tinymceId,
+      handleDone,
+      editorRef,
+    };
   },
 });
 </script>
+
+<style lang="less" scoped></style>
+
+<style lang="less">
+.tinymce-container {
+  position: relative;
+  line-height: normal;
+
+  textarea {
+    z-index: -1;
+    visibility: hidden;
+  }
+}
+</style>

+ 1 - 1
src/components/drawer-wrapper/index.vue

@@ -24,7 +24,7 @@ import { defineComponent, PropType, ref, watchEffect } from "vue";
 
 import usePagination from "@/hooks/usePagination";
 
-import { IMeta, PageOptions } from "@/types/api";
+import { IMeta, PageOptions } from "#/api";
 
 const DrawerWrapper = defineComponent({
   props: {

+ 1 - 1
src/helper/permission.ts

@@ -1,5 +1,5 @@
 const path = require("path");
-import { RouteConfig } from "@/types/route";
+import { RouteConfig } from "#/route";
 
 /**
  * 通过用户角色过滤有效路由

+ 1 - 1
src/hooks/composable/useAuthUser.ts

@@ -1,6 +1,6 @@
 import { reactive, ref, toRefs, watchEffect } from "vue";
 
-import { IUserItem } from "@/types/api";
+import { IUserItem } from "#/api";
 import { getAuthorUser } from "@/api";
 
 const useAuthUser = () => {

+ 1 - 1
src/hooks/useDebounceFn.ts

@@ -1,5 +1,5 @@
 import { createFilterWrapper, debounceFilter } from "./utils";
-import { FunctionArgs } from "@/types/hooks";
+import { FunctionArgs } from "#/hooks";
 
 const useDebounceFn = <T extends FunctionArgs>(fn: T, ms = 200): T => {
   return createFilterWrapper(debounceFilter(ms), fn);

+ 1 - 1
src/hooks/usePagination.ts

@@ -1,5 +1,5 @@
 import { ref, watch, reactive } from "vue";
-import { IMeta } from "@/types/api";
+import { IMeta } from "#/api";
 
 /**
  * 判断是否加载下一页的hooks

+ 1 - 1
src/hooks/useThrottleFn.ts

@@ -1,4 +1,4 @@
-import { FunctionArgs } from "@/types/hooks";
+import { FunctionArgs } from "#/hooks";
 import { createFilterWrapper, throttleFilter } from "./utils";
 
 const useThrottleFn = <T extends FunctionArgs>(

+ 1 - 1
src/hooks/utils/index.ts

@@ -1,4 +1,4 @@
-import { EventFilter, FunctionArgs } from "@/types/hooks";
+import { EventFilter, FunctionArgs } from "#/hooks";
 
 export function createFilterWrapper<T extends FunctionArgs>(
   filter: EventFilter,

+ 7 - 6
src/layout/index.vue

@@ -34,11 +34,12 @@
                 v-slot="{ navigate }"
               >
                 <a-menu-item>
-                  <p @click.stop="navigate"><span
-                    ><component :is="route.icon" />
-                    <span>{{ route.meta.title }}</span></span
-                  ></p>
-                  
+                  <p @click.stop="navigate">
+                    <span
+                      ><component :is="route.icon" />
+                      <span>{{ route.meta.title }}</span></span
+                    >
+                  </p>
                 </a-menu-item>
               </router-link>
             </template>
@@ -66,7 +67,7 @@ import useApp from "@/hooks/useApp";
 import { pathResolve } from "@/helper/index";
 import { formatNavRoutes } from "@/helper/permission";
 
-import { RouteConfig } from "@/types/route";
+import { RouteConfig } from "#/route";
 import {
   DesktopOutlined,
   PayCircleOutlined,

+ 1 - 1
src/router/async.ts

@@ -1,4 +1,4 @@
-import { RouteConfig } from "@/types/route";
+import { RouteConfig } from "#/route";
 
 export const AccountManager: RouteConfig = {
   name: "AccountManager",

+ 1 - 1
src/router/modules/constant.ts

@@ -1,4 +1,4 @@
-import { RouteConfig } from "@/types/route";
+import { RouteConfig } from "#/route";
 
 export const Login: RouteConfig = {
   name: "Login",

+ 1 - 1
src/router/permission.ts

@@ -7,7 +7,7 @@ import Layout from "@/layout/index.vue";
 
 import { ActionType } from "@/store/modules/app/_type";
 import { NotFound } from "./modules/constant";
-import { RouteConfig } from "@/types/route";
+import { RouteConfig } from "#/route";
 
 const WHITE_URL_LIST: string[] = ["/login"];
 

+ 2 - 2
src/store/modules/app/_type.ts

@@ -1,8 +1,8 @@
 import { AugmentedActionContext } from "./_module";
-import { RouteConfig } from "@/types/route";
+import { RouteConfig } from "#/route";
 import { RouteRecordRaw } from "vue-router";
 
-import { IUser } from "@/types/api";
+import { IUser } from "#/api";
 
 // state 定义
 type State = {

+ 1 - 1
src/store/modules/app/state.ts

@@ -1,5 +1,5 @@
 import { State } from "./_type";
-import { IUser } from "@/types/api";
+import { IUser } from "#/api";
 
 /**
  * TODO: 待优化

+ 0 - 23
src/types/global.d.ts

@@ -1,23 +0,0 @@
-declare interface Fn<T = any> {
-  (...arg: T[]): T;
-}
-
-declare interface IObj<T = any> {
-  [key: string]: T;
-  [key: number]: T;
-}
-
-declare type SelectOptions<T = any> = {
-  label: string;
-  value: T;
-}[];
-
-declare type EmitType = (event: string, ...args: any[]) => void;
-
-declare interface RangePickerClass {
-  add(text: string, range: moment.Moment[]): this;
-
-  pick(range: string[]): this;
-
-  getRange(): Record<string, moment.Moment[]>;
-}

+ 1 - 1
src/views/account/account.vue

@@ -206,7 +206,7 @@ import {
   setChannelRate,
   getOfficialBackConfig
 } from "@/api";
-import { IOfficials, PlanBack } from "@/types/api";
+import { IOfficials, PlanBack } from "#/api";
 import { message } from "ant-design-vue";
 import { InfoCircleOutlined } from "@ant-design/icons-vue";
 import {

+ 1 - 1
src/views/financial/index.vue

@@ -49,7 +49,7 @@ import ToolBar from "@/components/tool-bar/index.vue";
 import usePagination from "@/hooks/usePagination";
 import { getFinanceList } from "@/api";
 import { picker } from "@/helper/config/range";
-import { PageOptions, FinanceData } from "@/types/api";
+import { PageOptions, FinanceData } from "#/api";
 import moment from "moment";
 import { TableColumnOfFinancial } from "../_pageOptions/table_financial";
 

+ 1 - 1
src/views/put/ad-countdata.vue

@@ -106,7 +106,7 @@ import {
 } from "@/api";
 import usePagination from "@/hooks/usePagination";
 import EditableCell from "@/components/edit-cell/index.vue";
-import { AdgroupList, PageOptions } from "@/types/api";
+import { AdgroupList, PageOptions } from "#/api";
 import useAuthUser from "@/hooks/composable/useAuthUser";
 
 const Adgroup = defineComponent({

+ 1 - 1
src/views/put/ad-group.vue

@@ -79,7 +79,7 @@ import useApp from "@/hooks/useApp";
 import { getAdgroupList, setGroupStatus, ALLadGroupData } from "@/api";
 import usePagination from "@/hooks/usePagination";
 import { MutationType } from "@/store/modules/app/_type";
-import { AdGroupData, PageOptions, GroupDatas } from "@/types/api";
+import { AdGroupData, PageOptions, GroupDatas } from "#/api";
 import useAuthUser from "@/hooks/composable/useAuthUser";
 
 const Adgroup = defineComponent({

+ 1 - 1
src/views/put/landing/stepComp/step-one.vue

@@ -117,7 +117,7 @@ import { useRouter } from "vue-router";
 import ImageUpload from "@/components/image-upload/index.vue";
 
 import { getLandingBooks, getLandingDomains, getLandingOfficials } from "@/api";
-import { IDomainItem, IGZHItem, IPBookItem } from "@/types/api";
+import { IDomainItem, IGZHItem, IPBookItem } from "#/api";
 
 const StepOne = defineComponent({
   name: "StepOne",

+ 1 - 1
src/views/put/put-ad-account.vue

@@ -42,7 +42,7 @@ import ToolBar from "@/components/tool-bar/index.vue";
 import { TableColumnOfPutAdAccount } from "../_pageOptions/table-put";
 import usePagination from "@/hooks/usePagination";
 import { getAdPushList, getAdauth, statusAdChange } from "@/api";
-import { ADpushSimple, PageOptions } from "@/types/api";
+import { ADpushSimple, PageOptions } from "#/api";
 import useDebounceFn from "@/hooks/useDebounceFn";
 import { message } from "ant-design-vue";
 const PutAdAccount = defineComponent({

+ 1 - 1
src/views/put/put-ad-count.vue

@@ -23,7 +23,7 @@ import moment from "moment";
 import { getAdplanData, getAdplanTable } from "@/api";
 import usePagination from "@/hooks/usePagination";
 
-import { adPlanCount, PageOptions} from "@/types/api";
+import { adPlanCount, PageOptions} from "#/api";
 import useApp from "@/hooks/useApp";
 
 const PutCount = defineComponent({

+ 1 - 1
src/views/put/put-ad-plan.vue

@@ -326,7 +326,7 @@ import {
   getadDataSum
 } from "@/api";
 
-import { ADPlanItem, PageOptions, PlanBack } from "@/types/api";
+import { ADPlanItem, PageOptions, PlanBack } from "#/api";
 import useAuthUser from "@/hooks/composable/useAuthUser";
 
 const PutAdPlan = defineComponent({

+ 1 - 1
src/views/put/put-book.vue

@@ -156,7 +156,7 @@ import {
   onStopDeliveryBook,
 } from "@/api";
 import { TableColumnOfPutBooks } from "../_pageOptions/table-put";
-import { IBookSearchResult, IDeliveryBook } from "@/types/api";
+import { IBookSearchResult, IDeliveryBook } from "#/api";
 
 const PutBooks = defineComponent({
   components: {

+ 1 - 1
src/views/put/put-data-more.vue

@@ -25,7 +25,7 @@ import { TableColumnOfMoreStat,TableMoreStat } from "../_pageOptions/table-put";
 import { getDeliveryMoreStatList } from "@/api";
 import usePagination from "@/hooks/usePagination";
 
-import { moreStatPlanItem, PageOptions } from "@/types/api";
+import { moreStatPlanItem, PageOptions } from "#/api";
 
 const PutData = defineComponent({
   components: {

+ 1 - 1
src/views/put/put-data.vue

@@ -92,7 +92,7 @@ import {
 } from "@/api";
 import usePagination from "@/hooks/usePagination";
 
-import { deliveryPlanItem, PageOptions, moreStatPlanItem } from "@/types/api";
+import { deliveryPlanItem, PageOptions, moreStatPlanItem } from "#/api";
 import useApp from "@/hooks/useApp";
 import useAuthUser from "@/hooks/composable/useAuthUser";
 

+ 1 - 1
src/views/put/put-log.vue

@@ -56,7 +56,7 @@ import { TableColumnOfPutLog } from "../_pageOptions/table-put";
 import { opertaroLog } from "@/api";
 import usePagination from "@/hooks/usePagination";
 
-import { adPlanLog, PageOptions } from "@/types/api";
+import { adPlanLog, PageOptions } from "#/api";
 import useApp from "@/hooks/useApp";
 
 const PutData = defineComponent({

+ 1 - 1
src/views/put/register-data.vue

@@ -73,7 +73,7 @@ import { MatchList } from "../_pageOptions/table-put";
 import { getRegisterData, setMustUpback } from "@/api";
 import usePagination from "@/hooks/usePagination";
 
-import { RegisterData, PageOptions } from "@/types/api";
+import { RegisterData, PageOptions } from "#/api";
 import useApp from "@/hooks/useApp";
 
 const RegisterDatad = defineComponent({

+ 6 - 2
tsconfig.json

@@ -13,16 +13,20 @@
     "baseUrl": ".",
     "types": ["webpack-env"],
     "paths": {
-      "@/*": ["src/*"]
+      "@/*": ["src/*"],
+      "#/*": ["types/*"]
     },
     "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
   },
   "include": [
     "src/**/*.ts",
     "src/**/*.tsx",
+    "src/**/*.d.ts",
     "src/**/*.vue",
     "tests/**/*.ts",
+    "types/**/*.d.ts",
+    "types/**/*.ts",
     "tests/**/*.tsx"
   ],
-  "exclude": ["node_modules"]
+  "exclude": ["node_modules", "dist"]
 }

src/types/api.d.ts → types/api.d.ts


+ 24 - 0
window.d.ts

@@ -1,3 +1,27 @@
+declare interface Fn<T = any> {
+  (...arg: T[]): T;
+}
+
+declare interface IObj<T = any> {
+  [key: string]: T;
+  [key: number]: T;
+}
+
+declare type SelectOptions<T = any> = {
+  label: string;
+  value: T;
+}[];
+
+declare type EmitType = (event: string, ...args: any[]) => void;
+
+declare interface RangePickerClass {
+  add(text: string, range: moment.Moment[]): this;
+
+  pick(range: string[]): this;
+
+  getRange(): Record<string, moment.Moment[]>;
+}
+
 declare interface Fn<T = any, R = T> {
   (...arg: T[]): R;
 }

src/types/hooks.d.ts → types/hooks.d.ts


src/types/route.d.ts → types/route.d.ts


src/types/window.d.ts → types/window.d.ts


+ 12 - 5
yarn.lock

@@ -1536,6 +1536,11 @@
   optionalDependencies:
     prettier "^1.18.2"
 
+"@vue/devtools-api@^6.0.0-beta.10":
+  version "6.0.0-beta.10"
+  resolved "https://registry.nlark.com/@vue/devtools-api/download/@vue/devtools-api-6.0.0-beta.10.tgz#f39da7618cee292e39c7274227c34163e30eb3ca"
+  integrity sha1-852nYYzuKS45xydCJ8NBY+MOs8o=
+
 "@vue/preload-webpack-plugin@^1.1.0":
   version "1.1.2"
   resolved "https://registry.nlark.com/@vue/preload-webpack-plugin/download/@vue/preload-webpack-plugin-1.1.2.tgz#ceb924b4ecb3b9c43871c7a429a02f8423e621ab"
@@ -9148,10 +9153,12 @@ vue-loader@^15.9.2:
     vue-hot-reload-api "^2.3.0"
     vue-style-loader "^4.1.0"
 
-vue-router@^4.0.0-0:
-  version "4.0.6"
-  resolved "https://registry.nlark.com/vue-router/download/vue-router-4.0.6.tgz#91750db507d26642f225b0ec6064568e5fe448d6"
-  integrity sha1-kXUNtQfSZkLyJbDsYGRWjl/kSNY=
+vue-router@^4.0.4:
+  version "4.0.8"
+  resolved "https://registry.nlark.com/vue-router/download/vue-router-4.0.8.tgz?cache=0&sync_timestamp=1620899536020&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fvue-router%2Fdownload%2Fvue-router-4.0.8.tgz#55d4290a3122444edbc91a3cd2492bb1d0cef494"
+  integrity sha1-VdQpCjEiRE7byRo80kkrsdDO9JQ=
+  dependencies:
+    "@vue/devtools-api" "^6.0.0-beta.10"
 
 vue-style-loader@^4.1.0, vue-style-loader@^4.1.2:
   version "4.1.3"
@@ -9173,7 +9180,7 @@ vue-types@^3.0.0:
   dependencies:
     is-plain-object "3.0.1"
 
-vue@^3.0.0:
+vue@^3.0.0, vue@^3.0.7:
   version "3.0.11"
   resolved "https://registry.npm.taobao.org/vue/download/vue-3.0.11.tgz#c82f9594cbf4dcc869241d4c8dd3e08d9a8f4b5f"
   integrity sha1-yC+VlMv03MhpJB1MjdPgjZqPS18=