From f3f1f57b01fee2c7df577afc03ceafee940d06c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Mon, 16 May 2022 04:23:10 +0000 Subject: [PATCH 01/95] update README.md. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 620a826c..cc050f96 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ ## 总览 ![logo](readme/logo-t-y.png) +**`master-fetch` 分支是带有后端接口请求的分支** + +**后端地址:[https://gitee.com/MTrun/go-view-serve](https://gitee.com/MTrun/go-view-serve)** + +**接口说明地址:[https://www.apifox.cn/apidoc/project-982844/doc-757203](https://www.apifox.cn/apidoc/project-982844/doc-757203)** + GoView 是一个高效的拖拽式低代码数据可视化开发平台,将图表或页面元素封装为基础组件,无需编写代码即可制作数据大屏,减少心智负担。当然低代码也不是 “银弹”,希望所有人员都能理智看待此技术。 项目-Demo 地址:[https://www.mtruning.club](https://www.mtruning.club) From 63dd03e7554ad9502e330ecc7909e89b2b78b448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Mon, 16 May 2022 10:38:39 +0000 Subject: [PATCH 02/95] update README.md. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cc050f96..6593a9bf 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ **接口说明地址:[https://www.apifox.cn/apidoc/project-982844/doc-757203](https://www.apifox.cn/apidoc/project-982844/doc-757203)** +**接口文档也可以在 `Apifox` 的 `ApiHub` 平台上搜索项目名称:`GoView` 进行查找** + GoView 是一个高效的拖拽式低代码数据可视化开发平台,将图表或页面元素封装为基础组件,无需编写代码即可制作数据大屏,减少心智负担。当然低代码也不是 “银弹”,希望所有人员都能理智看待此技术。 项目-Demo 地址:[https://www.mtruning.club](https://www.mtruning.club) From c24b03f3da1bf9f572daf7e46f6c4562cd6ac30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Thu, 19 May 2022 01:56:30 +0000 Subject: [PATCH 03/95] update README.md. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6593a9bf..fa5f3912 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ **`master-fetch` 分支是带有后端接口请求的分支** -**后端地址:[https://gitee.com/MTrun/go-view-serve](https://gitee.com/MTrun/go-view-serve)** +**后端项目地址(开发中...):[https://gitee.com/MTrun/go-view-serve](https://gitee.com/MTrun/go-view-serve)** **接口说明地址:[https://www.apifox.cn/apidoc/project-982844/doc-757203](https://www.apifox.cn/apidoc/project-982844/doc-757203)** From 28bb82e57959260a39c3db708ac2f1e90510188c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Fri, 20 May 2022 16:12:09 +0800 Subject: [PATCH 04/95] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9plop=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plop/store-template/index.hbs | 2 +- plop/store-template/prompt.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/plop/store-template/index.hbs b/plop/store-template/index.hbs index 702352da..5722a89d 100644 --- a/plop/store-template/index.hbs +++ b/plop/store-template/index.hbs @@ -5,7 +5,7 @@ import { StorageEnum } from '@/enums/storageEnum' export const use{{upperDataName}}Store = defineStore({ id: 'use{{upperDataName}}Store', - state: (): {{name}}StoreType => ({}), + state: (): {{upperDataName}}StoreType => ({}), getters: {}, actions: {} }) \ No newline at end of file diff --git a/plop/store-template/prompt.js b/plop/store-template/prompt.js index 180cbd26..4fab8a88 100644 --- a/plop/store-template/prompt.js +++ b/plop/store-template/prompt.js @@ -22,7 +22,7 @@ module.exports = { const actions = [ { type: 'add', - path: `${process.cwd()}/src/store/modules/${dataName}Store/${dataName}Store}.ts`, // 这里的name就是上面定义的键 + path: `${process.cwd()}/src/store/modules/${dataName}Store/${dataName}Store.ts`, // 这里的name就是上面定义的键 templateFile: './store-template/index.hbs', data: { name: data.name, @@ -32,7 +32,11 @@ module.exports = { { type: 'add', path: `${process.cwd()}/src/store/modules/${dataName}Store/${dataName}Store.d.ts`, // 这里的name就是上面定义的键 - templateFile: './store-template/index.d.hbs' + templateFile: './store-template/index.d.hbs', + data: { + name: data.name, + upperDataName, + } }, ] From 7e237b508a3f10b7cda0f2d991de53875cbff15f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Fri, 20 May 2022 16:12:27 +0800 Subject: [PATCH 05/95] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=8E=A5=E5=8F=A3=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 12 ++--- build/getConfigFileName.ts | 9 ---- src/api/axios.ts | 9 +++- src/enums/httpEnum.ts | 18 ++++---- src/enums/storageEnum.ts | 6 +-- src/settings/httpSetting.ts | 2 + .../modules/settingStore/settingStore.ts | 6 +-- .../modules/systemStore/systemStore.d.ts | 19 ++++++++ src/store/modules/systemStore/systemStore.ts | 29 ++++++++++++ src/utils/http.ts | 6 +++ src/utils/index.ts | 1 + src/utils/router.ts | 9 ++-- src/views/login/api/index.ts | 13 ++++++ src/views/login/index.vue | 46 +++++++++++-------- types/vite-env.d.ts | 2 - vite.config.ts | 22 +++++++-- 16 files changed, 144 insertions(+), 65 deletions(-) delete mode 100644 build/getConfigFileName.ts create mode 100644 src/settings/httpSetting.ts create mode 100644 src/store/modules/systemStore/systemStore.d.ts create mode 100644 src/store/modules/systemStore/systemStore.ts create mode 100644 src/utils/http.ts create mode 100644 src/views/login/api/index.ts diff --git a/.env b/.env index 733a8577..857e18f9 100644 --- a/.env +++ b/.env @@ -1,14 +1,8 @@ # port -VITE_DEV_PORT = '8001' +VITE_DEV_PORT = '8080' # development path -VITE_DEV_PATH = '/' +VITE_DEV_PATH = 'http://124.70.187.180:8080' # production path -VITE_PRO_PATH = '/' - -# spa-title -VITE_GLOB_APP_TITLE = GoView - -# spa shortname -VITE_GLOB_APP_SHORT_NAME = GoView +VITE_PRO_PATH = 'http://124.70.187.180:8080' \ No newline at end of file diff --git a/build/getConfigFileName.ts b/build/getConfigFileName.ts deleted file mode 100644 index d61cd416..00000000 --- a/build/getConfigFileName.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Get the configuration file variable name - * @param env - */ -export const getConfigFileName = (env: Record) => { - return `__PRODUCTION__${env.VITE_GLOB_APP_SHORT_NAME || '__APP'}__CONF__` - .toUpperCase() - .replace(/\s/g, ''); -}; diff --git a/src/api/axios.ts b/src/api/axios.ts index 384ef3be..0cdd9386 100644 --- a/src/api/axios.ts +++ b/src/api/axios.ts @@ -2,9 +2,16 @@ import axios, { AxiosResponse, AxiosRequestConfig } from 'axios' import { ResultEnum } from "@/enums/httpEnum" import { ErrorPageNameMap } from "@/enums/pageEnum" import { redirectErrorPage } from '@/utils' +import { axiosPre } from '@/settings/httpSetting' + +interface MyResponseType { + code: number; + msg: string; + data: any; +} const axiosInstance = axios.create({ - baseURL: import.meta.env.DEV ? import.meta.env.VITE_DEV_PATH : import.meta.env.VITE_PRO_PATH, + baseURL: axiosPre, timeout: ResultEnum.TIMEOUT, }) diff --git a/src/enums/httpEnum.ts b/src/enums/httpEnum.ts index 165948f5..3c6ffa0c 100644 --- a/src/enums/httpEnum.ts +++ b/src/enums/httpEnum.ts @@ -1,6 +1,10 @@ -/** - * @description: 请求结果集 - */ +// 模块 Path 前缀分类 +export enum ModuleTypeEnum { + SYSTEM = 'sys', + PROJECT = 'project', +} + +// 请求结果集 export enum ResultEnum { DATA_SUCCESS = 0, SUCCESS = 200, @@ -18,9 +22,7 @@ export enum RequestDataTypeEnum { AJAX = 1, } -/** - * @description: 请求方法 - */ +// 请求方法 export enum RequestHttpEnum { GET = 'get', POST = 'post', @@ -29,9 +31,7 @@ export enum RequestHttpEnum { DELETE = 'delete', } -/** - * @description: 常用的contentTyp类型 - */ +// 常用的contentTyp类型 export enum ContentTypeEnum { // json JSON = 'application/json;charset=UTF-8', diff --git a/src/enums/storageEnum.ts b/src/enums/storageEnum.ts index b0818a24..a36e99e8 100644 --- a/src/enums/storageEnum.ts +++ b/src/enums/storageEnum.ts @@ -1,10 +1,8 @@ export enum StorageEnum { // 全局设置 - GO_SYSTEM_SETTING_STORE = 'GO_SYSTEM_SETTING', - // token 等信息 - GO_ACCESS_TOKEN_STORE = 'GO_ACCESS_TOKEN', + GO_SETTING_STORE = 'GO_SETTING', // 登录信息 - GO_LOGIN_INFO_STORE = 'GO_LOGIN_INFO', + GO_SYSTEM_STORE = 'GO_SYSTEM', // 语言 GO_LANG_STORE = 'GO_LANG', // 当前选择的主题 diff --git a/src/settings/httpSetting.ts b/src/settings/httpSetting.ts new file mode 100644 index 00000000..2dfd2c3a --- /dev/null +++ b/src/settings/httpSetting.ts @@ -0,0 +1,2 @@ +// 请求前缀 +export const axiosPre = '/goview/api/goview/' \ No newline at end of file diff --git a/src/store/modules/settingStore/settingStore.ts b/src/store/modules/settingStore/settingStore.ts index 775cd132..a1fd4cbe 100644 --- a/src/store/modules/settingStore/settingStore.ts +++ b/src/store/modules/settingStore/settingStore.ts @@ -4,10 +4,10 @@ import { asideCollapsedWidth } from '@/settings/designSetting' import { SettingStoreType, ToolsStatusEnum } from './settingStore.d' import { setLocalStorage, getLocalStorage } from '@/utils' import { StorageEnum } from '@/enums/storageEnum' -const { GO_SYSTEM_SETTING_STORE } = StorageEnum +const { GO_SETTING_STORE } = StorageEnum const storageSetting: SettingStoreType = getLocalStorage( - GO_SYSTEM_SETTING_STORE + GO_SETTING_STORE ) // 全局设置 @@ -45,7 +45,7 @@ export const useSettingStore = defineStore({ this.$patch(state => { state[key] = value }) - setLocalStorage(GO_SYSTEM_SETTING_STORE, this.$state) + setLocalStorage(GO_SETTING_STORE, this.$state) } } }) diff --git a/src/store/modules/systemStore/systemStore.d.ts b/src/store/modules/systemStore/systemStore.d.ts new file mode 100644 index 00000000..9bfec8ed --- /dev/null +++ b/src/store/modules/systemStore/systemStore.d.ts @@ -0,0 +1,19 @@ +export enum SystemStoreUserInfoEnum { + USER_TOKEN = 'userToken', + USER_ID = 'userId', + USER_NAME = 'userName', +} + +export interface UserInfoType { + [SystemStoreUserInfoEnum.USER_TOKEN]?: string, + [SystemStoreUserInfoEnum.USER_ID]?: string, + [SystemStoreUserInfoEnum.USER_NAME]?: string, +} + +export enum SystemStoreEnum { + USER_INFO = 'userInfo' +} + +export interface SystemStoreType { + [SystemStoreEnum.USER_INFO]: UserInfoType +} \ No newline at end of file diff --git a/src/store/modules/systemStore/systemStore.ts b/src/store/modules/systemStore/systemStore.ts new file mode 100644 index 00000000..08e10a23 --- /dev/null +++ b/src/store/modules/systemStore/systemStore.ts @@ -0,0 +1,29 @@ +import { defineStore } from 'pinia' +import { SystemStoreType, SystemStoreEnum } from './systemStore.d' +import { setLocalStorage, getLocalStorage } from '@/utils' +import { StorageEnum } from '@/enums/storageEnum' + +const { GO_SYSTEM_STORE } = StorageEnum + +const storageSystem: SystemStoreType = getLocalStorage(GO_SYSTEM_STORE) + +// 系统数据记录 +export const useSystemStore = defineStore({ + id: 'useSystemStore', + state: (): SystemStoreType => storageSystem || { + userInfo: { + userId: undefined, + userName: undefined, + userToken: undefined + } + }, + getters: {}, + actions: { + setItem(key: T, value: K): void { + this.$patch(state => { + state[key]= value + }); + setLocalStorage(GO_SYSTEM_STORE, this.$state) + } + } +}) \ No newline at end of file diff --git a/src/utils/http.ts b/src/utils/http.ts new file mode 100644 index 00000000..a8a114ca --- /dev/null +++ b/src/utils/http.ts @@ -0,0 +1,6 @@ +/** + * * 请求失败统一处理 + */ +export const httpErrorHandle = () => { + window['$message'].error('请求失败,请稍后重试!') +} \ No newline at end of file diff --git a/src/utils/index.ts b/src/utils/index.ts index fa9fa055..806d8902 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -7,3 +7,4 @@ export * from '@/utils/plugin' export * from '@/utils/componets' export * from '@/utils/type' export * from '@/utils/file' +export * from '@/utils/http' \ No newline at end of file diff --git a/src/utils/router.ts b/src/utils/router.ts index f2bf6142..6f38959c 100644 --- a/src/utils/router.ts +++ b/src/utils/router.ts @@ -2,7 +2,7 @@ import { useRoute } from 'vue-router' import { ResultEnum } from '@/enums/httpEnum' import { ErrorPageNameMap, PageEnum } from '@/enums/pageEnum' import { docPath, giteeSourceCodePath } from '@/settings/pathConst' -import { cryptoDecode } from './crypto' +import { SystemStoreEnum, SystemStoreUserInfoEnum } from '@/store/modules/systemStore/systemStore.d' import { StorageEnum } from '@/enums/storageEnum' import { clearLocalStorage, getLocalStorage } from './storage' import router from '@/router' @@ -104,7 +104,7 @@ export const reloadRoutePage = () => { * * 退出 */ export const logout = () => { - clearLocalStorage(StorageEnum.GO_LOGIN_INFO_STORE) + clearLocalStorage(StorageEnum.GO_SYSTEM_STORE) routerTurnByName(PageEnum.BASE_LOGIN_NAME) } @@ -167,10 +167,9 @@ export const goHome = () => { */ export const loginCheck = () => { try { - const info = getLocalStorage(StorageEnum.GO_LOGIN_INFO_STORE) + const info = getLocalStorage(StorageEnum.GO_SYSTEM_STORE) if (!info) return false - const decodeInfo = cryptoDecode(info) - if (decodeInfo) { + if (info[SystemStoreEnum.USER_INFO][SystemStoreUserInfoEnum.USER_TOKEN]) { return true } return false diff --git a/src/views/login/api/index.ts b/src/views/login/api/index.ts new file mode 100644 index 00000000..c4634ac6 --- /dev/null +++ b/src/views/login/api/index.ts @@ -0,0 +1,13 @@ +import { http } from '@/api/http' +import { httpErrorHandle } from '@/utils' +import { RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum' + +// 登录 +export const loginRequest = async (data: object) => { + try { + const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.SYSTEM}/login`, data); + return res; + } catch { + httpErrorHandle(); + } +} \ No newline at end of file diff --git a/src/views/login/index.vue b/src/views/login/index.vue index d8fda4e1..057a9857 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -118,7 +118,8 @@ import { reactive, ref, onMounted } from 'vue' import shuffle from 'lodash/shuffle' import { carouselInterval } from '@/settings/designSetting' -import { useDesignStore } from '@/store/modules/designStore/designStore' +import { useSystemStore } from '@/store/modules/systemStore/systemStore' +import { SystemStoreEnum, SystemStoreUserInfoEnum } from '@/store/modules/systemStore/systemStore.d' import { GoThemeSelect } from '@/components/GoThemeSelect' import { GoLangSelect } from '@/components/GoLangSelect' import { LayoutHeader } from '@/layout/components/LayoutHeader' @@ -126,22 +127,23 @@ import { LayoutFooter } from '@/layout/components/LayoutFooter' import { PageEnum } from '@/enums/pageEnum' import { icon } from '@/plugins' import { StorageEnum } from '@/enums/storageEnum' -import { routerTurnByName, cryptoEncode, setLocalStorage } from '@/utils' -const { GO_LOGIN_INFO_STORE } = StorageEnum - -const { PersonOutlineIcon, LockClosedOutlineIcon } = icon.ionicons5 +import { routerTurnByName } from '@/utils' +import { loginRequest } from './api/index' interface FormState { username: string password: string } +const { GO_SYSTEM_STORE } = StorageEnum +const { PersonOutlineIcon, LockClosedOutlineIcon } = icon.ionicons5 + const formRef = ref() const loading = ref(false) const autoLogin = ref(true) const show = ref(false) const showBg = ref(false) -const designStore = useDesignStore() +const systemStore = useSystemStore() const t = window['$t'] @@ -156,7 +158,7 @@ onMounted(() => { const formInline = reactive({ username: 'admin', - password: '123456', + password: 'admin', }) const rules = { @@ -203,24 +205,28 @@ const shuffleHandle = () => { }, carouselInterval) } -// 点击事件 -const handleSubmit = (e: Event) => { +// 登录 +const handleSubmit = async (e: Event) => { e.preventDefault() formRef.value.validate(async (errors: any) => { if (!errors) { const { username, password } = formInline loading.value = true - setLocalStorage( - GO_LOGIN_INFO_STORE, - cryptoEncode( - JSON.stringify({ - username, - password, - }) - ) - ) - window['$message'].success(`${t('login.login_success')}!`) - routerTurnByName(PageEnum.BASE_HOME_NAME, true) + // 提交请求 + const res:any = await loginRequest({ + username, + password + }) + if(res.data) { + const { tokenValue, loginId } = res.data + systemStore.setItem(SystemStoreEnum.USER_INFO, { + userToken: tokenValue, + userId: loginId, + userName: username, + }) + window['$message'].success(`${t('login.login_success')}!`) + routerTurnByName(PageEnum.BASE_HOME_NAME, true) + } } else { window['$message'].error(`${t('login.login_message')}!`) } diff --git a/types/vite-env.d.ts b/types/vite-env.d.ts index 0278f655..317bb4b2 100644 --- a/types/vite-env.d.ts +++ b/types/vite-env.d.ts @@ -1,8 +1,6 @@ /// interface ImportMetaEnv { - // 标题 - VITE_GLOB_APP_TITLE: string; // 端口 VITE_DEV_PORT: string; // 开发地址 diff --git a/vite.config.ts b/vite.config.ts index 2c06b424..e44d895b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,16 +1,17 @@ -import { defineConfig } from 'vite' +import { defineConfig, loadEnv } from 'vite' import vue from '@vitejs/plugin-vue' import { resolve } from 'path' import { OUTPUT_DIR, brotliSize, chunkSizeWarningLimit, terserOptions, rollupOptions } from './build/constant' import viteCompression from 'vite-plugin-compression' import { viteMockServe} from "vite-plugin-mock"; +import { axiosPre } from './src/settings/httpSetting' function pathResolve(dir: string) { return resolve(process.cwd(), '.', dir) } -export default defineConfig({ - base: './', +export default ({ mode }) => defineConfig({ + base: process.env.NODE_ENV === 'production' ? './' : '/', // 路径重定向 resolve: { alias: [ @@ -34,6 +35,21 @@ export default defineConfig({ } } }, + // 开发服务器配置 + server: { + host: true, + open: true, + port: 3000, + proxy: { + [axiosPre]: { + // @ts-ignore + target: loadEnv(mode, process.cwd()).VITE_DEV_PATH, + changeOrigin: true, + ws: true, + secure: true, + } + } + }, plugins: [ vue(), viteMockServe({ From 5b8dda60bd74d2347e81e83c5ead4bb9fa58aa98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Sat, 21 May 2022 17:31:01 +0800 Subject: [PATCH 06/95] =?UTF-8?q?feat=EF=BC=9A=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=A8=E5=B1=80=E6=8E=A5=E5=8F=A3=E5=B0=81?= =?UTF-8?q?=E8=A3=85=EF=BC=8C=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/axios.config.ts | 9 ++++ src/api/axios.ts | 38 +++++++++++++--- src/api/http.ts | 9 ++-- src/api/path/photo.ts | 3 ++ .../api/index.ts => api/path/project.ts} | 8 ++-- src/api/path/system.api.ts | 23 ++++++++++ src/enums/httpEnum.ts | 7 +++ src/i18n/en/index.ts | 1 + .../modules/systemStore/systemStore.d.ts | 2 + src/store/modules/systemStore/systemStore.ts | 3 +- src/utils/router.ts | 14 ++++-- src/utils/storage.ts | 44 +++++++++++++++++-- src/views/login/index.vue | 13 ++++-- .../ProjectItemsList/hooks/useData.hook.ts | 2 +- .../components/CreateModal/index.vue | 20 +++++---- 15 files changed, 161 insertions(+), 35 deletions(-) create mode 100644 src/api/axios.config.ts create mode 100644 src/api/path/photo.ts rename src/{views/login/api/index.ts => api/path/project.ts} (68%) create mode 100644 src/api/path/system.api.ts diff --git a/src/api/axios.config.ts b/src/api/axios.config.ts new file mode 100644 index 00000000..9a6f2ee2 --- /dev/null +++ b/src/api/axios.config.ts @@ -0,0 +1,9 @@ +import { ModuleTypeEnum } from '@/enums/httpEnum' + +// 接口白名单(免登录) +export const fetchAllowList = [ + `${ModuleTypeEnum.SYSTEM}/login` +] + +// 接口黑名单 +export const fetchBlockList = [] \ No newline at end of file diff --git a/src/api/axios.ts b/src/api/axios.ts index 0cdd9386..ef102ed0 100644 --- a/src/api/axios.ts +++ b/src/api/axios.ts @@ -1,8 +1,12 @@ import axios, { AxiosResponse, AxiosRequestConfig } from 'axios' -import { ResultEnum } from "@/enums/httpEnum" -import { ErrorPageNameMap } from "@/enums/pageEnum" -import { redirectErrorPage } from '@/utils' +import { ResultEnum, RequestHttpHeaderEnum } from "@/enums/httpEnum" +import { PageEnum, ErrorPageNameMap } from "@/enums/pageEnum" +import { StorageEnum } from '@/enums/storageEnum' import { axiosPre } from '@/settings/httpSetting' +import { SystemStoreEnum, SystemStoreUserInfoEnum } from '@/store/modules/systemStore/systemStore.d' +import { redirectErrorPage, getLocalStorage, routerTurnByName } from '@/utils' +import { fetchAllowList } from './axios.config' +import includes from 'lodash/includes' interface MyResponseType { code: number; @@ -17,7 +21,15 @@ const axiosInstance = axios.create({ axiosInstance.interceptors.request.use( (config: AxiosRequestConfig) => { - config.headers = {} + // 白名单校验 + if (includes(fetchAllowList, config.url)) return config + // 获取 token + const info = getLocalStorage(StorageEnum.GO_SYSTEM_STORE) + // 重新登录 + if (!info) return routerTurnByName(PageEnum.BASE_LOGIN_NAME) + config.headers = { + [RequestHttpHeaderEnum.TOKEN]: info[SystemStoreEnum.USER_INFO][SystemStoreUserInfoEnum.USER_TOKEN] || '' + } return config }, (error: AxiosRequestConfig) => { @@ -29,9 +41,23 @@ axiosInstance.interceptors.request.use( axiosInstance.interceptors.response.use( (res: AxiosResponse) => { const { code } = res.data as { code: number } - if (code === ResultEnum.DATA_SUCCESS) return Promise.resolve(res.data) + + // 成功 + if (code === ResultEnum.DATA_SUCCESS) { + return Promise.resolve(res.data) + } + + // 登录过期 + if (code === ResultEnum.SERVER_FORBIDDEN) { + routerTurnByName(PageEnum.BASE_LOGIN_NAME) + return Promise.reject(res.data) + } + // 重定向 - if (ErrorPageNameMap.get(code)) redirectErrorPage(code) + if (ErrorPageNameMap.get(code)) { + redirectErrorPage(code) + } + return Promise.resolve(res.data) }, (err: AxiosResponse) => { diff --git a/src/api/http.ts b/src/api/http.ts index 13d69659..1542ff3e 100644 --- a/src/api/http.ts +++ b/src/api/http.ts @@ -1,25 +1,26 @@ import axiosInstance from './axios' import { RequestHttpEnum, ContentTypeEnum } from '@/enums/httpEnum' -export const get = (url: string) => { +export const get = (url: string, params?: object) => { return axiosInstance({ url: url, method: RequestHttpEnum.GET, + params: params, }) } -export const post = (url: string, params: object, headersType?: string) => { +export const post = (url: string, data?: object, headersType?: string) => { return axiosInstance({ url: url, method: RequestHttpEnum.POST, - data: params, + data: data, headers: { 'Content-Type': headersType || ContentTypeEnum.JSON } }) } -export const del = (url: string, params: object) => { +export const del = (url: string, params?: object) => { return axiosInstance({ url: url, method: RequestHttpEnum.DELETE, diff --git a/src/api/path/photo.ts b/src/api/path/photo.ts new file mode 100644 index 00000000..986fec7f --- /dev/null +++ b/src/api/path/photo.ts @@ -0,0 +1,3 @@ +import { http } from '@/api/http' +import { httpErrorHandle } from '@/utils' +import { RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum' diff --git a/src/views/login/api/index.ts b/src/api/path/project.ts similarity index 68% rename from src/views/login/api/index.ts rename to src/api/path/project.ts index c4634ac6..40f90649 100644 --- a/src/views/login/api/index.ts +++ b/src/api/path/project.ts @@ -2,10 +2,10 @@ import { http } from '@/api/http' import { httpErrorHandle } from '@/utils' import { RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum' -// 登录 -export const loginRequest = async (data: object) => { - try { - const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.SYSTEM}/login`, data); +// * 新增项目 +export const createProjectApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.SYSTEM}/project/create`, data); return res; } catch { httpErrorHandle(); diff --git a/src/api/path/system.api.ts b/src/api/path/system.api.ts new file mode 100644 index 00000000..1197fd39 --- /dev/null +++ b/src/api/path/system.api.ts @@ -0,0 +1,23 @@ +import { http } from '@/api/http' +import { httpErrorHandle } from '@/utils' +import { RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum' + +// * 登录 +export const loginApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.SYSTEM}/login`, data); + return res; + } catch { + httpErrorHandle(); + } +} + +// * 登出 +export const logoutApi = async () => { + try { + const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.SYSTEM}/logout`); + return res; + } catch(err) { + httpErrorHandle(); + } +} \ No newline at end of file diff --git a/src/enums/httpEnum.ts b/src/enums/httpEnum.ts index 3c6ffa0c..8bb72a91 100644 --- a/src/enums/httpEnum.ts +++ b/src/enums/httpEnum.ts @@ -11,6 +11,7 @@ export enum ResultEnum { SERVER_ERROR = 500, SERVER_FORBIDDEN = 403, NOT_FOUND = 404, + TOKEN_OVERDUE = 886, TIMEOUT = 10042, } @@ -22,6 +23,12 @@ export enum RequestDataTypeEnum { AJAX = 1, } +// 头部 +export enum RequestHttpHeaderEnum { + TOKEN = 'Token', + COOKIE = 'Cookie' +} + // 请求方法 export enum RequestHttpEnum { GET = 'get', diff --git a/src/i18n/en/index.ts b/src/i18n/en/index.ts index 140a3add..f398a737 100644 --- a/src/i18n/en/index.ts +++ b/src/i18n/en/index.ts @@ -11,6 +11,7 @@ const global = { help: 'Help', contact: 'Contact Us', logout: 'Logout', + logout_success: 'Logout success', // system setting sys_set: 'System Setting', lang_set: 'Language Setting', diff --git a/src/store/modules/systemStore/systemStore.d.ts b/src/store/modules/systemStore/systemStore.d.ts index 9bfec8ed..acdc8120 100644 --- a/src/store/modules/systemStore/systemStore.d.ts +++ b/src/store/modules/systemStore/systemStore.d.ts @@ -2,12 +2,14 @@ export enum SystemStoreUserInfoEnum { USER_TOKEN = 'userToken', USER_ID = 'userId', USER_NAME = 'userName', + NICK_NAME = 'nickName', } export interface UserInfoType { [SystemStoreUserInfoEnum.USER_TOKEN]?: string, [SystemStoreUserInfoEnum.USER_ID]?: string, [SystemStoreUserInfoEnum.USER_NAME]?: string, + [SystemStoreUserInfoEnum.NICK_NAME]?: string, } export enum SystemStoreEnum { diff --git a/src/store/modules/systemStore/systemStore.ts b/src/store/modules/systemStore/systemStore.ts index 08e10a23..a1e11b15 100644 --- a/src/store/modules/systemStore/systemStore.ts +++ b/src/store/modules/systemStore/systemStore.ts @@ -14,7 +14,8 @@ export const useSystemStore = defineStore({ userInfo: { userId: undefined, userName: undefined, - userToken: undefined + userToken: undefined, + nickName: undefined } }, getters: {}, diff --git a/src/utils/router.ts b/src/utils/router.ts index 6f38959c..3f1d95b0 100644 --- a/src/utils/router.ts +++ b/src/utils/router.ts @@ -1,11 +1,12 @@ import { useRoute } from 'vue-router' -import { ResultEnum } from '@/enums/httpEnum' +import { ResultEnum, RequestHttpHeaderEnum } from '@/enums/httpEnum' import { ErrorPageNameMap, PageEnum } from '@/enums/pageEnum' import { docPath, giteeSourceCodePath } from '@/settings/pathConst' import { SystemStoreEnum, SystemStoreUserInfoEnum } from '@/store/modules/systemStore/systemStore.d' import { StorageEnum } from '@/enums/storageEnum' -import { clearLocalStorage, getLocalStorage } from './storage' +import { clearLocalStorage, getLocalStorage, clearCookie } from './storage' import router from '@/router' +import { logoutApi } from '@/api/path/system.api' /** * * 根据名字跳转路由 @@ -101,9 +102,14 @@ export const reloadRoutePage = () => { } /** - * * 退出 + * * 退出登录 */ -export const logout = () => { +export const logout = async () => { + const res:any = await logoutApi() + if(res.code === ResultEnum.SUCCESS) { + window['$message'].success((`${window.$t('global.logout_success')}!`)) + } + clearCookie(RequestHttpHeaderEnum.COOKIE) clearLocalStorage(StorageEnum.GO_SYSTEM_STORE) routerTurnByName(PageEnum.BASE_LOGIN_NAME) } diff --git a/src/utils/storage.ts b/src/utils/storage.ts index 60e7c7e8..be46d576 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -5,7 +5,7 @@ * @param v 键值(无需stringiiy) * @returns RemovableRef */ - export const setLocalStorage = (k: string, v: T) => { +export const setLocalStorage = (k: string, v: T) => { try { window.localStorage.setItem(k, JSON.stringify(v)) } catch (error) { @@ -18,7 +18,7 @@ * @param k 键名 * @returns any */ - export const getLocalStorage = (k: string) => { +export const getLocalStorage = (k: string) => { const item = window.localStorage.getItem(k) try { return item ? JSON.parse(item) : item @@ -31,7 +31,7 @@ * * 清除本地会话数据 * @param name */ - export const clearLocalStorage = (name: string) => { +export const clearLocalStorage = (name: string) => { window.localStorage.removeItem(name) } @@ -68,4 +68,42 @@ export const getSessionStorage: (k: string) => any = (k: string) => { */ export const clearSessioStorage = (name: string) => { window.sessionStorage.removeItem(name) +} + +/** + * * 设置 cookie + * @param name 键名 + * @param cvalue 键值 + * @param exdays 过期时间 + */ +export const setCookie = (name: string, cvalue: string, exdays: number) => { + const d = new Date(); + d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); + const expires = "expires=" + d.toUTCString(); + document.cookie = name + "=" + cvalue + "; " + expires; +} + +/** + * * 获取 cookie + * @param cname 键名 + * @returns string + */ +export const getCookie = (cname: string) => { + const name = cname + "="; + const ca = document.cookie.split(';'); + for (let i = 0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) == ' ') c = c.substring(1); + if (c.indexOf(name) != -1) return c.substring(name.length, c.length); + } + return ""; +} + +/** + * * 清除 cookie + * @param name 键名 + * @returns string + */ +export const clearCookie = (name: string) => { + setCookie(name, "", -1); } \ No newline at end of file diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 057a9857..cf1422e1 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -128,7 +128,7 @@ import { PageEnum } from '@/enums/pageEnum' import { icon } from '@/plugins' import { StorageEnum } from '@/enums/storageEnum' import { routerTurnByName } from '@/utils' -import { loginRequest } from './api/index' +import { loginApi } from '@/api/path/system.api' interface FormState { username: string @@ -213,17 +213,22 @@ const handleSubmit = async (e: Event) => { const { username, password } = formInline loading.value = true // 提交请求 - const res:any = await loginRequest({ + const res:any = await loginApi({ username, password }) if(res.data) { - const { tokenValue, loginId } = res.data + const { tokenValue } = res.data.token + const { nickname, username, id } = res.data.userinfo + + // 存储到 pinia systemStore.setItem(SystemStoreEnum.USER_INFO, { userToken: tokenValue, - userId: loginId, + userId: id, userName: username, + nickName: nickname, }) + window['$message'].success(`${t('login.login_success')}!`) routerTurnByName(PageEnum.BASE_HOME_NAME, true) } diff --git a/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts b/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts index 1c38b116..aa3b91d9 100644 --- a/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts +++ b/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts @@ -45,7 +45,7 @@ export const useDataListInit = () => { onPositiveCallback: () => new Promise(res => setTimeout(() => res(1), 1000)), promiseResCallback: (e: any) => { - window.$message.success('删除成功') + window['$message'].success('删除成功') list.value.splice(index, 1) } }) diff --git a/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue b/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue index 2cbae29e..d8cae3ff 100644 --- a/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue +++ b/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue @@ -18,7 +18,7 @@ :disabled="item.disabled" v-for="item in typeList" :key="item.key" - @click="btnHandle" + @click="btnHandle(item.key)" > From 4252725d9d986f7d5ca3d0b9feaa584b94f5cf85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Sun, 22 May 2022 22:11:56 +0800 Subject: [PATCH 16/95] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=A1=B9=E7=9B=AE=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/path/project.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/api/path/project.ts b/src/api/path/project.ts index e6a8b18a..56eee5b6 100644 --- a/src/api/path/project.ts +++ b/src/api/path/project.ts @@ -22,6 +22,17 @@ export const createProjectApi = async (data: object) => { } } +// * 获取项目 +export const fetchProjectApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.PROJECT}/getData`, data); + return res; + } catch { + httpErrorHandle(); + } +} + + // * 删除项目 export const deleteProjectApi = async (data: object) => { try { From 9a5d71fb5cab29f4ed34465339416575d63904c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Mon, 23 May 2022 23:50:35 +0800 Subject: [PATCH 17/95] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=A1=B9=E7=9B=AE=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=90=8C=E6=AD=A5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/path/project.ts | 20 +++ src/enums/editPageEnum.ts | 12 ++ src/i18n/zh/index.ts | 2 +- src/plugins/icon.ts | 7 +- .../chartEditStore/chartEditStore.d.ts | 9 +- .../modules/chartEditStore/chartEditStore.ts | 14 +- .../components/EditBottom/index.vue | 16 ++- .../components/EditDataSync/index.ts | 3 + .../components/EditDataSync/index.vue | 75 +++++++++++ .../components/EditHistory/index.vue | 5 +- .../components/EditShortcutKey/index.ts | 1 + .../EditTools/hooks/useFile.hooks.ts | 53 +------- .../components/EditTools/index.vue | 2 +- .../components/EditTools/utils/index.ts | 2 +- src/views/chart/ContentEdit/index.vue | 6 +- src/views/chart/hooks/useSync.hook.ts | 127 ++++++++++++++++++ 16 files changed, 282 insertions(+), 72 deletions(-) create mode 100644 src/views/chart/ContentEdit/components/EditDataSync/index.ts create mode 100644 src/views/chart/ContentEdit/components/EditDataSync/index.vue create mode 100644 src/views/chart/hooks/useSync.hook.ts diff --git a/src/api/path/project.ts b/src/api/path/project.ts index 56eee5b6..8d2d2c6d 100644 --- a/src/api/path/project.ts +++ b/src/api/path/project.ts @@ -32,6 +32,26 @@ export const fetchProjectApi = async (data: object) => { } } +// * 保存项目 +export const saveProjectApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.PROJECT}/save/data`, data); + return res; + } catch { + httpErrorHandle(); + } +} + +// * 修改项目 +export const updateProjectApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.PROJECT}/edit`, data); + return res; + } catch { + httpErrorHandle(); + } +} + // * 删除项目 export const deleteProjectApi = async (data: object) => { diff --git a/src/enums/editPageEnum.ts b/src/enums/editPageEnum.ts index 1bd8fbc6..7e4fdac5 100644 --- a/src/enums/editPageEnum.ts +++ b/src/enums/editPageEnum.ts @@ -35,4 +35,16 @@ export enum MacKeyboard { CTRL = '⌘', SHIFT = '⇧', ALT = '⌥', +} + +// 同步状态枚举 +export enum SyncEnum { + // 等待 + PENDING, + // 开始 + START, + // 成功 + SUCCESS, + // 失败 + FAILURE } \ No newline at end of file diff --git a/src/i18n/zh/index.ts b/src/i18n/zh/index.ts index 80653ded..61587031 100644 --- a/src/i18n/zh/index.ts +++ b/src/i18n/zh/index.ts @@ -34,7 +34,7 @@ const global = { } const http = { - error_message: '接口异常,请检查!', + error_message: '获取数据失败,请稍后重试!', token_overdue_message: '登录过期,请重新登录!' } diff --git a/src/plugins/icon.ts b/src/plugins/icon.ts index 7a9b3adf..50b4fffb 100644 --- a/src/plugins/icon.ts +++ b/src/plugins/icon.ts @@ -52,7 +52,8 @@ import { ArrowBack as ArrowBackIcon, ArrowForward as ArrowForwardIcon, Planet as PawIcon, - Search as SearchIcon + Search as SearchIcon, + Reload as ReloadIcon } from '@vicons/ionicons5' import { @@ -190,7 +191,9 @@ const ionicons5 = { // 狗爪 PawIcon, // 搜索(放大镜) - SearchIcon + SearchIcon, + // 加载 + ReloadIcon } const carbon = { diff --git a/src/store/modules/chartEditStore/chartEditStore.d.ts b/src/store/modules/chartEditStore/chartEditStore.d.ts index 653fc467..34a24a8d 100644 --- a/src/store/modules/chartEditStore/chartEditStore.d.ts +++ b/src/store/modules/chartEditStore/chartEditStore.d.ts @@ -1,6 +1,7 @@ import { CreateComponentType, FilterEnum} from '@/packages/index.d' import { HistoryActionTypeEnum } from '@/store/modules/chartHistoryStore/chartHistoryStore.d' import { RequestHttpEnum, RequestDataTypeEnum } from '@/enums/httpEnum' +import { SyncEnum } from '@/enums/editPageEnum' import { PreviewScaleEnum } from '@/enums/styleEnum' import type { ChartColorsNameType, @@ -17,9 +18,10 @@ export enum EditCanvasTypeEnum { LOCK_SCALE = 'lockScale', IS_CREATE = 'isCreate', IS_DRAG = 'isDrag', + SAVE_STATUS = 'saveStatus' } -// 编辑区域 +// 编辑区域(临时) export type EditCanvasType = { // 编辑区域 DOM [EditCanvasTypeEnum.EDIT_LAYOUT_DOM]: HTMLElement | null @@ -36,6 +38,8 @@ export type EditCanvasType = { [EditCanvasTypeEnum.IS_CREATE]: boolean // 拖拽中 [EditCanvasTypeEnum.IS_DRAG]: boolean + // 保存状态 + [EditCanvasTypeEnum.SAVE_STATUS]: SyncEnum } // 滤镜/背景色/宽高主题等 @@ -50,6 +54,7 @@ export enum EditCanvasConfigEnum { PREVIEW_SCALE_TYPE = 'previewScaleType', } +// 画布属性(需保存) export interface EditCanvasConfigType { // 滤镜-色相 [FilterEnum.HUE_ROTATE]: number @@ -137,6 +142,7 @@ export type RequestGlobalConfigType = { // 轮询时间 requestInterval: number } + // 单个图表请求配置 export type RequestConfigType = { // 获取数据的方式 @@ -159,6 +165,7 @@ export interface ChartEditStoreType { [ChartEditStoreEnum.COMPONENT_LIST]: CreateComponentType[] } +// 需要存储的数据内容 export interface ChartEditStorage { [ChartEditStoreEnum.EDIT_CANVAS_CONFIG]: EditCanvasConfigType [ChartEditStoreEnum.REQUEST_GLOBAL_CONFIG]: RequestGlobalConfigType diff --git a/src/store/modules/chartEditStore/chartEditStore.ts b/src/store/modules/chartEditStore/chartEditStore.ts index 843c942e..16e4e09e 100644 --- a/src/store/modules/chartEditStore/chartEditStore.ts +++ b/src/store/modules/chartEditStore/chartEditStore.ts @@ -9,9 +9,11 @@ import { requestInterval, previewScaleType } from '@/settings/designSetting' import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore' // 全局设置 import { useSettingStore } from '@/store/modules/settingStore/settingStore' +// 历史类型 import { HistoryActionTypeEnum, HistoryItemType, HistoryTargetTypeEnum } from '@/store/modules/chartHistoryStore/chartHistoryStore.d' -import { MenuEnum } from '@/enums/editPageEnum' -import { PreviewScaleEnum } from '@/enums/styleEnum' +// 画布枚举 +import { MenuEnum, SyncEnum } from '@/enums/editPageEnum' + import { ChartEditStoreEnum, ChartEditStorage, @@ -47,7 +49,9 @@ export const useChartEditStore = defineStore({ // 初始化 isCreate: false, // 拖拽中 - isDrag: false + isDrag: false, + // 同步中 + saveStatus: SyncEnum.PENDING }, // 右键菜单 rightMenuShow: false, @@ -517,8 +521,8 @@ export const useChartEditStore = defineStore({ attr.x -= distance break; } - }, - // ---------------- + }, + // * 页面缩放设置----------------- // * 设置页面大小 setPageSize(scale: number): void { this.setPageStyle('height', `${this.editCanvasConfig.height * scale}px`) diff --git a/src/views/chart/ContentEdit/components/EditBottom/index.vue b/src/views/chart/ContentEdit/components/EditBottom/index.vue index 864806f9..c0aa4786 100644 --- a/src/views/chart/ContentEdit/components/EditBottom/index.vue +++ b/src/views/chart/ContentEdit/components/EditBottom/index.vue @@ -1,6 +1,10 @@ diff --git a/src/api/axios.config.ts b/src/api/axios.config.ts index c42121c0..5c976c7c 100644 --- a/src/api/axios.config.ts +++ b/src/api/axios.config.ts @@ -4,6 +4,8 @@ import { ModuleTypeEnum } from '@/enums/httpEnum' export const fetchAllowList = [ // 登录 `${ModuleTypeEnum.SYSTEM}/login`, + // 获取 OSS 接口 + `${ModuleTypeEnum.SYSTEM}/getOssInfo`, // 预览获取数据 `${ModuleTypeEnum.PROJECT}/getData`, ] diff --git a/src/api/http.ts b/src/api/http.ts index ff1bf95e..6f3b2eff 100644 --- a/src/api/http.ts +++ b/src/api/http.ts @@ -20,7 +20,7 @@ export const post = (url: string, data?: object, headersType?: string) => { }) } -export const put = (url: string, data?: object, headersType?: string) => { +export const put = (url: string, data?: object, headersType?: ContentTypeEnum) => { return axiosInstance({ url: url, method: RequestHttpEnum.PUT, diff --git a/src/api/path/index.ts b/src/api/path/index.ts new file mode 100644 index 00000000..66594d27 --- /dev/null +++ b/src/api/path/index.ts @@ -0,0 +1,2 @@ +export * from '@/api/path/project.api' +export * from '@/api/path/system.api' \ No newline at end of file diff --git a/src/api/path/project.ts b/src/api/path/project.api.ts similarity index 58% rename from src/api/path/project.ts rename to src/api/path/project.api.ts index 6d05ced8..5123ff2f 100644 --- a/src/api/path/project.ts +++ b/src/api/path/project.api.ts @@ -5,7 +5,7 @@ import { ContentTypeEnum, RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEn // * 项目列表 export const projectListApi = async (data: object) => { try { - const res = await http(RequestHttpEnum.GET)(`/api/goview/${ModuleTypeEnum.PROJECT}/list`, data); + const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.PROJECT}/list`, data); return res; } catch { httpErrorHandle(); @@ -15,7 +15,7 @@ export const projectListApi = async (data: object) => { // * 新增项目 export const createProjectApi = async (data: object) => { try { - const res = await http(RequestHttpEnum.POST)(`/api/goview/${ModuleTypeEnum.PROJECT}/create`, data); + const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.PROJECT}/create`, data); return res; } catch { httpErrorHandle(); @@ -25,7 +25,7 @@ export const createProjectApi = async (data: object) => { // * 获取项目 export const fetchProjectApi = async (data: object) => { try { - const res = await http(RequestHttpEnum.GET)(`/api/goview/${ModuleTypeEnum.PROJECT}/getData`, data); + const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.PROJECT}/getData`, data); return res; } catch { httpErrorHandle(); @@ -35,7 +35,7 @@ export const fetchProjectApi = async (data: object) => { // * 保存项目 export const saveProjectApi = async (data: object) => { try { - const res = await http(RequestHttpEnum.POST)(`/api/goview/${ModuleTypeEnum.PROJECT}/save/data`, data, ContentTypeEnum.FORM_URLENCODED); + const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.PROJECT}/save/data`, data, ContentTypeEnum.FORM_URLENCODED); return res; } catch { httpErrorHandle(); @@ -45,7 +45,7 @@ export const saveProjectApi = async (data: object) => { // * 修改项目基础信息 export const updateProjectApi = async (data: object) => { try { - const res = await http(RequestHttpEnum.POST)(`/api/goview/${ModuleTypeEnum.PROJECT}/edit`, data); + const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.PROJECT}/edit`, data); return res; } catch { httpErrorHandle(); @@ -56,7 +56,7 @@ export const updateProjectApi = async (data: object) => { // * 删除项目 export const deleteProjectApi = async (data: object) => { try { - const res = await http(RequestHttpEnum.DELETE)(`/api/goview/${ModuleTypeEnum.PROJECT}/delete`, data); + const res = await http(RequestHttpEnum.DELETE)(`${ModuleTypeEnum.PROJECT}/delete`, data); return res; } catch { httpErrorHandle(); @@ -66,7 +66,7 @@ export const deleteProjectApi = async (data: object) => { // * 修改发布状态 [-1未发布,1发布] export const changeProjectReleaseApi = async (data: object) => { try { - const res = await http(RequestHttpEnum.PUT)(`/api/goview/${ModuleTypeEnum.PROJECT}/publish`, data); + const res = await http(RequestHttpEnum.PUT)(`${ModuleTypeEnum.PROJECT}/publish`, data); return res; } catch { httpErrorHandle(); @@ -74,9 +74,9 @@ export const changeProjectReleaseApi = async (data: object) => { } // * 上传文件 -export const uploadFile = async (data: object) => { +export const uploadFile = async (url:string, data: object) => { try { - const res = await http(RequestHttpEnum.POST)(`oss/object/v2-cloud`, data, ContentTypeEnum.FORM_DATA); + const res = await http(RequestHttpEnum.POST)(url, data, ContentTypeEnum.FORM_DATA); return res; } catch { httpErrorHandle(); diff --git a/src/api/path/system.api.ts b/src/api/path/system.api.ts index 522c17c9..499194c7 100644 --- a/src/api/path/system.api.ts +++ b/src/api/path/system.api.ts @@ -5,7 +5,7 @@ import { RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum' // * 登录 export const loginApi = async (data: object) => { try { - const res = await http(RequestHttpEnum.POST)(`/api/goview/${ModuleTypeEnum.SYSTEM}/login`, data); + const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.SYSTEM}/login`, data); return res; } catch(err) { httpErrorHandle(); @@ -15,7 +15,17 @@ export const loginApi = async (data: object) => { // * 登出 export const logoutApi = async () => { try { - const res = await http(RequestHttpEnum.GET)(`/api/goview/${ModuleTypeEnum.SYSTEM}/logout`); + const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.SYSTEM}/logout`); + return res; + } catch(err) { + httpErrorHandle(); + } +} + +// * 获取 oss 上传接口 +export const ossUrlApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.SYSTEM}/getOssInfo`, data); return res; } catch(err) { httpErrorHandle(); diff --git a/src/hooks/index.ts b/src/hooks/index.ts index 16b0bb69..c1d5037b 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -1,4 +1,5 @@ export * from '@/hooks/useTheme.hook' export * from '@/hooks/usePreviewScale.hook' export * from '@/hooks/useCode.hook' -export * from '@/hooks/useChartDataFetch.hook' \ No newline at end of file +export * from '@/hooks/useChartDataFetch.hook' +export * from '@/hooks/useSystemInit.hook' \ No newline at end of file diff --git a/src/hooks/useSystemInit.hook.ts b/src/hooks/useSystemInit.hook.ts new file mode 100644 index 00000000..7e8f7573 --- /dev/null +++ b/src/hooks/useSystemInit.hook.ts @@ -0,0 +1,23 @@ +import { useSystemStore } from '@/store/modules/systemStore/systemStore' +import { SystemStoreEnum } from '@/store/modules/systemStore/systemStore.d' +import { ResultEnum } from '@/enums/httpEnum' +import { ossUrlApi } from '@/api/path/' + + +// * 初始化 +export const useSystemInit = async () => { + const systemStore = useSystemStore() + + // 获取 OSS 信息 + const getOssUrl = async () => { + const res: any = await ossUrlApi({}) + if (res.code === ResultEnum.SUCCESS) { + systemStore.setItem(SystemStoreEnum.FETCH_INFO, { + OSSUrl: res.data?.bucketURL + }) + } + } + + // 执行 + getOssUrl() +} \ No newline at end of file diff --git a/src/settings/httpSetting.ts b/src/settings/httpSetting.ts index 7b3962d4..9e9334bf 100644 --- a/src/settings/httpSetting.ts +++ b/src/settings/httpSetting.ts @@ -1,2 +1,2 @@ // 请求前缀 -export const axiosPre = '/goview' \ No newline at end of file +export const axiosPre = '/api/goview' \ No newline at end of file diff --git a/src/store/modules/systemStore/systemStore.d.ts b/src/store/modules/systemStore/systemStore.d.ts index acdc8120..77f5c348 100644 --- a/src/store/modules/systemStore/systemStore.d.ts +++ b/src/store/modules/systemStore/systemStore.d.ts @@ -12,10 +12,18 @@ export interface UserInfoType { [SystemStoreUserInfoEnum.NICK_NAME]?: string, } +export interface FetchInfoType { + OSSUrl?: string, +} + export enum SystemStoreEnum { - USER_INFO = 'userInfo' + // 用户 + USER_INFO = 'userInfo', + // 请求 + FETCH_INFO = 'fetchInfo' } export interface SystemStoreType { [SystemStoreEnum.USER_INFO]: UserInfoType + [SystemStoreEnum.FETCH_INFO]: FetchInfoType } \ No newline at end of file diff --git a/src/store/modules/systemStore/systemStore.ts b/src/store/modules/systemStore/systemStore.ts index a1e11b15..bb507f2a 100644 --- a/src/store/modules/systemStore/systemStore.ts +++ b/src/store/modules/systemStore/systemStore.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia' -import { SystemStoreType, SystemStoreEnum } from './systemStore.d' +import { SystemStoreType, UserInfoType, FetchInfoType } from './systemStore.d' import { setLocalStorage, getLocalStorage } from '@/utils' import { StorageEnum } from '@/enums/storageEnum' @@ -16,13 +16,23 @@ export const useSystemStore = defineStore({ userName: undefined, userToken: undefined, nickName: undefined + }, + fetchInfo: { + OSSUrl: undefined } }, - getters: {}, + getters: { + getUserInfo(): UserInfoType { + return this.userInfo + }, + getFetchInfo(): FetchInfoType { + return this.fetchInfo + }, + }, actions: { setItem(key: T, value: K): void { this.$patch(state => { - state[key]= value + state[key] = value }); setLocalStorage(GO_SYSTEM_STORE, this.$state) } diff --git a/src/utils/router.ts b/src/utils/router.ts index db3d6134..4fd5bb9a 100644 --- a/src/utils/router.ts +++ b/src/utils/router.ts @@ -6,7 +6,7 @@ import { SystemStoreEnum, SystemStoreUserInfoEnum } from '@/store/modules/system import { StorageEnum } from '@/enums/storageEnum' import { clearLocalStorage, getLocalStorage, clearCookie } from './storage' import router from '@/router' -import { logoutApi } from '@/api/path/system.api' +import { logoutApi } from '@/api/path' /** * * 根据名字跳转路由 diff --git a/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue b/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue index 8964c093..25a75aac 100644 --- a/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue +++ b/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue @@ -128,18 +128,20 @@ import { backgroundImageSize } from '@/settings/designSetting' import { FileTypeEnum } from '@/enums/fileTypeEnum' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d' +import { useSystemStore } from '@/store/modules/systemStore/systemStore' import { StylesSetting } from '@/components/Pages/ChartItemSetting' import { UploadCustomRequestOptions } from 'naive-ui' import { fileToUrl, loadAsyncComponent, fetchRouteParamsLocation } from '@/utils' import { PreviewScaleEnum } from '@/enums/styleEnum' import { ResultEnum } from '@/enums/httpEnum' import { icon } from '@/plugins' -import { uploadFile} from '@/api/path/project' +import { uploadFile} from '@/api/path' const { ColorPaletteIcon } = icon.ionicons5 const { ZAxisIcon, ScaleIcon, FitToScreenIcon, FitToHeightIcon, FitToWidthIcon } = icon.carbon const chartEditStore = useChartEditStore() +const systemStore = useSystemStore() const canvasConfig = chartEditStore.getEditCanvasConfig const editCanvas = chartEditStore.getEditCanvas @@ -273,6 +275,10 @@ const switchSelectColorHandle = () => { const customRequest = (options: UploadCustomRequestOptions) => { const { file } = options nextTick(async () => { + if(!systemStore.getFetchInfo.OSSUrl) { + window['$message'].error('添加图片失败,请刷新页面重试!') + return + } if (file.file) { // 修改名称 const newNameFile = new File( @@ -282,7 +288,7 @@ const customRequest = (options: UploadCustomRequestOptions) => { ) let uploadParams = new FormData() uploadParams.append('object', newNameFile) - const uploadRes:any = await uploadFile(uploadParams) + const uploadRes:any = await uploadFile(systemStore.getFetchInfo.OSSUrl ,uploadParams) if(uploadRes.code === ResultEnum.SUCCESS) { chartEditStore.setEditCanvasConfig( diff --git a/src/views/chart/ContentHeader/headerTitle/index.vue b/src/views/chart/ContentHeader/headerTitle/index.vue index a56f2556..87c7884c 100644 --- a/src/views/chart/ContentHeader/headerTitle/index.vue +++ b/src/views/chart/ContentHeader/headerTitle/index.vue @@ -29,7 +29,7 @@ import { ResultEnum } from '@/enums/httpEnum' import { fetchRouteParamsLocation, httpErrorHandle } from '@/utils' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { ProjectInfoEnum } from '@/store/modules/chartEditStore/chartEditStore.d' -import { updateProjectApi } from '@/api/path/project' +import { updateProjectApi } from '@/api/path' import { useSync } from '../../hooks/useSync.hook' import { icon } from '@/plugins' diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index 6022bf16..3c1acb17 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -4,13 +4,14 @@ import { getUUID, httpErrorHandle, fetchRouteParamsLocation, base64toFile } from import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { EditCanvasTypeEnum, ChartEditStoreEnum, ProjectInfoEnum, ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore' +import { useSystemStore } from '@/store/modules/systemStore/systemStore' import { fetchChartComponent, createComponent } from '@/packages/index' import { CreateComponentType } from '@/packages/index.d' import { saveInterval } from '@/settings/designSetting' // 接口状态 import { ResultEnum } from '@/enums/httpEnum' // 接口 -import { saveProjectApi, fetchProjectApi, uploadFile, updateProjectApi } from '@/api/path/project' +import { saveProjectApi, fetchProjectApi, uploadFile, updateProjectApi } from '@/api/path' // 画布枚举 import { SyncEnum } from '@/enums/editPageEnum' @@ -18,6 +19,7 @@ import { SyncEnum } from '@/enums/editPageEnum' export const useSync = () => { const chartEditStore = useChartEditStore() const chartHistoryStore = useChartHistoryStore() + const systemStore = useSystemStore() /** * * 组件动态注册 @@ -112,6 +114,12 @@ export const useSync = () => { // * 数据保存 const dataSyncUpdate = async () => { if(!fetchRouteParamsLocation()) return + + if(!systemStore.getFetchInfo.OSSUrl) { + window['$message'].error('数据保存失败,请刷新页面重试!') + return + } + chartEditStore.setEditCanvas(EditCanvasTypeEnum.SAVE_STATUS, SyncEnum.START) // 获取缩略图片 @@ -127,7 +135,7 @@ export const useSync = () => { // 上传预览图 let uploadParams = new FormData() uploadParams.append('object', base64toFile(canvasImage.toDataURL(), `${fetchRouteParamsLocation()}_index_preview.png`)) - const uploadRes:any = await uploadFile(uploadParams) + const uploadRes:any = await uploadFile(systemStore.getFetchInfo.OSSUrl, uploadParams) // 保存预览图 if(uploadRes.code === ResultEnum.SUCCESS) { await updateProjectApi({ diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 616ecae8..6a881a6e 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -119,16 +119,16 @@ import { reactive, ref, onMounted } from 'vue' import shuffle from 'lodash/shuffle' import { carouselInterval } from '@/settings/designSetting' import { useSystemStore } from '@/store/modules/systemStore/systemStore' -import { SystemStoreEnum, SystemStoreUserInfoEnum } from '@/store/modules/systemStore/systemStore.d' +import { SystemStoreEnum } from '@/store/modules/systemStore/systemStore.d' import { GoThemeSelect } from '@/components/GoThemeSelect' import { GoLangSelect } from '@/components/GoLangSelect' import { LayoutHeader } from '@/layout/components/LayoutHeader' import { LayoutFooter } from '@/layout/components/LayoutFooter' import { PageEnum } from '@/enums/pageEnum' -import { icon } from '@/plugins' import { StorageEnum } from '@/enums/storageEnum' +import { icon } from '@/plugins' import { routerTurnByName } from '@/utils' -import { loginApi } from '@/api/path/system.api' +import { loginApi } from '@/api/path' interface FormState { username: string @@ -147,15 +147,6 @@ const systemStore = useSystemStore() const t = window['$t'] -onMounted(() => { - setTimeout(() => { - show.value = true - }, 300) - setTimeout(() => { - showBg.value = true - }, 100) -}) - const formInline = reactive({ username: 'admin', password: 'admin', @@ -198,7 +189,7 @@ const getImageUrl = (name: string, folder: string) => { return new URL(`../../assets/images/${folder}/${name}.png`, import.meta.url).href } -// 打乱 +// 打乱图片顺序 const shuffleHandle = () => { shuffleTimiing.value = setInterval(() => { bgList.value = shuffle(bgList.value) @@ -239,6 +230,14 @@ const handleSubmit = async (e: Event) => { } onMounted(() => { + setTimeout(() => { + show.value = true + }, 300) + + setTimeout(() => { + showBg.value = true + }, 100) + shuffleHandle() }) @@ -326,7 +325,7 @@ $carousel-image-height: 60vh; align-items: center; width: 100vw; height: 100vh; - background: url('../../assets/images/login/login-bg.png') no-repeat 0 -120px; + background: url('@/assets/images/login/login-bg.png') no-repeat 0 -120px; .bg-slot { width: $carousel-width; } diff --git a/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts b/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts index ef8e050d..29a87f1f 100644 --- a/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts +++ b/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts @@ -1,7 +1,7 @@ import { ref, reactive } from 'vue'; import { goDialog, httpErrorHandle } from '@/utils' import { DialogEnum } from '@/enums/pluginEnum' -import { projectListApi, deleteProjectApi, changeProjectReleaseApi } from '@/api/path/project' +import { projectListApi, deleteProjectApi, changeProjectReleaseApi } from '@/api/path' import { Chartype, ChartList } from '../../../index.d' import { ResultEnum } from '@/enums/httpEnum' diff --git a/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue b/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue index 4c77f4ac..6d6384e0 100644 --- a/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue +++ b/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue @@ -40,7 +40,7 @@ import { icon } from '@/plugins' import { PageEnum, ChartEnum } from '@/enums/pageEnum' import { ResultEnum } from '@/enums/httpEnum' import { fetchPathByName, routerTurnByPath, renderLang, getUUID } from '@/utils' -import { createProjectApi } from '@/api/path/project' +import { createProjectApi } from '@/api/path' const { FishIcon, CloseIcon } = icon.ionicons5 const { StoreIcon, ObjectStorageIcon } = icon.carbon From 1e678b7492e55cd4a355902b58ae00c4a6f5792b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Tue, 31 May 2022 11:19:17 +0800 Subject: [PATCH 35/95] =?UTF-8?q?build:=20=E4=BF=AE=E6=94=B9=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 5f8465c2..87882566 100644 --- a/.env +++ b/.env @@ -2,7 +2,7 @@ VITE_DEV_PORT = '8080' # development path -VITE_DEV_PATH = 'http://127.0.0.1:8080' +VITE_DEV_PATH = 'http://1.117.240.165:8080' # production path -VITE_PRO_PATH = 'http://127.0.0.1:8080' \ No newline at end of file +VITE_PRO_PATH = 'http://1.117.240.165:8080' \ No newline at end of file From 294a4a6cdf6d63c7a379829c435124650ec7e690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Wed, 1 Jun 2022 19:01:05 +0800 Subject: [PATCH 36/95] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E6=8D=AE=EF=BC=8C=E4=BD=86=E6=98=AF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=A8=A1=E5=9D=97=E4=B8=8D=E5=AE=8C=E6=95=B4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/chart/hooks/useSync.hook.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index 3c1acb17..614bfbba 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -5,7 +5,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore import { EditCanvasTypeEnum, ChartEditStoreEnum, ProjectInfoEnum, ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore' import { useSystemStore } from '@/store/modules/systemStore/systemStore' -import { fetchChartComponent, createComponent } from '@/packages/index' +import { fetchChartComponent, fetchConfigComponent, createComponent } from '@/packages/index' import { CreateComponentType } from '@/packages/index.d' import { saveInterval } from '@/settings/designSetting' // 接口状态 @@ -42,6 +42,10 @@ export const useSync = () => { e.chartConfig.chartKey, fetchChartComponent(e.chartConfig) ) + window['$vue'].component( + e.chartConfig.conKey, + fetchConfigComponent(e.chartConfig) + ) } }) // 数据赋值 From 2917cde2e53903ada46075ac96176686211a61c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Wed, 1 Jun 2022 20:16:38 +0800 Subject: [PATCH 37/95] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=9B=BE=E7=89=87=E5=B1=95=E7=A4=BA=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/project/items/components/ProjectItemsCard/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/project/items/components/ProjectItemsCard/index.vue b/src/views/project/items/components/ProjectItemsCard/index.vue index 18dfb399..6a8e7d6e 100644 --- a/src/views/project/items/components/ProjectItemsCard/index.vue +++ b/src/views/project/items/components/ProjectItemsCard/index.vue @@ -17,7 +17,7 @@ object-fit="contain" height="180" preview-disabled - :src="cardData.image" + :src="`${cardData.image}?time=${new Date().getTime()}`" :alt="cardData.title" :fallback-src="requireErrorImg()" > From 6b551ae68bec5d0971c17ffb58aeeef58edb02da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Wed, 1 Jun 2022 22:13:49 +0800 Subject: [PATCH 38/95] =?UTF-8?q?build=EF=BC=9A=E5=8D=87=E7=BA=A7=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- pnpm-lock.yaml | 72 +++++++++++++++++++++++++------------------------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 59f44de2..45beac26 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "pinia": "^2.0.13", "screenfull": "^6.0.1", "vue": "^3.2.31", - "vue-i18n": "9.1.9", + "vue-i18n": "9.1.10", "vue-router": "4.0.12", "vue3-lazyload": "^0.2.5-beta", "vue3-sketch-ruler": "^1.3.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b3396ecf..8d290381 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,7 +44,7 @@ specifiers: vite-plugin-mock: ^2.9.6 vue: ^3.2.31 vue-echarts: ^6.0.2 - vue-i18n: 9.1.9 + vue-i18n: 9.1.10 vue-router: 4.0.12 vue-tsc: ^0.28.10 vue3-lazyload: ^0.2.5-beta @@ -67,7 +67,7 @@ dependencies: pinia: 2.0.13_hhks2xcoho7x4jrwn5stbz36vy screenfull: 6.0.1 vue: 3.2.31 - vue-i18n: 9.1.9_vue@3.2.31 + vue-i18n: 9.1.10_vue@3.2.31 vue-router: 4.0.12_vue@3.2.31 vue3-lazyload: 0.2.5-beta_j5zg3yborh7xiumw6is6xmn3z4 vue3-sketch-ruler: 1.3.3_vue@3.2.31 @@ -482,60 +482,60 @@ packages: resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} dev: true - /@intlify/core-base/9.1.9: - resolution: {integrity: sha512-x5T0p/Ja0S8hs5xs+ImKyYckVkL4CzcEXykVYYV6rcbXxJTe2o58IquSqX9bdncVKbRZP7GlBU1EcRaQEEJ+vw==} + /@intlify/core-base/9.1.10: + resolution: {integrity: sha512-So9CNUavB/IsZ+zBmk2Cv6McQp6vc2wbGi1S0XQmJ8Vz+UFcNn9MFXAe9gY67PreIHrbLsLxDD0cwo1qsxM1Nw==} engines: {node: '>= 10'} dependencies: - '@intlify/devtools-if': 9.1.9 - '@intlify/message-compiler': 9.1.9 - '@intlify/message-resolver': 9.1.9 - '@intlify/runtime': 9.1.9 - '@intlify/shared': 9.1.9 - '@intlify/vue-devtools': 9.1.9 + '@intlify/devtools-if': 9.1.10 + '@intlify/message-compiler': 9.1.10 + '@intlify/message-resolver': 9.1.10 + '@intlify/runtime': 9.1.10 + '@intlify/shared': 9.1.10 + '@intlify/vue-devtools': 9.1.10 dev: false - /@intlify/devtools-if/9.1.9: - resolution: {integrity: sha512-oKSMKjttG3Ut/1UGEZjSdghuP3fwA15zpDPcjkf/1FjlOIm6uIBGMNS5jXzsZy593u+P/YcnrZD6cD3IVFz9vQ==} + /@intlify/devtools-if/9.1.10: + resolution: {integrity: sha512-SHaKoYu6sog3+Q8js1y3oXLywuogbH1sKuc7NSYkN3GElvXSBaMoCzW+we0ZSFqj/6c7vTNLg9nQ6rxhKqYwnQ==} engines: {node: '>= 10'} dependencies: - '@intlify/shared': 9.1.9 + '@intlify/shared': 9.1.10 dev: false - /@intlify/message-compiler/9.1.9: - resolution: {integrity: sha512-6YgCMF46Xd0IH2hMRLCssZI3gFG4aywidoWQ3QP4RGYQXQYYfFC54DxhSgfIPpVoPLQ+4AD29eoYmhiHZ+qLFQ==} + /@intlify/message-compiler/9.1.10: + resolution: {integrity: sha512-+JiJpXff/XTb0EadYwdxOyRTB0hXNd4n1HaJ/a4yuV960uRmPXaklJsedW0LNdcptd/hYUZtCkI7Lc9J5C1gxg==} engines: {node: '>= 10'} dependencies: - '@intlify/message-resolver': 9.1.9 - '@intlify/shared': 9.1.9 + '@intlify/message-resolver': 9.1.10 + '@intlify/shared': 9.1.10 source-map: 0.6.1 dev: false - /@intlify/message-resolver/9.1.9: - resolution: {integrity: sha512-Lx/DBpigeK0sz2BBbzv5mu9/dAlt98HxwbG7xLawC3O2xMF9MNWU5FtOziwYG6TDIjNq0O/3ZbOJAxwITIWXEA==} + /@intlify/message-resolver/9.1.10: + resolution: {integrity: sha512-5YixMG/M05m0cn9+gOzd4EZQTFRUu8RGhzxJbR1DWN21x/Z3bJ8QpDYj6hC4FwBj5uKsRfKpJQ3Xqg98KWoA+w==} engines: {node: '>= 10'} dev: false - /@intlify/runtime/9.1.9: - resolution: {integrity: sha512-XgPw8+UlHCiie3fI41HPVa/VDJb3/aSH7bLhY1hJvlvNV713PFtb4p4Jo+rlE0gAoMsMCGcsiT982fImolSltg==} + /@intlify/runtime/9.1.10: + resolution: {integrity: sha512-7QsuByNzpe3Gfmhwq6hzgXcMPpxz8Zxb/XFI6s9lQdPLPe5Lgw4U1ovRPZTOs6Y2hwitR3j/HD8BJNGWpJnOFA==} engines: {node: '>= 10'} dependencies: - '@intlify/message-compiler': 9.1.9 - '@intlify/message-resolver': 9.1.9 - '@intlify/shared': 9.1.9 + '@intlify/message-compiler': 9.1.10 + '@intlify/message-resolver': 9.1.10 + '@intlify/shared': 9.1.10 dev: false - /@intlify/shared/9.1.9: - resolution: {integrity: sha512-xKGM1d0EAxdDFCWedcYXOm6V5Pfw/TMudd6/qCdEb4tv0hk9EKeg7lwQF1azE0dP2phvx0yXxrt7UQK+IZjNdw==} + /@intlify/shared/9.1.10: + resolution: {integrity: sha512-Om54xJeo1Vw+K1+wHYyXngE8cAbrxZHpWjYzMR9wCkqbhGtRV5VLhVc214Ze2YatPrWlS2WSMOWXR8JktX/IgA==} engines: {node: '>= 10'} dev: false - /@intlify/vue-devtools/9.1.9: - resolution: {integrity: sha512-YPehH9uL4vZcGXky4Ev5qQIITnHKIvsD2GKGXgqf+05osMUI6WSEQHaN9USRa318Rs8RyyPCiDfmA0hRu3k7og==} + /@intlify/vue-devtools/9.1.10: + resolution: {integrity: sha512-5l3qYARVbkWAkagLu1XbDUWRJSL8br1Dj60wgMaKB0+HswVsrR6LloYZTg7ozyvM621V6+zsmwzbQxbVQyrytQ==} engines: {node: '>= 10'} dependencies: - '@intlify/message-resolver': 9.1.9 - '@intlify/runtime': 9.1.9 - '@intlify/shared': 9.1.9 + '@intlify/message-resolver': 9.1.10 + '@intlify/runtime': 9.1.10 + '@intlify/shared': 9.1.10 dev: false /@jridgewell/resolve-uri/3.0.5: @@ -4436,15 +4436,15 @@ packages: - supports-color dev: true - /vue-i18n/9.1.9_vue@3.2.31: - resolution: {integrity: sha512-JeRdNVxS2OGp1E+pye5XB6+M6BBkHwAv9C80Q7+kzoMdUDGRna06tjC0vCB/jDX9aWrl5swxOMFcyAr7or8XTA==} + /vue-i18n/9.1.10_vue@3.2.31: + resolution: {integrity: sha512-jpr7gV5KPk4n+sSPdpZT8Qx3XzTcNDWffRlHV/cT2NUyEf+sEgTTmLvnBAibjOFJ0zsUyZlVTAWH5DDnYep+1g==} engines: {node: '>= 10'} peerDependencies: vue: ^3.0.0 dependencies: - '@intlify/core-base': 9.1.9 - '@intlify/shared': 9.1.9 - '@intlify/vue-devtools': 9.1.9 + '@intlify/core-base': 9.1.10 + '@intlify/shared': 9.1.10 + '@intlify/vue-devtools': 9.1.10 '@vue/devtools-api': 6.1.4 vue: 3.2.31 dev: false From 6ab34a09969d8af80644a8e44b67a2be5dbc266c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Wed, 1 Jun 2022 22:14:33 +0800 Subject: [PATCH 39/95] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=B3=A8=E5=86=8C=E4=BC=9A=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/preview/hooks/useComInstall.hook.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/preview/hooks/useComInstall.hook.ts b/src/views/preview/hooks/useComInstall.hook.ts index 4ce45576..f25064dc 100644 --- a/src/views/preview/hooks/useComInstall.hook.ts +++ b/src/views/preview/hooks/useComInstall.hook.ts @@ -8,7 +8,7 @@ export const useComInstall = (localStorageInfo: ChartEditStorageType) => { // 注册组件(一开始无法获取window['$vue']) const intervalTiming = setInterval(() => { - if (window['$vue'].component) { + if (window['$vue']?.component) { clearInterval(intervalTiming) localStorageInfo.componentList.forEach(async (e: CreateComponentType) => { if (!window['$vue'].component(e.chartConfig.chartKey)) { From 221351ec1130ef838765395d8daabdbc9cdcf2ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Wed, 1 Jun 2022 22:19:03 +0800 Subject: [PATCH 40/95] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E9=A2=84=E8=A7=88=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/path/system.api.ts | 9 ++ src/views/chart/hooks/useSync.hook.ts | 4 - src/views/preview/hooks/useScale.hook.ts | 1 + src/views/preview/index.d.ts | 3 +- src/views/preview/index.vue | 99 +------------------- src/views/preview/suspenseIndex.vue | 110 +++++++++++++++++++++++ src/views/preview/utils/storage.ts | 38 +++++--- 7 files changed, 152 insertions(+), 112 deletions(-) create mode 100644 src/views/preview/suspenseIndex.vue diff --git a/src/api/path/system.api.ts b/src/api/path/system.api.ts index 499194c7..1839b109 100644 --- a/src/api/path/system.api.ts +++ b/src/api/path/system.api.ts @@ -12,6 +12,15 @@ export const loginApi = async (data: object) => { } } +// * 新接口 +export const newApi = async (data: object) => { + try { + const resonse = await http(RequestHttpEnum.POST)(`新接口的路劲/xxx/xxx`, data) + } catch (error) { + httpErrorHandle(); + } +} + // * 登出 export const logoutApi = async () => { try { diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index 614bfbba..528e60ff 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -129,12 +129,8 @@ export const useSync = () => { // 获取缩略图片 const range = document.querySelector('.go-edit-range') as HTMLElement const ruler = document.getElementById('mb-ruler') - // 去除标尺Dom - if (ruler) ruler.style.display = 'none' // 生成图片 const canvasImage: HTMLCanvasElement = await html2canvas(range) - // 还原标尺 - if (ruler) ruler.style.display = 'block' // 上传预览图 let uploadParams = new FormData() diff --git a/src/views/preview/hooks/useScale.hook.ts b/src/views/preview/hooks/useScale.hook.ts index 0db5e48b..202aaf05 100644 --- a/src/views/preview/hooks/useScale.hook.ts +++ b/src/views/preview/hooks/useScale.hook.ts @@ -4,6 +4,7 @@ import type { ChartEditStorageType } from '../index.d' import { PreviewScaleEnum } from '@/enums/styleEnum' export const useScale = (localStorageInfo: ChartEditStorageType) => { + const entityRef = ref() const previewRef = ref() const width = ref(localStorageInfo.editCanvasConfig.width) diff --git a/src/views/preview/index.d.ts b/src/views/preview/index.d.ts index 612f037f..0dfbe7ca 100644 --- a/src/views/preview/index.d.ts +++ b/src/views/preview/index.d.ts @@ -1,5 +1,6 @@ import { ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' export interface ChartEditStorageType extends ChartEditStorage { - id: string + id: string, + isRelease?: boolean } \ No newline at end of file diff --git a/src/views/preview/index.vue b/src/views/preview/index.vue index ea057f64..4e6bc664 100644 --- a/src/views/preview/index.vue +++ b/src/views/preview/index.vue @@ -1,100 +1,9 @@ - - diff --git a/src/views/preview/suspenseIndex.vue b/src/views/preview/suspenseIndex.vue new file mode 100644 index 00000000..7036df6e --- /dev/null +++ b/src/views/preview/suspenseIndex.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/src/views/preview/utils/storage.ts b/src/views/preview/utils/storage.ts index 1a97af29..798ed751 100644 --- a/src/views/preview/utils/storage.ts +++ b/src/views/preview/utils/storage.ts @@ -1,26 +1,40 @@ -import { getSessionStorage } from '@/utils' +import { getSessionStorage, fetchRouteParamsLocation, httpErrorHandle } from '@/utils' +import { ResultEnum } from '@/enums/httpEnum' import { StorageEnum } from '@/enums/storageEnum' import { ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' +import { fetchProjectApi } from '@/api/path' export interface ChartEditStorageType extends ChartEditStorage { id: string } // 根据路由 id 获取存储数据的信息 -export const getSessionStorageInfo = () => { - const urlHash = document.location.hash - const toPathArray = urlHash.split('/') - const id = toPathArray && toPathArray[toPathArray.length - 1] - +export const getSessionStorageInfo = async () => { + const id = fetchRouteParamsLocation() const storageList: ChartEditStorageType[] = getSessionStorage( StorageEnum.GO_CHART_STORAGE_LIST ) - - if(!storageList) return - - for (let i = 0; i < storageList.length; i++) { - if (id.toString() === storageList[i]['id']) { - return storageList[i] + + // 是否本地预览 + if (!storageList) { + // 接口调用 + const res: any = await fetchProjectApi({ projectId: id }) + if (res.code === ResultEnum.SUCCESS) { + const { content, state } = res.data + if (state === -1) { + // 跳转未发布页 + return { isRelease: false } + } + return { ...JSON.parse(content), id } + } else { + httpErrorHandle() + } + } else { + // 本地读取 + for (let i = 0; i < storageList.length; i++) { + if (id.toString() === storageList[i]['id']) { + return storageList[i] + } } } } \ No newline at end of file From 568fd6c10598b786654b6ad11f33ab551d129309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Wed, 1 Jun 2022 22:20:05 +0800 Subject: [PATCH 41/95] =?UTF-8?q?chore=EF=BC=9A=E4=BC=98=E5=8C=96=E4=BA=86?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=86=99=E6=B3=95=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86=E9=94=99=E8=AF=AF=E9=A1=B5=E9=9D=A2=E7=9A=84=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=9C=AA=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/enums/pageEnum.ts | 7 +++++- src/router/base.ts | 41 ++++++++++++++++---------------- src/router/constant.ts | 4 ++++ src/router/index.ts | 6 ++--- src/utils/router.ts | 2 +- src/views/exception/403.vue | 2 +- src/views/exception/404.vue | 2 +- src/views/exception/500.vue | 2 +- src/views/redirect/UnPublish.vue | 35 +++++++++++++++++++++++++++ src/views/redirect/index.vue | 25 +++++++++++++++---- 10 files changed, 92 insertions(+), 34 deletions(-) create mode 100644 src/views/redirect/UnPublish.vue diff --git a/src/enums/pageEnum.ts b/src/enums/pageEnum.ts index d709043c..9612dc31 100644 --- a/src/enums/pageEnum.ts +++ b/src/enums/pageEnum.ts @@ -20,10 +20,15 @@ export enum PageEnum { //重定向 REDIRECT = '/redirect', REDIRECT_NAME = 'Redirect', + + // 未发布 + REDIRECT_UN_PUBLISH = '/redirect/unPublish', + REDIRECT_UN_PUBLISH_NAME = 'redirect-un-publish', + + // 重载 RELOAD = '/reload', RELOAD_NAME = 'Reload', - // 首页 BASE_HOME = '/project', BASE_HOME_NAME = 'Project', diff --git a/src/router/base.ts b/src/router/base.ts index 5e3a0279..8e4202b8 100644 --- a/src/router/base.ts +++ b/src/router/base.ts @@ -1,13 +1,13 @@ import { RouteRecordRaw } from 'vue-router' import type { AppRouteRecordRaw } from '@/router/types'; -import { ErrorPage404, ErrorPage403, ErrorPage500, Layout } from '@/router/constant'; +import { ErrorPage404, ErrorPage403, ErrorPage500, Layout, RedirectHome, RedirectUnPublish } from '@/router/constant'; import { PageEnum } from '@/enums/pageEnum' import { GoReload } from '@/components/GoReload' export const LoginRoute: RouteRecordRaw = { - path: '/login', - name: 'Login', + path: PageEnum.BASE_LOGIN, + name: PageEnum.BASE_LOGIN_NAME, component: () => import('@/views/login/index.vue'), meta: { title: '登录', @@ -60,22 +60,21 @@ export const ReloadRoute: AppRouteRecordRaw = { }, } -export const RedirectRoute: AppRouteRecordRaw = { - path: PageEnum.REDIRECT, - name: PageEnum.REDIRECT_NAME, - component: Layout, - meta: { - title: PageEnum.REDIRECT_NAME, - }, - children: [ - { - path: '/redirect/:path(.*)', - name: PageEnum.REDIRECT_NAME, - component: () => import('@/views/redirect/index.vue'), - meta: { - title: PageEnum.REDIRECT_NAME, - hideBreadcrumb: true, - }, +export const RedirectRoute: RouteRecordRaw[] = [ + { + path: PageEnum.REDIRECT, + name: PageEnum.REDIRECT_NAME, + component: RedirectHome, + meta: { + title: PageEnum.REDIRECT_NAME, }, - ], -}; + }, + { + path: PageEnum.REDIRECT_UN_PUBLISH, + name: PageEnum.REDIRECT_UN_PUBLISH_NAME, + component: RedirectUnPublish, + meta: { + title: PageEnum.REDIRECT_UN_PUBLISH_NAME, + }, + }, +] diff --git a/src/router/constant.ts b/src/router/constant.ts index 73f22267..d540b6f5 100644 --- a/src/router/constant.ts +++ b/src/router/constant.ts @@ -4,6 +4,10 @@ export const ErrorPage403 = () => import('@/views/exception/403.vue'); export const ErrorPage500 = () => import('@/views/exception/500.vue'); +export const RedirectHome = () => import('@/views/redirect/index.vue'); + +export const RedirectUnPublish = () => import('@/views/redirect/UnPublish.vue'); + export const Layout = () => import('@/layout/index.vue'); export const ParentLayout = () => import('@/layout/parentLayout.vue'); diff --git a/src/router/index.ts b/src/router/index.ts index 88e42395..0a7e7e04 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,9 +1,8 @@ import type { App } from 'vue' import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router' -import { RedirectRoute } from '@/router/base' import { createRouterGuards } from './router-guards' import { PageEnum } from '@/enums/pageEnum' -import { HttpErrorPage, LoginRoute, ReloadRoute } from '@/router/base' +import { HttpErrorPage, LoginRoute, ReloadRoute, RedirectRoute } from '@/router/base' import { Layout } from '@/router/constant' import modules from '@/router/modules' @@ -19,6 +18,7 @@ const RootRoute: Array = [ }, children: [ ...HttpErrorPage, + ...RedirectRoute, modules.projectRoutes, modules.chartRoutes, modules.previewRoutes @@ -27,7 +27,7 @@ const RootRoute: Array = [ ] -export const constantRouter: any[] = [LoginRoute, ...RootRoute, RedirectRoute, ReloadRoute]; +export const constantRouter: any[] = [LoginRoute, ...RootRoute, ReloadRoute]; const router = createRouter({ history: createWebHashHistory(''), diff --git a/src/utils/router.ts b/src/utils/router.ts index 4fd5bb9a..6c41b229 100644 --- a/src/utils/router.ts +++ b/src/utils/router.ts @@ -185,7 +185,7 @@ export const goHome = () => { } /** - * * 判断是否登录(现阶段是有 login 数据即可) + * * 判断是否登录 * @return boolean */ export const loginCheck = () => { diff --git a/src/views/exception/403.vue b/src/views/exception/403.vue index 679462d7..8f973b23 100644 --- a/src/views/exception/403.vue +++ b/src/views/exception/403.vue @@ -4,7 +4,7 @@
-

抱歉,你无权访问该页面

+

抱歉,你无权访问该页面

回到首页 diff --git a/src/views/exception/404.vue b/src/views/exception/404.vue index 86546c3b..d6e0a82c 100644 --- a/src/views/exception/404.vue +++ b/src/views/exception/404.vue @@ -4,7 +4,7 @@
-

抱歉,你访问的页面不存在

+

抱歉,你访问的页面不存在

回到首页 diff --git a/src/views/exception/500.vue b/src/views/exception/500.vue index c0d35a6a..82928c1e 100644 --- a/src/views/exception/500.vue +++ b/src/views/exception/500.vue @@ -4,7 +4,7 @@
-

抱歉,服务器出错了

+

抱歉,服务器出错了

回到首页 diff --git a/src/views/redirect/UnPublish.vue b/src/views/redirect/UnPublish.vue new file mode 100644 index 00000000..2429dd3f --- /dev/null +++ b/src/views/redirect/UnPublish.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/views/redirect/index.vue b/src/views/redirect/index.vue index 4aa7df88..7ff0e233 100644 --- a/src/views/redirect/index.vue +++ b/src/views/redirect/index.vue @@ -1,9 +1,11 @@ + From 2fcd3b1132de36ccb0d8e27ae7cd11650180fffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Wed, 1 Jun 2022 22:28:46 +0800 Subject: [PATCH 42/95] =?UTF-8?q?build:=20=E4=BF=AE=E6=94=B9=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=200.0.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 45beac26..dabfbc6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "go-view", - "version": "1.0.2", + "version": "0.0.9", "scripts": { "dev": "vite --host", "build": "vue-tsc --noEmit && vite build", From 0b04bf4929eacbe883bf9b2128bd601b7b4074b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Wed, 1 Jun 2022 22:41:11 +0800 Subject: [PATCH 43/95] =?UTF-8?q?type:=20=E5=AE=9A=E4=B9=89=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E8=BF=94=E5=9B=9E=E5=80=BC=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/axios.ts | 6 ------ src/hooks/useChartDataFetch.hook.ts | 2 +- src/hooks/useSystemInit.hook.ts | 2 +- src/utils/router.ts | 2 +- .../ContentConfigurations/components/CanvasPage/index.vue | 2 +- src/views/chart/ContentHeader/headerTitle/index.vue | 4 ++-- src/views/chart/hooks/useSync.hook.ts | 6 +++--- src/views/login/index.vue | 4 ++-- src/views/preview/utils/storage.ts | 2 +- .../components/ProjectItemsList/hooks/useData.hook.ts | 8 ++++---- .../ProjectLayoutCreate/components/CreateModal/index.vue | 4 ++-- types/global.d.ts | 7 +++++++ 12 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/api/axios.ts b/src/api/axios.ts index 52b932fc..8557403e 100644 --- a/src/api/axios.ts +++ b/src/api/axios.ts @@ -8,12 +8,6 @@ import { redirectErrorPage, getLocalStorage, routerTurnByName, httpErrorHandle } import { fetchAllowList } from './axios.config' import includes from 'lodash/includes' -interface MyResponseType { - code: number; - msg: string; - data: any; -} - const axiosInstance = axios.create({ baseURL: `${import.meta.env.PROD ? import.meta.env.VITE_PRO_PATH : ''}${axiosPre}`, timeout: ResultEnum.TIMEOUT, diff --git a/src/hooks/useChartDataFetch.hook.ts b/src/hooks/useChartDataFetch.hook.ts index ac522475..e9b5a58c 100644 --- a/src/hooks/useChartDataFetch.hook.ts +++ b/src/hooks/useChartDataFetch.hook.ts @@ -43,7 +43,7 @@ export const useChartDataFetch = ( if (!completePath) return fetchInterval = setInterval(async () => { - const res:any = await http(requestHttpType.value)(completePath || '', {}) + const res = await http(requestHttpType.value)(completePath || '', {}) as unknown as MyResponseType if (res.data) { // 是否是 Echarts 组件 const isECharts = diff --git a/src/hooks/useSystemInit.hook.ts b/src/hooks/useSystemInit.hook.ts index 7e8f7573..72f2d0fa 100644 --- a/src/hooks/useSystemInit.hook.ts +++ b/src/hooks/useSystemInit.hook.ts @@ -10,7 +10,7 @@ export const useSystemInit = async () => { // 获取 OSS 信息 const getOssUrl = async () => { - const res: any = await ossUrlApi({}) + const res = await ossUrlApi({}) as unknown as MyResponseType if (res.code === ResultEnum.SUCCESS) { systemStore.setItem(SystemStoreEnum.FETCH_INFO, { OSSUrl: res.data?.bucketURL diff --git a/src/utils/router.ts b/src/utils/router.ts index 6c41b229..a748830a 100644 --- a/src/utils/router.ts +++ b/src/utils/router.ts @@ -106,7 +106,7 @@ export const reloadRoutePage = () => { */ export const logout = async () => { try { - const res:any = await logoutApi() + const res = await logoutApi() as unknown as MyResponseType if(res.code === ResultEnum.SUCCESS) { window['$message'].success(window['$t']('global.logout_success')) clearCookie(RequestHttpHeaderEnum.COOKIE) diff --git a/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue b/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue index 25a75aac..c4caad4d 100644 --- a/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue +++ b/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue @@ -288,7 +288,7 @@ const customRequest = (options: UploadCustomRequestOptions) => { ) let uploadParams = new FormData() uploadParams.append('object', newNameFile) - const uploadRes:any = await uploadFile(systemStore.getFetchInfo.OSSUrl ,uploadParams) + const uploadRes = await uploadFile(systemStore.getFetchInfo.OSSUrl ,uploadParams) as unknown as MyResponseType if(uploadRes.code === ResultEnum.SUCCESS) { chartEditStore.setEditCanvasConfig( diff --git a/src/views/chart/ContentHeader/headerTitle/index.vue b/src/views/chart/ContentHeader/headerTitle/index.vue index 87c7884c..3e3163df 100644 --- a/src/views/chart/ContentHeader/headerTitle/index.vue +++ b/src/views/chart/ContentHeader/headerTitle/index.vue @@ -61,10 +61,10 @@ const handleFocus = () => { const handleBlur = async () => { focus.value = false chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, title.value || '') - const res:any = await updateProjectApi({ + const res = await updateProjectApi({ id: fetchRouteParamsLocation(), projectName: title.value, - }) + }) as unknown as MyResponseType if(res.code === ResultEnum.SUCCESS) { dataSyncUpdate() } else { diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index 528e60ff..ab551d56 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -95,7 +95,7 @@ export const useSync = () => { const dataSyncFetch = async () => { chartEditStore.setEditCanvas(EditCanvasTypeEnum.SAVE_STATUS, SyncEnum.START) try { - const res: any = await fetchProjectApi({ projectId: fetchRouteParamsLocation() }) + const res = await fetchProjectApi({ projectId: fetchRouteParamsLocation() }) as unknown as MyResponseType if (res.code === ResultEnum.SUCCESS) { if (res.data) { updateStoreInfo(res.data) @@ -135,7 +135,7 @@ export const useSync = () => { // 上传预览图 let uploadParams = new FormData() uploadParams.append('object', base64toFile(canvasImage.toDataURL(), `${fetchRouteParamsLocation()}_index_preview.png`)) - const uploadRes:any = await uploadFile(systemStore.getFetchInfo.OSSUrl, uploadParams) + const uploadRes = await uploadFile(systemStore.getFetchInfo.OSSUrl, uploadParams) as unknown as MyResponseType // 保存预览图 if(uploadRes.code === ResultEnum.SUCCESS) { await updateProjectApi({ @@ -148,7 +148,7 @@ export const useSync = () => { let params = new FormData() params.append('projectId', fetchRouteParamsLocation()) params.append('content', JSON.stringify(chartEditStore.getStorageInfo || {})) - const res: any = await saveProjectApi(params) + const res= await saveProjectApi(params) as unknown as MyResponseType if (res.code === ResultEnum.SUCCESS) { // 成功状态 diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 6a881a6e..eaf1ab08 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -204,10 +204,10 @@ const handleSubmit = async (e: Event) => { const { username, password } = formInline loading.value = true // 提交请求 - const res:any = await loginApi({ + const res = await loginApi({ username, password - }) + }) as unknown as MyResponseType if(res.data) { const { tokenValue } = res.data.token const { nickname, username, id } = res.data.userinfo diff --git a/src/views/preview/utils/storage.ts b/src/views/preview/utils/storage.ts index 798ed751..b708488c 100644 --- a/src/views/preview/utils/storage.ts +++ b/src/views/preview/utils/storage.ts @@ -18,7 +18,7 @@ export const getSessionStorageInfo = async () => { // 是否本地预览 if (!storageList) { // 接口调用 - const res: any = await fetchProjectApi({ projectId: id }) + const res = await fetchProjectApi({ projectId: id }) as unknown as MyResponseType if (res.code === ResultEnum.SUCCESS) { const { content, state } = res.data if (state === -1) { diff --git a/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts b/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts index 29a87f1f..9c051846 100644 --- a/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts +++ b/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts @@ -24,10 +24,10 @@ export const useDataListInit = () => { // 数据请求 const fetchList = async () => { loading.value = true - const res: any = await projectListApi({ + const res = await projectListApi({ page: paginat.page, limit: paginat.limit - }) + }) as unknown as MyResponseType if (res.data) { const { count } = res paginat.count = count @@ -86,11 +86,11 @@ export const useDataListInit = () => { // 发布处理 const releaseHandle = async (cardData: Chartype, index: number) => { const { id, release } = cardData - const res: any = await changeProjectReleaseApi({ + const res = await changeProjectReleaseApi({ id: id, // [-1未发布, 1发布] state: !release ? 1 : -1 - }) + }) as unknown as MyResponseType if (res.code === ResultEnum.SUCCESS) { list.value = [] fetchList() diff --git a/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue b/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue index 6d6384e0..d1b48531 100644 --- a/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue +++ b/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue @@ -89,14 +89,14 @@ const btnHandle = async (key: string) => { case ChartEnum.CHART_HOME_NAME: try { // 新增项目 - const res:any = await createProjectApi({ + const res = await createProjectApi({ // 项目名称 projectName: getUUID(), // remarks remarks: null, // 图片地址 indexImage: null, - }) + }) as unknown as MyResponseType if(res.code === ResultEnum.SUCCESS) { window['$message'].success(window['$t']('project.create_success')) diff --git a/types/global.d.ts b/types/global.d.ts index 74863473..b361c932 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -7,4 +7,11 @@ interface Window { $vue: any } + +declare interface MyResponseType { + code: number; + msg: string; + data: any; +} + declare type Recordable = Record \ No newline at end of file From f655a57e617f87ecfab105eb83f74c7c7ba3990d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Wed, 1 Jun 2022 22:58:22 +0800 Subject: [PATCH 44/95] =?UTF-8?q?fix=EF=BC=9A=E5=A4=84=E7=90=86=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=A1=B5=E6=A0=87=E9=A2=98=E8=BF=87=E9=95=BF=E7=9A=84?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ProjectItemsCard/index.vue | 96 ++++++++++--------- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/src/views/project/items/components/ProjectItemsCard/index.vue b/src/views/project/items/components/ProjectItemsCard/index.vue index 6a8e7d6e..5207838f 100644 --- a/src/views/project/items/components/ProjectItemsCard/index.vue +++ b/src/views/project/items/components/ProjectItemsCard/index.vue @@ -24,56 +24,58 @@ {{ item.title }} + + + + + + + 保存 + From 3c04f811479ac666bf489ca3c6b11152ed3e248e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Fri, 19 Aug 2022 11:43:23 +0800 Subject: [PATCH 88/95] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=85=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=90=88=E5=B9=B6=E4=B8=A2=E5=A4=B1=E7=9A=84=E6=9E=9A?= =?UTF-8?q?=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/enums/editPageEnum.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/enums/editPageEnum.ts b/src/enums/editPageEnum.ts index 832fa041..5fb94988 100644 --- a/src/enums/editPageEnum.ts +++ b/src/enums/editPageEnum.ts @@ -60,6 +60,9 @@ export enum MacKeyboard { CTRL = '⌘', SHIFT = '⇧', ALT = '⌥', + CTRL_SOURCE_KEY = "⌘", + SHIFT_SOURCE_KEY = "⇧", + ALT_SOURCE_KEY = "⌥" } // 同步状态枚举 From 72c26b71f3afa431ff444d85d8762a1468288a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Sun, 21 Aug 2022 14:52:30 +0800 Subject: [PATCH 89/95] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=8F=82?= =?UTF-8?q?=E8=80=83=E7=BA=BF=E7=9A=84=E5=B1=95=E7=A4=BA=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/chart/hooks/useSync.hook.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index 310e9268..8e869a4f 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -177,7 +177,6 @@ export const useSync = () => { // 获取缩略图片 const range = document.querySelector('.go-edit-range') as HTMLElement - const ruler = document.getElementById('mb-ruler') // 生成图片 const canvasImage: HTMLCanvasElement = await html2canvas(range, { backgroundColor: null From 801aa1f82f5498529e88444c71dcde153078bf1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Mon, 29 Aug 2022 10:13:37 +0000 Subject: [PATCH 90/95] update LICENSE. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 奔跑的面条 <1262327911@qq.com> --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index d012d2a8..a44f18f9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-present Naive Ui Admin +Copyright (c) 2021-present GoView Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From da809f13b357c1db717f553a494541d8b50c4dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Mon, 29 Aug 2022 21:35:51 +0800 Subject: [PATCH 91/95] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E8=83=8C=E6=99=AF=E5=9B=BE=E7=89=87=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=88=AA=E5=9B=BE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/utils.ts | 4 +++- src/views/chart/hooks/useSync.hook.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 43a3746c..2604efa9 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -154,7 +154,9 @@ export const canvasCut = (html: HTMLElement | null, callback?: Function) => { } html2canvas(html, { - backgroundColor: null + backgroundColor: null, + allowTaint: true, + useCORS: true }).then((canvas: HTMLCanvasElement) => { window['$message'].success('导出成功!') downloadByA(canvas.toDataURL(), undefined, 'png') diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index 8e869a4f..943bbf57 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -179,7 +179,9 @@ export const useSync = () => { const range = document.querySelector('.go-edit-range') as HTMLElement // 生成图片 const canvasImage: HTMLCanvasElement = await html2canvas(range, { - backgroundColor: null + backgroundColor: null, + allowTaint: true, + useCORS: true }) // 上传预览图 From 171e0aa408ef791bb6da45edf8fd447c7b94d6d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Tue, 30 Aug 2022 15:03:25 +0800 Subject: [PATCH 92/95] =?UTF-8?q?perf:=20=E5=AE=8C=E5=96=84=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E9=A2=84=E8=A7=88=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/router.ts | 4 ++-- src/views/preview/utils/storage.ts | 2 +- .../components/ProjectItemsCard/index.vue | 16 ++++++++++---- .../ProjectItemsList/hooks/useModal.hook.ts | 14 +++++++++---- .../components/ProjectItemsList/index.vue | 21 ++++--------------- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/utils/router.ts b/src/utils/router.ts index 5a117357..5f104f56 100644 --- a/src/utils/router.ts +++ b/src/utils/router.ts @@ -205,9 +205,9 @@ export const loginCheck = () => { * * 预览地址 * @returns */ - export const previewPath = () => { + export const previewPath = (id?: string | number) => { const { origin, pathname } = document.location const path = fetchPathByName(PreviewEnum.CHART_PREVIEW_NAME, 'href') - const previewPath = `${origin}${pathname}${path}/${fetchRouteParamsLocation()}` + const previewPath = `${origin}${pathname}${path}/${id || fetchRouteParamsLocation()}` return previewPath } \ No newline at end of file diff --git a/src/views/preview/utils/storage.ts b/src/views/preview/utils/storage.ts index b708488c..494315c7 100644 --- a/src/views/preview/utils/storage.ts +++ b/src/views/preview/utils/storage.ts @@ -16,7 +16,7 @@ export const getSessionStorageInfo = async () => { ) // 是否本地预览 - if (!storageList) { + if (!storageList || storageList.findIndex(e => e.id === id.toString()) === -1) { // 接口调用 const res = await fetchProjectApi({ projectId: id }) as unknown as MyResponseType if (res.code === ResultEnum.SUCCESS) { diff --git a/src/views/project/items/components/ProjectItemsCard/index.vue b/src/views/project/items/components/ProjectItemsCard/index.vue index d9622c95..a0f847cf 100644 --- a/src/views/project/items/components/ProjectItemsCard/index.vue +++ b/src/views/project/items/components/ProjectItemsCard/index.vue @@ -7,7 +7,7 @@ @@ -98,7 +98,7 @@ const { SendIcon } = icon.ionicons5 -const emit = defineEmits(['delete', 'resize', 'edit', 'release']) +const emit = defineEmits(['preview', 'delete', 'resize', 'edit', 'release']) const props = defineProps({ cardData: Object as PropType @@ -165,8 +165,11 @@ const selectOptions = ref([ const handleSelect = (key: string) => { switch (key) { + case 'preview': + previewHandle() + break case 'delete': - deleteHanlde() + deleteHandle() break case 'release': releaseHandle() @@ -177,8 +180,13 @@ const handleSelect = (key: string) => { } } +// 预览处理 +const previewHandle = () => { + emit('preview', props.cardData) +} + // 删除处理 -const deleteHanlde = () => { +const deleteHandle = () => { emit('delete', props.cardData) } diff --git a/src/views/project/items/components/ProjectItemsList/hooks/useModal.hook.ts b/src/views/project/items/components/ProjectItemsList/hooks/useModal.hook.ts index af74d44a..e28b1f91 100644 --- a/src/views/project/items/components/ProjectItemsList/hooks/useModal.hook.ts +++ b/src/views/project/items/components/ProjectItemsList/hooks/useModal.hook.ts @@ -1,6 +1,6 @@ import { ref } from 'vue' import { ChartEnum } from '@/enums/pageEnum' -import { fetchPathByName, routerTurnByPath } from '@/utils' +import { fetchPathByName, routerTurnByPath, openNewWindow, previewPath } from '@/utils' import { Chartype } from '../../../index.d' export const useModalDataInit = () => { const modalShow = ref(false) @@ -12,25 +12,31 @@ export const useModalDataInit = () => { modalData.value = null } - // 打开 modal + // 缩放处理 const resizeHandle = (cardData: Chartype) => { if (!cardData) return modalShow.value = true modalData.value = cardData } - // 打开 modal + // 编辑处理 const editHandle = (cardData: Chartype) => { if (!cardData) return const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href') routerTurnByPath(path, [cardData.id], undefined, true) } + // 预览处理 + const previewHandle = (cardData: Chartype) => { + openNewWindow(previewPath(cardData.id)) + } + return { modalData, modalShow, closeModal, resizeHandle, - editHandle + editHandle, + previewHandle } } diff --git a/src/views/project/items/components/ProjectItemsList/index.vue b/src/views/project/items/components/ProjectItemsList/index.vue index 73783e8a..2ce7145c 100644 --- a/src/views/project/items/components/ProjectItemsList/index.vue +++ b/src/views/project/items/components/ProjectItemsList/index.vue @@ -6,15 +6,11 @@
- +