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,