添加 useCool

This commit is contained in:
icssoa 2021-10-27 19:15:39 +08:00
parent ab623bf1f0
commit db2a2d71c9
35 changed files with 99 additions and 147 deletions

View File

@ -33,15 +33,13 @@
"</template>",
"",
"<script lang=\"ts\">",
"import { defineComponent, inject, reactive } from \"vue\";",
"import { defineComponent, reactive } from \"vue\";",
"import { CrudLoad, Upsert, Table } from \"cl-admin-crud-vue3/types\";",
"import { useRefs } from \"/@/core\";",
"import { useCool } from \"/@/core\";",
"",
"export default defineComponent({",
" setup() {",
" const { refs, setRefs } = useRefs();",
" // 请求服务",
" const service = inject<any>(\"service\");",
" const { refs, setRefs, service } = useCool();",
"",
" // 新增、编辑配置",
" const upsert = reactive<Upsert>({",

View File

@ -1,6 +1,6 @@
{
"name": "front-next",
"version": "0.8.0",
"version": "0.8.1",
"scripts": {
"dev": "vite",
"build": "vite build",
@ -11,7 +11,7 @@
"dependencies": {
"array.prototype.flat": "^1.2.4",
"axios": "^0.21.1",
"cl-admin-crud-vue3": "^0.9.3",
"cl-admin-crud-vue3": "^0.9.6",
"clipboard": "^2.0.8",
"clone-deep": "^4.0.1",
"codemirror": "^5.62.0",

View File

@ -21,7 +21,7 @@
import { computed, defineComponent } from "vue";
import { ElConfigProvider } from "element-plus";
import zhCn from "element-plus/lib/locale/lang/zh-cn";
import { useStore } from "vuex";
import { useCool } from "/@/core";
export default defineComponent({
components: {
@ -29,7 +29,7 @@ export default defineComponent({
},
setup() {
const store = useStore();
const { store } = useCool();
const locale = zhCn;
const loading = computed(() => store.getters.appLoading);

View File

@ -1,7 +1,7 @@
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
import { deepTree } from "/@/core/utils";
import { ElMessage, ElMessageBox } from "element-plus";
import { defineComponent, h, inject, ref } from "vue";
import { defineComponent, h, ref } from "vue";
export default defineComponent({
name: "cl-dept-move",
@ -9,8 +9,7 @@ export default defineComponent({
emits: ["success", "error"],
setup(_: any, { emit }) {
const service = inject<any>("service");
const { refs, setRefs }: any = useRefs();
const { refs, setRefs, service }: any = useCool();
// 树形列表
const list = ref<any[]>([]);

View File

@ -64,7 +64,7 @@
import { defineComponent, inject, onMounted, ref } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { ContextMenu } from "cl-admin-crud-vue3";
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
import { deepTree, isArray, revDeepTree, isPc } from "/@/core/utils";
export default defineComponent({
@ -84,7 +84,7 @@ export default defineComponent({
emits: ["list-change", "row-click", "user-add"],
setup(props, { emit }) {
const { refs, setRefs } = useRefs();
const { refs, setRefs } = useCool();
//
const list = ref<any[]>([]);

View File

@ -16,7 +16,7 @@ import { computed, defineComponent, onMounted, ref, watch } from "vue";
import Quill from "quill";
import "quill/dist/quill.snow.css";
import { isNumber } from "/@/core/utils";
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
export default defineComponent({
name: "cl-editor-quill",
@ -31,7 +31,7 @@ export default defineComponent({
emits: ["update:modelValue", "load"],
setup(props, { emit }) {
const { refs, setRefs }: any = useRefs();
const { refs, setRefs }: any = useCool();
let quill: any = null;

View File

@ -1,15 +1,12 @@
import { useStore } from "vuex";
import { computed, defineComponent, h, ref, watch } from "vue";
import "./index.scss";
import { useRoute, useRouter } from "vue-router";
import { useCool } from "/@/core";
export default defineComponent({
name: "cl-menu-slider",
setup() {
const router = useRouter();
const route = useRoute();
const store = useStore();
const { router, route, store } = useCool();
// 是否可见
const visible = ref<boolean>(true);

View File

@ -16,22 +16,14 @@
<script lang="ts">
import { computed, defineComponent, onMounted, ref } from "vue";
import { useStore } from "vuex";
import { useRoute, useRouter } from "vue-router";
import { firstMenu } from "../../utils";
import { useCool } from "/@/core";
export default defineComponent({
name: "cl-menu-topbar",
setup() {
//
const store = useStore();
//
const router = useRouter();
//
const route = useRoute();
const { store, router, route } = useCool();
//
const index = ref<string>("0");

View File

@ -32,20 +32,15 @@
<script lang="ts">
import { computed, reactive, watch } from "vue";
import { useStore } from "vuex";
import { useRoute, useRouter } from "vue-router";
import { last } from "/@/core/utils";
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
import { ContextMenu } from "cl-admin-crud-vue3";
export default {
name: "cl-process",
setup() {
const router = useRouter();
const route = useRoute();
const store = useStore();
const { refs, setRefs }: any = useRefs();
const { refs, setRefs, store, route, router }: any = useCool();
//
const menu = reactive<any>({

View File

@ -17,17 +17,15 @@
<script lang="ts">
import { computed, defineComponent, ref, watch } from "vue";
import { useStore } from "vuex";
import { useRoute } from "vue-router";
import _ from "lodash";
import { isEmpty } from "/@/core/utils";
import { useCool } from "/@/core";
export default defineComponent({
name: "cl-route-nav",
setup() {
const route = useRoute();
const store = useStore();
const { store, route } = useCool();
//
const list = ref<any[]>([]);

View File

@ -33,10 +33,9 @@
</template>
<script lang="ts">
import { useStore } from "vuex";
import { computed, defineComponent, ref } from "vue";
import { useRouter } from "vue-router";
import { href } from "/@/core/utils";
import { useCool } from "/@/core";
export default defineComponent({
props: {
@ -45,8 +44,7 @@ export default defineComponent({
},
setup() {
const store = useStore();
const router = useRouter();
const { store, router } = useCool();
const url = ref<string>("");
const isLogout = ref<boolean>(false);

View File

@ -56,10 +56,8 @@
<script lang="ts">
import { defineComponent, reactive, ref } from "vue";
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
import { useStore } from "vuex";
import Captcha from "./components/captcha.vue";
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
export default defineComponent({
cool: {
@ -73,9 +71,7 @@ export default defineComponent({
},
setup() {
const router = useRouter();
const store = useStore();
const { refs, setRefs }: any = useRefs();
const { refs, setRefs, store, router }: any = useCool();
const saving = ref<boolean>(false);

View File

@ -1,6 +1,9 @@
import { BaseService, Service, Permission } from "/@/core";
@Service("base/sys/department")
@Service({
namespace: "base/sys/department",
proxy: "/dev"
})
class SysDepartment extends BaseService {
@Permission("order")
order(data: any) {

View File

@ -24,8 +24,8 @@
<script lang="ts">
import { ElMessage } from "element-plus";
import { defineComponent, inject, reactive, ref } from "vue";
import { useStore } from "vuex";
import { defineComponent, reactive, ref } from "vue";
import { useCool } from "/@/core";
import { cloneDeep } from "/@/core/utils";
export default defineComponent({
@ -41,8 +41,7 @@ export default defineComponent({
},
setup() {
const store = useStore();
const service = inject<any>("service");
const { store, service } = useCool();
//
const form = reactive<any>(cloneDeep(store.getters.userInfo));

View File

@ -39,17 +39,16 @@
</template>
<script lang="ts">
import { defineComponent, inject, reactive, ref } from "vue";
import { defineComponent, reactive, ref } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
import { CrudLoad, Table } from "cl-admin-crud-vue3/types";
export default defineComponent({
name: "sys-log",
setup() {
const service = inject<any>("service");
const { refs, setRefs }: any = useRefs();
const { refs, setRefs, service }: any = useCool();
//
const day = ref<number>(1);

View File

@ -77,19 +77,16 @@
</template>
<script lang="ts">
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
import { deepTree } from "/@/core/utils";
import { useRouter } from "vue-router";
import { defineComponent, inject, reactive } from "vue";
import { defineComponent, reactive } from "vue";
import { CrudLoad, Table, Upsert, RefreshOp } from "cl-admin-crud-vue3/types";
export default defineComponent({
name: "sys-menu",
setup() {
const router = useRouter();
const { refs, setRefs } = useRefs();
const service = inject<any>("service");
const { refs, setRefs, service, router } = useCool();
// crud
function onLoad({ ctx, app }: CrudLoad) {

View File

@ -35,16 +35,15 @@
<script lang="ts">
import { ElMessageBox } from "element-plus";
import { defineComponent, inject, nextTick, reactive } from "vue";
import { useRefs } from "/@/core";
import { defineComponent, nextTick, reactive } from "vue";
import { useCool } from "/@/core";
import { CrudLoad, Table, Upsert } from "cl-admin-crud-vue3/types";
export default defineComponent({
name: "sys-param",
setup() {
const service = inject<any>("service");
const { refs, setRefs } = useRefs();
const { refs, setRefs, service } = useCool();
//
const tab = reactive<any>({

View File

@ -48,17 +48,16 @@
<script lang="ts">
import { ElMessage } from "element-plus";
import { defineComponent, inject, reactive } from "vue";
import { defineComponent, reactive } from "vue";
import { checkPerm } from "/$/base";
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
import { CrudLoad, RefreshOp, Table } from "cl-admin-crud-vue3/types";
export default defineComponent({
name: "plugin",
setup() {
const service = inject<any>("service");
const { refs, setRefs } = useRefs();
const { refs, setRefs, service } = useCool();
//
const { config, getConfig, enable } = service.base.plugin.info.permission;

View File

@ -102,18 +102,15 @@
</template>
<script lang="ts">
import { computed, defineComponent, inject, reactive, ref, watch } from "vue";
import { useStore } from "vuex";
import { useRefs } from "/@/core";
import { computed, defineComponent, reactive, ref, watch } from "vue";
import { useCool } from "/@/core";
import { Table, Upsert } from "cl-admin-crud-vue3/types";
export default defineComponent({
name: "sys-user",
setup() {
const service = inject<any>("service");
const store = useStore();
const { refs, setRefs } = useRefs();
const { refs, setRefs, store, service } = useCool();
//
const isExpand = ref<boolean>(true);

View File

@ -45,8 +45,7 @@
</template>
<script lang="ts">
import { computed, defineComponent, h, inject, onUnmounted, provide, ref } from "vue";
import { useStore } from "vuex";
import { computed, defineComponent, h, onUnmounted, provide, ref } from "vue";
import { ElNotification } from "element-plus";
import dayjs from "dayjs";
// import io from "socket.io-client";
@ -55,7 +54,7 @@ import Session from "./session.vue";
import Message from "./message.vue";
import Input from "./input.vue";
import { parseContent } from "../utils";
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
import NotifyMp3 from "../static/notify.mp3";
export default defineComponent({
@ -81,10 +80,7 @@ export default defineComponent({
emits: ["message"],
setup(_, { emit }) {
const store = useStore();
const { refs, setRefs } = useRefs();
const service = inject<any>("service");
const mitt = inject<any>("mitt");
const { refs, setRefs, service, mitt, store } = useCool();
//
const session = computed(() => store.getters.session);

View File

@ -29,7 +29,7 @@
<script lang="ts">
import { computed, defineComponent, ref } from "vue";
import { useStore } from "vuex";
import { useCool } from "/@/core";
//
const emoji = {
@ -130,7 +130,7 @@ export default defineComponent({
emits: ["select"],
setup(_, { emit }) {
const store = useStore();
const { store } = useCool();
//
const visible = ref<boolean>(false);

View File

@ -42,9 +42,9 @@
<script lang="ts">
import { defineComponent, inject, nextTick, reactive, ref } from "vue";
import { useStore } from "vuex";
import Emoji from "./emoji.vue";
import Upload from "./upload.vue";
import { useCool } from "/@/core";
export default defineComponent({
components: {
@ -53,9 +53,10 @@ export default defineComponent({
},
setup() {
const store = useStore();
const { store, mitt } = useCool();
//
const chat = inject<any>("chat");
const mitt = inject<any>("mitt");
//
const text = ref<string>("");

View File

@ -113,9 +113,8 @@
import { computed, defineComponent, inject, nextTick, onUnmounted, reactive, ref } from "vue";
import dayjs from "dayjs";
import { ElMessage } from "element-plus";
import { useStore } from "vuex";
import { isString } from "/@/core/utils";
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
import IconVoice from "./icon-voice.vue";
import AvatarUrl from "../static/images/custom-avatar.png";
@ -126,11 +125,10 @@ export default defineComponent({
},
setup() {
const store = useStore();
const { refs, setRefs } = useRefs();
const service = inject<any>("service");
const { refs, setRefs, service, store, mitt } = useCool();
//
const chat = inject<any>("chat");
const mitt = inject<any>("mitt");
//
const session = computed(() => store.getters.session);

View File

@ -10,15 +10,14 @@
</template>
<script lang="ts">
import { defineComponent, inject, onBeforeMount, ref } from "vue-demi";
import { useRefs } from "/@/core";
import { defineComponent, onBeforeMount, ref } from "vue-demi";
import { useCool } from "/@/core";
export default defineComponent({
name: "cl-chat-notice",
setup() {
const service = inject<any>("service");
const { refs, setRefs } = useRefs();
const { refs, setRefs, service } = useCool();
const number = ref<number>(0);

View File

@ -53,18 +53,16 @@
</template>
<script lang="ts">
import { computed, defineComponent, inject, onUnmounted, reactive, ref } from "vue";
import { useStore } from "vuex";
import { computed, defineComponent, onUnmounted, reactive, ref } from "vue";
import { ElMessage } from "element-plus";
import { isEmpty } from "/@/core/utils";
import { ContextMenu } from "cl-admin-crud-vue3";
import { parseContent } from "../utils";
import { useCool } from "/@/core";
export default defineComponent({
setup() {
const store = useStore();
const service = inject<any>("service");
const mitt = inject<any>("mitt");
const { store, service, mitt } = useCool();
//
const session = computed(() => store.getters.session);

View File

@ -11,9 +11,8 @@
</template>
<script lang="ts">
import { ElFile } from "element-plus/lib/el-upload/src/upload.type";
import { defineComponent, inject } from "vue";
import { useStore } from "vuex";
import { useCool } from "/@/core";
export default defineComponent({
props: {
@ -24,11 +23,13 @@ export default defineComponent({
emits: ["before-upload", "success"],
setup(props, { emit }) {
const store = useStore();
const { store } = useCool();
//
const chat = inject<any>("chat");
//
function onBeforeUpload(file: ElFile) {
function onBeforeUpload(file: any) {
//
function next(options = {}) {
const data = {

View File

@ -7,12 +7,12 @@
<script lang="ts">
import { defineComponent, onMounted, ref } from "vue";
import { TableColumn } from "cl-admin-crud-vue3/types";
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
import Test2 from "./render/test2";
export default defineComponent({
setup() {
const { refs, setRefs } = useRefs();
const { refs, setRefs } = useCool();
const columns = ref<TableColumn[]>([
{

View File

@ -214,13 +214,13 @@
</template>
<script lang="ts">
import { computed, defineComponent, inject, onMounted, reactive } from "vue";
import { computed, defineComponent, onMounted, reactive } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import Draggable from "vuedraggable/src/vuedraggable";
import { checkPerm } from "/$/base";
import { ContextMenu } from "cl-admin-crud-vue3";
import Cron from "../components/cron";
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
export default defineComponent({
name: "task",
@ -231,8 +231,7 @@ export default defineComponent({
},
setup() {
const { refs, setRefs } = useRefs();
const service = inject<any>("service");
const { refs, setRefs, service } = useCool();
//
const list = reactive<any[]>([

View File

@ -35,10 +35,9 @@
<script lang="ts">
import { ElMessage, ElMessageBox } from "element-plus";
import { computed, defineComponent, inject, ref, watch } from "vue";
import { useStore } from "vuex";
import { isEmpty } from "/@/core/utils";
import { ContextMenu } from "cl-admin-crud-vue3";
import { useRefs } from "/@/core";
import { useCool } from "/@/core";
export default defineComponent({
name: "cl-upload-space-category",
@ -50,9 +49,8 @@ export default defineComponent({
emits: ["update:modelValue", "change"],
setup(_, { emit }) {
const store = useStore();
const { refs, setRefs }: any = useRefs();
const service: any = inject("service");
const { refs, setRefs, service, store }: any = useCool();
const space = inject<any>("space");
//

View File

@ -138,13 +138,12 @@
</template>
<script lang="ts">
import { computed, defineComponent, inject, provide, reactive, ref, watch } from "vue";
import { useStore } from "vuex";
import { computed, defineComponent, provide, reactive, ref, watch } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { ElFile } from "element-plus/lib/el-upload/src/upload.type";
import { isEmpty } from "/@/core/utils";
import Category from "./category.vue";
import FileItem from "./file-item.vue";
import { useCool } from "/@/core";
export default defineComponent({
name: "cl-upload-space",
@ -191,8 +190,7 @@ export default defineComponent({
emits: ["update:modelValue", "confirm"],
setup(props, { emit }) {
const store = useStore();
const service = inject<any>("service");
const { store, service } = useCool();
//
const visible = ref<boolean>(false);
@ -262,7 +260,7 @@ export default defineComponent({
}
//
function onSuccess(res: any, file: ElFile) {
function onSuccess(res: any, file: any) {
const item = list.value.find((e: any) => file.uid == e.uid);
if (item) {

View File

@ -5,11 +5,11 @@ import { useModule } from "./module";
import router from "/@/router";
import store from "/@/store";
const services = useService();
const service = useService();
async function bootstrap(app: any) {
app.config.globalProperties.service = store.service = services;
app.provide("service", services);
app.config.globalProperties.service = store.service = service;
app.provide("service", service);
useRouter();
useModule(app);
@ -34,8 +34,8 @@ function usePermission(list: any[]) {
}
}
deep(services);
deep(service);
}
export { Service, Permission, BaseService, services, bootstrap, usePermission };
export { Service, Permission, BaseService, service, bootstrap, usePermission };
export * from "./hook";

View File

@ -30,9 +30,9 @@
<script lang="ts">
import { computed, defineComponent } from "vue";
import { useStore } from "vuex";
import Topbar from "./topbar.vue";
import Slider from "./slider.vue";
import { useCool } from "/@/core";
export default defineComponent({
components: {
@ -41,7 +41,7 @@ export default defineComponent({
},
setup() {
const store = useStore();
const { store } = useCool();
//
const menuCollapse = computed<boolean>(() => store.getters.menuCollapse);

View File

@ -13,12 +13,12 @@
<script lang="ts">
import { computed, defineComponent } from "vue";
import { useStore } from "vuex";
import Logo from "/@/assets/icon/logo/silder-simple.png";
import { useCool } from "/@/core";
export default defineComponent({
setup() {
const store = useStore();
const { store } = useCool();
//
const menuCollapse = computed<any>(() => store.getters.menuCollapse);

View File

@ -50,14 +50,12 @@
<script lang="ts">
import { computed, defineComponent } from "vue";
import { useRouter } from "vue-router";
import { useStore } from "vuex";
import { useCool } from "/@/core";
import { href } from "/@/core/utils";
export default defineComponent({
setup() {
const store = useStore();
const router = useRouter();
const { store, router } = useCool();
//
const menuCollapse = computed<any>(() => store.getters.menuCollapse);

View File

@ -1122,10 +1122,10 @@ change-case@^4.1.2:
optionalDependencies:
fsevents "~2.3.2"
cl-admin-crud-vue3@^0.9.3:
version "0.9.3"
resolved "https://registry.npmmirror.com/cl-admin-crud-vue3/download/cl-admin-crud-vue3-0.9.3.tgz#9594238d445e93eea8e1c2d1f849e8de6c687ac2"
integrity sha1-lZQjjURek+6o4cLR+Eno3mxoesI=
cl-admin-crud-vue3@^0.9.6:
version "0.9.6"
resolved "https://registry.yarnpkg.com/cl-admin-crud-vue3/-/cl-admin-crud-vue3-0.9.6.tgz#735034dd8ec2d38022a77aac695f9553483863d2"
integrity sha512-3t2Q0h9BK9jqsboJy3aFYGhwNZREy6HQzCpuIUeVGnxHYT+1TOiTyDmQx8svIS1mL5VrJXNmwO8mzVZFQcOXjQ==
dependencies:
array.prototype.flat "^1.2.4"
core-js "^3.6.5"