diff --git a/mock/tools.ts b/mock/tools.ts index 8487ec1..e5b51bb 100644 --- a/mock/tools.ts +++ b/mock/tools.ts @@ -123,7 +123,7 @@ export default [ //标题筛选 if (title != '') { list = list.filter(item => { - let tmpValue = item.value.toLowerCase() + let tmpValue = item.title.toLowerCase() return tmpValue.indexOf(title.toLowerCase()) !== -1; }); } diff --git a/src/App.vue b/src/App.vue index 8c26721..9c313ec 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,7 +11,13 @@ import Right from '@/components/Layout/Right/Right.vue' - + + + + + + + @@ -25,4 +31,20 @@ import Right from '@/components/Layout/Right/Right.vue' diff --git a/src/api/ip/index.ts b/src/api/ip/index.ts index dce7ad7..0b0f128 100644 --- a/src/api/ip/index.ts +++ b/src/api/ip/index.ts @@ -2,6 +2,7 @@ import request from '@/utils/request' import type { + IpReqData, getIpResponseData } from './type' @@ -9,7 +10,7 @@ import type { enum API { //获取ip - GET_IP = '/ip/get?ip=' + GET_IP = '/openapi/ip' } //获取ip -export const getIp = (ip:string) => request.get(API.GET_IP + ip) \ No newline at end of file +export const getIp = (data: IpReqData) => request.post(API.GET_IP, data) \ No newline at end of file diff --git a/src/api/ip/type.ts b/src/api/ip/type.ts index 07bb4d7..a19c4da 100644 --- a/src/api/ip/type.ts +++ b/src/api/ip/type.ts @@ -1,6 +1,16 @@ -//响应格式 -export interface getIpResponseData { - code: number, +import { ResponseData } from "../common" + +export interface IpReqData { + ip: string +} + +export interface IpInfo { ip: string, - address: string + pos: string, + isp: string +} + +//响应格式 +export interface getIpResponseData extends ResponseData { + data: IpInfo } \ No newline at end of file diff --git a/src/components/Home/Home.vue b/src/components/Home/Home.vue index fba3b97..ebc8360 100644 --- a/src/components/Home/Home.vue +++ b/src/components/Home/Home.vue @@ -28,7 +28,7 @@ onMounted(() => {
- +
diff --git a/src/components/Ip/Ip.vue b/src/components/Ip/Ip.vue index 89e420f..ba0df97 100644 --- a/src/components/Ip/Ip.vue +++ b/src/components/Ip/Ip.vue @@ -1,24 +1,26 @@ diff --git a/src/components/TimeTran/TimeTran.vue b/src/components/TimeTran/TimeTran.vue index 987fd37..ba57375 100644 --- a/src/components/TimeTran/TimeTran.vue +++ b/src/components/TimeTran/TimeTran.vue @@ -2,9 +2,8 @@ import { onMounted, onUnmounted, reactive } from 'vue' import { VideoPause,VideoPlay,CopyDocument } from '@element-plus/icons-vue' import { Jh_getTimeStamp,Jh_timeStampToTime,Jh_convertTimeStamp } from '@/utils/time' -import clipboard3 from 'vue-clipboard3' -import { ElMessage } from 'element-plus'; import DetailHeader from '@/components/Layout/DetailHeader/DetailHeader.vue' +import { copy } from '@/utils/string' const info = reactive({ title: "时间戳转换", nowTime: Jh_getTimeStamp(), @@ -77,24 +76,8 @@ const timeTran = (type: string) => { } //复制时间戳 -const {toClipboard} = clipboard3() -const copyStamp = async () => { - try { - await toClipboard('' + info.nowTime) - ElMessage({ - message: "复制成功", - type: "success", - duration: 1500 - }) - } catch (error) { - console.log("复制失败") - console.log(error) - ElMessage({ - message: "复制失败", - type: "error", - duration: 1500 - }) - } +const copyRes = async () => { + copy('' + info.nowTime) } @@ -105,7 +88,7 @@ const copyStamp = async () => {
现在 - {{ info.nowTime }} + {{ info.nowTime }} 停止 开始
diff --git a/src/router/index.ts b/src/router/index.ts index 81fd532..a7ca95c 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -14,9 +14,9 @@ const router = createRouter({ } }, }) -router.beforeEach((to, from, next) => { +// _form: ‘_’表示占位变量,可以不被使用 +router.beforeEach((to, _from, next) => { if (to.meta.title && to.meta.title != '') { - console.log(from) let oldTitle = document.title document.title = to.meta.title + ' - ' + oldTitle } diff --git a/src/store/modules/tools.ts b/src/store/modules/tools.ts index 224cfc6..f507a33 100644 --- a/src/store/modules/tools.ts +++ b/src/store/modules/tools.ts @@ -1,13 +1,16 @@ //创建tools相关的小工具 import { defineStore } from 'pinia' import { getTools, getToolCate} from '@/api/tools' +import { getIp } from '@/api/ip' import type { ToolsReqData, ToolsInfo, ToolCate } from '@/api/tools/type' +import type { IpReqData, IpInfo } from '@/api/ip/type' export const useToolsStore = defineStore('tools', { //用来存放变量 state: () => ({ list: [] as ToolsInfo[], cates: [] as ToolCate[], + ipData: {} as IpInfo, }), //方法 actions: { @@ -32,6 +35,16 @@ export const useToolsStore = defineStore('tools', { } else { return Promise.reject(new Error(result.message)) } + }, + //获取ip + async getIp(data: IpReqData) { + const result: any = await getIp(data) + if (result.code == 200) { + this.ipData = result.data + return result.message + } else { + return Promise.reject(new Error(result.message)) + } } } }) \ No newline at end of file diff --git a/src/utils/request.ts b/src/utils/request.ts index 8b8dabb..4cc367f 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -2,7 +2,7 @@ import axios from "axios"; import { ElMessage } from "element-plus"; //创建axios实例 let request = axios.create({ - baseURL: import.meta.env.VITE_APP_BASE_API, + baseURL: import.meta.env.VITE_IS_MOCK == 'true' ? import.meta.env.VITE_APP_BASE_API : import.meta.env.VITE_SERVE + import.meta.env.VITE_APP_BASE_API, timeout: 5000 }) //请求拦截器 diff --git a/src/utils/string.ts b/src/utils/string.ts index 4594828..598a1c9 100644 --- a/src/utils/string.ts +++ b/src/utils/string.ts @@ -42,8 +42,6 @@ export function copy(resStr: string) { duration: 1500 }) } catch (error) { - console.log("复制失败") - console.log(error) ElMessage({ message: "复制失败", type: "error", diff --git a/vite.config.ts b/vite.config.ts index 3afcc47..50172dc 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -9,6 +9,9 @@ import { createHtmlPlugin } from 'vite-plugin-html' export default defineConfig(({command, mode}) => { let env = loadEnv(mode, process.cwd()) return { + define: { + 'process.env.NODE_ENV': JSON.stringify('production') + }, plugins: [ vue(), createSvgIconsPlugin({ @@ -37,17 +40,6 @@ export default defineConfig(({command, mode}) => { }, server: { proxy: { - '/v1/ip': { - target: 'https://searchplugin.csdn.net', //ip查询 - changeOrigin: true, - rewrite: (path) => path.replace(/^\/v1\/ip/, '/api/v1/ip'), - // bypass(req, res, options) { - // console.log(1111) - // const proxyUrl = new URL(options.rewrite(req.url) || '', (options.target) as string)?.href || '' - // req.headers['x-req-proxyUrl'] = proxyUrl; - // res.setHeader("x-res-proxyUrl", proxyUrl) - // } - }, [env.VITE_APP_BASE_API] : { target: env.VITE_SERVE, changeOrigin: true,