@@ -67,6 +70,16 @@ const {setLoginVisible, setInfo, setToken} = useUserInfo()
const token = computed(() => useUserInfo().$state.token);
const userInfo = ref()
const keyword = ref('')
+const defaultActive = computed((): string=>{
+ // const routes = ['index', 'inform', 'rules', 'warning', 'tptsps', 'case', 'comment', 'about']
+
+ if (!route.meta.parentPath && route.path.includes('search')) {
+ return ('/' + ( route.params.id === 'index' ? '' : route.params.id)) as unknown as string
+ }else {
+ return ( route.meta.parentPath || route.path ) as unknown as string
+ }
+
+})
function handleCommand(command: string) {
if (command === '5') {
ElMessageBox.confirm(
@@ -98,15 +111,8 @@ function handleCommand(command: string) {
})
}
}
-
-
-watchEffect(() => {
- console.log('useUserInfo().$state.info>>>>>>> header', useUserInfo().$state.info)
- userInfo.value = useUserInfo().$state.info;
-})
-
-
function handleChange(val: any) {
+ store.setSearchVal('')
activeRoute.value = val.path;
if (val.meta.hasOwnProperty('headerHost') && val.meta.headerHost) {
store.setMenuTheme('dark')
@@ -121,6 +127,15 @@ function handleChange(val: any) {
}
}
+function handleSearch() {
+ router.push({
+ path: '/search/index',
+ query:{
+ keywords: keyword.value
+ }
+ })
+}
+
watch(() => route, (val) => {
activeRoute.value = val.path;
if (val.meta.hasOwnProperty('headerHost') && val.meta.headerHost) {
@@ -136,6 +151,10 @@ watch(() => route, (val) => {
}
}, {deep: true})
+watchEffect(() => {
+ console.log('useUserInfo().$state.info>>>>>>> header', useUserInfo().$state.info)
+ userInfo.value = useUserInfo().$state.info;
+})
watchEffect(() => {
handleChange(route)
})
diff --git a/composables/useAppStore.ts b/composables/useAppStore.ts
index ace1090..b7b482c 100644
--- a/composables/useAppStore.ts
+++ b/composables/useAppStore.ts
@@ -5,18 +5,21 @@ export interface AppState {
menuTheme: menu;
homeBanner: boolean;
bannerTitle: string;
+ searchVal?: string
}
const useAppStore = defineStore('app', {
state: (): AppState => ({
menuTheme: 'light',
homeBanner: true,
- bannerTitle: ''
+ bannerTitle: '',
+ searchVal: ''
}),
getters:{
getMenuTheme: (state)=> state.menuTheme,
getHomeBanner: (state)=> state.homeBanner,
getBannerTitle: (state)=> state.bannerTitle,
+ getSearchVal: (state)=> state.searchVal,
},
actions: {
@@ -28,6 +31,9 @@ const useAppStore = defineStore('app', {
},
setBannerTitle(title: string): void{
this.bannerTitle = title;
+ },
+ setSearchVal(val: string): void{
+ this.searchVal = val;
}
}
diff --git a/layouts/tabLayout.vue b/layouts/tabLayout.vue
index ce0ad98..7568e89 100644
--- a/layouts/tabLayout.vue
+++ b/layouts/tabLayout.vue
@@ -1,11 +1,12 @@
-
-
+
+
+
@@ -17,10 +18,21 @@
const store = useAppStore()
const route = useRoute()
const loginStatus = ref(useUserInfo().getLoginVisible)
+const searchVal = ref('')
+function handleSearch(val) {
+ searchVal.value = val
+}
watchEffect(()=>{
loginStatus.value = useUserInfo().getLoginVisible;
console.log('loginStatus>>>', loginStatus.value)
+ if (route.path.includes('/search')) {
+ searchVal.value = route.query.keywords
+ }
+})
+
+watchEffect(()=>{
+ store.setSearchVal(searchVal.value)
})
// console.log()
diff --git a/middleware/isSearch.ts b/middleware/isSearch.ts
new file mode 100644
index 0000000..213472b
--- /dev/null
+++ b/middleware/isSearch.ts
@@ -0,0 +1,21 @@
+import {
+ defineNuxtRouteMiddleware,
+ navigateTo,
+} from "#app";
+
+// import useUserStore from "@/store/user.store";
+
+export default defineNuxtRouteMiddleware((to, form) => {
+ const routes = ['index', 'inform', 'rules', 'warning', 'tptsps']
+
+ console.log(routes.includes(to.params.id))
+ if (!routes.includes(to.params.id)) {
+ return navigateTo('/404')
+ }
+ // console.log(getToken, 'getToken')
+ // if (!getToken) {
+ // setLoginVisible(true)
+ // }else {
+ // setLoginVisible(false)
+ // }
+});
diff --git a/pages/search/[id].vue b/pages/search/[id].vue
new file mode 100644
index 0000000..3f64cc4
--- /dev/null
+++ b/pages/search/[id].vue
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
{{ item.title }}
+ {{ categoryNames[item.category_id] }}
+
+
+
{{ item.description }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/translate.vue b/pages/translate.vue
index a8f087d..d7c4336 100644
--- a/pages/translate.vue
+++ b/pages/translate.vue
@@ -167,17 +167,22 @@
import dayjs from "dayjs";
import {onClickOutside} from "@vueuse/core"
-// import socket from "@/utils/socket";
-// import io from 'socket.io-client'
-// import {process} from "unenv/runtime/node/process/_process";
-
-
definePageMeta({
name: '翻译',
hidden: true,
hiddenBanner: true,
middleware: ['auth']
})
+
+useHead({
+ title: '翻译',
+ script: [
+ {
+ type: 'text/javascript',
+ src: 'https://cdn.bootcss.com/socket.io/1.3.7/socket.io.js'
+ }
+ ]
+})
const {prefixCls} = useDesign('mai-wrap');
const router = useRouter()
const route = useRoute()
@@ -222,49 +227,31 @@ const fileUrl = ref('')
const uid = ref('')
const socket = ref(null)
-watch(currentLangModalStatus,(val)=>{
- allLanguage()
+watch(currentLangModalStatus, (val) => {
+ allLanguage()
})
-watch(targetLangModalStatus,(val)=>{
- allLanguage()
+watch(targetLangModalStatus, (val) => {
+ allLanguage()
})
watchEffect(() => {
radio1.value = route.query?.type ?? 1;
const user = useUserInfo()
- // 连接服务端 // @ts-ignore
- // if(porce.client) {
- // 连接服务端 // @ts-ignore
-
- // socket.on("disconnect", () => {
- // console.log(socket.id); // undefined
- // });
- // if (user.$state.info.id) {
-
- // socket.on("connect", () => {
- // const transport = socket.io.engine.transport.name; // 在大多数情况下, "polling"
-
- // socket.emit('login', user.$state.info.id);
- // socket.io.engine.on("upgrade", () => {
- // const upgradedTransport = socket.io.engine.transport.name; // 在大多数情况下, "websocket"
- // });
-// });
-// }
- // }
- if(user.$state.info.id) {
- window.io = null
+ if (user.$state.info.id) {
+ // window.io = null
// if (process.client) {
- const socketio = document.createElement('script')
- socketio.src = 'https://cdn.bootcss.com/socket.io/1.3.7/socket.io.js'
+ // const socketio = document.createElement('script')
+ // socketio.src = 'https://cdn.bootcss.com/socket.io/1.3.7/socket.io.js'
- document.body.append(socketio)
+ // document.body.append(socketio)
- let timer = setInterval(()=>{
-// @ts-ignore
+ let timer = setInterval(() => {
+ // @ts-ignore
if (io) {
+ // @ts-ignore
socket.value = io('http://research.mcnetmart.com:2120');//这里请填写你的域名,外网,端口为socket端口
-// @ts-ignore
+ // @ts-ignore
socket.value.on('connect', function () {
// @ts-ingore
console.log('dengll', user)
@@ -285,6 +272,7 @@ async function inputChange() {
const {data: data} = await translateApi.getAllLanguage({keyword: searchLanguage.value})
language.value = data
}
+
async function inputChange2() {
const {data: data} = await translateApi.getAllLanguage({keyword: searchLanguage2.value})
language2.value = data
@@ -397,14 +385,15 @@ async function translate() {
textarea2.value = data
}
}
+
async function translate3() {
- const {data: data} = await translateApi.ocrTranslate({
- file: fileUrl.value,
- source: abbreviation1.value,
- target: abbreviation2.value
- })
- textarea2.value = data
-
+ const {data: data} = await translateApi.ocrTranslate({
+ file: fileUrl.value,
+ source: abbreviation1.value,
+ target: abbreviation2.value
+ })
+ textarea2.value = data
+
}
async function translate2() {
@@ -827,7 +816,8 @@ allLanguage()
box-shadow: none !important;
// padding: 0px; //前边边距去掉
}
-.HtmlPreview{
+
+.HtmlPreview {
height: 239px !important;
margin: 17px;
border-radius: 16px;