模板语法

reactive() 只适用于对象,它不能持有如 string、number 或 boolean 这样的原始类型,对解构操作不友好。ref() 则可以接受任何类型。ref对象解包后不用使用.value
v-bind:<attribute> :class
v-on也可以@

v-for
v-bind:[attributeName]
@submit.prevent

v-if
v-else​
v-else-if
v-show

<template>

v-if v-for同时使用优先级不明显,v-if优先级更高,无法访问v-for的变量,会报错。使用computed计算filter后再用v-for

v-model

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// 计算属性
const publishedBooksMessage = computed(() => {
return author.books.length > 0 ? 'Yes' : 'No'
})

// 挂载后处理原生dom
onMounted(() => {
ElementRef.value.textContent = 'mounted!'
})

// 副作用
watch(todoId, callback)

// 定义获取的属性值
defineProps(['title'])

// 属性传入事件
const emit = defineEmits(['response'])
emit('response', 'hello from child')
<ChildComp @response="(msg) => childMsg = msg" />

事件处理:@keyup.alt.enter="clear"

<tr is="vue:blog-post-row"></tr>

<BlogPost v-bind="Object" />

我们可以通过设定defineOptions({ inheritAttrs: false })和使用 v-bind=”$attrs” 来实现属性透传到非直接子组件

父元素:<slot name="header"></slot>子元素:<template #header>
slot子元素添加样式<div v-if="$slots.footer" class="card-footer">

依赖注入:组件后代提供数据

1
2
3
4
5
6
// 祖先元素处
const message = ref('hello')
provide('message', message)

//后代元素处
const message = inject('message')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// 定义默认值
const props = withDefaults(defineProps<Props>(), {
msg: 'hello',
labels: () => ['one', 'two']
})

// 选项式API路由
$route.fullPath
$router.push('/about')

// 组合式API
import { useRoute, useRouter } from 'vue-router'
const router = useRouter()
const route = useRoute()
const search = computed({
get() {
// route.query
return route.query.search ?? ''
},
set(search) {
router.replace({ query: { search } })
},
})
router.push()
router.replace()
router.go(n)

// 指向/user/erina
<router-link :to="{ name: 'profile', params: { username: 'erina' } }">
User profile
</router-link>

// id路由
const routes = [
// 动态字段以冒号开始
{ path: '/users/:id', component: User },
]
{{ $route.params.id }}

// 对路由变化做出响应...
import { watch } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute()
watch(() => route.params.id, (newId, oldId) => {
// 对路由变化做出响应...
})


const routes = [
{
path: '/user/:id',
component: User,
children: [
// 当 /user/:id 匹配成功
// UserHome 将被渲染到 User 的 <router-view> 内部
{ path: '', component: UserHome },
{
// 当 /user/:id/profile 匹配成功
// UserProfile 将被渲染到 User 的 <router-view> 内部
path: 'profile',
component: UserProfile,
},
{
// 当 /user/:id/posts 匹配成功
// UserPosts 将被渲染到 User 的 <router-view> 内部
path: 'posts',
component: UserPosts,
},
],
},
]
<!-- User.vue -->
<template>
<div class="user">
<h2>User {{ $route.params.id }}</h2>
<router-view />
</div>
</template>

// 请注意redirect,导航守卫并没有应用在跳转路由上,而仅仅应用在其目标上。在上面的例子中,在 /home 路由中添加 beforeEnter 守卫不会有任何效果。

// 以 / 开头,以使嵌套路径中的路径成为绝对路径

// 登录重定向
router.beforeEach((to, from, next) => {
if (to.name !== 'Login' && !isAuthenticated) next({ name: 'Login' })
else next()
})

// 登录重定向
const routes = [
{
path: '/users/:id',
component: UserDetails,
beforeEnter: (to, from) => {
// reject the navigation
return false
},
},
]

// 路由重定向
function removeQueryParams(to) {
if (Object.keys(to.query).length)
return { path: to.path, query: {}, hash: to.hash }
}
function removeHash(to) {
if (to.hash) return { path: to.path, query: to.query, hash: '' }
}
const routes = [
{
path: '/users/:id',
component: UserDetails,
beforeEnter: [removeQueryParams, removeHash],
},
{
path: '/about',
component: UserDetails,
beforeEnter: [removeQueryParams],
},
]

// 路由懒加载,代码分片
const UserDetails = () => import('./views/UserDetails.vue')
const router = createRouter({
// ...
routes: [
{ path: '/users/:id', component: UserDetails }
// 或在路由定义里直接使用它
{ path: '/users/:id', component: () => import('./views/UserDetails.vue') },
],
})

路由

layout.js相当于公共父组件,page.js相当于react-router的index组件

form

zod + server actions

useSearchParams, usePathname, and useRouter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { useSearchParams, usePathname, useRouter } from 'next/navigation';

export default function Search() {
const searchParams = useSearchParams();
const pathname = usePathname();
const { replace } = useRouter();

function handleSearch(term: string) {
const params = new URLSearchParams(searchParams);
if (term) {
params.set('query', term);
} else {
params.delete('query');
}
replace(`${pathname}?${params.toString()}`);
}
return (
<input
className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500"
placeholder={placeholder}
onChange={(e) => {
handleSearch(e.target.value);
}}
defaultValue={searchParams.get('query')?.toString()}
/>
)
}

Metadata

pnpm不能删除多余的包

登录光猫的管理员账号

不知道密码可以重置光猫后(长按重置的小圆点按钮,所用指示灯全亮后松开。就可以使用默认管理员账户登录。

  1. 电信光猫

    用户名:telecomadmin

    密码:nE7jA%m
  2. 移动光猫

    用户名:CMCCAdmin

    密码:aDm8H%MdA
  3. 联通光猫

    用户名:CUAdmin

    密码:CUAdmin

修改设置

进入光猫”网络=>LAN侧地址配置”

  1. 关闭DHCP
  2. 设置ip地址为交换机对应的网段的地址(如所在网段为192.168.1.0,则可以设置为192.168.1.254,记住设置的地址,重启后使用这个地址才能登录光猫)

调试

打开Tampermonkey的设置里面的Debug scripts后会在代码开头自动添加debugger,使代码开始时进入调试模式。

无痕窗口

无痕窗口更新Tampermonkey的设置不及时,应该在正常窗口调试。

在本地改代码调试

use an external editor to edit my scripts

// @require file://D:/repository/demo/JavaScript/myj.js放在其他脚本(// @require)加载的后面

在后台标签页被冻结(tab freezing)

在设置=>性能=>始终让以下网站保持活跃状态=>选择网站。就可以在开发者工具中刷新,页面也不会被冻结。

安装中文语言包

  1. 下载中文语言包
  2. 第一步:AndroidStudio->设置->插件->从磁盘安装插件->下载的jar包->重启AndroidStudio
    第二步:自定义(Customize)->语言和地区(Language and Region)->语言(Language)->Chinese->重启AndroidStudio
    或者 设置->外观与行为->系统设置->Language and Region->语言(Language)->Chinese->重启AndroidStudio

Gradle-指定Gradle依赖的JDK版本

您的构建当前配置为使用不兼容的 Java 21.0.6 和 Gradle 7.2。无法同步项目。

  1. 需要安装Gradle对应版本的jdk。Gradle 7.2对应jdk 17,下载并解压jdk 17。
  2. 依次点击 “File” - “Settings” - “Build, Execution, Deployment” - “Build Tool” - “Gradle” - “Gradle JDK”, 选择jdk解压的地址即可。

更改mirror

termux-change-repo

安装sshd,端口默认为8022

1
2
3
4
pkg upgrade
pkg i openssh
passwd
sshd

局域网中运行vnc远程桌面

1
2
3
4
5
6
7
8
9
10
pkg install x11-repo
pkg install tigervnc
pkg install xfce4

# 修改对应的内网IP地址
vncserver :1 -indirect 192.168.1.102 -geometry 3000x2000

/data/data/com.termux/files/usr/bin/ps
/data/data/com.termux/files/usr/bin/nano
/data/data/com.termux/files/usr/bin/vi

~/.vnc/xstartup文件中添加
xfce4-session &

打开vnc客户端:输入vnc服务器地址和端口5901

关闭vnc:
vncserver -kill :1

防止应用被系统终止

1
2
su
settings put global settings_enable_monitor_phantom_procs false

解决自动退出
幻影进程详情

代理

有时候开v2rayng会断开连接,有时候可以开代理连接。

lxqt打不开

更新所有软件pkg upgrade后,可以打开了

xfce4经常自动关闭

切换为lxqt后就好了。

alpinelinux

系统资源占用少

安装

1
2
3
wget --no-check-certificate -qO InstallNET.sh 'https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/InstallNET.sh' && chmod a+x InstallNET.sh
bash InstallNET.sh -alpine
reboot

ssh的登陆信息:

1
2
3
ssh 端口:22
用户名:root
密码:LeitboGi0ro

/etc/ssh/sshd_config中修改

1
2
3
Port *
PermitRootLogin yes
PasswordAuthentication yes

修改密码passwd root

开启BBR3

1
2
3
4
5
6
7
cat > /etc/sysctl.conf << EOF

net.core.default_qdisc=fq_pie

net.ipv4.tcp_congestion_control=bbr

EOF

更新alpinelinux来源

更新alpinelinux

1
2
3
4
5
6
7
8
# 查看当前版本
cat /etc/alpine-release
# 修改镜像源
setup-apkrepos
(清华镜像源)[https://mirrors.tuna.tsinghua.edu.cn/help/alpine/]
apk update
apk add --upgrade apk-tools
apk upgrade --available

安装xray来源

安装xray

更新xray

Xray-install for Alpine Linux

English | 简体中文 | 繁體中文

安装 Xray

安装 cURL

1
apk add curl

下载安装脚本

1
curl -O -L https://github.com/XTLS/Xray-install/raw/main/alpinelinux/install-release.sh

运行安装脚本

1
ash install-release.sh

管理命令

启用 Xray 服务 (开机自启)

1
rc-update add xray

禁用 Xray 服务 (取消自启)

1
rc-update del xray

运行 Xray

1
rc-service xray start

停止 Xray

1
rc-service xray stop

重启 Xray

1
rc-service xray restart

xray默认的的log路径

/var/log/xray/access.log
/var/log/xray/error.log

netsh wlan set hostednetwork mode = allow ssid=[wifi_name] key=[wifi_password]
netsh wlan start hostednetwork

vscode中安装c++扩展后进行调试

点击最左边Run and Debug,再点击设置图标打开launch.json,点击右下边的Add Configuration。选择gdb launch。
修改program值为生成的可执行程序目录地址。
miDebuggerPath值修改为gdb.exe的目录地址。
回到Run and Debug,点击左上角运行按钮,即可使用断点调试了,左下角的调试按钮不是根据launch.json的配置调试的。

cmake编译项目

安装vscode的cmake扩展。settings.json的”cmake.sourceDirectory”中设置CMakeLists.txt位置。
点击最左侧cmake按钮,点击PROJECT STATUS的Delete Cache and Reconfigure。
点击PROJECT OUTLINE的Build All Projects,完成编译

手动命令编译

没有vscode上面的编译方法的多线程编译,可能编译较慢

1
2
3
# 在build文件夹,".."为上级目录即CMakeLists.txt的所在目录
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .
1
2
3
4
# 其他常用命令
cmake --install .
ctest.exe -VV
cpack -G ZIP
0%