mk95 Blog
website·Indexed 30 days ago
https://www.mk95.cnA personal technical blog featuring guides and experiences with Nacos configuration, Vue.js iframe issues in IE, Tencent Cloud Code Assistant, EdgeOne static site hosting, and Podman mirror configuration.
What's inside mk95
- EdgeOne Pages is a frontend development and deployment platform built on Tencent EdgeOne infrastructure. It allows developers to build and deploy static sites and serverless applications. Unlike standard static hosting (e.g., GitHub Pages), it includes integrated Edge Functions and KV storage, enabling lightweight server-side logic such as page view statistics.
Explain complex code using Tencent Cloud Code Assistant
Tencent Cloud Code Assistant helps developers understand and maintain code through the following features:
- Detailed Explanations: Provides clear breakdowns of complex logic, explaining the execution process and purpose of the code.
- Real-time Feedback: Offers immediate explanations and suggestions during the coding process to improve readability.
- Knowledge Base Q&A: Includes a technical dialogue function to answer programming questions and resolve difficulties quickly.
Perform AI-powered code reviews with Tencent Cloud Code Assistant
Tencent Cloud Code Assistant provides automated code review capabilities to improve code quality and reduce manual effort. Key features include:
- Intelligent Detection: Automatically identifies syntax and logic errors and suggests corrections to standardize code formatting.
- Automated Review: Analyzes selected code snippets to identify potential bugs and performance bottlenecks.
- Iterative Optimization: Supports multi-turn dialogues to refine diagnostic results and align them with developer expectations.
Generate code using Tencent Cloud Code Assistant
Tencent Cloud Code Assistant allows developers to automatically generate code based on specific requirements and comments. It supports multiple programming languages and frameworks, including HTML, JavaScript, Python, and Java. Additionally, it provides real-time intelligent code completion based on the current context to reduce syntax errors and typing time.Configure Podman to use a docker.io mirror registry
To redirect Podman image pulls from the default Docker Hub registry to a specific mirror (e.g., docker.1panel.live), modify the registries configuration. This setup ensures that unqualified search requests fordocker.ioare routed to the specified mirror location and allows insecure connections if required.# Disable searching from multiple default registries and restrict to docker.io unqualified-search-registries = ["docker.io"] [[registry]] prefix = "docker.io" location = "docker.1panel.live" insecure = trueAutomate static site deployment from CNB to EdgeOne Pages
To automate the build and deployment of a static site (e.g., Hexo) from a CNB repository to EdgeOne Pages, configure the.cnb.ymlfile. The pipeline should include a build stage to generate the static files and a deployment stage using thetencentcom/deploy-eopagesimage. The deployment command requires the directory of the generated files, the site name, and an EdgeOne secret token.push: eo_deploy: runner: cpus: 4 docker: image: docker.cnb.cool/examples/workspace-images/workspace-node:22 stages: - name: build script: - pnpm i - pnpm hexo generate - name: 部署我的 eo pages 正式环境 imports: - https://cnb.cool/devsss/env/-/blob/main/tencent.yml image: tencentcom/deploy-eopages:latest script: edgeone pages deploy ./public -n cnb-www-devsss -t $EO_SECRETConfigure a cloud development environment in CNB
CNB provides a cloud-based development environment that persists configuration across sessions. You can set up a workspace for frameworks like Next.js, Hexo, or Docusaurus by defining thevscodesection in.cnb.yml. This allows you to run a development server directly in the cloud environment.$: vscode: - docker: image: docker.cnb.cool/examples/workspace-images/workspace-node:22 services: - vscode - docker stages: - name: 安装依赖 script: pnpm i - name: 启动 script: pnpm hexo serverConfigure Nacos Service Discovery and Config Center
To integrate a Spring Boot application with Nacos, configure the server address, credentials, and namespace inbootstrap.yml. Additionally, define the application name and the specific Nacos configuration file to import inapplication.ymlusing thespring.config.importproperty withrefresh=trueto enable dynamic updates.# bootstrap.yml spring: cloud: nacos: discovery: server-addr: 192.168.1.4:8848 username: nacos password: nacos namespace: public ip: 192.168.8.36 config: server-addr: 192.168.1.4:8848 username: nacos password: nacos # application.yml spring: application: name: app-test profiles: active: dev6 config: import: - nacos:${spring.application.name}.yml?refresh=trueFix Nacos dynamic configuration not updating (Refresh keys changed: [])
If you encounter the log message
Refresh keys changed: []after updating Nacos configurations and the values are not updating in the application, it is likely because the application failed to resolvespring.application.nameduring the bootstrap phase.This happens when the application name is defined in
application.ymlbut the Nacos config import is processed too early. To resolve this, move the application name and Nacos import configuration fromapplication.ymltobootstrap.ymlto ensure they are loaded during the program's bootstrap phase.Understand Spring Cloud Config file loading order
Spring Cloud Config loads configuration files in the following specific order of precedence (from earliest/lowest priority to latest/highest priority):
bootstrap.yml(System-level parameters, loaded during program bootstrap)application.yml(Application-level common parameters)application-{profile}.yml(Profile-specific parameters)- Configuration Center (Remote configurations from Nacos/Config Server)
Fix blank iframe pages in IE for Vue apps using Hash mode
When using Vue Router in hash mode, URLs starting with#/are automatically redirected toindex.html#/in most browsers. However, Internet Explorer (IE) does not perform this redirection automatically within aniframe, resulting in a blank page. To resolve this, ensure theiframesource uses the full path includingindex.htmlinstead of just the hash root.// Replace '/#/' with '/index.html#/' to ensure IE loads the page targetUrl = targetUrl.replaceAll("/#/", "/index.html#/");Force iframe refresh in Vue when changing source URL
Vue may not automatically refresh aniframewhen thesrcattribute changes. To force theiframeto reload when the URL is updated, bind a unique:key(such as a timestamp) to theiframeelement. When the key changes, Vue will destroy and re-create theiframecomponent, triggering a fresh load of the new URL.<template> <div class="iframe-container"> <iframe width="100%" height="100%" frameborder="0" :src="formattedUrl" :key="key" ></iframe> </div> </template> <script> export default { props: ["url"], data() { return { key: Date.now() } }, computed: { formattedUrl() { let targetUrl = this.url; // Fix for IE blank page in Vue Hash mode targetUrl = targetUrl.replaceAll("/#/", "/index.html#/"); // Update key to force iframe refresh this.key = Date.now(); return targetUrl; }, }, }; </script> <style> .iframe-container { height: 100%; overflow: hidden; } iframe { height: 100%; width: 100%; } </style>