您好!SpreadJS暂时没有API能直接检查授权码是否过期,您可以尝试在系统运行前执行以下代码判断授权码是否有效:
- import React from 'react'
- import ReactDOM from 'react-dom/client'
- import App from './App'
- import './index.css'
- import '@grapecity/spread-sheets-resources-zh'
- import * as GC from '@grapecity/spread-sheets-designer'
- function getDefaultLicense() {
- return {
- SHEETS_LICENSE_KEY: 'guanyuanshuju,776598819366453#B1nSyzcjZUVRFXOvIVWi3UcFNjWoNFNI9WZWtUZGVEN6lzUnt4d6kXR5UWQyEUV9Qlc7ZGVGdGRVFUe6BVbUpXOINzKtBDeYxmVMd4cvYVTkBlQHlkewE5VpVjRHhHODpkamBlWR3yK4FUZodUYNBDWO3maa9GUp5EeLdzUIRnUuVzRLJWdzJ4VHl4b9I7VSBFevolYYpERsd4a8AHb4wUciNkVZVDV9kHW7onah56U8JDavc7ZWVjVGRlcvVEOQVVWG3yL6ATSaZ4UyQFb7R7Yq9GWSRkSYVXSZFHVP9UVtxGZLp7aYd7MvkVaUZGOs3CaiojITJCLiI4MEBTOzQjNiojIIJCLygzMyETN8YzN0IicfJye&Qf35VficFVDplI0IyQiwiI6EjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIiNzkDMwEDI9AjNwMjMwIjI0ICdyNkIsIiNwITMzIDMyIiOiAHeFJCLi8ajmDblmz9voz9voL8po19tl7anmLiOiEmTDJCLiMTN4YjNzkTM8gTO5YzN7IiOiQWSiwSfdtlOicGbmJCLlNHbhZmOiI7ckJye0ICbuFkI1pjIEJCLi4TPRZUVFFneZVWOyYGZWJGVj3ycrtyTUt4QnFWbFBTdqZnQC9WOy5UOhh6QPdjV6YUe9gFVvgTM5UES9siT8glWj3CW8cGdq94ds5GezJWQnJjYCVFVRN6KvxmVQJDT5NDZ5V5jmu0',
- SHEETS_DESIGNER_LICENSE_KEY: 'guanyuanshuju,666326449326546#B1k4y9QkbV9UQ7d4dCd6bwMXMyokNBJDT7JUTwxUOyMHRVdWTnRHdItGZ8YlW6ZmY7A5QRJXNuZzMYN4RIpmdXFGVQZWNVdzTwEEey4UT5FFZ4pnVnJUTR5mQqZ4TqpmbodGCKBFW034bJdTSWhkZihnbPhnRxdDbzgEayAVdKxGaLZlbntyYqhlMJJjaStCZod5UvYUVWpnM92mc0dmaXlzVEtWYjpFaKZmUMpmViVGUDR5Q8FmSuVndWhjQn3EOup7Vs5kRrNzKGhzZoFEcxF6L6hTV8YmRS3EcvVDdVZVSuNTSxQmQatmUiojITJCLiEjMwU4NzYkI0ICSiwCM6kzNxcDM7MTM0IicfJye&Qf35Vfi4EU9cjI0IyQiwiI6EjL6BibvRGZB5icl96ZpNXZE5yUKRWYlJHcTJiOi8kI1tlOiQmcQJCLiUDNwEDMxASOwYDMzIDMyIiOiQncDJCLiYDMyEzMyAjMiojIwhXRiwiIu6o9wWp9c+L0c+L0CeK0eeb9t6p9iojIh94QiwiI6QTN6IzM9QDN6IzM6YjNiojIklkI1pjIEJCLi4TPRF4Nlx4YI3SY4dXSj3GWwkXYR34Y8VUOtd6ciZVMvEzb9ljerJ5VqlTMsFzTXlWejpWeDd7S8UnRNJkYO3iRmhzMNVGZydmR8Bldw3SR7pWUWdDW4YDS6IUZRdDV5hEN78mZycVaEV6Q0EFP5',
- }
- }
- function registerLicenseKey() {
- if (!GC) return
- const license = getDefaultLicense()
- if (!GC.Spread.Sheets.LicenseKey) {
- GC.Spread.Sheets.LicenseKey = license.SHEETS_LICENSE_KEY
- }
- if (!GC.Spread.Sheets.Designer.LicenseKey) {
- GC.Spread.Sheets.Designer.LicenseKey = license.SHEETS_DESIGNER_LICENSE_KEY
- }
- }
- registerLicenseKey();
- let invalidLicense = false;
- try {
- debugger;
- let dummyDom = document.createElement('div');
- let designer = new GC.Spread.Sheets.Designer.Designer(dummyDom);
- designer.setConfig({ ...GC.Spread.Sheets.Designer.DefaultConfig });
- } catch (e) {
- invalidLicense = true;
- document.body.innerHTML = `<h1>Invalid License</h1>`;
- }
- if (!invalidLicense) {
- ReactDOM.createRoot(document.getElementById('root')!).render(
- <React.StrictMode>
- <App />
- </React.StrictMode>
- )
- }
复制代码
|